aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/world/level/block/StemBlock.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/level/block/StemBlock.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/world/level/block/StemBlock.java.patch174
1 files changed, 174 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/level/block/StemBlock.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/StemBlock.java.patch
new file mode 100644
index 0000000000..02f9b900e7
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/StemBlock.java.patch
@@ -0,0 +1,174 @@
+--- a/net/minecraft/world/level/block/StemBlock.java
++++ b/net/minecraft/world/level/block/StemBlock.java
+@@ -16,26 +16,27 @@
+ import net.minecraft.world.item.Item;
+ import net.minecraft.world.item.ItemStack;
+ import net.minecraft.world.level.BlockGetter;
+-import net.minecraft.world.level.ItemLike;
++import net.minecraft.world.level.IMaterial;
+ import net.minecraft.world.level.Level;
+ import net.minecraft.world.level.LevelReader;
+ 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.IntegerProperty;
+ import net.minecraft.world.phys.shapes.CollisionContext;
+ import net.minecraft.world.phys.shapes.VoxelShape;
++import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
+ public class StemBlock extends BushBlock implements BonemealableBlock {
+
+ public static final MapCodec<StemBlock> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
+- return instance.group(ResourceKey.codec(Registries.BLOCK).fieldOf("fruit").forGetter((stemblock) -> {
+- return stemblock.fruit;
+- }), ResourceKey.codec(Registries.BLOCK).fieldOf("attached_stem").forGetter((stemblock) -> {
+- return stemblock.attachedStem;
+- }), ResourceKey.codec(Registries.ITEM).fieldOf("seed").forGetter((stemblock) -> {
+- return stemblock.seed;
++ return instance.group(ResourceKey.codec(Registries.BLOCK).fieldOf("fruit").forGetter((blockstem) -> {
++ return blockstem.fruit;
++ }), ResourceKey.codec(Registries.BLOCK).fieldOf("attached_stem").forGetter((blockstem) -> {
++ return blockstem.attachedStem;
++ }), ResourceKey.codec(Registries.ITEM).fieldOf("seed").forGetter((blockstem) -> {
++ return blockstem.seed;
+ }), propertiesCodec()).apply(instance, StemBlock::new);
+ });
+ public static final int MAX_AGE = 7;
+@@ -47,56 +48,56 @@
+ private final ResourceKey<Item> seed;
+
+ @Override
+- @Override
+ public MapCodec<StemBlock> codec() {
+ return StemBlock.CODEC;
+ }
+
+- protected StemBlock(ResourceKey<Block> resourcekey, ResourceKey<Block> resourcekey1, ResourceKey<Item> resourcekey2, BlockBehaviour.Properties blockbehaviour_properties) {
+- super(blockbehaviour_properties);
++ protected StemBlock(ResourceKey<Block> resourcekey, ResourceKey<Block> resourcekey1, ResourceKey<Item> resourcekey2, BlockBehaviour.Properties blockbase_info) {
++ super(blockbase_info);
+ this.fruit = resourcekey;
+ this.attachedStem = resourcekey1;
+ this.seed = resourcekey2;
+- this.registerDefaultState((BlockState) ((BlockState) this.stateDefinition.any()).setValue(StemBlock.AGE, 0));
++ this.registerDefaultState((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(StemBlock.AGE, 0));
+ }
+
+ @Override
+- @Override
+- public VoxelShape getShape(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos, CollisionContext collisioncontext) {
+- return StemBlock.SHAPE_BY_AGE[(Integer) blockstate.getValue(StemBlock.AGE)];
++ public VoxelShape getShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) {
++ return StemBlock.SHAPE_BY_AGE[(Integer) state.getValue(StemBlock.AGE)];
+ }
+
+ @Override
+- @Override
+- protected boolean mayPlaceOn(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos) {
+- return blockstate.is(Blocks.FARMLAND);
++ protected boolean mayPlaceOn(IBlockData state, BlockGetter level, BlockPos pos) {
++ return state.is(Blocks.FARMLAND);
+ }
+
+ @Override
+- @Override
+- public void randomTick(BlockState blockstate, ServerLevel serverlevel, BlockPos blockpos, RandomSource randomsource) {
+- if (serverlevel.getRawBrightness(blockpos, 0) >= 9) {
+- float f = CropBlock.getGrowthSpeed(this, serverlevel, blockpos);
++ public void randomTick(IBlockData state, ServerLevel level, BlockPos pos, RandomSource random) {
++ if (level.getRawBrightness(pos, 0) >= 9) {
++ float f = CropBlock.getGrowthSpeed(this, level, pos);
+
+- if (randomsource.nextInt((int) (25.0F / f) + 1) == 0) {
+- int i = (Integer) blockstate.getValue(StemBlock.AGE);
++ if (random.nextInt((int) (25.0F / f) + 1) == 0) {
++ int i = (Integer) state.getValue(StemBlock.AGE);
+
+ if (i < 7) {
+- blockstate = (BlockState) blockstate.setValue(StemBlock.AGE, i + 1);
+- serverlevel.setBlock(blockpos, blockstate, 2);
++ state = (IBlockData) state.setValue(StemBlock.AGE, i + 1);
++ CraftEventFactory.handleBlockGrowEvent(level, pos, state, 2); // CraftBukkit
+ } else {
+- Direction direction = Direction.Plane.HORIZONTAL.getRandomDirection(randomsource);
+- BlockPos blockpos1 = blockpos.relative(direction);
+- BlockState blockstate1 = serverlevel.getBlockState(blockpos1.below());
++ Direction enumdirection = Direction.Plane.HORIZONTAL.getRandomDirection(random);
++ BlockPos blockposition1 = pos.relative(enumdirection);
++ IBlockData iblockdata1 = level.getBlockState(blockposition1.below());
+
+- if (serverlevel.getBlockState(blockpos1).isAir() && (blockstate1.is(Blocks.FARMLAND) || blockstate1.is(BlockTags.DIRT))) {
+- Registry<Block> registry = serverlevel.registryAccess().registryOrThrow(Registries.BLOCK);
+- Optional<Block> optional = registry.getOptional(this.fruit);
+- Optional<Block> optional1 = registry.getOptional(this.attachedStem);
++ if (level.getBlockState(blockposition1).isAir() && (iblockdata1.is(Blocks.FARMLAND) || iblockdata1.is(BlockTags.DIRT))) {
++ Registry<Block> iregistry = level.registryAccess().registryOrThrow(Registries.BLOCK);
++ Optional<Block> optional = iregistry.getOptional(this.fruit);
++ Optional<Block> optional1 = iregistry.getOptional(this.attachedStem);
+
+ if (optional.isPresent() && optional1.isPresent()) {
+- serverlevel.setBlockAndUpdate(blockpos1, ((Block) optional.get()).defaultBlockState());
+- serverlevel.setBlockAndUpdate(blockpos, (BlockState) ((Block) optional1.get()).defaultBlockState().setValue(HorizontalDirectionalBlock.FACING, direction));
++ // CraftBukkit start
++ if (!CraftEventFactory.handleBlockGrowEvent(level, blockposition1, ((Block) optional.get()).defaultBlockState())) {
++ return;
++ }
++ // CraftBukkit end
++ level.setBlockAndUpdate(pos, (IBlockData) ((Block) optional1.get()).defaultBlockState().setValue(HorizontalDirectionalBlock.FACING, enumdirection));
+ }
+ }
+ }
+@@ -106,39 +107,34 @@
+ }
+
+ @Override
+- @Override
+- public ItemStack getCloneItemStack(LevelReader levelreader, BlockPos blockpos, BlockState blockstate) {
+- return new ItemStack((ItemLike) DataFixUtils.orElse(levelreader.registryAccess().registryOrThrow(Registries.ITEM).getOptional(this.seed), this));
++ public ItemStack getCloneItemStack(LevelReader iworldreader, BlockPos blockposition, IBlockData iblockdata) {
++ return new ItemStack((IMaterial) DataFixUtils.orElse(iworldreader.registryAccess().registryOrThrow(Registries.ITEM).getOptional(this.seed), this));
+ }
+
+ @Override
+- @Override
+- public boolean isValidBonemealTarget(LevelReader levelreader, BlockPos blockpos, BlockState blockstate) {
+- return (Integer) blockstate.getValue(StemBlock.AGE) != 7;
++ public boolean isValidBonemealTarget(LevelReader iworldreader, BlockPos blockposition, IBlockData iblockdata) {
++ return (Integer) iblockdata.getValue(StemBlock.AGE) != 7;
+ }
+
+ @Override
+- @Override
+- public boolean isBonemealSuccess(Level level, RandomSource randomsource, BlockPos blockpos, BlockState blockstate) {
++ public boolean isBonemealSuccess(Level level, RandomSource random, BlockPos pos, IBlockData state) {
+ return true;
+ }
+
+ @Override
+- @Override
+- public void performBonemeal(ServerLevel serverlevel, RandomSource randomsource, BlockPos blockpos, BlockState blockstate) {
+- int i = Math.min(7, (Integer) blockstate.getValue(StemBlock.AGE) + Mth.nextInt(serverlevel.random, 2, 5));
+- BlockState blockstate1 = (BlockState) blockstate.setValue(StemBlock.AGE, i);
++ public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, IBlockData state) {
++ int i = Math.min(7, (Integer) state.getValue(StemBlock.AGE) + Mth.nextInt(level.random, 2, 5));
++ IBlockData iblockdata1 = (IBlockData) state.setValue(StemBlock.AGE, i);
+
+- serverlevel.setBlock(blockpos, blockstate1, 2);
++ CraftEventFactory.handleBlockGrowEvent(level, pos, iblockdata1, 2); // CraftBukkit
+ if (i == 7) {
+- blockstate1.randomTick(serverlevel, blockpos, serverlevel.random);
++ iblockdata1.randomTick(level, pos, level.random);
+ }
+
+ }
+
+ @Override
+- @Override
+- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> statedefinition_builder) {
+- statedefinition_builder.add(StemBlock.AGE);
++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) {
++ builder.add(StemBlock.AGE);
+ }
+ }