fix cauldron
@@ -19,61 +19,75 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
+import net.minecraft.world.phys.shapes.EntityCollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraftforge.common.MinecraftForge;
-public class ReinforcedCauldronBlock extends CauldronBlock implements IReinforcedBlock, EntityBlock {
-
- public ReinforcedCauldronBlock(Properties properties) {
+public class ReinforcedCauldronBlock extends CauldronBlock implements IReinforcedBlock, EntityBlock
+{
+ public ReinforcedCauldronBlock(Properties properties)
+ {
super(properties);
}
@Override
- public VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext ctx) {
- Entity entity = ctx.getEntity();
+ public VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext collisionContext)
+ {
+ if(collisionContext instanceof EntityCollisionContext ctx)
+ {
+ if(ctx.getEntity().isPresent())
+ {
+ Entity entity = ctx.getEntity().get();
- if (entity instanceof Player player) {
- BlockEntity te = world.getBlockEntity(pos);
+ if(entity instanceof Player player)
+ {
+ BlockEntity tile = world.getBlockEntity(pos);
- if (te instanceof ReinforcedCauldronTileEntity && ((ReinforcedCauldronTileEntity)te).isAllowedToInteract(player))
+ if(tile instanceof ReinforcedCauldronTileEntity te && te.isAllowedToInteract(player))
return SHAPE;
else
return Shapes.block();
}
+ }
+ }
return SHAPE;
}
@Override
- public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
- BlockEntity te = world.getBlockEntity(pos);
+ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit)
+ {
+ BlockEntity tile = world.getBlockEntity(pos);
- if (te instanceof ReinforcedCauldronTileEntity && ((ReinforcedCauldronTileEntity)te).isAllowedToInteract(player)) {
+ if(tile instanceof ReinforcedCauldronTileEntity te && te.isAllowedToInteract(player))
return super.use(state, world, pos, player, hand, hit);
- }
return InteractionResult.PASS;
}
@Override
- public Block getVanillaBlock() {
+ public Block getVanillaBlock()
+ {
return Blocks.CAULDRON;
}
@Override
- public BlockState getConvertedState(BlockState vanillaState) {
+ public BlockState getConvertedState(BlockState vanillaState)
+ {
return defaultBlockState().setValue(LEVEL, vanillaState.getValue(LEVEL));
}
@Override
- public void setPlacedBy(Level world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) {
- if(placer instanceof Player)
- MinecraftForge.EVENT_BUS.post(new OwnershipEvent(world, pos, (Player)placer));
+ public void setPlacedBy(Level world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack)
+ {
+ if(placer instanceof Player player)
+ MinecraftForge.EVENT_BUS.post(new OwnershipEvent(world, pos, player));
}
@Override
- public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
+ public BlockEntity newBlockEntity(BlockPos pos, BlockState state)
+ {
return new ReinforcedCauldronTileEntity(pos, state);
}
}
