diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/level/block/SpongeBlock.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/level/block/SpongeBlock.java.patch | 177 |
1 files changed, 177 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/level/block/SpongeBlock.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/SpongeBlock.java.patch new file mode 100644 index 0000000000..4dc39bd7b6 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/SpongeBlock.java.patch @@ -0,0 +1,177 @@ +--- a/net/minecraft/world/level/block/SpongeBlock.java ++++ b/net/minecraft/world/level/block/SpongeBlock.java +@@ -10,8 +10,14 @@ + import net.minecraft.world.level.Level; + import net.minecraft.world.level.block.entity.BlockEntity; + 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.material.FluidState; ++// CraftBukkit start ++import java.util.List; ++import org.bukkit.craftbukkit.block.CraftBlockState; ++import org.bukkit.craftbukkit.util.BlockStateListPopulator; ++import org.bukkit.event.block.SpongeAbsorbEvent; ++// CraftBukkit end + + public class SpongeBlock extends Block { + +@@ -21,85 +27,122 @@ + private static final Direction[] ALL_DIRECTIONS = Direction.values(); + + @Override +- @Override + public MapCodec<SpongeBlock> codec() { + return SpongeBlock.CODEC; + } + +- protected SpongeBlock(BlockBehaviour.Properties blockbehaviour_properties) { +- super(blockbehaviour_properties); ++ protected SpongeBlock(BlockBehaviour.Properties properties) { ++ super(properties); + } + + @Override +- @Override +- public void onPlace(BlockState blockstate, Level level, BlockPos blockpos, BlockState blockstate1, boolean flag) { +- if (!blockstate1.is(blockstate.getBlock())) { +- this.tryAbsorbWater(level, blockpos); ++ public void onPlace(IBlockData state, Level level, BlockPos pos, IBlockData oldState, boolean isMoving) { ++ if (!oldState.is(state.getBlock())) { ++ this.tryAbsorbWater(level, pos); + } + } + + @Override +- @Override +- public void neighborChanged(BlockState blockstate, Level level, BlockPos blockpos, Block block, BlockPos blockpos1, boolean flag) { +- this.tryAbsorbWater(level, blockpos); +- super.neighborChanged(blockstate, level, blockpos, block, blockpos1, flag); ++ public void neighborChanged(IBlockData state, Level level, BlockPos pos, Block block, BlockPos fromPos, boolean isMoving) { ++ this.tryAbsorbWater(level, pos); ++ super.neighborChanged(state, level, pos, block, fromPos, isMoving); + } + +- protected void tryAbsorbWater(Level level, BlockPos blockpos) { +- if (this.removeWaterBreadthFirstSearch(level, blockpos)) { +- level.setBlock(blockpos, Blocks.WET_SPONGE.defaultBlockState(), 2); +- level.playSound((Player) null, blockpos, SoundEvents.SPONGE_ABSORB, SoundSource.BLOCKS, 1.0F, 1.0F); ++ protected void tryAbsorbWater(Level level, BlockPos pos) { ++ if (this.removeWaterBreadthFirstSearch(level, pos)) { ++ level.setBlock(pos, Blocks.WET_SPONGE.defaultBlockState(), 2); ++ level.playSound((Player) null, pos, SoundEvents.SPONGE_ABSORB, SoundSource.BLOCKS, 1.0F, 1.0F); + } + + } + +- private boolean removeWaterBreadthFirstSearch(Level level, BlockPos blockpos) { +- return BlockPos.breadthFirstTraversal(blockpos, 6, 65, (blockpos1, consumer) -> { +- Direction[] adirection = SpongeBlock.ALL_DIRECTIONS; +- int i = adirection.length; ++ private boolean removeWaterBreadthFirstSearch(Level level, BlockPos pos) { ++ BlockStateListPopulator blockList = new BlockStateListPopulator(level); // CraftBukkit - Use BlockStateListPopulator ++ BlockPos.breadthFirstTraversal(pos, 6, 65, (blockposition1, consumer) -> { ++ Direction[] aenumdirection = SpongeBlock.ALL_DIRECTIONS; ++ int i = aenumdirection.length; + + for (int j = 0; j < i; ++j) { +- Direction direction = adirection[j]; ++ Direction enumdirection = aenumdirection[j]; + +- consumer.accept(blockpos1.relative(direction)); ++ consumer.accept(blockposition1.relative(enumdirection)); + } + +- }, (blockpos1) -> { +- if (blockpos1.equals(blockpos)) { ++ }, (blockposition1) -> { ++ if (blockposition1.equals(pos)) { + return true; + } else { +- BlockState blockstate = level.getBlockState(blockpos1); +- FluidState fluidstate = level.getFluidState(blockpos1); ++ // CraftBukkit start ++ IBlockData iblockdata = blockList.getBlockState(blockposition1); ++ FluidState fluid = blockList.getFluidState(blockposition1); ++ // CraftBukkit end + +- if (!fluidstate.is(FluidTags.WATER)) { ++ if (!fluid.is(FluidTags.WATER)) { + return false; + } else { +- Block block = blockstate.getBlock(); ++ Block block = iblockdata.getBlock(); + + if (block instanceof BucketPickup) { +- BucketPickup bucketpickup = (BucketPickup) block; ++ BucketPickup ifluidsource = (BucketPickup) block; + +- if (!bucketpickup.pickupBlock((Player) null, level, blockpos1, blockstate).isEmpty()) { ++ if (!ifluidsource.pickupBlock((Player) null, blockList, blockposition1, iblockdata).isEmpty()) { // CraftBukkit + return true; + } + } + +- if (blockstate.getBlock() instanceof LiquidBlock) { +- level.setBlock(blockpos1, Blocks.AIR.defaultBlockState(), 3); ++ if (iblockdata.getBlock() instanceof LiquidBlock) { ++ blockList.setBlock(blockposition1, Blocks.AIR.defaultBlockState(), 3); // CraftBukkit + } else { +- if (!blockstate.is(Blocks.KELP) && !blockstate.is(Blocks.KELP_PLANT) && !blockstate.is(Blocks.SEAGRASS) && !blockstate.is(Blocks.TALL_SEAGRASS)) { ++ if (!iblockdata.is(Blocks.KELP) && !iblockdata.is(Blocks.KELP_PLANT) && !iblockdata.is(Blocks.SEAGRASS) && !iblockdata.is(Blocks.TALL_SEAGRASS)) { + return false; + } + +- BlockEntity blockentity = blockstate.hasBlockEntity() ? level.getBlockEntity(blockpos1) : null; ++ // CraftBukkit start ++ // TileEntity tileentity = iblockdata.hasBlockEntity() ? world.getBlockEntity(blockposition1) : null; + +- dropResources(blockstate, level, blockpos1, blockentity); +- level.setBlock(blockpos1, Blocks.AIR.defaultBlockState(), 3); ++ // dropResources(iblockdata, world, blockposition1, tileentity); ++ blockList.setBlock(blockposition1, Blocks.AIR.defaultBlockState(), 3); ++ // CraftBukkit end + } + + return true; + } + } +- }) > 1; ++ }); ++ // CraftBukkit start ++ List<CraftBlockState> blocks = blockList.getList(); // Is a clone ++ if (!blocks.isEmpty()) { ++ final org.bukkit.block.Block bblock = level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); ++ ++ SpongeAbsorbEvent event = new SpongeAbsorbEvent(bblock, (List<org.bukkit.block.BlockState>) (List) blocks); ++ level.getCraftServer().getPluginManager().callEvent(event); ++ ++ if (event.isCancelled()) { ++ return false; ++ } ++ ++ for (CraftBlockState block : blocks) { ++ BlockPos blockposition1 = block.getPosition(); ++ IBlockData iblockdata = level.getBlockState(blockposition1); ++ FluidState fluid = level.getFluidState(blockposition1); ++ ++ if (fluid.is(FluidTags.WATER)) { ++ if (iblockdata.getBlock() instanceof BucketPickup && !((BucketPickup) iblockdata.getBlock()).pickupBlock((Player) null, blockList, blockposition1, iblockdata).isEmpty()) { ++ // NOP ++ } else if (iblockdata.getBlock() instanceof LiquidBlock) { ++ // NOP ++ } else if (iblockdata.is(Blocks.KELP) || iblockdata.is(Blocks.KELP_PLANT) || iblockdata.is(Blocks.SEAGRASS) || iblockdata.is(Blocks.TALL_SEAGRASS)) { ++ BlockEntity tileentity = iblockdata.hasBlockEntity() ? level.getBlockEntity(blockposition1) : null; ++ ++ dropResources(iblockdata, level, blockposition1, tileentity); ++ } ++ } ++ level.setBlock(blockposition1, block.getHandle(), block.getFlag()); ++ } ++ ++ return true; ++ } ++ return false; ++ // CraftBukkit end + } + } |