diff options
author | MiniDigger | Martin <[email protected]> | 2024-01-14 11:04:49 +0100 |
---|---|---|
committer | MiniDigger | Martin <[email protected]> | 2024-01-14 11:04:49 +0100 |
commit | bee74680e607c2e29b038329f62181238911cd83 (patch) | |
tree | 708fd1a4a0227d9071243adf2a42d5e9e96cde4a /patch-remap/mache-spigotflower/net/minecraft/world/item/BoneMealItem.java.patch | |
parent | 0a44692ef6ff6e255d48eb3ba1bb114166eafda9 (diff) | |
download | Paper-softspoon.tar.gz Paper-softspoon.zip |
add remapped patches as a testsoftspoon
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/item/BoneMealItem.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/item/BoneMealItem.java.patch | 260 |
1 files changed, 260 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/item/BoneMealItem.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/item/BoneMealItem.java.patch new file mode 100644 index 0000000000..850ee9f189 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/item/BoneMealItem.java.patch @@ -0,0 +1,260 @@ +--- a/net/minecraft/world/item/BoneMealItem.java ++++ b/net/minecraft/world/item/BoneMealItem.java +@@ -19,7 +19,7 @@ + import net.minecraft.world.level.block.Block; + import net.minecraft.world.level.block.Blocks; + import net.minecraft.world.level.block.BonemealableBlock; +-import net.minecraft.world.level.block.state.BlockState; ++import net.minecraft.world.level.block.state.IBlockData; + import net.minecraft.world.level.gameevent.GameEvent; + + public class BoneMealItem extends Item { +@@ -28,55 +28,60 @@ + public static final int GRASS_SPREAD_HEIGHT = 1; + public static final int GRASS_COUNT_MULTIPLIER = 3; + +- public BoneMealItem(Item.Properties item_properties) { +- super(item_properties); ++ public BoneMealItem(Item.Properties properties) { ++ super(properties); + } + + @Override +- @Override +- public InteractionResult useOn(UseOnContext useoncontext) { +- Level level = useoncontext.getLevel(); +- BlockPos blockpos = useoncontext.getClickedPos(); +- BlockPos blockpos1 = blockpos.relative(useoncontext.getClickedFace()); ++ public InteractionResult useOn(UseOnContext context) { ++ // CraftBukkit start - extract bonemeal application logic to separate, static method ++ return applyBonemeal(context); ++ } + +- if (growCrop(useoncontext.getItemInHand(), level, blockpos)) { +- if (!level.isClientSide) { +- useoncontext.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH); +- level.levelEvent(1505, blockpos, 0); ++ public static InteractionResult applyBonemeal(UseOnContext itemactioncontext) { ++ // CraftBukkit end ++ Level world = itemactioncontext.getLevel(); ++ BlockPos blockposition = itemactioncontext.getClickedPos(); ++ BlockPos blockposition1 = blockposition.relative(itemactioncontext.getClickedFace()); ++ ++ if (growCrop(itemactioncontext.getItemInHand(), world, blockposition)) { ++ if (!world.isClientSide) { ++ if (itemactioncontext.getPlayer() != null) itemactioncontext.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH); // CraftBukkit - SPIGOT-7518 ++ world.levelEvent(1505, blockposition, 0); + } + +- return InteractionResult.sidedSuccess(level.isClientSide); ++ return InteractionResult.sidedSuccess(world.isClientSide); + } else { +- BlockState blockstate = level.getBlockState(blockpos); +- boolean flag = blockstate.isFaceSturdy(level, blockpos, useoncontext.getClickedFace()); ++ IBlockData iblockdata = world.getBlockState(blockposition); ++ boolean flag = iblockdata.isFaceSturdy(world, blockposition, itemactioncontext.getClickedFace()); + +- if (flag && growWaterPlant(useoncontext.getItemInHand(), level, blockpos1, useoncontext.getClickedFace())) { +- if (!level.isClientSide) { +- useoncontext.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH); +- level.levelEvent(1505, blockpos1, 0); ++ if (flag && growWaterPlant(itemactioncontext.getItemInHand(), world, blockposition1, itemactioncontext.getClickedFace())) { ++ if (!world.isClientSide) { ++ if (itemactioncontext.getPlayer() != null) itemactioncontext.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH); // CraftBukkit - SPIGOT-7518 ++ world.levelEvent(1505, blockposition1, 0); + } + +- return InteractionResult.sidedSuccess(level.isClientSide); ++ return InteractionResult.sidedSuccess(world.isClientSide); + } else { + return InteractionResult.PASS; + } + } + } + +- public static boolean growCrop(ItemStack itemstack, Level level, BlockPos blockpos) { +- BlockState blockstate = level.getBlockState(blockpos); +- Block block = blockstate.getBlock(); ++ public static boolean growCrop(ItemStack stack, Level level, BlockPos pos) { ++ IBlockData iblockdata = level.getBlockState(pos); ++ Block block = iblockdata.getBlock(); + + if (block instanceof BonemealableBlock) { +- BonemealableBlock bonemealableblock = (BonemealableBlock) block; ++ BonemealableBlock iblockfragileplantelement = (BonemealableBlock) block; + +- if (bonemealableblock.isValidBonemealTarget(level, blockpos, blockstate)) { ++ if (iblockfragileplantelement.isValidBonemealTarget(level, pos, iblockdata)) { + if (level instanceof ServerLevel) { +- if (bonemealableblock.isBonemealSuccess(level, level.random, blockpos, blockstate)) { +- bonemealableblock.performBonemeal((ServerLevel) level, level.random, blockpos, blockstate); ++ if (iblockfragileplantelement.isBonemealSuccess(level, level.random, pos, iblockdata)) { ++ iblockfragileplantelement.performBonemeal((ServerLevel) level, level.random, pos, iblockdata); + } + +- itemstack.shrink(1); ++ stack.shrink(1); + } + + return true; +@@ -86,8 +91,8 @@ + return false; + } + +- public static boolean growWaterPlant(ItemStack itemstack, Level level, BlockPos blockpos, @Nullable Direction direction) { +- if (level.getBlockState(blockpos).is(Blocks.WATER) && level.getFluidState(blockpos).getAmount() == 8) { ++ public static boolean growWaterPlant(ItemStack stack, Level level, BlockPos pos, @Nullable Direction clickedSide) { ++ if (level.getBlockState(pos).is(Blocks.WATER) && level.getFluidState(pos).getAmount() == 8) { + if (!(level instanceof ServerLevel)) { + return true; + } else { +@@ -95,54 +100,54 @@ + int i = 0; + + while (i < 128) { +- BlockPos blockpos1 = blockpos; +- BlockState blockstate = Blocks.SEAGRASS.defaultBlockState(); ++ BlockPos blockposition1 = pos; ++ IBlockData iblockdata = Blocks.SEAGRASS.defaultBlockState(); + int j = 0; + + while (true) { + if (j < i / 16) { +- blockpos1 = blockpos1.offset(randomsource.nextInt(3) - 1, (randomsource.nextInt(3) - 1) * randomsource.nextInt(3) / 2, randomsource.nextInt(3) - 1); +- if (!level.getBlockState(blockpos1).isCollisionShapeFullBlock(level, blockpos1)) { ++ blockposition1 = blockposition1.offset(randomsource.nextInt(3) - 1, (randomsource.nextInt(3) - 1) * randomsource.nextInt(3) / 2, randomsource.nextInt(3) - 1); ++ if (!level.getBlockState(blockposition1).isCollisionShapeFullBlock(level, blockposition1)) { + ++j; + continue; + } + } else { +- Holder<Biome> holder = level.getBiome(blockpos1); ++ Holder<Biome> holder = level.getBiome(blockposition1); + + if (holder.is(BiomeTags.PRODUCES_CORALS_FROM_BONEMEAL)) { +- if (i == 0 && direction != null && direction.getAxis().isHorizontal()) { +- blockstate = (BlockState) BuiltInRegistries.BLOCK.getTag(BlockTags.WALL_CORALS).flatMap((holderset_named) -> { ++ if (i == 0 && clickedSide != null && clickedSide.getAxis().isHorizontal()) { ++ iblockdata = (IBlockData) BuiltInRegistries.BLOCK.getTag(BlockTags.WALL_CORALS).flatMap((holderset_named) -> { + return holderset_named.getRandomElement(level.random); + }).map((holder1) -> { + return ((Block) holder1.value()).defaultBlockState(); +- }).orElse(blockstate); +- if (blockstate.hasProperty(BaseCoralWallFanBlock.FACING)) { +- blockstate = (BlockState) blockstate.setValue(BaseCoralWallFanBlock.FACING, direction); ++ }).orElse(iblockdata); ++ if (iblockdata.hasProperty(BaseCoralWallFanBlock.FACING)) { ++ iblockdata = (IBlockData) iblockdata.setValue(BaseCoralWallFanBlock.FACING, clickedSide); + } + } else if (randomsource.nextInt(4) == 0) { +- blockstate = (BlockState) BuiltInRegistries.BLOCK.getTag(BlockTags.UNDERWATER_BONEMEALS).flatMap((holderset_named) -> { ++ iblockdata = (IBlockData) BuiltInRegistries.BLOCK.getTag(BlockTags.UNDERWATER_BONEMEALS).flatMap((holderset_named) -> { + return holderset_named.getRandomElement(level.random); + }).map((holder1) -> { + return ((Block) holder1.value()).defaultBlockState(); +- }).orElse(blockstate); ++ }).orElse(iblockdata); + } + } + +- if (blockstate.is(BlockTags.WALL_CORALS, (blockbehaviour_blockstatebase) -> { +- return blockbehaviour_blockstatebase.hasProperty(BaseCoralWallFanBlock.FACING); ++ if (iblockdata.is(BlockTags.WALL_CORALS, (blockbase_blockdata) -> { ++ return blockbase_blockdata.hasProperty(BaseCoralWallFanBlock.FACING); + })) { +- for (int k = 0; !blockstate.canSurvive(level, blockpos1) && k < 4; ++k) { +- blockstate = (BlockState) blockstate.setValue(BaseCoralWallFanBlock.FACING, Direction.Plane.HORIZONTAL.getRandomDirection(randomsource)); ++ for (int k = 0; !iblockdata.canSurvive(level, blockposition1) && k < 4; ++k) { ++ iblockdata = (IBlockData) iblockdata.setValue(BaseCoralWallFanBlock.FACING, Direction.Plane.HORIZONTAL.getRandomDirection(randomsource)); + } + } + +- if (blockstate.canSurvive(level, blockpos1)) { +- BlockState blockstate1 = level.getBlockState(blockpos1); ++ if (iblockdata.canSurvive(level, blockposition1)) { ++ IBlockData iblockdata1 = level.getBlockState(blockposition1); + +- if (blockstate1.is(Blocks.WATER) && level.getFluidState(blockpos1).getAmount() == 8) { +- level.setBlock(blockpos1, blockstate, 3); +- } else if (blockstate1.is(Blocks.SEAGRASS) && randomsource.nextInt(10) == 0) { +- ((BonemealableBlock) Blocks.SEAGRASS).performBonemeal((ServerLevel) level, randomsource, blockpos1, blockstate1); ++ if (iblockdata1.is(Blocks.WATER) && level.getFluidState(blockposition1).getAmount() == 8) { ++ level.setBlock(blockposition1, iblockdata, 3); ++ } else if (iblockdata1.is(Blocks.SEAGRASS) && randomsource.nextInt(10) == 0) { ++ ((BonemealableBlock) Blocks.SEAGRASS).performBonemeal((ServerLevel) level, randomsource, blockposition1, iblockdata1); + } + } + } +@@ -152,7 +157,7 @@ + } + } + +- itemstack.shrink(1); ++ stack.shrink(1); + return true; + } + } else { +@@ -160,44 +165,44 @@ + } + } + +- public static void addGrowthParticles(LevelAccessor levelaccessor, BlockPos blockpos, int i) { +- if (i == 0) { +- i = 15; ++ public static void addGrowthParticles(LevelAccessor level, BlockPos pos, int data) { ++ if (data == 0) { ++ data = 15; + } + +- BlockState blockstate = levelaccessor.getBlockState(blockpos); ++ IBlockData iblockdata = level.getBlockState(pos); + +- if (!blockstate.isAir()) { ++ if (!iblockdata.isAir()) { + double d0 = 0.5D; + double d1; + +- if (blockstate.is(Blocks.WATER)) { +- i *= 3; ++ if (iblockdata.is(Blocks.WATER)) { ++ data *= 3; + d1 = 1.0D; + d0 = 3.0D; +- } else if (blockstate.isSolidRender(levelaccessor, blockpos)) { +- blockpos = blockpos.above(); +- i *= 3; ++ } else if (iblockdata.isSolidRender(level, pos)) { ++ pos = pos.above(); ++ data *= 3; + d0 = 3.0D; + d1 = 1.0D; + } else { +- d1 = blockstate.getShape(levelaccessor, blockpos).max(Direction.Axis.Y); ++ d1 = iblockdata.getShape(level, pos).max(Direction.Axis.Y); + } + +- levelaccessor.addParticle(ParticleTypes.HAPPY_VILLAGER, (double) blockpos.getX() + 0.5D, (double) blockpos.getY() + 0.5D, (double) blockpos.getZ() + 0.5D, 0.0D, 0.0D, 0.0D); +- RandomSource randomsource = levelaccessor.getRandom(); ++ level.addParticle(ParticleTypes.HAPPY_VILLAGER, (double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, 0.0D, 0.0D, 0.0D); ++ RandomSource randomsource = level.getRandom(); + +- for (int j = 0; j < i; ++j) { ++ for (int j = 0; j < data; ++j) { + double d2 = randomsource.nextGaussian() * 0.02D; + double d3 = randomsource.nextGaussian() * 0.02D; + double d4 = randomsource.nextGaussian() * 0.02D; + double d5 = 0.5D - d0; +- double d6 = (double) blockpos.getX() + d5 + randomsource.nextDouble() * d0 * 2.0D; +- double d7 = (double) blockpos.getY() + randomsource.nextDouble() * d1; +- double d8 = (double) blockpos.getZ() + d5 + randomsource.nextDouble() * d0 * 2.0D; ++ double d6 = (double) pos.getX() + d5 + randomsource.nextDouble() * d0 * 2.0D; ++ double d7 = (double) pos.getY() + randomsource.nextDouble() * d1; ++ double d8 = (double) pos.getZ() + d5 + randomsource.nextDouble() * d0 * 2.0D; + +- if (!levelaccessor.getBlockState(BlockPos.containing(d6, d7, d8).below()).isAir()) { +- levelaccessor.addParticle(ParticleTypes.HAPPY_VILLAGER, d6, d7, d8, d2, d3, d4); ++ if (!level.getBlockState(BlockPos.containing(d6, d7, d8).below()).isAir()) { ++ level.addParticle(ParticleTypes.HAPPY_VILLAGER, d6, d7, d8, d2, d3, d4); + } + } + |