diff options
Diffstat (limited to 'src/main/java/lv/enes/mc/eris_alchemy/block/AlchemicalChestBlock.java')
| -rw-r--r-- | src/main/java/lv/enes/mc/eris_alchemy/block/AlchemicalChestBlock.java | 53 |
1 files changed, 43 insertions, 10 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 9a3b413..1d8698a 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 | |||
| @@ -2,8 +2,8 @@ package lv.enes.mc.eris_alchemy.block; | |||
| 2 | 2 | ||
| 3 | import jakarta.annotation.Nonnull; | 3 | import jakarta.annotation.Nonnull; |
| 4 | import jakarta.annotation.Nullable; | 4 | import jakarta.annotation.Nullable; |
| 5 | import lv.enes.mc.eris_alchemy.ErisAlchemyRegistry; | ||
| 5 | import lv.enes.mc.eris_alchemy.block.entity.AlchemicalChestBlockEntity; | 6 | import lv.enes.mc.eris_alchemy.block.entity.AlchemicalChestBlockEntity; |
| 6 | import lv.enes.mc.eris_alchemy.block.entity.ErisAlchemyBlockEntities; | ||
| 7 | import lv.enes.mc.eris_alchemy.menu.AlchemicalChestMenu; | 7 | import lv.enes.mc.eris_alchemy.menu.AlchemicalChestMenu; |
| 8 | import net.minecraft.core.BlockPos; | 8 | import net.minecraft.core.BlockPos; |
| 9 | import net.minecraft.core.Direction; | 9 | import net.minecraft.core.Direction; |
| @@ -32,12 +32,18 @@ import net.minecraft.world.phys.BlockHitResult; | |||
| 32 | import net.minecraft.world.phys.shapes.CollisionContext; | 32 | import net.minecraft.world.phys.shapes.CollisionContext; |
| 33 | import net.minecraft.world.phys.shapes.VoxelShape; | 33 | import net.minecraft.world.phys.shapes.VoxelShape; |
| 34 | 34 | ||
| 35 | public class AlchemicalChestBlock extends AbstractChestBlock<AlchemicalChestBlockEntity> implements SimpleWaterloggedBlock { | 35 | public class AlchemicalChestBlock |
| 36 | extends AbstractChestBlock<AlchemicalChestBlockEntity> | ||
| 37 | implements SimpleWaterloggedBlock | ||
| 38 | { | ||
| 36 | public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING; | 39 | public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING; |
| 37 | public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; | 40 | public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; |
| 38 | 41 | ||
| 39 | public static final Component CONTAINER_TITLE = Component.translatable("container.eris_alchemy.alchemical_chest"); | 42 | public static final Component CONTAINER_TITLE = Component.translatable("container.eris_alchemy.alchemical_chest"); |
| 40 | public static final VoxelShape SHAPE = Block.box(1.0, 0.0, 1.0, 15.0, 14.0, 15.0); | 43 | public static final VoxelShape SHAPE = Block.box( |
| 44 | 1.0, 0.0, 1.0, | ||
| 45 | 15.0, 14.0, 15.0 | ||
| 46 | ); | ||
| 41 | 47 | ||
| 42 | public static Container getContainer(Level world, BlockPos pos) { | 48 | public static Container getContainer(Level world, BlockPos pos) { |
| 43 | if (world.getBlockEntity(pos) instanceof AlchemicalChestBlockEntity container) { | 49 | if (world.getBlockEntity(pos) instanceof AlchemicalChestBlockEntity container) { |
| @@ -47,7 +53,7 @@ public class AlchemicalChestBlock extends AbstractChestBlock<AlchemicalChestBloc | |||
| 47 | } | 53 | } |
| 48 | 54 | ||
| 49 | public AlchemicalChestBlock(Properties properties) { | 55 | public AlchemicalChestBlock(Properties properties) { |
| 50 | super(properties, () -> ErisAlchemyBlockEntities.ALCHEMICAL_CHEST); | 56 | super(properties, () -> ErisAlchemyRegistry.BlockEntities.ALCHEMICAL_CHEST); |
| 51 | registerDefaultState(getStateDefinition().any() | 57 | registerDefaultState(getStateDefinition().any() |
| 52 | .setValue(FACING, Direction.NORTH) | 58 | .setValue(FACING, Direction.NORTH) |
| 53 | .setValue(WATERLOGGED, false) | 59 | .setValue(WATERLOGGED, false) |
| @@ -56,7 +62,12 @@ public class AlchemicalChestBlock extends AbstractChestBlock<AlchemicalChestBloc | |||
| 56 | 62 | ||
| 57 | @Nonnull | 63 | @Nonnull |
| 58 | @Override | 64 | @Override |
| 59 | public DoubleBlockCombiner.NeighborCombineResult<? extends ChestBlockEntity> combine(BlockState state, Level world, BlockPos pos, boolean ignoreBlocked) { | 65 | public DoubleBlockCombiner.NeighborCombineResult<? extends ChestBlockEntity> combine( |
| 66 | BlockState state, | ||
| 67 | Level world, | ||
| 68 | BlockPos pos, | ||
| 69 | boolean ignoreBlocked | ||
| 70 | ) { | ||
| 60 | return DoubleBlockCombiner.Combiner::acceptNone; | 71 | return DoubleBlockCombiner.Combiner::acceptNone; |
| 61 | } | 72 | } |
| 62 | 73 | ||
| @@ -102,8 +113,16 @@ public class AlchemicalChestBlock extends AbstractChestBlock<AlchemicalChestBloc | |||
| 102 | } | 113 | } |
| 103 | 114 | ||
| 104 | @Override | 115 | @Override |
| 105 | public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level ignoredWorld, BlockState ignoredState, BlockEntityType<T> type) { | 116 | public <T extends BlockEntity> BlockEntityTicker<T> getTicker( |
| 106 | return createTickerHelper(type, blockEntityType.get(), (world, pos, state, entity) -> entity.tick(world, pos, state)); | 117 | Level ignoredWorld, |
| 118 | BlockState ignoredState, | ||
| 119 | BlockEntityType<T> type | ||
| 120 | ) { | ||
| 121 | return createTickerHelper( | ||
| 122 | type, | ||
| 123 | blockEntityType.get(), | ||
| 124 | (world, pos, state, entity) -> entity.tick(world, pos, state) | ||
| 125 | ); | ||
| 107 | } | 126 | } |
| 108 | 127 | ||
| 109 | @SuppressWarnings("deprecation") | 128 | @SuppressWarnings("deprecation") |
| @@ -155,7 +174,14 @@ public class AlchemicalChestBlock extends AbstractChestBlock<AlchemicalChestBloc | |||
| 155 | @SuppressWarnings("deprecation") | 174 | @SuppressWarnings("deprecation") |
| 156 | @Nonnull | 175 | @Nonnull |
| 157 | @Override | 176 | @Override |
| 158 | public BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { | 177 | public BlockState updateShape( |
| 178 | BlockState state, | ||
| 179 | Direction direction, | ||
| 180 | BlockState neighborState, | ||
| 181 | LevelAccessor world, | ||
| 182 | BlockPos pos, | ||
| 183 | BlockPos neighborPos | ||
| 184 | ) { | ||
| 159 | if (state.getValue(WATERLOGGED)) { | 185 | if (state.getValue(WATERLOGGED)) { |
| 160 | world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); | 186 | world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); |
| 161 | } | 187 | } |
| @@ -166,7 +192,14 @@ public class AlchemicalChestBlock extends AbstractChestBlock<AlchemicalChestBloc | |||
| 166 | @SuppressWarnings("deprecation") | 192 | @SuppressWarnings("deprecation") |
| 167 | @Nonnull | 193 | @Nonnull |
| 168 | @Override | 194 | @Override |
| 169 | public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { | 195 | public InteractionResult use( |
| 196 | BlockState state, | ||
| 197 | Level world, | ||
| 198 | BlockPos pos, | ||
| 199 | Player player, | ||
| 200 | InteractionHand hand, | ||
| 201 | BlockHitResult hit | ||
| 202 | ) { | ||
| 170 | if (world.isClientSide) { | 203 | if (world.isClientSide) { |
| 171 | return InteractionResult.SUCCESS; | 204 | return InteractionResult.SUCCESS; |
| 172 | } | 205 | } |
| @@ -174,7 +207,7 @@ public class AlchemicalChestBlock extends AbstractChestBlock<AlchemicalChestBloc | |||
| 174 | var provider = getMenuProvider(state, world, pos); | 207 | var provider = getMenuProvider(state, world, pos); |
| 175 | if (provider != null) { | 208 | if (provider != null) { |
| 176 | player.openMenu(provider); | 209 | player.openMenu(provider); |
| 177 | // player.awardStat(getOpenChestStat); | 210 | // TODO: player.awardStat(getOpenChestStat); |
| 178 | PiglinAi.angerNearbyPiglins(player, true); | 211 | PiglinAi.angerNearbyPiglins(player, true); |
| 179 | } | 212 | } |
| 180 | 213 | ||