From 4df5265a2bec84505025aba521556da422faa3e3 Mon Sep 17 00:00:00 2001 From: FlorianMichael Date: Fri, 25 Oct 2024 14:53:34 +0200 Subject: [PATCH] More fixes --- .../viafabricplus/fixes/data/recipe/RecipeInfo.java | 7 ++++--- .../versioned/EnchantmentAttributesEmulation1_20_6.java | 2 +- .../mixin/fixes/minecraft/MixinKeyboardInput.java | 4 ++-- .../fixes/minecraft/entity/MixinClientPlayerEntity.java | 4 ++-- .../fixes/minecraft/item/MixinFireworkRocketItem.java | 4 ++-- .../mixin/fixes/minecraft/item/MixinItemRenderer.java | 2 +- .../minecraft/network/MixinClientPlayNetworkHandler.java | 4 ++-- 7 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/data/recipe/RecipeInfo.java b/src/main/java/de/florianmichael/viafabricplus/fixes/data/recipe/RecipeInfo.java index 81add228..05e534a7 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/data/recipe/RecipeInfo.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/data/recipe/RecipeInfo.java @@ -109,19 +109,20 @@ public final class RecipeInfo { } final int height = shape.size(); - final DefaultedList ingredients = DefaultedList.of(); + final DefaultedList> ingredients = DefaultedList.of(); for (String row : shape) { for (int x = 0; x < width; x++) { final char key = row.charAt(x); Ingredient ingredient = legend.get(key); if (ingredient == null) { if (key == ' ') { - ingredient = Ingredient.EMPTY; + ingredients.add(Optional.empty()); } else { throw new IllegalArgumentException("Unknown character in shape: " + key); } + } else { + ingredients.add(Optional.of(ingredient)); } - ingredients.add(ingredient); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/EnchantmentAttributesEmulation1_20_6.java b/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/EnchantmentAttributesEmulation1_20_6.java index efe1cb9a..467d304b 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/EnchantmentAttributesEmulation1_20_6.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/EnchantmentAttributesEmulation1_20_6.java @@ -48,7 +48,7 @@ public class EnchantmentAttributesEmulation1_20_6 { // Update generic attributes for all entities for (Entity entity : world.getEntities()) { if (entity.isLogicalSideForUpdatingMovement() && entity instanceof LivingEntity livingEntity) { - livingEntity.getAttributeInstance(EntityAttributes.GENERIC_WATER_MOVEMENT_EFFICIENCY).setBaseValue(getEquipmentLevel(Enchantments.DEPTH_STRIDER, livingEntity) / 3F); + livingEntity.getAttributeInstance(EntityAttributes.WATER_MOVEMENT_EFFICIENCY).setBaseValue(getEquipmentLevel(Enchantments.DEPTH_STRIDER, livingEntity) / 3F); setGenericMovementEfficiencyAttribute(livingEntity); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinKeyboardInput.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinKeyboardInput.java index 7b1f88e6..c3b9c4ec 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinKeyboardInput.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinKeyboardInput.java @@ -34,9 +34,9 @@ public abstract class MixinKeyboardInput extends Input { @ModifyVariable(method = "tick", at = @At(value = "LOAD", ordinal = 0), argsOnly = true) private boolean changeSneakSlowdownCondition(boolean slowDown) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) { - return this.sneaking; + return this.playerInput.sneak(); } else if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) { - return !MinecraftClient.getInstance().player.isSpectator() && (this.sneaking || slowDown); + return !MinecraftClient.getInstance().player.isSpectator() && (this.playerInput.sneak() || slowDown); } else { return slowDown; } 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 77101ddc..f38fe0c1 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 @@ -147,10 +147,10 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity @Inject(method = "tickMovement()V", slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isCamera()Z")), - at = @At(value = "FIELD", target = "Lnet/minecraft/client/input/Input;sneaking:Z", ordinal = 0)) + at = @At(value = "INVOKE", target = "Lnet/minecraft/util/PlayerInput;sneak()Z", ordinal = 0)) private void injectTickMovement(CallbackInfo ci) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) { - if (this.input.sneaking) { + if (this.input.playerInput.sneak()) { this.input.movementSideways = (float) ((double) this.input.movementSideways / 0.3D); this.input.movementForward = (float) ((double) this.input.movementForward / 0.3D); } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinFireworkRocketItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinFireworkRocketItem.java index 2dfaac3d..663b40b7 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinFireworkRocketItem.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinFireworkRocketItem.java @@ -30,9 +30,9 @@ import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(FireworkRocketItem.class) public abstract class MixinFireworkRocketItem { - @Redirect(method = "use", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isFallFlying()Z", ordinal = 0)) + @Redirect(method = "use", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isGliding()Z", ordinal = 0)) private boolean disableFireworkElytraBoost(PlayerEntity player) { - return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_11) && player.isFallFlying(); + return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_11) && player.isGliding(); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemRenderer.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemRenderer.java index f5950694..25295653 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemRenderer.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemRenderer.java @@ -44,7 +44,7 @@ public abstract class MixinItemRenderer { @Inject(method = "getModel(Lnet/minecraft/item/ItemStack;Lnet/minecraft/world/World;Lnet/minecraft/entity/LivingEntity;I)Lnet/minecraft/client/render/model/BakedModel;", at = @At("HEAD"), cancellable = true) private void removeModel(ItemStack stack, World world, LivingEntity entity, int seed, CallbackInfoReturnable cir) { if (VisualSettings.global().replacePetrifiedOakSlab.isEnabled() && world != null /* world is null in gui rendering */ && stack.isOf(Items.PETRIFIED_OAK_SLAB)) { - cir.setReturnValue(this.models.getModelManager().getMissingModel()); + cir.setReturnValue(this.models.getModel(ItemStack.EMPTY)); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayNetworkHandler.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayNetworkHandler.java index 9c689950..3b144e3e 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayNetworkHandler.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayNetworkHandler.java @@ -38,7 +38,7 @@ import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; import net.minecraft.entity.attribute.AttributeContainer; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.vehicle.BoatEntity; +import net.minecraft.entity.vehicle.AbstractBoatEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.network.ClientConnection; @@ -222,7 +222,7 @@ public abstract class MixinClientPlayNetworkHandler extends ClientCommonNetworkH } @SuppressWarnings({"InvalidInjectorMethodSignature"}) - @ModifyConstant(method = "onEntityPassengersSet", constant = @Constant(classValue = BoatEntity.class)) + @ModifyConstant(method = "onEntityPassengersSet", constant = @Constant(classValue = AbstractBoatEntity.class)) private Class dontChangeYawWhenMountingBoats(Object entity, Class boatClass) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_18)) { return Integer.class; // Dummy class file to false the instanceof check