diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/EntityRidingOffsetsPre1_20_2.java b/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/EntityRidingOffsetsPre1_20_2.java index 649d72e3..fc671b1b 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/EntityRidingOffsetsPre1_20_2.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/EntityRidingOffsetsPre1_20_2.java @@ -133,7 +133,7 @@ public class EntityRidingOffsetsPre1_20_2 { } if (entity instanceof AbstractHorseEntity abstractHorseEntity) { - if (abstractHorseEntity.lastAngryAnimationProgress > 0.0f) { + if (abstractHorseEntity.lastAngryAnimationProgress > 0.0F) { return new Vector3f(0, yOffset + 0.15F * abstractHorseEntity.lastAngryAnimationProgress, -0.7F * abstractHorseEntity.lastAngryAnimationProgress); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinFlowableFluid.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinFlowableFluid.java index c75b8c7d..e14753f2 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinFlowableFluid.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinFlowableFluid.java @@ -48,7 +48,6 @@ public abstract class MixinFlowableFluid { return false; } } - return instance.isSideSolidFullSquare(blockView, blockPos, direction); } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinAnvilBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinAnvilBlock.java index 8a194f6b..62a8aa68 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinAnvilBlock.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinAnvilBlock.java @@ -56,7 +56,7 @@ public abstract class MixinAnvilBlock extends FallingBlock { private boolean viaFabricPlus$requireOriginalShape; @Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true) - public void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { + private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { if (viaFabricPlus$requireOriginalShape) { viaFabricPlus$requireOriginalShape = false; } else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) { diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinEndPortalFrameBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinEndPortalFrameBlock.java index 04126051..7806638f 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinEndPortalFrameBlock.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinEndPortalFrameBlock.java @@ -60,7 +60,7 @@ public abstract class MixinEndPortalFrameBlock extends Block { } @Inject(method = "getOutlineShape", at = @At(value = "HEAD"), cancellable = true) - private void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { + private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) { cir.setReturnValue(FRAME_SHAPE); } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinHopperBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinHopperBlock.java index 090e0ce1..2afca1f6 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinHopperBlock.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinHopperBlock.java @@ -50,7 +50,7 @@ public abstract class MixinHopperBlock extends BlockWithEntity { } @Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true) - public void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { + private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { if (viaFabricPlus$requireOriginalShape) { viaFabricPlus$requireOriginalShape = false; } else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) { @@ -59,7 +59,7 @@ public abstract class MixinHopperBlock extends BlockWithEntity { } @Inject(method = "getRaycastShape", at = @At("HEAD"), cancellable = true) - public void changeRaycastShape(BlockState state, BlockView world, BlockPos pos, CallbackInfoReturnable cir) { + private void changeRaycastShape(BlockState state, BlockView world, BlockPos pos, CallbackInfoReturnable cir) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) { cir.setReturnValue(viaFabricPlus$inside_shape_r1_12_2); } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinCamelEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinCamelEntity.java index f36004ee..d0359de5 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinCamelEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinCamelEntity.java @@ -59,7 +59,7 @@ public abstract class MixinCamelEntity extends AbstractHorseEntity { final float passengerYaw = passenger.getYaw(); final float deltaDegrees = MathHelper.wrapDegrees(passengerYaw - this.getYaw()); - final float clampedDelta = MathHelper.clamp(deltaDegrees, -160.0f, 160.0f); + final float clampedDelta = MathHelper.clamp(deltaDegrees, -160.0F, 160.0F); passenger.prevYaw += clampedDelta - deltaDegrees; final float newYaw = passengerYaw + clampedDelta - deltaDegrees; diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinClientPlayerEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinClientPlayerEntity.java index 0defcc9a..06ba7602 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinClientPlayerEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinClientPlayerEntity.java @@ -170,7 +170,7 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity @Redirect(method = "tickMovement", slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isWalking()Z")), at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isSwimming()Z", ordinal = 0)) - private boolean redirectIsSneakingWhileSwimming(ClientPlayerEntity instance) { + private boolean dontAllowSneakingWhileSwimming(ClientPlayerEntity instance) { return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_14_1) && instance.isSwimming(); } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntity.java index 371a83cc..9ff69815 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntity.java @@ -138,8 +138,9 @@ public abstract class MixinEntity implements IEntity { private static double fixVelocityEpsilon(double epsilon) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) { return 1E-4; + } else { + return epsilon; } - return epsilon; } @Inject(method = "getRotationVector(FF)Lnet/minecraft/util/math/Vec3d;", at = @At("HEAD"), cancellable = true) diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntityRenderDispatcher.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntityRenderDispatcher.java index a6ab31a9..a79e13d4 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntityRenderDispatcher.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntityRenderDispatcher.java @@ -42,17 +42,17 @@ public abstract class MixinEntityRenderDispatcher { @Unique private BoatRenderer1_8 viaFabricPlus$boatRenderer; + @Inject(method = "reload", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD) + private void createBoatRenderer1_8(ResourceManager manager, CallbackInfo ci, EntityRendererFactory.Context context) { + viaFabricPlus$boatRenderer = new BoatRenderer1_8(context); + } + @SuppressWarnings("unchecked") @Inject(method = "getRenderer", at = @At("HEAD"), cancellable = true) - private void onGetRenderer(T entity, CallbackInfoReturnable> ci) { + private void useBoatRenderer1_8(T entity, CallbackInfoReturnable> ci) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8) && entity instanceof BoatEntity) { ci.setReturnValue((EntityRenderer) viaFabricPlus$boatRenderer); } } - @Inject(method = "reload", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD) - private void onReload(ResourceManager manager, CallbackInfo ci, EntityRendererFactory.Context context) { - viaFabricPlus$boatRenderer = new BoatRenderer1_8(context); - } - } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntityRenderer.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntityRenderer.java index d1541161..6d707f73 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntityRenderer.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntityRenderer.java @@ -56,7 +56,7 @@ public abstract class MixinPlayerEntityRenderer { @Redirect(method = "getPositionOffset(Lnet/minecraft/client/network/AbstractClientPlayerEntity;F)Lnet/minecraft/util/math/Vec3d;", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;isInSneakingPose()Z")) private boolean disableSneakPositionOffset(AbstractClientPlayerEntity player) { - return (ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_11_1to1_11_2)) && player.isInSneakingPose(); + return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_11_1to1_11_2) && player.isInSneakingPose(); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemGroup_EntriesImpl.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemGroup_EntriesImpl.java index 274ff84c..50282991 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemGroup_EntriesImpl.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemGroup_EntriesImpl.java @@ -19,6 +19,8 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import de.florianmichael.viafabricplus.fixes.data.ItemRegistryDiff; import de.florianmichael.viafabricplus.settings.impl.GeneralSettings; import net.minecraft.client.MinecraftClient; @@ -26,6 +28,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.registry.Registries; import net.minecraft.resource.featuretoggle.FeatureSet; +import net.minecraft.util.Identifier; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -39,17 +42,18 @@ public abstract class MixinItemGroup_EntriesImpl { @Final private ItemGroup group; - @Redirect(method = "add", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/Item;isEnabled(Lnet/minecraft/resource/featuretoggle/FeatureSet;)Z")) - private boolean removeUnknownItems(Item instance, FeatureSet featureSet) { + @WrapOperation(method = "add", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/Item;isEnabled(Lnet/minecraft/resource/featuretoggle/FeatureSet;)Z")) + private boolean removeUnknownItems(Item instance, FeatureSet featureSet, Operation original) { + final boolean originalValue = original.call(instance, featureSet); final int index = GeneralSettings.global().removeNotAvailableItemsFromCreativeTab.getIndex(); - if (index == 2 || MinecraftClient.getInstance().isInSingleplayer()) return instance.isEnabled(featureSet); - if (index == 1 && !Registries.ITEM_GROUP.getId(this.group).getNamespace().equals("minecraft")) return instance.isEnabled(featureSet); - - if (ItemRegistryDiff.keepItem(instance)) { - return instance.isEnabled(featureSet); + if (index == 2 /* Off */ || MinecraftClient.getInstance().isInSingleplayer()) { + return originalValue; + } else if (index == 1 /* Vanilla only */ && !Registries.ITEM_GROUP.getId(this.group).getNamespace().equals(Identifier.DEFAULT_NAMESPACE)) { + return originalValue; + } else { + return ItemRegistryDiff.keepItem(instance) && originalValue; } - return false; } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemPlacementContext.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemPlacementContext.java index 472f8b37..c3604c86 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemPlacementContext.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemPlacementContext.java @@ -44,7 +44,7 @@ public abstract class MixinItemPlacementContext extends ItemUsageContext { } @Inject(method = "getPlayerLookDirection", at = @At("HEAD"), cancellable = true) - private void getLookDirection1_12_2(CallbackInfoReturnable cir) { + private void getPlayerLookDirection1_12_2(CallbackInfoReturnable cir) { final ItemPlacementContext self = (ItemPlacementContext) (Object) this; final PlayerEntity player = self.getPlayer(); diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemStack.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemStack.java index eb926cda..735e87b1 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemStack.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemStack.java @@ -102,7 +102,6 @@ public abstract class MixinItemStack implements IItemStack { return OptionalDouble.of(3 + materialBonus); } } - return OptionalDouble.empty(); } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayerInteractionManager.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayerInteractionManager.java index f7985a47..703c8a90 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayerInteractionManager.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayerInteractionManager.java @@ -146,13 +146,13 @@ public abstract class MixinClientPlayerInteractionManager implements IClientPlay private boolean handleWindowClick1_16_5(ClientPlayNetworkHandler instance, Packet packet) throws Exception { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5) && packet instanceof ClickSlotC2SPacket clickSlot) { ItemStack slotItemBeforeModification; - - if (this.viaFabricPlus$shouldBeEmpty(clickSlot.getActionType(), clickSlot.getSlot())) + if (this.viaFabricPlus$shouldBeEmpty(clickSlot.getActionType(), clickSlot.getSlot())) { slotItemBeforeModification = ItemStack.EMPTY; - else if (clickSlot.getSlot() < 0 || clickSlot.getSlot() >= viaFabricPlus$oldItems.size()) + } else if (clickSlot.getSlot() < 0 || clickSlot.getSlot() >= viaFabricPlus$oldItems.size()) { slotItemBeforeModification = viaFabricPlus$oldCursorStack; - else + } else { slotItemBeforeModification = viaFabricPlus$oldItems.get(clickSlot.getSlot()); + } final PacketWrapper clickWindowPacket = PacketWrapper.create(ServerboundPackets1_16_2.CLICK_WINDOW, ((IClientConnection) networkHandler.getConnection()).viaFabricPlus$getUserConnection()); clickWindowPacket.write(Type.UNSIGNED_BYTE, (short) clickSlot.getSyncId()); diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinBookEditScreen.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinBookEditScreen.java index d5f0effc..949da7e5 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinBookEditScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinBookEditScreen.java @@ -30,20 +30,20 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant; public abstract class MixinBookEditScreen { @ModifyConstant(method = "method_27596", constant = @Constant(intValue = 1024)) - private int modifyPageLength(int oldVal) { + private int modifyPageLength(int constant) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) { return 256; } else { - return oldVal; + return constant; } } @ModifyConstant(method = "appendNewPage", constant = @Constant(intValue = 100)) - private int modifyPageCount(int oldVal) { + private int modifyPageCount(int constant) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) { return 50; } else { - return oldVal; + return constant; } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/screenhandler/MixinAbstractFurnaceScreenHandler.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/screenhandler/MixinAbstractFurnaceScreenHandler.java index c4f7f2a0..61a2afee 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/screenhandler/MixinAbstractFurnaceScreenHandler.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/screenhandler/MixinAbstractFurnaceScreenHandler.java @@ -39,12 +39,12 @@ public abstract class MixinAbstractFurnaceScreenHandler { @Redirect(method = "quickMove", at = @At(value = "INVOKE", target = "Lnet/minecraft/screen/AbstractFurnaceScreenHandler;isSmeltable(Lnet/minecraft/item/ItemStack;)Z")) private boolean disableShiftClickSmeltingSlot(AbstractFurnaceScreenHandler instance, ItemStack itemStack) { - return this.isSmeltable(itemStack) && !ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_2_1tor1_2_3); + return this.isSmeltable(itemStack) && ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_2_1tor1_2_3); } @Redirect(method = "quickMove", at = @At(value = "INVOKE", target = "Lnet/minecraft/screen/AbstractFurnaceScreenHandler;isFuel(Lnet/minecraft/item/ItemStack;)Z")) private boolean disableShiftClickFuelSlot(AbstractFurnaceScreenHandler instance, ItemStack itemStack) { - return this.isFuel(itemStack) && !ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_2_1tor1_2_3); + return this.isFuel(itemStack) && ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_2_1tor1_2_3); } }