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 new file mode 100644 index 00000000..99e3d005 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinTextRenderer_Drawer.java @@ -0,0 +1,54 @@ +/* + * 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.fixes.minecraft; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; +import net.minecraft.client.font.TextRenderer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyArg; + +@Mixin(TextRenderer.Drawer.class) +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/GlyphRenderer$Rectangle;(FFFFFFFFF)V", ordinal = 0), index = 1) + private float fixStrikethroughMinY(float value) { + if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) { + return value - viaFabricPlus$offset; + } else { + return value; + } + } + + @ModifyArg(method = "accept", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/GlyphRenderer$Rectangle;(FFFFFFFFF)V", ordinal = 0), index = 3) + private float fixStrikethroughMaxY(float value) { + if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) { + return value - viaFabricPlus$offset; + } else { + return value; + } + } + +} diff --git a/src/main/resources/viafabricplus.accesswidener b/src/main/resources/viafabricplus.accesswidener index 1dba0522..d696ee96 100644 --- a/src/main/resources/viafabricplus.accesswidener +++ b/src/main/resources/viafabricplus.accesswidener @@ -27,6 +27,7 @@ accessible method net/minecraft/item/BlockItem getPlacementState (Lnet/minecraft accessible class net/minecraft/client/gui/screen/GameModeSelectionScreen$GameModeSelection accessible class net/minecraft/client/font/FontStorage$GlyphPair +accessible class net/minecraft/client/font/TextRenderer$Drawer mutable field net/minecraft/entity/EntityType dimensions Lnet/minecraft/entity/EntityDimensions; mutable field net/minecraft/block/AbstractBlock velocityMultiplier F diff --git a/src/main/resources/viafabricplus.mixins.json b/src/main/resources/viafabricplus.mixins.json index d6e4fe92..a304cf8e 100644 --- a/src/main/resources/viafabricplus.mixins.json +++ b/src/main/resources/viafabricplus.mixins.json @@ -62,6 +62,7 @@ "fixes.minecraft.MixinStaticSound", "fixes.minecraft.MixinStringHelper", "fixes.minecraft.MixinTextRenderer", + "fixes.minecraft.MixinTextRenderer_Drawer", "fixes.minecraft.MixinWorldRenderer", "fixes.minecraft.block.MixinAbstractBlock", "fixes.minecraft.block.MixinAbstractBlock_AbstractBlockState",