More fixes (#641)

This commit is contained in:
lowercasebtw 2024-12-03 17:53:39 -05:00 committed by FlorianMichael
parent 6ce5c55b7f
commit 6045626f08
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
10 changed files with 58 additions and 47 deletions

View File

@ -63,7 +63,7 @@ public class FootStepParticle1_12_2 extends SpriteBillboardParticle {
} }
@Override @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; final float strength = ((float) this.age + tickDelta) / (float) this.maxAge;
this.alpha = 2.0F - (strength * strength) * 2.0F; this.alpha = 2.0F - (strength * strength) * 2.0F;
if (this.alpha > 1.0F) { if (this.alpha > 1.0F) {

View File

@ -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) { private int disableServerPinging(int x) {
if (viaFabricPlus$disableServerPinging) { // Move server label to the right (as we remove the ping bar) if (viaFabricPlus$disableServerPinging) { // Move server label to the right (as we remove the ping bar)
x += 15 /* ping bar width */ - 3 /* magical offset */; x += 15 /* ping bar width */ - 3 /* magical offset */;

View File

@ -0,0 +1,42 @@
/*
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> 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 <http://www.gnu.org/licenses/>.
*/
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();
}
}
}

View File

@ -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.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; 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.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.fabricmc.fabric.impl.registry.sync.RegistrySyncManager;
import net.minecraft.registry.Registry; import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; 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) @Mixin(RegistrySyncManager.class)
public abstract class MixinRegistrySyncManager { 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<Identifier, Object2IntMap<Identifier>> map, CallbackInfo ci) {
if (DebugSettings.global().ignoreFabricSyncErrors.getValue()) {
ViaFabricPlus.global().getLogger().warn("Ignoring missing registries from Fabric API");
ci.cancel();
}
}
} }

View File

@ -33,7 +33,7 @@ public abstract class MixinTextRenderer_Drawer {
@Unique @Unique
private static final float viaFabricPlus$offset = 0.5F; // Magical offset to revert the changes done in 1.13 pre6->1.13 pre7 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;<init>(FFFFFI)V", ordinal = 0), index = 1) @ModifyArg(method = "accept", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/BakedGlyph$Rectangle;<init>(FFFFFIIF)V", ordinal = 0), index = 1)
private float fixStrikethroughMinY(float value) { private float fixStrikethroughMinY(float value) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
return value - viaFabricPlus$offset; 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;<init>(FFFFFI)V", ordinal = 0), index = 3) @ModifyArg(method = "accept", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/BakedGlyph$Rectangle;<init>(FFFFFIIF)V", ordinal = 0), index = 3)
private float fixStrikethroughMaxY(float value) { private float fixStrikethroughMaxY(float value) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
return value - viaFabricPlus$offset; return value - viaFabricPlus$offset;

View File

@ -33,7 +33,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(WeatherRendering.class) @Mixin(WeatherRendering.class)
public abstract class MixinWeatherRendering { 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) { private float forceSnow(World instance, float delta) {
if (CPEAdditions.isSnowing()) { if (CPEAdditions.isSnowing()) {
return 1F; return 1F;

View File

@ -172,7 +172,7 @@ public abstract class MixinWallBlock extends Block {
@Unique @Unique
private static int viaFabricPlus$getDirectionMask(Direction dir) { private static int viaFabricPlus$getDirectionMask(Direction dir) {
return 1 << dir.getHorizontal(); return 1 << dir.getHorizontalQuarterTurns();
} }
@Unique @Unique

View File

@ -58,7 +58,7 @@ public abstract class MixinLivingEntity extends Entity {
protected boolean jumping; protected boolean jumping;
@Shadow @Shadow
protected abstract float getBaseMovementSpeedMultiplier(); protected abstract float getBaseWaterMovementSpeedMultiplier();
@Shadow @Shadow
private Optional<BlockPos> climbingPos; private Optional<BlockPos> climbingPos;
@ -218,7 +218,7 @@ public abstract class MixinLivingEntity extends Entity {
@ModifyConstant(method = "travelInFluid", constant = @Constant(floatValue = 0.9F)) @ModifyConstant(method = "travelInFluid", constant = @Constant(floatValue = 0.9F))
private float modifySwimFriction(float constant) { private float modifySwimFriction(float constant) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
return this.getBaseMovementSpeedMultiplier(); return this.getBaseWaterMovementSpeedMultiplier();
} else { } else {
return constant; return constant;
} }

View File

@ -26,7 +26,6 @@ import net.minecraft.client.render.item.HeldItemRenderer;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.ShieldItem;
import net.minecraft.util.Arm; import net.minecraft.util.Arm;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.RotationAxis; 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.Unique;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Slice;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(HeldItemRenderer.class) @Mixin(HeldItemRenderer.class)
@ -45,34 +43,19 @@ public abstract class MixinHeldItemRenderer {
protected abstract void applySwingOffset(MatrixStack matrices, Arm arm, float swingProgress); protected abstract void applySwingOffset(MatrixStack matrices, Arm arm, float swingProgress);
@Inject(method = "renderFirstPersonItem", @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)) 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) { 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); viaFabricPlus$applySwingOffset(player, hand, swingProgress, matrices);
} }
@Inject(method = "renderFirstPersonItem", @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) { 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); viaFabricPlus$applySwingOffset(player, hand, swingProgress, matrices);
} }

View File

@ -30,6 +30,7 @@
"base.perserverversion.MixinServerInfo", "base.perserverversion.MixinServerInfo",
"compat.classic4j.MixinCCAuthenticationResponse", "compat.classic4j.MixinCCAuthenticationResponse",
"compat.classic4j.MixinTextFieldWidget", "compat.classic4j.MixinTextFieldWidget",
"compat.fabricapi.MixinClientRegistrySyncHandler",
"compat.fabricapi.MixinRegistrySyncManager", "compat.fabricapi.MixinRegistrySyncManager",
"compat.ipnext.MixinAutoRefillHandler_ItemSlotMonitor", "compat.ipnext.MixinAutoRefillHandler_ItemSlotMonitor",
"compat.lithium.MixinEntity", "compat.lithium.MixinEntity",