Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to support 1.20.4 #163

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ org.gradle.jvmargs=-Xmx2G

# Fabric Properties
# check these on https://fabricmc.net/use or https://modmuss50.me/fabric.html
minecraft_version=1.20
minecraft_version=1.20.4
display_minecraft_version=1.20
yarn_mappings=1.20+build.1
loader_version=0.14.3
carpet_minecraft_version=1.20
yarn_mappings=1.20.4+build.3
loader_version=0.15.3
carpet_minecraft_version=1.20.3
# check available versions on maven for the given minecraft version you are using
carpet_core_version=1.4.112+v230608
carpet_core_version=1.4.128+v231205


# Mod Properties
Expand Down
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ill be removing it, as minecraft has done significant work on it to fix lag issues.

Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,30 @@
public class MinecraftServer_autosaveDelayMixin {


@ModifyConstant(
method = "tick(Ljava/util/function/BooleanSupplier;)V",
constant = @Constant(intValue = 6000)
)
public int tickAutoSave(int autoSaveDelay) {
return CFSettings.delayBetweenAutoSaves;
}


@ModifyConstant(
method = "canExecute(Lnet/minecraft/server/ServerTask;)Z",
constant = @Constant(intValue = 3) //statusUpdateDelay
)
public int shouldRunWithLatency(int maxTickLatency) {
return CFSettings.maxTickLatency;
}


@ModifyConstant(
method = "tick(Ljava/util/function/BooleanSupplier;)V",
constant = @Constant(longValue = 5000000000L)
)
public long customStatusUpdateDelay(long maxTickLatency) {
return CFSettings.statusUpdateDelay;
}
// FIXME - this seems to have been rewritten
// @ModifyConstant(
// method = "tick(Ljava/util/function/BooleanSupplier;)V",
// constant = @Constant(intValue = 6000)
// )
// public int tickAutoSave(int autoSaveDelay) {
// return CFSettings.delayBetweenAutoSaves;
// }
//
//
// @ModifyConstant(
// method = "canExecute(Lnet/minecraft/server/ServerTask;)Z",
// constant = @Constant(intValue = 3) //statusUpdateDelay
// )
// public int shouldRunWithLatency(int maxTickLatency) {
// return CFSettings.maxTickLatency;
// }
//
//
// @ModifyConstant(
// method = "tick(Ljava/util/function/BooleanSupplier;)V",
// constant = @Constant(longValue = 5000000000L)
// )
// public long customStatusUpdateDelay(long maxTickLatency) {
// return CFSettings.statusUpdateDelay;
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class EnchantingTableBlock_transparentMixin {


@Redirect(
method = "canAccessBookshelf(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;" +
method = "canAccessPowerProvider(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;" +
"Lnet/minecraft/util/math/BlockPos;)Z",
at = @At(
value = "INVOKE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public HopperBlock_missingUpdateMixin(Settings settings) {

@ModifyArg(
method = "updateEnabled(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;" +
"Lnet/minecraft/block/BlockState;I)V",
"Lnet/minecraft/block/BlockState;)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/World;" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private Direction directionToUpdate(BlockState state) {


@Inject(
method = "onUse",
method = "flip",
at = @At(
shift = At.Shift.AFTER,
value = "INVOKE",
Expand All @@ -59,7 +59,7 @@ private Direction directionToUpdate(BlockState state) {
)
)
private void updateOnUseCorrectly(BlockState state, World world, BlockPos pos, PlayerEntity player,
Hand hand, BlockHitResult hit, CallbackInfoReturnable<ActionResult> cir) {
CallbackInfo ci) {
if (CFSettings.trapdoorMissingUpdateFix)
world.updateNeighbor(pos.offset(directionToUpdate(state)),state.getBlock(),pos);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import carpetfixes.helpers.BlockUpdateUtils;
import net.minecraft.block.BlockState;
import net.minecraft.block.RedstoneTorchBlock;
import net.minecraft.block.TorchBlock;
import net.minecraft.block.AbstractTorchBlock;
import net.minecraft.particle.ParticleEffect;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
Expand All @@ -18,12 +18,12 @@
*/

@Mixin(RedstoneTorchBlock.class)
public abstract class RedstoneTorchBlock_updateMixin extends TorchBlock {
public abstract class RedstoneTorchBlock_updateMixin extends AbstractTorchBlock {

RedstoneTorchBlock self = (RedstoneTorchBlock)(Object)this;

protected RedstoneTorchBlock_updateMixin(Settings settings, ParticleEffect particle) {
super(settings, particle);
protected RedstoneTorchBlock_updateMixin(Settings settings) {
super(settings);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public abstract class StatusEffectInstance_wrongEffectMixin {
private void addHere(LivingEntity entity, Runnable overwriteCallback, CallbackInfoReturnable<Boolean> cir) {
if (CFSettings.brokenHiddenStatusEffectFix) {
((LivingEntityAccessor)entity).setEffectsChanged(true);
this.getEffectType().onRemoved(entity, entity.getAttributes(), this.getAmplifier());
this.getEffectType().onRemoved(entity.getAttributes());
}
}

Expand All @@ -63,7 +63,7 @@ private void addHere(LivingEntity entity, Runnable overwriteCallback, CallbackIn
)
private void removeHere(LivingEntity entity, Runnable overwriteCallback, CallbackInfoReturnable<Boolean> cir) {
if (CFSettings.brokenHiddenStatusEffectFix) {
this.getEffectType().onApplied(entity, entity.getAttributes(), this.getAmplifier());
this.getEffectType().onApplied(entity.getAttributes(), this.getAmplifier());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,23 @@ public TripwireHookBlock_hookDupeMixin(Settings settings) {
}

@Shadow
protected abstract void playSound(World w, BlockPos pos, boolean a, boolean on, boolean detached, boolean off);
protected static void playSound(World w, BlockPos pos, boolean a, boolean on, boolean detached, boolean off) { }

@Shadow
protected abstract void updateNeighborsOnAxis(World world, BlockPos pos, Direction direction);
protected static void updateNeighborsOnAxis(Block block, World world, BlockPos pos, Direction direction) { }


/**
* @author FX - PR0CESS
* @reason Fix for the tripwire hook duplication bug
*/
@Overwrite
public void update(World world, BlockPos pos, BlockState state, boolean beingRemoved,
public static void update(World world, BlockPos pos, BlockState state, boolean beingRemoved,
boolean bl, int i, @Nullable BlockState blockState) {
Direction direction = state.get(FACING);
boolean attached = state.get(ATTACHED);
boolean powered = state.get(POWERED);
Block block = state.getBlock();
boolean notRemoving = !beingRemoved;
boolean on = false;
int index = 0;
Expand All @@ -63,32 +64,32 @@ public void update(World world, BlockPos pos, BlockState state, boolean beingRem
on |= armed && blockState2.get(TripwireBlock.POWERED);
blockStates[k] = blockState2;
if (k == i) {
world.scheduleBlockTick(pos, this, 10);
world.scheduleBlockTick(pos, block, 10);
notRemoving &= armed;
}
}
}
notRemoving &= index > 1;
on &= notRemoving;
BlockState newState = this.getDefaultState().with(ATTACHED, notRemoving).with(POWERED, on);
BlockState newState = block.getDefaultState().with(ATTACHED, notRemoving).with(POWERED, on);
if (index > 0) {
blockPos = pos.offset(direction, index);
Direction blockState2 = direction.getOpposite();
world.setBlockState(blockPos, newState.with(FACING, blockState2), Block.NOTIFY_ALL);
this.updateNeighborsOnAxis(world, blockPos, blockState2);
this.playSound(world, blockPos, notRemoving, on, attached, powered);
updateNeighborsOnAxis(block, world, blockPos, blockState2);
playSound(world, blockPos, notRemoving, on, attached, powered);
}
this.playSound(world, pos, notRemoving, on, attached, powered);
if (!beingRemoved && (!CFSettings.tripwireHookDupeFix || world.getBlockState(pos).isOf(this))) {
playSound(world, pos, notRemoving, on, attached, powered);
if (!beingRemoved && (!CFSettings.tripwireHookDupeFix || world.getBlockState(pos).isOf(Blocks.TRIPWIRE_HOOK))) {
world.setBlockState(pos, newState.with(FACING, direction), Block.NOTIFY_ALL);
if (bl) this.updateNeighborsOnAxis(world, pos, direction);
if (bl) updateNeighborsOnAxis(block, world, pos, direction);
}
if (attached != notRemoving) {
for(int x = 1; x < index; ++x) {
BlockPos pos2 = pos.offset(direction, x);
BlockState state2 = blockStates[x];
if (state2 != null) {
if (!CFSettings.tripwireNotDisarmingFix || world.getBlockState(pos2).isOf(this)) {
if (!CFSettings.tripwireNotDisarmingFix || world.getBlockState(pos2).isOf(Blocks.TRIPWIRE_HOOK)) {
world.setBlockState(pos2, state2.with(ATTACHED, notRemoving), Block.NOTIFY_ALL);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package carpetfixes.mixins.dupeFixes.saferItemTransfer;

import carpetfixes.CFSettings;
import net.minecraft.block.BlockState;
import net.minecraft.block.DropperBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.server.world.ServerWorld;
Expand All @@ -24,7 +25,7 @@ public class DropperBlock_dontCopyMixin {


@Redirect(
method = "dispense(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/util/math/BlockPos;)V",
method = "dispense(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;)V",
slice = @Slice(
from = @At("HEAD"),
to = @At(
Expand All @@ -46,7 +47,7 @@ protected ItemStack shouldCopyFirst(ItemStack itemStack) {


@Redirect(
method = "dispense(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/util/math/BlockPos;)V",
method = "dispense(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;)V",
slice = @Slice(
from = @At(
value = "INVOKE",
Expand All @@ -65,10 +66,10 @@ protected ItemStack shouldCopy(ItemStack itemStack) {


@Inject(
method = "dispense(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/util/math/BlockPos;)V",
method = "dispense(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;)V",
at = @At("TAIL")
)
private void removeInstance(ServerWorld world, BlockPos pos, CallbackInfo ci) {
private void removeInstance(ServerWorld world, BlockState state, BlockPos pos, CallbackInfo ci) {
stack = ItemStack.EMPTY;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public abstract class ArmorStandEntity_damageMixin {
method = "damage(Lnet/minecraft/entity/damage/DamageSource;F)Z",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/entity/damage/DamageSource;getSource()Lnet/minecraft/entity/Entity;",
target = "Lnet/minecraft/entity/damage/DamageSource;getAttacker()Lnet/minecraft/entity/Entity;",
ordinal = 0,
shift = At.Shift.BEFORE
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public DrownedEntity_enchantedTridentMixin(EntityType<? extends ZombieEntity> en


@Redirect(
method = "attack",
method = "shootAt",
at = @At(
value = "NEW",
target = "net/minecraft/item/ItemStack"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.minecraft.entity.EntityType;
import net.minecraft.entity.projectile.PersistentProjectileEntity;
import net.minecraft.entity.projectile.TridentEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -17,8 +18,8 @@
@Mixin(TridentEntity.class)
public abstract class TridentEntity_fallingMixin extends PersistentProjectileEntity {

protected TridentEntity_fallingMixin(EntityType<? extends PersistentProjectileEntity> entityType, World world) {
super(entityType, world);
protected TridentEntity_fallingMixin(EntityType<? extends PersistentProjectileEntity> entityType, World world, ItemStack stack) {
super(entityType, world, stack);
}

@Shadow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import carpetfixes.CFSettings;
import net.minecraft.advancement.Advancement;
import net.minecraft.advancement.AdvancementEntry;
import net.minecraft.advancement.PlayerAdvancementTracker;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.world.GameMode;
Expand All @@ -27,7 +28,7 @@ public class PlayerAdvancementTracker_grantCriterionMixin {
at = @At("HEAD"),
cancellable = true
)
private void grantCriterion(Advancement advancement, String criterionName, CallbackInfoReturnable<Boolean> cir) {
private void grantCriterion(AdvancementEntry advancement, String criterionName, CallbackInfoReturnable<Boolean> cir) {
if (CFSettings.spectatorAdvancementGrantingFix &&
owner.interactionManager.getGameMode().equals(GameMode.SPECTATOR)) {
cir.cancel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected PlayerEntity_absorptionMixin(EntityType<? extends LivingEntity> entity


@Inject(
method = "setAbsorptionAmount(F)V",
method = "setAbsorptionAmountUnclamped(F)V",
at = @At("RETURN")
)
private void onAbsorptionChanged(float amount, CallbackInfo ci) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

@Mixin(AbstractRedstoneGateBlock.class)
public class AbstractRedstoneGateBlock_repeaterPriorityMixin extends HorizontalFacingBlock {
abstract public class AbstractRedstoneGateBlock_repeaterPriorityMixin extends HorizontalFacingBlock {

protected AbstractRedstoneGateBlock_repeaterPriorityMixin(Settings settings) {
super(settings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private static Vec3d adjustMovementForCollisionsAtPos(@Nullable Entity entity, V
}

private static boolean canWorldBorderCollideAtPos(WorldBorder worldBorder, Vec3d pos, Box box) {
double d = Math.max(MathHelper.absMax(box.getXLength(), box.getZLength()), 1.0);
double d = Math.max(MathHelper.absMax(box.getLengthX(), box.getLengthZ()), 1.0);
return worldBorder.getDistanceInsideBorder(pos.getX(), pos.getZ()) < d * 2.0 &&
worldBorder.contains(pos.getX(), pos.getZ(), d);
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/carpet-fixes.accesswidener
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ accessible class net/minecraft/world/chunk/PaletteResizeListener
accessible method net/minecraft/world/chunk/ArrayPalette <init> (Lnet/minecraft/util/collection/IndexedIterable;[Ljava/lang/Object;Lnet/minecraft/world/chunk/PaletteResizeListener;II)V
accessible method net/minecraft/world/chunk/BiMapPalette <init> (Lnet/minecraft/util/collection/IndexedIterable;ILnet/minecraft/world/chunk/PaletteResizeListener;Lnet/minecraft/util/collection/Int2ObjectBiMap;)V
accessible field net/minecraft/block/AbstractPressurePlateBlock blockSetType Lnet/minecraft/block/BlockSetType;
extendable method net/minecraft/entity/LivingEntity canBreatheInWater ()Z
Loading