Skip to content

Commit

Permalink
More fixes (#641)
Browse files Browse the repository at this point in the history
  • Loading branch information
lowercasebtw authored and FlorianMichael committed Dec 6, 2024
1 parent 6ce5c55 commit 6045626
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public ParticleTextureSheet getType() {
}

@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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private List<OrderedText> disableServerPinging(TextRenderer instance, StringVisi
}
}

@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 */;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <[email protected]> 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();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,12 @@

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 {
Expand All @@ -48,12 +41,4 @@ private static Identifier skipFootStepParticle(Registry instance, Object t, Oper
}
}

@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();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;<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) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
return value - viaFabricPlus$offset;
Expand All @@ -42,7 +42,7 @@ private float fixStrikethroughMinY(float value) {
}
}

@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) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
return value - viaFabricPlus$offset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
@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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public VoxelShape getCullingShape(BlockState state) {

@Unique
private static int viaFabricPlus$getDirectionMask(Direction dir) {
return 1 << dir.getHorizontal();
return 1 << dir.getHorizontalQuarterTurns();
}

@Unique
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<BlockPos> climbingPos;
Expand Down Expand Up @@ -218,7 +218,7 @@ private void modifySwimSprintFallSpeed(double gravity, boolean movingDown, Vec3d
@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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
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;
Expand All @@ -35,7 +34,6 @@
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)
Expand All @@ -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;

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);
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 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 = 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 = 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);
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/viafabricplus.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 6045626

Please sign in to comment.