From 41ab6b6f780daae230f2abbd0692ab0b05a167a3 Mon Sep 17 00:00:00 2001 From: Uko Kokņevičs Date: Tue, 9 Jan 2024 20:36:17 +0100 Subject: Make Alchemical Chest waterloggable. --- .../eris_alchemy/block/AlchemicalChestBlock.java | 40 ++++++++++++++++++---- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/src/main/java/lv/enes/mc/eris_alchemy/block/AlchemicalChestBlock.java b/src/main/java/lv/enes/mc/eris_alchemy/block/AlchemicalChestBlock.java index c013df6..9a3b413 100644 --- a/src/main/java/lv/enes/mc/eris_alchemy/block/AlchemicalChestBlock.java +++ b/src/main/java/lv/enes/mc/eris_alchemy/block/AlchemicalChestBlock.java @@ -14,6 +14,7 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.block.*; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; @@ -22,15 +23,20 @@ import net.minecraft.world.level.block.entity.ChestBlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.BooleanProperty; import net.minecraft.world.level.block.state.properties.DirectionProperty; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; import net.minecraft.world.level.pathfinder.PathComputationType; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; -public class AlchemicalChestBlock extends AbstractChestBlock { - public static final Component CONTAINER_TITLE = Component.translatable("container.eris_alchemy.alchemical_chest"); +public class AlchemicalChestBlock extends AbstractChestBlock implements SimpleWaterloggedBlock { public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING; + public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; + + public static final Component CONTAINER_TITLE = Component.translatable("container.eris_alchemy.alchemical_chest"); public static final VoxelShape SHAPE = Block.box(1.0, 0.0, 1.0, 15.0, 14.0, 15.0); public static Container getContainer(Level world, BlockPos pos) { @@ -44,6 +50,7 @@ public class AlchemicalChestBlock extends AbstractChestBlock ErisAlchemyBlockEntities.ALCHEMICAL_CHEST); registerDefaultState(getStateDefinition().any() .setValue(FACING, Direction.NORTH) + .setValue(WATERLOGGED, false) ); } @@ -53,15 +60,17 @@ public class AlchemicalChestBlock extends AbstractChestBlock builder) { - builder.add(FACING); + public int getAnalogOutputSignal(BlockState state, Level world, BlockPos pos) { + return AlchemicalChestMenu.getRedstoneSignalFromContainer(getContainer(world, pos)); } @SuppressWarnings("deprecation") + @Nonnull @Override - public int getAnalogOutputSignal(BlockState state, Level world, BlockPos pos) { - return AlchemicalChestMenu.getRedstoneSignalFromContainer(getContainer(world, pos)); + public FluidState getFluidState(BlockState state) { + return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state); } @Override @@ -88,7 +97,8 @@ public class AlchemicalChestBlock extends AbstractChestBlock builder) { + builder.add(FACING, WATERLOGGED); + } } -- cgit v1.2.3