diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/level/block/SpongeBlock.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/level/block/SpongeBlock.java.patch | 195 |
1 files changed, 195 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/level/block/SpongeBlock.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/level/block/SpongeBlock.java.patch new file mode 100644 index 0000000000..2fb61bbd53 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/level/block/SpongeBlock.java.patch @@ -0,0 +1,195 @@ +--- a/net/minecraft/world/level/block/SpongeBlock.java ++++ b/net/minecraft/world/level/block/SpongeBlock.java +@@ -1,19 +1,26 @@ + package net.minecraft.world.level.block; + + import com.mojang.serialization.MapCodec; +-import java.util.function.Consumer; + import net.minecraft.core.BlockPos; + import net.minecraft.core.Direction; + import net.minecraft.sounds.SoundEvents; + import net.minecraft.sounds.SoundSource; + import net.minecraft.tags.FluidTags; ++import net.minecraft.world.entity.player.Player; + 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 { ++ + public static final MapCodec<SpongeBlock> CODEC = simpleCodec(SpongeBlock::new); + public static final int MAX_DEPTH = 6; + public static final int MAX_COUNT = 64; +@@ -21,7 +28,7 @@ + + @Override + public MapCodec<SpongeBlock> codec() { +- return CODEC; ++ return SpongeBlock.CODEC; + } + + protected SpongeBlock(BlockBehaviour.Properties properties) { +@@ -29,14 +36,14 @@ + } + + @Override +- public void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean isMoving) { ++ public void onPlace(IBlockData state, Level level, BlockPos pos, IBlockData oldState, boolean isMoving) { + if (!oldState.is(state.getBlock())) { + this.tryAbsorbWater(level, pos); + } + } + + @Override +- public void neighborChanged(BlockState state, Level level, BlockPos pos, Block block, BlockPos fromPos, boolean isMoving) { ++ 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); + } +@@ -44,54 +51,98 @@ + protected void tryAbsorbWater(Level level, BlockPos pos) { + if (this.removeWaterBreadthFirstSearch(level, pos)) { + level.setBlock(pos, Blocks.WET_SPONGE.defaultBlockState(), 2); +- level.playSound(null, pos, SoundEvents.SPONGE_ABSORB, SoundSource.BLOCKS, 1.0F, 1.0F); ++ level.playSound((Player) null, pos, SoundEvents.SPONGE_ABSORB, SoundSource.BLOCKS, 1.0F, 1.0F); + } ++ + } + + private boolean removeWaterBreadthFirstSearch(Level level, BlockPos pos) { +- return BlockPos.breadthFirstTraversal( +- pos, +- 6, +- 65, +- (validPos, queueAdder) -> { +- for (Direction direction : ALL_DIRECTIONS) { +- queueAdder.accept(validPos.relative(direction)); ++ 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 enumdirection = aenumdirection[j]; ++ ++ consumer.accept(blockposition1.relative(enumdirection)); ++ } ++ ++ }, (blockposition1) -> { ++ if (blockposition1.equals(pos)) { ++ return true; ++ } else { ++ // CraftBukkit start ++ IBlockData iblockdata = blockList.getBlockState(blockposition1); ++ FluidState fluid = blockList.getFluidState(blockposition1); ++ // CraftBukkit end ++ ++ if (!fluid.is(FluidTags.WATER)) { ++ return false; ++ } else { ++ Block block = iblockdata.getBlock(); ++ ++ if (block instanceof BucketPickup) { ++ BucketPickup ifluidsource = (BucketPickup) block; ++ ++ if (!ifluidsource.pickupBlock((Player) null, blockList, blockposition1, iblockdata).isEmpty()) { // CraftBukkit ++ return true; ++ } + } +- }, +- currentPos -> { +- if (currentPos.equals(pos)) { +- return true; ++ ++ if (iblockdata.getBlock() instanceof LiquidBlock) { ++ blockList.setBlock(blockposition1, Blocks.AIR.defaultBlockState(), 3); // CraftBukkit + } else { +- BlockState blockState = level.getBlockState(currentPos); +- FluidState fluidState = level.getFluidState(currentPos); +- if (!fluidState.is(FluidTags.WATER)) { ++ if (!iblockdata.is(Blocks.KELP) && !iblockdata.is(Blocks.KELP_PLANT) && !iblockdata.is(Blocks.SEAGRASS) && !iblockdata.is(Blocks.TALL_SEAGRASS)) { + return false; +- } else { +- if (blockState.getBlock() instanceof BucketPickup bucketPickup +- && !bucketPickup.pickupBlock(null, level, currentPos, blockState).isEmpty()) { +- return true; +- } +- +- if (blockState.getBlock() instanceof LiquidBlock) { +- level.setBlock(currentPos, Blocks.AIR.defaultBlockState(), 3); +- } else { +- if (!blockState.is(Blocks.KELP) +- && !blockState.is(Blocks.KELP_PLANT) +- && !blockState.is(Blocks.SEAGRASS) +- && !blockState.is(Blocks.TALL_SEAGRASS)) { +- return false; +- } +- +- BlockEntity blockEntity = blockState.hasBlockEntity() ? level.getBlockEntity(currentPos) : null; +- dropResources(blockState, level, currentPos, blockEntity); +- level.setBlock(currentPos, Blocks.AIR.defaultBlockState(), 3); +- } +- +- return true; + } ++ ++ // CraftBukkit start ++ // TileEntity tileentity = iblockdata.hasBlockEntity() ? world.getBlockEntity(blockposition1) : null; ++ ++ // 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 + } + } |