Temporary workaround GH-436 again

This commit is contained in:
FlorianMichael 2024-11-25 22:10:44 +01:00
parent fd8fcaf859
commit 3ed87660bd
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126

View File

@ -25,6 +25,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.FarmlandBlock;
import net.minecraft.block.ShapeContext;
import net.minecraft.client.MinecraftClient;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
@ -49,6 +50,13 @@ public abstract class MixinFarmlandBlock extends Block {
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
if (MinecraftClient.getInstance() != null && MinecraftClient.getInstance().isInSingleplayer()) {
// When joining the singleplayer, we set the target version to the native version when the integrated server is started
// However this is already to late for blocks since the world and entities have already been loaded, causing block collisions
// to make issues as described via https://github.com/ViaVersion/ViaFabricPlus/issues/436. TODO move version setting to earlier stage
return;
}
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_9_3)) {
cir.setReturnValue(VoxelShapes.fullCube());
}
@ -56,6 +64,11 @@ public abstract class MixinFarmlandBlock extends Block {
@Override
public VoxelShape getCullingShape(BlockState state) {
if (MinecraftClient.getInstance() != null && MinecraftClient.getInstance().isInSingleplayer()) {
// See above for explanation
return super.getCullingShape(state);
}
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_9_3)) {
return SHAPE;
} else {