aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/world/level/block/StemBlock.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/level/block/StemBlock.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/world/level/block/StemBlock.java.patch194
1 files changed, 194 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/level/block/StemBlock.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/level/block/StemBlock.java.patch
new file mode 100644
index 0000000000..e3ffac8ec4
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/world/level/block/StemBlock.java.patch
@@ -0,0 +1,194 @@
+--- a/net/minecraft/world/level/block/StemBlock.java
++++ b/net/minecraft/world/level/block/StemBlock.java
+@@ -3,7 +3,6 @@
+ import com.mojang.datafixers.DataFixUtils;
+ import com.mojang.serialization.MapCodec;
+ import com.mojang.serialization.codecs.RecordCodecBuilder;
+-import com.mojang.serialization.codecs.RecordCodecBuilder.Instance;
+ import java.util.Optional;
+ import net.minecraft.core.BlockPos;
+ import net.minecraft.core.Direction;
+@@ -17,120 +16,125 @@
+ import net.minecraft.world.item.Item;
+ import net.minecraft.world.item.ItemStack;
+ import net.minecraft.world.level.BlockGetter;
++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 -> instance.group(
+- ResourceKey.codec(Registries.BLOCK).fieldOf("fruit").forGetter(stemBlock -> stemBlock.fruit),
+- ResourceKey.codec(Registries.BLOCK).fieldOf("attached_stem").forGetter(stemBlock -> stemBlock.attachedStem),
+- ResourceKey.codec(Registries.ITEM).fieldOf("seed").forGetter(stemBlock -> stemBlock.seed),
+- propertiesCodec()
+- )
+- .apply(instance, StemBlock::new)
+- );
++
++ public static final MapCodec<StemBlock> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
++ 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;
+ public static final IntegerProperty AGE = BlockStateProperties.AGE_7;
+ protected static final float AABB_OFFSET = 1.0F;
+- protected static final VoxelShape[] SHAPE_BY_AGE = new VoxelShape[]{
+- Block.box(7.0, 0.0, 7.0, 9.0, 2.0, 9.0),
+- Block.box(7.0, 0.0, 7.0, 9.0, 4.0, 9.0),
+- Block.box(7.0, 0.0, 7.0, 9.0, 6.0, 9.0),
+- Block.box(7.0, 0.0, 7.0, 9.0, 8.0, 9.0),
+- Block.box(7.0, 0.0, 7.0, 9.0, 10.0, 9.0),
+- Block.box(7.0, 0.0, 7.0, 9.0, 12.0, 9.0),
+- Block.box(7.0, 0.0, 7.0, 9.0, 14.0, 9.0),
+- Block.box(7.0, 0.0, 7.0, 9.0, 16.0, 9.0)
+- };
++ protected static final VoxelShape[] SHAPE_BY_AGE = new VoxelShape[]{Block.box(7.0D, 0.0D, 7.0D, 9.0D, 2.0D, 9.0D), Block.box(7.0D, 0.0D, 7.0D, 9.0D, 4.0D, 9.0D), Block.box(7.0D, 0.0D, 7.0D, 9.0D, 6.0D, 9.0D), Block.box(7.0D, 0.0D, 7.0D, 9.0D, 8.0D, 9.0D), Block.box(7.0D, 0.0D, 7.0D, 9.0D, 10.0D, 9.0D), Block.box(7.0D, 0.0D, 7.0D, 9.0D, 12.0D, 9.0D), Block.box(7.0D, 0.0D, 7.0D, 9.0D, 14.0D, 9.0D), Block.box(7.0D, 0.0D, 7.0D, 9.0D, 16.0D, 9.0D)};
+ private final ResourceKey<Block> fruit;
+ private final ResourceKey<Block> attachedStem;
+ private final ResourceKey<Item> seed;
+
+ @Override
+ public MapCodec<StemBlock> codec() {
+- return CODEC;
++ return StemBlock.CODEC;
+ }
+
+- protected StemBlock(ResourceKey<Block> resourceKey, ResourceKey<Block> resourceKey1, ResourceKey<Item> resourceKey2, BlockBehaviour.Properties properties) {
+- super(properties);
+- this.fruit = resourceKey;
+- this.attachedStem = resourceKey1;
+- this.seed = resourceKey2;
+- this.registerDefaultState(this.stateDefinition.any().setValue(AGE, Integer.valueOf(0)));
++ 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((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(StemBlock.AGE, 0));
+ }
+
+ @Override
+- public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
+- return SHAPE_BY_AGE[state.getValue(AGE)];
++ public VoxelShape getShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) {
++ return StemBlock.SHAPE_BY_AGE[(Integer) state.getValue(StemBlock.AGE)];
+ }
+
+ @Override
+- protected boolean mayPlaceOn(BlockState state, BlockGetter level, BlockPos pos) {
++ protected boolean mayPlaceOn(IBlockData state, BlockGetter level, BlockPos pos) {
+ return state.is(Blocks.FARMLAND);
+ }
+
+ @Override
+- public void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) {
++ public void randomTick(IBlockData state, ServerLevel level, BlockPos pos, RandomSource random) {
+ if (level.getRawBrightness(pos, 0) >= 9) {
+- float growthSpeed = CropBlock.getGrowthSpeed(this, level, pos);
+- if (random.nextInt((int)(25.0F / growthSpeed) + 1) == 0) {
+- int i = state.getValue(AGE);
++ float f = CropBlock.getGrowthSpeed(this, level, pos);
++
++ if (random.nextInt((int) (25.0F / f) + 1) == 0) {
++ int i = (Integer) state.getValue(StemBlock.AGE);
++
+ if (i < 7) {
+- state = state.setValue(AGE, Integer.valueOf(i + 1));
+- level.setBlock(pos, state, 2);
++ state = (IBlockData) state.setValue(StemBlock.AGE, i + 1);
++ CraftEventFactory.handleBlockGrowEvent(level, pos, state, 2); // CraftBukkit
+ } else {
+- Direction randomDirection = Direction.Plane.HORIZONTAL.getRandomDirection(random);
+- BlockPos blockPos = pos.relative(randomDirection);
+- BlockState blockState = level.getBlockState(blockPos.below());
+- if (level.getBlockState(blockPos).isAir() && (blockState.is(Blocks.FARMLAND) || blockState.is(BlockTags.DIRT))) {
+- Registry<Block> registry = level.registryAccess().registryOrThrow(Registries.BLOCK);
+- Optional<Block> optional = registry.getOptional(this.fruit);
+- Optional<Block> optional1 = registry.getOptional(this.attachedStem);
++ Direction enumdirection = Direction.Plane.HORIZONTAL.getRandomDirection(random);
++ BlockPos blockposition1 = pos.relative(enumdirection);
++ IBlockData iblockdata1 = level.getBlockState(blockposition1.below());
++
++ 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()) {
+- level.setBlockAndUpdate(blockPos, optional.get().defaultBlockState());
+- level.setBlockAndUpdate(pos, optional1.get().defaultBlockState().setValue(HorizontalDirectionalBlock.FACING, randomDirection));
++ // 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));
+ }
+ }
+ }
+ }
++
+ }
+ }
+
+ @Override
+- public ItemStack getCloneItemStack(LevelReader levelReader, BlockPos blockPos, BlockState blockState) {
+- return new ItemStack(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
+- public boolean isValidBonemealTarget(LevelReader levelReader, BlockPos blockPos, BlockState blockState) {
+- return blockState.getValue(AGE) != 7;
++ public boolean isValidBonemealTarget(LevelReader iworldreader, BlockPos blockposition, IBlockData iblockdata) {
++ return (Integer) iblockdata.getValue(StemBlock.AGE) != 7;
+ }
+
+ @Override
+- public boolean isBonemealSuccess(Level level, RandomSource random, BlockPos pos, BlockState state) {
++ public boolean isBonemealSuccess(Level level, RandomSource random, BlockPos pos, IBlockData state) {
+ return true;
+ }
+
+ @Override
+- public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, BlockState state) {
+- int min = Math.min(7, state.getValue(AGE) + Mth.nextInt(level.random, 2, 5));
+- BlockState blockState = state.setValue(AGE, Integer.valueOf(min));
+- level.setBlock(pos, blockState, 2);
+- if (min == 7) {
+- blockState.randomTick(level, pos, level.random);
++ 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);
++
++ CraftEventFactory.handleBlockGrowEvent(level, pos, iblockdata1, 2); // CraftBukkit
++ if (i == 7) {
++ iblockdata1.randomTick(level, pos, level.random);
+ }
++
+ }
+
+ @Override
+- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
+- builder.add(AGE);
++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) {
++ builder.add(StemBlock.AGE);
+ }
+ }