From 6045626f08b06534ae429babc7b38b3d10709e4c Mon Sep 17 00:00:00 2001 From: lowercasebtw <126462578+lowercasebtw@users.noreply.github.com> Date: Tue, 3 Dec 2024 17:53:39 -0500 Subject: [PATCH] More fixes (#641) --- .../visual/FootStepParticle1_12_2.java | 2 +- ...ltiplayerServerListWidget_ServerEntry.java | 2 +- .../MixinClientRegistrySyncHandler.java | 42 +++++++++++++++++++ .../fabricapi/MixinRegistrySyncManager.java | 15 ------- .../minecraft/MixinTextRenderer_Drawer.java | 4 +- .../minecraft/MixinWeatherRendering.java | 2 +- .../fixes/minecraft/block/MixinWallBlock.java | 2 +- .../minecraft/entity/MixinLivingEntity.java | 4 +- .../minecraft/item/MixinHeldItemRenderer.java | 31 ++++---------- src/main/resources/viafabricplus.mixins.json | 1 + 10 files changed, 58 insertions(+), 47 deletions(-) create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/compat/fabricapi/MixinClientRegistrySyncHandler.java diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/FootStepParticle1_12_2.java b/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/FootStepParticle1_12_2.java index 68620182..e95af586 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/FootStepParticle1_12_2.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/FootStepParticle1_12_2.java @@ -63,7 +63,7 @@ public class FootStepParticle1_12_2 extends SpriteBillboardParticle { } @Override - public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float tickDelta) { + public void render(VertexConsumer vertexConsumer, Camera camera, float tickDelta) { final float strength = ((float) this.age + tickDelta) / (float) this.maxAge; this.alpha = 2.0F - (strength * strength) * 2.0F; if (this.alpha > 1.0F) { diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinMultiplayerServerListWidget_ServerEntry.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinMultiplayerServerListWidget_ServerEntry.java index 589f0dbd..7a9b03b5 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinMultiplayerServerListWidget_ServerEntry.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinMultiplayerServerListWidget_ServerEntry.java @@ -92,7 +92,7 @@ public abstract class MixinMultiplayerServerListWidget_ServerEntry { } } - @ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawText(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/Text;IIIZ)I"), index = 2) + @ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTextWithShadow(Lnet/minecraft/client/font/TextRenderer;Ljava/lang/String;III)I"), index = 2) private int disableServerPinging(int x) { if (viaFabricPlus$disableServerPinging) { // Move server label to the right (as we remove the ping bar) x += 15 /* ping bar width */ - 3 /* magical offset */; diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/compat/fabricapi/MixinClientRegistrySyncHandler.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/compat/fabricapi/MixinClientRegistrySyncHandler.java new file mode 100644 index 00000000..c5b37b84 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/compat/fabricapi/MixinClientRegistrySyncHandler.java @@ -0,0 +1,42 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus + * Copyright (C) 2021-2024 FlorianMichael/EnZaXD and RK_01/RaphiMC + * Copyright (C) 2023-2024 contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.florianmichael.viafabricplus.injection.mixin.compat.fabricapi; + +import de.florianmichael.viafabricplus.ViaFabricPlus; +import de.florianmichael.viafabricplus.settings.impl.DebugSettings; +import net.fabricmc.fabric.impl.client.registry.sync.ClientRegistrySyncHandler; +import net.fabricmc.fabric.impl.registry.sync.packet.RegistryPacketHandler; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(ClientRegistrySyncHandler.class) +public abstract class MixinClientRegistrySyncHandler { + + @Inject(method = "checkRemoteRemap", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;error(Ljava/lang/String;)V", ordinal = 0), cancellable = true, remap = false) + private static void ignoreFabricSyncErrors(RegistryPacketHandler.SyncedPacketData data, CallbackInfo ci) { + if (DebugSettings.global().ignoreFabricSyncErrors.getValue()) { + ViaFabricPlus.global().getLogger().warn("Ignoring missing registries from Fabric API"); + ci.cancel(); + } + } + +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/compat/fabricapi/MixinRegistrySyncManager.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/compat/fabricapi/MixinRegistrySyncManager.java index 1d33fa96..16e5f703 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/compat/fabricapi/MixinRegistrySyncManager.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/compat/fabricapi/MixinRegistrySyncManager.java @@ -21,19 +21,12 @@ package de.florianmichael.viafabricplus.injection.mixin.compat.fabricapi; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import de.florianmichael.viafabricplus.ViaFabricPlus; import de.florianmichael.viafabricplus.fixes.versioned.visual.FootStepParticle1_12_2; -import de.florianmichael.viafabricplus.settings.impl.DebugSettings; -import it.unimi.dsi.fastutil.objects.Object2IntMap; import net.fabricmc.fabric.impl.registry.sync.RegistrySyncManager; import net.minecraft.registry.Registry; import net.minecraft.util.Identifier; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.Map; @Mixin(RegistrySyncManager.class) public abstract class MixinRegistrySyncManager { @@ -48,12 +41,4 @@ public abstract class MixinRegistrySyncManager { } } - @Inject(method = "checkRemoteRemap", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;error(Ljava/lang/String;)V", ordinal = 0), cancellable = true, remap = false) - private static void ignoreFabricSyncErrors(Map> map, CallbackInfo ci) { - if (DebugSettings.global().ignoreFabricSyncErrors.getValue()) { - ViaFabricPlus.global().getLogger().warn("Ignoring missing registries from Fabric API"); - ci.cancel(); - } - } - } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinTextRenderer_Drawer.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinTextRenderer_Drawer.java index f2f3a3ad..7681da22 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinTextRenderer_Drawer.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinTextRenderer_Drawer.java @@ -33,7 +33,7 @@ public abstract class MixinTextRenderer_Drawer { @Unique private static final float viaFabricPlus$offset = 0.5F; // Magical offset to revert the changes done in 1.13 pre6->1.13 pre7 - @ModifyArg(method = "accept", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/BakedGlyph$Rectangle;(FFFFFI)V", ordinal = 0), index = 1) + @ModifyArg(method = "accept", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/BakedGlyph$Rectangle;(FFFFFIIF)V", ordinal = 0), index = 1) private float fixStrikethroughMinY(float value) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) { return value - viaFabricPlus$offset; @@ -42,7 +42,7 @@ public abstract class MixinTextRenderer_Drawer { } } - @ModifyArg(method = "accept", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/BakedGlyph$Rectangle;(FFFFFI)V", ordinal = 0), index = 3) + @ModifyArg(method = "accept", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/BakedGlyph$Rectangle;(FFFFFIIF)V", ordinal = 0), index = 3) private float fixStrikethroughMaxY(float value) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) { return value - viaFabricPlus$offset; diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinWeatherRendering.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinWeatherRendering.java index 9b399e6f..9f984d8d 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinWeatherRendering.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinWeatherRendering.java @@ -33,7 +33,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(WeatherRendering.class) public abstract class MixinWeatherRendering { - @Redirect(method = "renderPrecipitation(Lnet/minecraft/world/World;Lnet/minecraft/client/render/LightmapTextureManager;IFLnet/minecraft/util/math/Vec3d;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getRainGradient(F)F")) + @Redirect(method = "renderPrecipitation(Lnet/minecraft/world/World;Lnet/minecraft/client/render/VertexConsumerProvider;IFLnet/minecraft/util/math/Vec3d;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getRainGradient(F)F")) private float forceSnow(World instance, float delta) { if (CPEAdditions.isSnowing()) { return 1F; diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinWallBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinWallBlock.java index 1f019c20..d0ba5619 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinWallBlock.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinWallBlock.java @@ -172,7 +172,7 @@ public abstract class MixinWallBlock extends Block { @Unique private static int viaFabricPlus$getDirectionMask(Direction dir) { - return 1 << dir.getHorizontal(); + return 1 << dir.getHorizontalQuarterTurns(); } @Unique diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java index e56f07bb..acbe4784 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java @@ -58,7 +58,7 @@ public abstract class MixinLivingEntity extends Entity { protected boolean jumping; @Shadow - protected abstract float getBaseMovementSpeedMultiplier(); + protected abstract float getBaseWaterMovementSpeedMultiplier(); @Shadow private Optional climbingPos; @@ -218,7 +218,7 @@ public abstract class MixinLivingEntity extends Entity { @ModifyConstant(method = "travelInFluid", constant = @Constant(floatValue = 0.9F)) private float modifySwimFriction(float constant) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) { - return this.getBaseMovementSpeedMultiplier(); + return this.getBaseWaterMovementSpeedMultiplier(); } else { return constant; } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinHeldItemRenderer.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinHeldItemRenderer.java index f4a206c7..7c79e029 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinHeldItemRenderer.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinHeldItemRenderer.java @@ -26,7 +26,6 @@ import net.minecraft.client.render.item.HeldItemRenderer; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.BlockItem; import net.minecraft.item.ItemStack; -import net.minecraft.item.ShieldItem; import net.minecraft.util.Arm; import net.minecraft.util.Hand; import net.minecraft.util.math.RotationAxis; @@ -35,7 +34,6 @@ import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Slice; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(HeldItemRenderer.class) @@ -45,34 +43,19 @@ public abstract class MixinHeldItemRenderer { protected abstract void applySwingOffset(MatrixStack matrices, Arm arm, float swingProgress); @Inject(method = "renderFirstPersonItem", - slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getUseAction()Lnet/minecraft/item/consume/UseAction;")), at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;applyEquipOffset(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/util/Arm;F)V", ordinal = 2, shift = At.Shift.AFTER)) - private void transformSwordBlockingPosition(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { - if (!VisualSettings.global().swordBlockingAnimation.isEnabled()) { - return; - } - - final Arm arm = hand == Hand.MAIN_HAND ? player.getMainArm() : player.getMainArm().getOpposite(); - final int direction = arm == Arm.RIGHT ? 1 : -1; - - viaFabricPlus$applySwingOffset(player, hand, swingProgress, matrices); - if (!(item.getItem() instanceof ShieldItem)) { - // Values stripped from early 1.9 snapshots, 15w33b specifically, which is the version prior to them removing sword blocking - matrices.translate(direction * -0.14142136F, 0.08F, 0.14142136F); - matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(-102.25F)); - matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(direction * 13.365F)); - matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(direction * 78.05F)); - } - } - - @Inject(method = "renderFirstPersonItem", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;applyEquipOffset(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/util/Arm;F)V", ordinal = 3, shift = At.Shift.AFTER)) private void applyFoodSwingOffset(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { viaFabricPlus$applySwingOffset(player, hand, swingProgress, matrices); } @Inject(method = "renderFirstPersonItem", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;applyEquipOffset(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/util/Arm;F)V", ordinal = 5, shift = At.Shift.AFTER)) + at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;applyEquipOffset(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/util/Arm;F)V", ordinal = 3, shift = At.Shift.AFTER)) + private void applyBlockingSwingOffset(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { + viaFabricPlus$applySwingOffset(player, hand, swingProgress, matrices); + } + + @Inject(method = "renderFirstPersonItem", + at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;applyEquipOffset(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/util/Arm;F)V", ordinal = 4, shift = At.Shift.AFTER)) private void applyBowSwingOffset(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { viaFabricPlus$applySwingOffset(player, hand, swingProgress, matrices); } diff --git a/src/main/resources/viafabricplus.mixins.json b/src/main/resources/viafabricplus.mixins.json index 25ebe101..b662dd2e 100644 --- a/src/main/resources/viafabricplus.mixins.json +++ b/src/main/resources/viafabricplus.mixins.json @@ -30,6 +30,7 @@ "base.perserverversion.MixinServerInfo", "compat.classic4j.MixinCCAuthenticationResponse", "compat.classic4j.MixinTextFieldWidget", + "compat.fabricapi.MixinClientRegistrySyncHandler", "compat.fabricapi.MixinRegistrySyncManager", "compat.ipnext.MixinAutoRefillHandler_ItemSlotMonitor", "compat.lithium.MixinEntity",