Fix strikethrough offset in <= 1.12.2

Closes https://github.com/ViaVersion/ViaFabricPlus/issues/507

Co-authored-by: lowercasebtw <126462578+lowercasebtw@users.noreply.github.com>
This commit is contained in:
FlorianMichael 2024-08-07 13:17:06 +02:00
parent 8b98e9fd4c
commit 59fe914604
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
3 changed files with 56 additions and 0 deletions

View File

@ -0,0 +1,54 @@
/*
* 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.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;<init>(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;<init>(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;
}
}
}

View File

@ -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

View File

@ -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",