diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/level/block/SculkShriekerBlock.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/level/block/SculkShriekerBlock.java.patch | 210 |
1 files changed, 210 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/level/block/SculkShriekerBlock.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/level/block/SculkShriekerBlock.java.patch new file mode 100644 index 0000000000..321db785aa --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/level/block/SculkShriekerBlock.java.patch @@ -0,0 +1,210 @@ +--- a/net/minecraft/world/level/block/SculkShriekerBlock.java ++++ b/net/minecraft/world/level/block/SculkShriekerBlock.java +@@ -19,53 +19,54 @@ + import net.minecraft.world.level.block.entity.BlockEntityType; + import net.minecraft.world.level.block.entity.SculkShriekerBlockEntity; + import net.minecraft.world.level.block.state.BlockBehaviour; +-import net.minecraft.world.level.block.state.BlockState; ++import net.minecraft.world.level.block.state.IBlockData; + 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.gameevent.vibrations.VibrationSystem; ++import net.minecraft.world.level.material.Fluid; + import net.minecraft.world.level.material.FluidState; + import net.minecraft.world.level.material.Fluids; + import net.minecraft.world.phys.shapes.CollisionContext; + import net.minecraft.world.phys.shapes.VoxelShape; + + public class SculkShriekerBlock extends BaseEntityBlock implements SimpleWaterloggedBlock { ++ + public static final MapCodec<SculkShriekerBlock> CODEC = simpleCodec(SculkShriekerBlock::new); + public static final BooleanProperty SHRIEKING = BlockStateProperties.SHRIEKING; + public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; + public static final BooleanProperty CAN_SUMMON = BlockStateProperties.CAN_SUMMON; +- protected static final VoxelShape COLLIDER = Block.box(0.0, 0.0, 0.0, 16.0, 8.0, 16.0); +- public static final double TOP_Y = COLLIDER.max(Direction.Axis.Y); ++ protected static final VoxelShape COLLIDER = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D); ++ public static final double TOP_Y = SculkShriekerBlock.COLLIDER.max(Direction.Axis.Y); + + @Override + public MapCodec<SculkShriekerBlock> codec() { +- return CODEC; ++ return SculkShriekerBlock.CODEC; + } + + public SculkShriekerBlock(BlockBehaviour.Properties properties) { + super(properties); +- this.registerDefaultState( +- this.stateDefinition +- .any() +- .setValue(SHRIEKING, Boolean.valueOf(false)) +- .setValue(WATERLOGGED, Boolean.valueOf(false)) +- .setValue(CAN_SUMMON, Boolean.valueOf(false)) +- ); ++ this.registerDefaultState((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(SculkShriekerBlock.SHRIEKING, false)).setValue(SculkShriekerBlock.WATERLOGGED, false)).setValue(SculkShriekerBlock.CAN_SUMMON, false)); + } + + @Override +- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { +- builder.add(SHRIEKING); +- builder.add(WATERLOGGED); +- builder.add(CAN_SUMMON); ++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) { ++ builder.add(SculkShriekerBlock.SHRIEKING); ++ builder.add(SculkShriekerBlock.WATERLOGGED); ++ builder.add(SculkShriekerBlock.CAN_SUMMON); + } + + @Override +- public void stepOn(Level level, BlockPos pos, BlockState state, Entity entity) { +- if (level instanceof ServerLevel serverLevel) { +- ServerPlayer serverPlayer = SculkShriekerBlockEntity.tryGetPlayer(entity); +- if (serverPlayer != null) { +- serverLevel.getBlockEntity(pos, BlockEntityType.SCULK_SHRIEKER).ifPresent(sculkShrieker -> sculkShrieker.tryShriek(serverLevel, serverPlayer)); ++ public void stepOn(Level level, BlockPos pos, IBlockData state, Entity entity) { ++ if (level instanceof ServerLevel) { ++ ServerLevel worldserver = (ServerLevel) level; ++ ServerPlayer entityplayer = SculkShriekerBlockEntity.tryGetPlayer(entity); ++ ++ if (entityplayer != null) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(entityplayer, org.bukkit.event.block.Action.PHYSICAL, pos, null, null, null).isCancelled()) return; // CraftBukkit ++ worldserver.getBlockEntity(pos, BlockEntityType.SCULK_SHRIEKER).ifPresent((sculkshriekerblockentity) -> { ++ sculkshriekerblockentity.tryShriek(worldserver, entityplayer); ++ }); + } + } + +@@ -73,52 +74,61 @@ + } + + @Override +- public void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean movedByPiston) { +- if (level instanceof ServerLevel serverLevel && state.getValue(SHRIEKING) && !state.is(newState.getBlock())) { +- serverLevel.getBlockEntity(pos, BlockEntityType.SCULK_SHRIEKER).ifPresent(sculkShrieker -> sculkShrieker.tryRespond(serverLevel)); ++ public void onRemove(IBlockData state, Level level, BlockPos pos, IBlockData newState, boolean movedByPiston) { ++ if (level instanceof ServerLevel) { ++ ServerLevel worldserver = (ServerLevel) level; ++ ++ if ((Boolean) state.getValue(SculkShriekerBlock.SHRIEKING) && !state.is(newState.getBlock())) { ++ worldserver.getBlockEntity(pos, BlockEntityType.SCULK_SHRIEKER).ifPresent((sculkshriekerblockentity) -> { ++ sculkshriekerblockentity.tryRespond(worldserver); ++ }); ++ } + } + + super.onRemove(state, level, pos, newState, movedByPiston); + } + + @Override +- public void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { +- if (state.getValue(SHRIEKING)) { +- level.setBlock(pos, state.setValue(SHRIEKING, Boolean.valueOf(false)), 3); +- level.getBlockEntity(pos, BlockEntityType.SCULK_SHRIEKER).ifPresent(sculkShrieker -> sculkShrieker.tryRespond(level)); ++ public void tick(IBlockData state, ServerLevel level, BlockPos pos, RandomSource random) { ++ if ((Boolean) state.getValue(SculkShriekerBlock.SHRIEKING)) { ++ level.setBlock(pos, (IBlockData) state.setValue(SculkShriekerBlock.SHRIEKING, false), 3); ++ level.getBlockEntity(pos, BlockEntityType.SCULK_SHRIEKER).ifPresent((sculkshriekerblockentity) -> { ++ sculkshriekerblockentity.tryRespond(level); ++ }); + } ++ + } + + @Override +- public RenderShape getRenderShape(BlockState state) { +- return RenderShape.MODEL; ++ public EnumRenderType getRenderShape(IBlockData state) { ++ return EnumRenderType.MODEL; + } + + @Override +- public VoxelShape getCollisionShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { +- return COLLIDER; ++ public VoxelShape getCollisionShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) { ++ return SculkShriekerBlock.COLLIDER; + } + + @Override +- public VoxelShape getOcclusionShape(BlockState state, BlockGetter level, BlockPos pos) { +- return COLLIDER; ++ public VoxelShape getOcclusionShape(IBlockData state, BlockGetter level, BlockPos pos) { ++ return SculkShriekerBlock.COLLIDER; + } + + @Override +- public boolean useShapeForLightOcclusion(BlockState state) { ++ public boolean useShapeForLightOcclusion(IBlockData state) { + return true; + } + + @Nullable + @Override +- public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { ++ public BlockEntity newBlockEntity(BlockPos pos, IBlockData state) { + return new SculkShriekerBlockEntity(pos, state); + } + + @Override +- public BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor level, BlockPos pos, BlockPos neighborPos) { +- if (state.getValue(WATERLOGGED)) { +- level.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(level)); ++ public IBlockData updateShape(IBlockData state, Direction direction, IBlockData neighborState, LevelAccessor level, BlockPos pos, BlockPos neighborPos) { ++ if ((Boolean) state.getValue(SculkShriekerBlock.WATERLOGGED)) { ++ level.scheduleTick(pos, (Fluid) Fluids.WATER, Fluids.WATER.getTickDelay(level)); + } + + return super.updateShape(state, direction, neighborState, level, pos, neighborPos); +@@ -126,33 +136,36 @@ + + @Nullable + @Override +- public BlockState getStateForPlacement(BlockPlaceContext context) { +- return this.defaultBlockState() +- .setValue(WATERLOGGED, Boolean.valueOf(context.getLevel().getFluidState(context.getClickedPos()).getType() == Fluids.WATER)); ++ public IBlockData getStateForPlacement(BlockPlaceContext context) { ++ return (IBlockData) this.defaultBlockState().setValue(SculkShriekerBlock.WATERLOGGED, context.getLevel().getFluidState(context.getClickedPos()).getType() == Fluids.WATER); + } + + @Override +- public FluidState getFluidState(BlockState state) { +- return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state); ++ public FluidState getFluidState(IBlockData state) { ++ return (Boolean) state.getValue(SculkShriekerBlock.WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state); + } + + @Override +- public void spawnAfterBreak(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack, boolean dropExperience) { ++ public void spawnAfterBreak(IBlockData state, ServerLevel level, BlockPos pos, ItemStack stack, boolean dropExperience) { + super.spawnAfterBreak(state, level, pos, stack, dropExperience); +- if (dropExperience) { +- this.tryDropExperience(level, pos, stack, ConstantInt.of(5)); ++ // CraftBukkit start - Delegate to getExpDrop ++ } ++ ++ @Override ++ public int getExpDrop(IBlockData iblockdata, ServerLevel worldserver, BlockPos blockposition, ItemStack itemstack, boolean flag) { ++ if (flag) { ++ return this.tryDropExperience(worldserver, blockposition, itemstack, ConstantInt.of(5)); + } ++ ++ return 0; ++ // CraftBukkit end + } + + @Nullable + @Override +- public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> blockEntityType) { +- return !level.isClientSide +- ? BaseEntityBlock.createTickerHelper( +- blockEntityType, +- BlockEntityType.SCULK_SHRIEKER, +- (level1, pos, state1, blockEntity) -> VibrationSystem.Ticker.tick(level1, blockEntity.getVibrationData(), blockEntity.getVibrationUser()) +- ) +- : null; ++ public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, IBlockData state, BlockEntityType<T> blockEntityType) { ++ return !level.isClientSide ? BaseEntityBlock.createTickerHelper(blockEntityType, BlockEntityType.SCULK_SHRIEKER, (world1, blockposition, iblockdata1, sculkshriekerblockentity) -> { ++ VibrationSystem.Ticker.tick(world1, sculkshriekerblockentity.getVibrationData(), sculkshriekerblockentity.getVibrationUser()); ++ }) : null; + } + } |