diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/level/block/SculkBlock.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/level/block/SculkBlock.java.patch | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/level/block/SculkBlock.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/SculkBlock.java.patch new file mode 100644 index 0000000000..b277c76353 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/SculkBlock.java.patch @@ -0,0 +1,138 @@ +--- a/net/minecraft/world/level/block/SculkBlock.java ++++ b/net/minecraft/world/level/block/SculkBlock.java +@@ -10,7 +10,7 @@ + import net.minecraft.world.entity.player.Player; + import net.minecraft.world.level.LevelAccessor; + 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.properties.BlockStateProperties; + import net.minecraft.world.level.material.Fluid; + import net.minecraft.world.level.material.Fluids; +@@ -20,83 +20,84 @@ + public static final MapCodec<SculkBlock> CODEC = simpleCodec(SculkBlock::new); + + @Override +- @Override + public MapCodec<SculkBlock> codec() { + return SculkBlock.CODEC; + } + +- public SculkBlock(BlockBehaviour.Properties blockbehaviour_properties) { +- super(ConstantInt.of(1), blockbehaviour_properties); ++ public SculkBlock(BlockBehaviour.Properties properties) { ++ super(ConstantInt.of(1), properties); + } + + @Override +- @Override +- public int attemptUseCharge(SculkSpreader.ChargeCursor sculkspreader_chargecursor, LevelAccessor levelaccessor, BlockPos blockpos, RandomSource randomsource, SculkSpreader sculkspreader, boolean flag) { +- int i = sculkspreader_chargecursor.getCharge(); ++ public int attemptUseCharge(SculkSpreader.ChargeCursor cursor, LevelAccessor level, BlockPos pos, RandomSource random, SculkSpreader spreader, boolean shouldConvertBlocks) { ++ int i = cursor.getCharge(); + +- if (i != 0 && randomsource.nextInt(sculkspreader.chargeDecayRate()) == 0) { +- BlockPos blockpos1 = sculkspreader_chargecursor.getPos(); +- boolean flag1 = blockpos1.closerThan(blockpos, (double) sculkspreader.noGrowthRadius()); ++ if (i != 0 && random.nextInt(spreader.chargeDecayRate()) == 0) { ++ BlockPos blockposition1 = cursor.getPos(); ++ boolean flag1 = blockposition1.closerThan(pos, (double) spreader.noGrowthRadius()); + +- if (!flag1 && canPlaceGrowth(levelaccessor, blockpos1)) { +- int j = sculkspreader.growthSpawnCost(); ++ if (!flag1 && canPlaceGrowth(level, blockposition1)) { ++ int j = spreader.growthSpawnCost(); + +- if (randomsource.nextInt(j) < i) { +- BlockPos blockpos2 = blockpos1.above(); +- BlockState blockstate = this.getRandomGrowthState(levelaccessor, blockpos2, randomsource, sculkspreader.isWorldGeneration()); ++ if (random.nextInt(j) < i) { ++ BlockPos blockposition2 = blockposition1.above(); ++ IBlockData iblockdata = this.getRandomGrowthState(level, blockposition2, random, spreader.isWorldGeneration()); + +- levelaccessor.setBlock(blockpos2, blockstate, 3); +- levelaccessor.playSound((Player) null, blockpos1, blockstate.getSoundType().getPlaceSound(), SoundSource.BLOCKS, 1.0F, 1.0F); ++ // CraftBukkit start - Call BlockSpreadEvent ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, blockposition2, iblockdata, 3)) { ++ level.playSound((Player) null, blockposition1, iblockdata.getSoundType().getPlaceSound(), SoundSource.BLOCKS, 1.0F, 1.0F); ++ } ++ // CraftBukkit end + } + + return Math.max(0, i - j); + } else { +- return randomsource.nextInt(sculkspreader.additionalDecayRate()) != 0 ? i : i - (flag1 ? 1 : getDecayPenalty(sculkspreader, blockpos1, blockpos, i)); ++ return random.nextInt(spreader.additionalDecayRate()) != 0 ? i : i - (flag1 ? 1 : getDecayPenalty(spreader, blockposition1, pos, i)); + } + } else { + return i; + } + } + +- private static int getDecayPenalty(SculkSpreader sculkspreader, BlockPos blockpos, BlockPos blockpos1, int i) { +- int j = sculkspreader.noGrowthRadius(); +- float f = Mth.square((float) Math.sqrt(blockpos.distSqr(blockpos1)) - (float) j); ++ private static int getDecayPenalty(SculkSpreader spreader, BlockPos cursorPos, BlockPos rootPos, int charge) { ++ int j = spreader.noGrowthRadius(); ++ float f = Mth.square((float) Math.sqrt(cursorPos.distSqr(rootPos)) - (float) j); + int k = Mth.square(24 - j); + float f1 = Math.min(1.0F, f / (float) k); + +- return Math.max(1, (int) ((float) i * f1 * 0.5F)); ++ return Math.max(1, (int) ((float) charge * f1 * 0.5F)); + } + +- private BlockState getRandomGrowthState(LevelAccessor levelaccessor, BlockPos blockpos, RandomSource randomsource, boolean flag) { +- BlockState blockstate; ++ private IBlockData getRandomGrowthState(LevelAccessor level, BlockPos pos, RandomSource random, boolean isWorldGeneration) { ++ IBlockData iblockdata; + +- if (randomsource.nextInt(11) == 0) { +- blockstate = (BlockState) Blocks.SCULK_SHRIEKER.defaultBlockState().setValue(SculkShriekerBlock.CAN_SUMMON, flag); ++ if (random.nextInt(11) == 0) { ++ iblockdata = (IBlockData) Blocks.SCULK_SHRIEKER.defaultBlockState().setValue(SculkShriekerBlock.CAN_SUMMON, isWorldGeneration); + } else { +- blockstate = Blocks.SCULK_SENSOR.defaultBlockState(); ++ iblockdata = Blocks.SCULK_SENSOR.defaultBlockState(); + } + +- return blockstate.hasProperty(BlockStateProperties.WATERLOGGED) && !levelaccessor.getFluidState(blockpos).isEmpty() ? (BlockState) blockstate.setValue(BlockStateProperties.WATERLOGGED, true) : blockstate; ++ return iblockdata.hasProperty(BlockStateProperties.WATERLOGGED) && !level.getFluidState(pos).isEmpty() ? (IBlockData) iblockdata.setValue(BlockStateProperties.WATERLOGGED, true) : iblockdata; + } + +- private static boolean canPlaceGrowth(LevelAccessor levelaccessor, BlockPos blockpos) { +- BlockState blockstate = levelaccessor.getBlockState(blockpos.above()); ++ private static boolean canPlaceGrowth(LevelAccessor level, BlockPos pos) { ++ IBlockData iblockdata = level.getBlockState(pos.above()); + +- if (!blockstate.isAir() && (!blockstate.is(Blocks.WATER) || !blockstate.getFluidState().is((Fluid) Fluids.WATER))) { ++ if (!iblockdata.isAir() && (!iblockdata.is(Blocks.WATER) || !iblockdata.getFluidState().is((Fluid) Fluids.WATER))) { + return false; + } else { + int i = 0; +- Iterator iterator = BlockPos.betweenClosed(blockpos.offset(-4, 0, -4), blockpos.offset(4, 2, 4)).iterator(); ++ Iterator iterator = BlockPos.betweenClosed(pos.offset(-4, 0, -4), pos.offset(4, 2, 4)).iterator(); + + do { + if (!iterator.hasNext()) { + return true; + } + +- BlockPos blockpos1 = (BlockPos) iterator.next(); +- BlockState blockstate1 = levelaccessor.getBlockState(blockpos1); ++ BlockPos blockposition1 = (BlockPos) iterator.next(); ++ IBlockData iblockdata1 = level.getBlockState(blockposition1); + +- if (blockstate1.is(Blocks.SCULK_SENSOR) || blockstate1.is(Blocks.SCULK_SHRIEKER)) { ++ if (iblockdata1.is(Blocks.SCULK_SENSOR) || iblockdata1.is(Blocks.SCULK_SHRIEKER)) { + ++i; + } + } while (i <= 2); +@@ -106,7 +107,6 @@ + } + + @Override +- @Override + public boolean canChangeBlockStateOnSpread() { + return false; + } |