From 6cdfd2ddb6db4984181105294f425a1278ae82fa Mon Sep 17 00:00:00 2001 From: ManInMyVan <113963219+ManInMyVan@users.noreply.github.com> Date: Mon, 16 Sep 2024 09:29:55 -0600 Subject: [PATCH] Fix ascending rail collision box in 1.10 (#564) --- .../block/MixinAbstractRailBlock.java | 58 +++++++++++++++++++ src/main/resources/viafabricplus.mixins.json | 1 + 2 files changed, 59 insertions(+) create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinAbstractRailBlock.java diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinAbstractRailBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinAbstractRailBlock.java new file mode 100644 index 00000000..5d934e65 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinAbstractRailBlock.java @@ -0,0 +1,58 @@ +/* + * 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.block; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; +import net.minecraft.block.*; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +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.Redirect; + +@Mixin(AbstractRailBlock.class) +public abstract class MixinAbstractRailBlock extends Block { + + @Shadow + @Final + protected static VoxelShape ASCENDING_SHAPE; + + @Unique + private static final VoxelShape viaFabricPlus$ascending_shape_r1_10_x = VoxelShapes.fullCube(); + + public MixinAbstractRailBlock(Settings settings) { + super(settings); + } + + @Redirect(method = "getOutlineShape", at = @At(value = "FIELD", target = "Lnet/minecraft/block/AbstractRailBlock;ASCENDING_SHAPE:Lnet/minecraft/util/shape/VoxelShape;")) + private VoxelShape changeOutlineShape() { + // https://bugs.mojang.com/browse/MC-102638 + if (ProtocolTranslator.getTargetVersion().equalTo(ProtocolVersion.v1_10)) { + return viaFabricPlus$ascending_shape_r1_10_x; + } else { + return ASCENDING_SHAPE; + } + } + +} diff --git a/src/main/resources/viafabricplus.mixins.json b/src/main/resources/viafabricplus.mixins.json index cdd058fd..54112e1b 100644 --- a/src/main/resources/viafabricplus.mixins.json +++ b/src/main/resources/viafabricplus.mixins.json @@ -67,6 +67,7 @@ "fixes.minecraft.MixinWorldRenderer", "fixes.minecraft.block.MixinAbstractBlock", "fixes.minecraft.block.MixinAbstractBlock_AbstractBlockState", + "fixes.minecraft.block.MixinAbstractRailBlock", "fixes.minecraft.block.MixinAbstractSignBlock", "fixes.minecraft.block.MixinAnvilBlock", "fixes.minecraft.block.MixinBedBlock",