diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinCactusBlock.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinCactusBlock.java new file mode 100644 index 00000000..af9e177b --- /dev/null +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinCactusBlock.java @@ -0,0 +1,52 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2025 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2025 ViaVersion and 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 com.viaversion.viafabricplus.injection.mixin.features.bedrock.block.shape; + +import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; +import net.minecraft.block.BlockState; +import net.minecraft.block.CactusBlock; +import net.minecraft.block.ShapeContext; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import net.minecraft.world.BlockView; +import net.raphimc.viabedrock.api.BedrockProtocolVersion; +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.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(CactusBlock.class) +public abstract class MixinCactusBlock { + + @Unique + private static final VoxelShape viaFabricPlus$shape_bedrock = VoxelShapes.cuboid(0.0625, 0, 0.0625, 0.9375, 1, 0.9375); + + @Inject(method = "getCollisionShape", at = @At(value = "RETURN"), cancellable = true) + private void changeCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { + if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { + cir.setReturnValue(viaFabricPlus$shape_bedrock); + } + } + +} diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinCandleCakeBlock.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinCandleCakeBlock.java new file mode 100644 index 00000000..7fa35640 --- /dev/null +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinCandleCakeBlock.java @@ -0,0 +1,71 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2025 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2025 ViaVersion and 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 com.viaversion.viafabricplus.injection.mixin.features.bedrock.block.shape; + +import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.CandleCakeBlock; +import net.minecraft.block.ShapeContext; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.world.BlockView; +import net.raphimc.viabedrock.api.BedrockProtocolVersion; +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.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(CandleCakeBlock.class) +public abstract class MixinCandleCakeBlock extends Block { + + @Unique + private static final VoxelShape viaFabricPlus$shape_bedrock = Block.createColumnShape(14.0F, 0.0F, 8.0F); + + @Shadow + @Final + private static VoxelShape SHAPE; + + public MixinCandleCakeBlock(final Settings settings) { + super(settings); + } + + @Inject(method = "getOutlineShape", at = @At(value = "HEAD"), cancellable = true) + private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { + if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { + cir.setReturnValue(viaFabricPlus$shape_bedrock); + } + } + + @Override + public VoxelShape getCullingShape(BlockState state) { + if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { + return SHAPE; + } else { + return super.getCullingShape(state); + } + } + +} diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinConduitBlock.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinConduitBlock.java new file mode 100644 index 00000000..30b7664a --- /dev/null +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinConduitBlock.java @@ -0,0 +1,72 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2025 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2025 ViaVersion and 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 com.viaversion.viafabricplus.injection.mixin.features.bedrock.block.shape; + +import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.ConduitBlock; +import net.minecraft.block.ShapeContext; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import net.minecraft.world.BlockView; +import net.raphimc.viabedrock.api.BedrockProtocolVersion; +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.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(ConduitBlock.class) +public abstract class MixinConduitBlock extends Block { + + @Unique + private static final VoxelShape viaFabricPlus$shape_bedrock = VoxelShapes.cuboid(0.25, 0, 0.25, 0.75, 0.5, 0.75); + + @Shadow + @Final + private static VoxelShape SHAPE; + + public MixinConduitBlock(final Settings settings) { + super(settings); + } + + @Inject(method = "getOutlineShape", at = @At(value = "RETURN"), cancellable = true) + private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { + if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { + cir.setReturnValue(viaFabricPlus$shape_bedrock); + } + } + + @Override + public VoxelShape getCullingShape(BlockState state) { + if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { + return SHAPE; + } else { + return super.getCullingShape(state); + } + } + +} diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinDoorBlock.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinDoorBlock.java new file mode 100644 index 00000000..d7d63909 --- /dev/null +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinDoorBlock.java @@ -0,0 +1,81 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2025 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2025 ViaVersion and 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 com.viaversion.viafabricplus.injection.mixin.features.bedrock.block.shape; + +import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.DoorBlock; +import net.minecraft.state.property.EnumProperty; +import net.minecraft.util.math.Direction; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import net.raphimc.viabedrock.api.BedrockProtocolVersion; +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; +import java.util.Map; + +@Mixin(DoorBlock.class) +public abstract class MixinDoorBlock extends Block { + + @Unique + private static final Map viaFabricPlus$shape_bedrock = Map.of( + Direction.NORTH, VoxelShapes.cuboid(0, 0, 0.8175, 1, 1, 1), + Direction.SOUTH, VoxelShapes.cuboid(0, 0, 0, 1, 1, 0.1825), + Direction.WEST, VoxelShapes.cuboid(0.8175, 0, 0, 1, 1, 1), + Direction.EAST, VoxelShapes.cuboid(0, 0, 0, 0.1825, 1, 1) + ); + + @Shadow + @Final + private static Map SHAPES_BY_DIRECTION; + + @Shadow + @Final + public static EnumProperty FACING; + + public MixinDoorBlock(final Settings settings) { + super(settings); + } + + @Redirect(method = "getOutlineShape", at = @At(value = "FIELD", target = "Lnet/minecraft/block/DoorBlock;SHAPES_BY_DIRECTION:Ljava/util/Map;")) + private Map changeOutlineShape() { + if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { + return viaFabricPlus$shape_bedrock; + } + return SHAPES_BY_DIRECTION; + } + + @Override + public VoxelShape getCullingShape(BlockState state) { + if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { + return SHAPES_BY_DIRECTION.get(state.get(FACING)); + } else { + return super.getCullingShape(state); + } + } + +} diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinDragonEggBlock.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinDragonEggBlock.java new file mode 100644 index 00000000..cf400253 --- /dev/null +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinDragonEggBlock.java @@ -0,0 +1,67 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2025 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2025 ViaVersion and 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 com.viaversion.viafabricplus.injection.mixin.features.bedrock.block.shape; + +import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.DragonEggBlock; +import net.minecraft.block.ShapeContext; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import net.minecraft.world.BlockView; +import net.raphimc.viabedrock.api.BedrockProtocolVersion; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(DragonEggBlock.class) +public abstract class MixinDragonEggBlock extends Block { + + @Shadow + @Final + private static VoxelShape SHAPE; + + public MixinDragonEggBlock(final Settings settings) { + super(settings); + } + + @Inject(method = "getOutlineShape", at = @At(value = "RETURN"), cancellable = true) + private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { + if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { + cir.setReturnValue(VoxelShapes.fullCube()); + } + } + + @Override + public VoxelShape getCullingShape(BlockState state) { + if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { + return SHAPE; + } else { + return super.getCullingShape(state); + } + } +} diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinHoneyBlock.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinHoneyBlock.java new file mode 100644 index 00000000..5ae92270 --- /dev/null +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinHoneyBlock.java @@ -0,0 +1,52 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2025 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2025 ViaVersion and 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 com.viaversion.viafabricplus.injection.mixin.features.bedrock.block.shape; + +import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; +import net.minecraft.block.BlockState; +import net.minecraft.block.HoneyBlock; +import net.minecraft.block.ShapeContext; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import net.minecraft.world.BlockView; +import net.raphimc.viabedrock.api.BedrockProtocolVersion; +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.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(HoneyBlock.class) +public abstract class MixinHoneyBlock { + + @Unique + private static final VoxelShape viaFabricPlus$shape_bedrock = VoxelShapes.cuboid(0.0625, 0, 0.0625, 0.9375, 1, 0.9375); + + @Inject(method = "getCollisionShape", at = @At(value = "RETURN"), cancellable = true) + private void changeCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { + if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { + cir.setReturnValue(viaFabricPlus$shape_bedrock); + } + } + +} diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinLanternBlock.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinLanternBlock.java new file mode 100644 index 00000000..cdb7f900 --- /dev/null +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinLanternBlock.java @@ -0,0 +1,84 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2025 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2025 ViaVersion and 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 com.viaversion.viafabricplus.injection.mixin.features.bedrock.block.shape; + +import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.LanternBlock; +import net.minecraft.block.ShapeContext; +import net.minecraft.state.property.BooleanProperty; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import net.minecraft.world.BlockView; +import net.raphimc.viabedrock.api.BedrockProtocolVersion; +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.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(LanternBlock.class) +public abstract class MixinLanternBlock extends Block { + + @Unique + private static final VoxelShape viaFabricPlus$shape_bedrock = VoxelShapes.cuboid(0.3125, 0, 0.3125, 0.6875, 0.5, 0.6875); + + @Unique + private static final VoxelShape viaFabricPlus$shape_hanging_bedrock = VoxelShapes.cuboid(0.3125, 0.125, 0.3125, 0.6875, 0.625, 0.6875); + + @Shadow + @Final + public static BooleanProperty HANGING; + + @Shadow + @Final + private static VoxelShape STANDING_SHAPE; + + @Shadow + @Final + private static VoxelShape HANGING_SHAPE; + + public MixinLanternBlock(final Settings settings) { + super(settings); + } + + @Inject(method = "getOutlineShape", at = @At("RETURN"), cancellable = true) + private void modifyCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { + if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { + cir.setReturnValue(state.get(HANGING) ? viaFabricPlus$shape_hanging_bedrock : viaFabricPlus$shape_bedrock); + } + } + + @Override + public VoxelShape getCullingShape(BlockState state) { + if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { + return state.get(HANGING) ? HANGING_SHAPE : STANDING_SHAPE; + } else { + return super.getCullingShape(state); + } + } + +} diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinLecternBlock.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinLecternBlock.java new file mode 100644 index 00000000..12fba145 --- /dev/null +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinLecternBlock.java @@ -0,0 +1,52 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2025 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2025 ViaVersion and 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 com.viaversion.viafabricplus.injection.mixin.features.bedrock.block.shape; + +import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; +import net.minecraft.block.BlockState; +import net.minecraft.block.LecternBlock; +import net.minecraft.block.ShapeContext; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import net.minecraft.world.BlockView; +import net.raphimc.viabedrock.api.BedrockProtocolVersion; +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.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(LecternBlock.class) +public abstract class MixinLecternBlock { + + @Unique + private static final VoxelShape viaFabricPlus$shape_bedrock = VoxelShapes.cuboid(0, 0, 0, 1, 0.9, 1); + + @Inject(method = "getCollisionShape", at = @At("RETURN"), cancellable = true) + private void changeCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { + if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { + cir.setReturnValue(viaFabricPlus$shape_bedrock); + } + } + +} diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinSeaPickleBlock.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinSeaPickleBlock.java new file mode 100644 index 00000000..dd6324af --- /dev/null +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinSeaPickleBlock.java @@ -0,0 +1,102 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2025 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2025 ViaVersion and 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 com.viaversion.viafabricplus.injection.mixin.features.bedrock.block.shape; + +import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.SeaPickleBlock; +import net.minecraft.block.ShapeContext; +import net.minecraft.state.property.IntProperty; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import net.minecraft.world.BlockView; +import net.raphimc.viabedrock.api.BedrockProtocolVersion; +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.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(SeaPickleBlock.class) +public class MixinSeaPickleBlock extends Block { + + @Unique + private static final VoxelShape viaFabricPlus$shape_bedrock = Block.createColumnShape(16.0F, 0.0F, 6.0F); + + @Shadow + @Final + private static VoxelShape ONE_PICKLE_SHAPE; + + @Shadow + @Final + private static VoxelShape TWO_PICKLES_SHAPE; + + @Shadow + @Final + private static VoxelShape THREE_PICKLES_SHAPE; + + @Shadow + @Final + private static VoxelShape FOUR_PICKLES_SHAPE; + + @Shadow + @Final + public static IntProperty PICKLES; + + public MixinSeaPickleBlock(final Settings settings) { + super(settings); + } + + @Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true) + private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { + if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { + cir.setReturnValue(viaFabricPlus$shape_bedrock); + } + } + + @Override + public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { + if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { + return VoxelShapes.empty(); + } else { + return super.getCollisionShape(state, world, pos, context); + } + } + + @Override + public VoxelShape getCullingShape(BlockState state) { + if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { + return switch (state.get(PICKLES)) { + case 2 -> TWO_PICKLES_SHAPE; + case 3 -> THREE_PICKLES_SHAPE; + case 4 -> FOUR_PICKLES_SHAPE; + default -> ONE_PICKLE_SHAPE; + }; + } else { + return super.getCullingShape(state); + } + } +} diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinTrapdoorBlock.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinTrapdoorBlock.java new file mode 100644 index 00000000..840dda9a --- /dev/null +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/bedrock/block/shape/MixinTrapdoorBlock.java @@ -0,0 +1,89 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2025 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2025 ViaVersion and 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 com.viaversion.viafabricplus.injection.mixin.features.bedrock.block.shape; + +import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; +import net.minecraft.block.BlockState; +import net.minecraft.block.HorizontalFacingBlock; +import net.minecraft.block.TrapdoorBlock; +import net.minecraft.block.enums.BlockHalf; +import net.minecraft.state.property.BooleanProperty; +import net.minecraft.state.property.EnumProperty; +import net.minecraft.util.math.Direction; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import net.raphimc.viabedrock.api.BedrockProtocolVersion; +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; +import java.util.Map; + +@Mixin(TrapdoorBlock.class) +public abstract class MixinTrapdoorBlock extends HorizontalFacingBlock { + + @Unique + private static final Map viaFabricPlus$shape_bedrock = Map.of( + Direction.NORTH, VoxelShapes.cuboid(0, 0, 0.8175, 1, 1, 1), + Direction.SOUTH, VoxelShapes.cuboid(0, 0, 0, 1, 1, 0.1825), + Direction.WEST, VoxelShapes.cuboid(0.8175, 0, 0, 1, 1, 1), + Direction.EAST, VoxelShapes.cuboid(0, 0, 0, 0.1825, 1, 1), + Direction.DOWN, VoxelShapes.cuboid(0, 0.8175, 0, 1, 1, 1), + Direction.UP, VoxelShapes.cuboid(0, 0, 0, 1, 0.1825, 1) + ); + + @Shadow + @Final + private static Map shapeByDirection; + + @Shadow + @Final + public static EnumProperty HALF; + + @Shadow + @Final + public static BooleanProperty OPEN; + + public MixinTrapdoorBlock(final Settings settings) { + super(settings); + } + + @Redirect(method = "getOutlineShape", at = @At(value = "FIELD", target = "Lnet/minecraft/block/TrapdoorBlock;shapeByDirection:Ljava/util/Map;")) + private Map changeOutlineShape() { + if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { + return viaFabricPlus$shape_bedrock; + } + return shapeByDirection; + } + + @Override + public VoxelShape getCullingShape(BlockState state) { + if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { + return shapeByDirection.get(state.get(OPEN) ? state.get(FACING) : (state.get(HALF) == BlockHalf.TOP ? Direction.DOWN : Direction.UP)); + } else { + return super.getCullingShape(state); + } + } + +} diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/block/shape/MixinCauldronBlock.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/block/shape/MixinCauldronBlock.java index 6fa05c5b..ed00b049 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/block/shape/MixinCauldronBlock.java +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/block/shape/MixinCauldronBlock.java @@ -35,6 +35,7 @@ import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; import net.minecraft.world.BlockView; +import net.raphimc.viabedrock.api.BedrockProtocolVersion; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; @@ -48,6 +49,15 @@ public abstract class MixinCauldronBlock extends AbstractCauldronBlock { BooleanBiFunction.ONLY_FIRST ); + @Unique + private static final VoxelShape viaFabricPlus$shape_bedrock = VoxelShapes.union( + VoxelShapes.cuboid(0.0, 0.0, 0.0, 1.0, 0.3125, 1.0), + VoxelShapes.cuboid(0.0, 0.0, 0.0, 0.125, 1.0, 1.0), + VoxelShapes.cuboid(0.0, 0.0, 0.0, 1.0, 1.0, 0.125), + VoxelShapes.cuboid(1.0 - 0.125, 0.0, 0.0, 1.0, 1.0, 1.0), + VoxelShapes.cuboid(0.0, 0.0, 1.0 - 0.125, 1.0, 1.0, 1.0) + ); + public MixinCauldronBlock(Settings settings, CauldronBehavior.CauldronBehaviorMap behaviorMap) { super(settings, behaviorMap); } @@ -61,6 +71,8 @@ public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos po viaFabricPlus$requireOriginalShape = false; } else if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) { return viaFabricPlus$shape_r1_12_2; + } else if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { + return viaFabricPlus$shape_bedrock; } return super.getOutlineShape(state, world, pos, context); } diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/block/shape/MixinChestBlock.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/block/shape/MixinChestBlock.java index 5b3ad382..509cc70f 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/block/shape/MixinChestBlock.java +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/block/shape/MixinChestBlock.java @@ -25,12 +25,14 @@ import java.util.Map; import java.util.function.Supplier; import net.minecraft.block.AbstractChestBlock; +import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.ChestBlock; import net.minecraft.block.ShapeContext; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.ChestBlockEntity; import net.minecraft.block.enums.ChestType; +import net.minecraft.state.property.EnumProperty; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.shape.VoxelShape; @@ -41,6 +43,7 @@ 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.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @@ -48,6 +51,17 @@ @Mixin(ChestBlock.class) public abstract class MixinChestBlock extends AbstractChestBlock { + @Unique + private static final VoxelShape viaFabricPlus$single_chest_shape_bedrock = VoxelShapes.cuboid(0.025, 0, 0.025, 0.975, 0.95, 0.975); + + @Unique + private static final Map viaFabricPlus$double_chest_shapes_bedrock = Map.of( + Direction.NORTH, VoxelShapes.cuboid(0.025, 0, 0, 0.975, 0.95, 0.975), + Direction.SOUTH, VoxelShapes.cuboid(0.025, 0, 0.025, 0.975, 0.95, 1), + Direction.WEST, VoxelShapes.cuboid(0, 0, 0.025, 0.975, 0.95, 0.975), + Direction.EAST, VoxelShapes.cuboid(0.025, 0, 0.025, 1, 0.95, 0.975) + ); + @Shadow @Final private static Map DOUBLE_SHAPES_BY_DIRECTION; @@ -56,6 +70,15 @@ public abstract class MixinChestBlock extends AbstractChestBlock CHEST_TYPE; + + @Shadow + public static Direction getFacing(final BlockState state) { + return null; + } + protected MixinChestBlock(Settings settings, Supplier> blockEntityTypeSupplier) { super(settings, blockEntityTypeSupplier); } @@ -65,12 +88,18 @@ private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_4_2) || ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { cir.setReturnValue(VoxelShapes.fullCube()); + } else if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { + cir.setReturnValue(switch (state.get(CHEST_TYPE)) { + case SINGLE -> viaFabricPlus$single_chest_shape_bedrock; + case LEFT, RIGHT -> viaFabricPlus$double_chest_shapes_bedrock.get(getFacing(state)); + }); } } @Override public VoxelShape getCullingShape(BlockState state) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_4_2)) { + if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_4_2) + || ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { if (state.get(ChestBlock.CHEST_TYPE) == ChestType.SINGLE) { return SINGLE_SHAPE; } else { diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/block/shape/MixinEndPortalFrameBlock.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/block/shape/MixinEndPortalFrameBlock.java index 877219f9..ec9dab27 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/block/shape/MixinEndPortalFrameBlock.java +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/block/shape/MixinEndPortalFrameBlock.java @@ -32,6 +32,7 @@ import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; import net.minecraft.world.BlockView; +import net.raphimc.viabedrock.api.BedrockProtocolVersion; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -57,6 +58,9 @@ public abstract class MixinEndPortalFrameBlock extends Block { @Unique private static final VoxelShape viaFabricPlus$frame_with_eye_shape_r1_12_2 = VoxelShapes.union(FRAME_SHAPE, viaFabricPlus$eye_shape_r1_12_2); + @Unique + private static final VoxelShape viaFabricPlus$shape_frame_bedrock = VoxelShapes.cuboid(0, 0, 0, 1, 0.8125, 1); + public MixinEndPortalFrameBlock(Settings settings) { super(settings); } @@ -65,6 +69,9 @@ public MixinEndPortalFrameBlock(Settings settings) { private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) { cir.setReturnValue(FRAME_SHAPE); + } else if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { + // The eye doesn't have a different shape on bedrock + cir.setReturnValue(viaFabricPlus$shape_frame_bedrock); } } @@ -77,4 +84,13 @@ public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos } } + @Override + public VoxelShape getCullingShape(BlockState state) { + if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { + return FRAME_SHAPE; + } else { + return super.getCullingShape(state); + } + } + } diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/block/shape/MixinEnderChestBlock.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/block/shape/MixinEnderChestBlock.java index 0d70119d..e2c5e1cb 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/block/shape/MixinEnderChestBlock.java +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/block/shape/MixinEnderChestBlock.java @@ -22,6 +22,7 @@ package com.viaversion.viafabricplus.injection.mixin.features.block.shape; import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; +import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.BlockWithEntity; import net.minecraft.block.EnderChestBlock; @@ -35,6 +36,7 @@ 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.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @@ -42,6 +44,9 @@ @Mixin(EnderChestBlock.class) public abstract class MixinEnderChestBlock extends BlockWithEntity { + @Unique + private static final VoxelShape viaFabricPlus$shape_bedrock = VoxelShapes.cuboid(0.025, 0, 0.025, 0.975, 0.95, 0.975); + @Shadow @Final private static VoxelShape SHAPE; @@ -55,12 +60,15 @@ private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_4_2) || ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { cir.setReturnValue(VoxelShapes.fullCube()); + } else if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { + cir.setReturnValue(viaFabricPlus$shape_bedrock); } } @Override public VoxelShape getCullingShape(BlockState state) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_4_2)) { + if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_4_2) + || ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { return SHAPE; } else { return super.getCullingShape(state); diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/block/shape/MixinLadderBlock.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/block/shape/MixinLadderBlock.java index d03169a1..833a1e62 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/block/shape/MixinLadderBlock.java +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/block/shape/MixinLadderBlock.java @@ -26,40 +26,68 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.LadderBlock; -import net.minecraft.block.ShapeContext; -import net.minecraft.util.math.BlockPos; +import net.minecraft.state.property.EnumProperty; +import net.minecraft.util.math.Direction; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; +import net.minecraft.util.shape.VoxelShapes; +import net.raphimc.viabedrock.api.BedrockProtocolVersion; +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.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.Redirect; +import java.util.Map; @Mixin(LadderBlock.class) -public abstract class MixinLadderBlock { +public abstract class MixinLadderBlock extends Block { @Unique - private static final VoxelShape viaFabricPlus$east_shape_r1_8_x = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 2.0D, 16.0D, 16.0D); + private static final Map viaFabricPlus$shapes_r1_8_x = Map.of( + Direction.NORTH, Block.createCuboidShape(0.0D, 0.0D, 14.0D, 16.0D, 16.0D, 16.0D), + Direction.SOUTH, Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 2.0D), + Direction.WEST, Block.createCuboidShape(14.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D), + Direction.EAST, Block.createCuboidShape(0.0D, 0.0D, 0.0D, 2.0D, 16.0D, 16.0D) + ); @Unique - private static final VoxelShape viaFabricPlus$west_shape_r1_8_x = Block.createCuboidShape(14.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D); + private static final Map viaFabricPlus$shapes_bedrock = Map.of( + Direction.NORTH, VoxelShapes.cuboid(0, 0, 0.8125, 1, 1, 1), + Direction.SOUTH, VoxelShapes.cuboid(0, 0, 0, 1, 1, 0.1875), + Direction.WEST, VoxelShapes.cuboid(0.8125, 0, 0, 1, 1, 1), + Direction.EAST, VoxelShapes.cuboid(0, 0, 0, 0.1875, 1, 1) + ); - @Unique - private static final VoxelShape viaFabricPlus$south_shape_r1_8_x = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 2.0D); + @Shadow + @Final + public static Map SHAPES_BY_DIRECTION; - @Unique - private static final VoxelShape viaFabricPlus$north_shape_r1_8_x = Block.createCuboidShape(0.0D, 0.0D, 14.0D, 16.0D, 16.0D, 16.0D); + @Shadow + @Final + public static EnumProperty FACING; + + public MixinLadderBlock(final Settings settings) { + super(settings); + } - @Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true) - private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable ci) { + @Redirect(method = "getOutlineShape", at = @At(value = "FIELD", target = "Lnet/minecraft/block/LadderBlock;SHAPES_BY_DIRECTION:Ljava/util/Map;")) + private Map changeOutlineShape() { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) { - switch (state.get(LadderBlock.FACING)) { - case NORTH -> ci.setReturnValue(viaFabricPlus$north_shape_r1_8_x); - case SOUTH -> ci.setReturnValue(viaFabricPlus$south_shape_r1_8_x); - case WEST -> ci.setReturnValue(viaFabricPlus$west_shape_r1_8_x); - default -> ci.setReturnValue(viaFabricPlus$east_shape_r1_8_x); - } + return viaFabricPlus$shapes_r1_8_x; + } else if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { + return viaFabricPlus$shapes_bedrock; + } else { + return SHAPES_BY_DIRECTION; + } + } + + @Override + public VoxelShape getCullingShape(BlockState state) { + if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8) + || ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { + return SHAPES_BY_DIRECTION.get(state.get(FACING)); + } else { + return super.getCullingShape(state); } } diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/movement/constants/MixinEntity.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/movement/constants/MixinEntity.java index 50e12da4..dee19688 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/movement/constants/MixinEntity.java +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/movement/constants/MixinEntity.java @@ -61,4 +61,4 @@ private void expandHitBox(CallbackInfoReturnable cir) { } } -} \ No newline at end of file +} diff --git a/src/main/resources/viafabricplus.mixins.json b/src/main/resources/viafabricplus.mixins.json index a335e5d0..48fad7e7 100644 --- a/src/main/resources/viafabricplus.mixins.json +++ b/src/main/resources/viafabricplus.mixins.json @@ -46,6 +46,16 @@ "features.april_fools_8bit_sound.MixinStaticSound", "features.bedrock.allow_new_line.MixinTextRenderer", "features.bedrock.reach_around_raycast.MixinGameRenderer", + "features.bedrock.block.shape.MixinCactusBlock", + "features.bedrock.block.shape.MixinCandleCakeBlock", + "features.bedrock.block.shape.MixinConduitBlock", + "features.bedrock.block.shape.MixinDoorBlock", + "features.bedrock.block.shape.MixinDragonEggBlock", + "features.bedrock.block.shape.MixinHoneyBlock", + "features.bedrock.block.shape.MixinLanternBlock", + "features.bedrock.block.shape.MixinLecternBlock", + "features.bedrock.block.shape.MixinSeaPickleBlock", + "features.bedrock.block.shape.MixinTrapdoorBlock", "features.bedrock.remove_dummy_player_suggestions.MixinClientCommandSource", "features.block.interaction.MixinAbstractSignBlock", "features.block.interaction.MixinCanPlaceAt1_14",