aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/world/level/block/CropBlock.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/level/block/CropBlock.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/world/level/block/CropBlock.java.patch254
1 files changed, 254 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/level/block/CropBlock.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/level/block/CropBlock.java.patch
new file mode 100644
index 0000000000..83c3a312b4
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/world/level/block/CropBlock.java.patch
@@ -0,0 +1,254 @@
+--- a/net/minecraft/world/level/block/CropBlock.java
++++ b/net/minecraft/world/level/block/CropBlock.java
+@@ -11,98 +11,95 @@
+ import net.minecraft.world.item.Items;
+ import net.minecraft.world.level.BlockGetter;
+ import net.minecraft.world.level.GameRules;
+-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 CropBlock extends BushBlock implements BonemealableBlock {
++
+ public static final MapCodec<CropBlock> CODEC = simpleCodec(CropBlock::new);
+ public static final int MAX_AGE = 7;
+ public static final IntegerProperty AGE = BlockStateProperties.AGE_7;
+- private static final VoxelShape[] SHAPE_BY_AGE = new VoxelShape[]{
+- Block.box(0.0, 0.0, 0.0, 16.0, 2.0, 16.0),
+- Block.box(0.0, 0.0, 0.0, 16.0, 4.0, 16.0),
+- Block.box(0.0, 0.0, 0.0, 16.0, 6.0, 16.0),
+- Block.box(0.0, 0.0, 0.0, 16.0, 8.0, 16.0),
+- Block.box(0.0, 0.0, 0.0, 16.0, 10.0, 16.0),
+- Block.box(0.0, 0.0, 0.0, 16.0, 12.0, 16.0),
+- Block.box(0.0, 0.0, 0.0, 16.0, 14.0, 16.0),
+- Block.box(0.0, 0.0, 0.0, 16.0, 16.0, 16.0)
+- };
++ private static final VoxelShape[] SHAPE_BY_AGE = new VoxelShape[]{Block.box(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 4.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 6.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 10.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 12.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 14.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D)};
+
+ @Override
+ public MapCodec<? extends CropBlock> codec() {
+- return CODEC;
++ return CropBlock.CODEC;
+ }
+
+ protected CropBlock(BlockBehaviour.Properties properties) {
+ super(properties);
+- this.registerDefaultState(this.stateDefinition.any().setValue(this.getAgeProperty(), Integer.valueOf(0)));
++ this.registerDefaultState((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(this.getAgeProperty(), 0));
+ }
+
+ @Override
+- public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
+- return SHAPE_BY_AGE[this.getAge(state)];
++ public VoxelShape getShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) {
++ return CropBlock.SHAPE_BY_AGE[this.getAge(state)];
+ }
+
+ @Override
+- protected boolean mayPlaceOn(BlockState state, BlockGetter level, BlockPos pos) {
++ protected boolean mayPlaceOn(IBlockData state, BlockGetter level, BlockPos pos) {
+ return state.is(Blocks.FARMLAND);
+ }
+
+ protected IntegerProperty getAgeProperty() {
+- return AGE;
++ return CropBlock.AGE;
+ }
+
+ public int getMaxAge() {
+ return 7;
+ }
+
+- public int getAge(BlockState state) {
+- return state.getValue(this.getAgeProperty());
++ public int getAge(IBlockData state) {
++ return (Integer) state.getValue(this.getAgeProperty());
+ }
+
+- public BlockState getStateForAge(int age) {
+- return this.defaultBlockState().setValue(this.getAgeProperty(), Integer.valueOf(age));
++ public IBlockData getStateForAge(int age) {
++ return (IBlockData) this.defaultBlockState().setValue(this.getAgeProperty(), age);
+ }
+
+- public final boolean isMaxAge(BlockState state) {
++ public final boolean isMaxAge(IBlockData state) {
+ return this.getAge(state) >= this.getMaxAge();
+ }
+
+ @Override
+- public boolean isRandomlyTicking(BlockState state) {
++ public boolean isRandomlyTicking(IBlockData state) {
+ return !this.isMaxAge(state);
+ }
+
+ @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) {
+- int age = this.getAge(state);
+- if (age < this.getMaxAge()) {
+- float growthSpeed = getGrowthSpeed(this, level, pos);
+- if (random.nextInt((int)(25.0F / growthSpeed) + 1) == 0) {
+- level.setBlock(pos, this.getStateForAge(age + 1), 2);
++ int i = this.getAge(state);
++
++ if (i < this.getMaxAge()) {
++ float f = getGrowthSpeed(this, level, pos);
++
++ if (random.nextInt((int) (25.0F / f) + 1) == 0) {
++ CraftEventFactory.handleBlockGrowEvent(level, pos, this.getStateForAge(i + 1), 2); // CraftBukkit
+ }
+ }
+ }
++
+ }
+
+- public void growCrops(Level level, BlockPos pos, BlockState state) {
++ public void growCrops(Level level, BlockPos pos, IBlockData state) {
+ int i = this.getAge(state) + this.getBonemealAgeIncrease(level);
+- int maxAge = this.getMaxAge();
+- if (i > maxAge) {
+- i = maxAge;
++ int j = this.getMaxAge();
++
++ if (i > j) {
++ i = j;
+ }
+
+- level.setBlock(pos, this.getStateForAge(i), 2);
++ CraftEventFactory.handleBlockGrowEvent(level, pos, this.getStateForAge(i), 2); // CraftBukkit
+ }
+
+ protected int getBonemealAgeIncrease(Level level) {
+@@ -111,20 +108,21 @@
+
+ protected static float getGrowthSpeed(Block block, BlockGetter level, BlockPos pos) {
+ float f = 1.0F;
+- BlockPos blockPos = pos.below();
++ BlockPos blockposition1 = pos.below();
+
+- for (int i = -1; i <= 1; i++) {
+- for (int i1 = -1; i1 <= 1; i1++) {
++ for (int i = -1; i <= 1; ++i) {
++ for (int j = -1; j <= 1; ++j) {
+ float f1 = 0.0F;
+- BlockState blockState = level.getBlockState(blockPos.offset(i, 0, i1));
+- if (blockState.is(Blocks.FARMLAND)) {
++ IBlockData iblockdata = level.getBlockState(blockposition1.offset(i, 0, j));
++
++ if (iblockdata.is(Blocks.FARMLAND)) {
+ f1 = 1.0F;
+- if (blockState.getValue(FarmBlock.MOISTURE) > 0) {
++ if ((Integer) iblockdata.getValue(FarmBlock.MOISTURE) > 0) {
+ f1 = 3.0F;
+ }
+ }
+
+- if (i != 0 || i1 != 0) {
++ if (i != 0 || j != 0) {
+ f1 /= 4.0F;
+ }
+
+@@ -132,19 +130,18 @@
+ }
+ }
+
+- BlockPos blockPos1 = pos.north();
+- BlockPos blockPos2 = pos.south();
+- BlockPos blockPos3 = pos.west();
+- BlockPos blockPos4 = pos.east();
+- boolean flag = level.getBlockState(blockPos3).is(block) || level.getBlockState(blockPos4).is(block);
+- boolean flag1 = level.getBlockState(blockPos1).is(block) || level.getBlockState(blockPos2).is(block);
++ BlockPos blockposition2 = pos.north();
++ BlockPos blockposition3 = pos.south();
++ BlockPos blockposition4 = pos.west();
++ BlockPos blockposition5 = pos.east();
++ boolean flag = level.getBlockState(blockposition4).is(block) || level.getBlockState(blockposition5).is(block);
++ boolean flag1 = level.getBlockState(blockposition2).is(block) || level.getBlockState(blockposition3).is(block);
++
+ if (flag && flag1) {
+ f /= 2.0F;
+ } else {
+- boolean flag2 = level.getBlockState(blockPos3.north()).is(block)
+- || level.getBlockState(blockPos4.north()).is(block)
+- || level.getBlockState(blockPos4.south()).is(block)
+- || level.getBlockState(blockPos3.south()).is(block);
++ boolean flag2 = level.getBlockState(blockposition4.north()).is(block) || level.getBlockState(blockposition5.north()).is(block) || level.getBlockState(blockposition5.south()).is(block) || level.getBlockState(blockposition4.south()).is(block);
++
+ if (flag2) {
+ f /= 2.0F;
+ }
+@@ -154,49 +151,49 @@
+ }
+
+ @Override
+- public boolean canSurvive(BlockState state, LevelReader level, BlockPos pos) {
++ public boolean canSurvive(IBlockData state, LevelReader level, BlockPos pos) {
+ return hasSufficientLight(level, pos) && super.canSurvive(state, level, pos);
+ }
+
+- protected static boolean hasSufficientLight(LevelReader levelReader, BlockPos blockPos) {
+- return levelReader.getRawBrightness(blockPos, 0) >= 8;
++ protected static boolean hasSufficientLight(LevelReader iworldreader, BlockPos blockposition) {
++ return iworldreader.getRawBrightness(blockposition, 0) >= 8;
+ }
+
+ @Override
+- public void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) {
+- if (entity instanceof Ravager && level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
++ public void entityInside(IBlockData state, Level level, BlockPos pos, Entity entity) {
++ if (entity instanceof Ravager && CraftEventFactory.callEntityChangeBlockEvent(entity, pos, Blocks.AIR.defaultBlockState(), !level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit
+ level.destroyBlock(pos, true, entity);
+ }
+
+ super.entityInside(state, level, pos, entity);
+ }
+
+- protected ItemLike getBaseSeedId() {
++ protected IMaterial getBaseSeedId() {
+ return Items.WHEAT_SEEDS;
+ }
+
+ @Override
+- public ItemStack getCloneItemStack(LevelReader levelReader, BlockPos blockPos, BlockState blockState) {
++ public ItemStack getCloneItemStack(LevelReader iworldreader, BlockPos blockposition, IBlockData iblockdata) {
+ return new ItemStack(this.getBaseSeedId());
+ }
+
+ @Override
+- public boolean isValidBonemealTarget(LevelReader levelReader, BlockPos blockPos, BlockState blockState) {
+- return !this.isMaxAge(blockState);
++ public boolean isValidBonemealTarget(LevelReader iworldreader, BlockPos blockposition, IBlockData iblockdata) {
++ return !this.isMaxAge(iblockdata);
+ }
+
+ @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) {
++ public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, IBlockData state) {
+ this.growCrops(level, pos, state);
+ }
+
+ @Override
+- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
+- builder.add(AGE);
++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) {
++ builder.add(CropBlock.AGE);
+ }
+ }