diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/level/block/CropBlock.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/level/block/CropBlock.java.patch | 246 |
1 files changed, 246 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/level/block/CropBlock.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/CropBlock.java.patch new file mode 100644 index 0000000000..d8354c373e --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/CropBlock.java.patch @@ -0,0 +1,246 @@ +--- a/net/minecraft/world/level/block/CropBlock.java ++++ b/net/minecraft/world/level/block/CropBlock.java +@@ -11,16 +11,17 @@ + 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 { + +@@ -30,26 +31,23 @@ + 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 +- @Override + public MapCodec<? extends CropBlock> codec() { + return CropBlock.CODEC; + } + +- protected CropBlock(BlockBehaviour.Properties blockbehaviour_properties) { +- super(blockbehaviour_properties); +- this.registerDefaultState((BlockState) ((BlockState) this.stateDefinition.any()).setValue(this.getAgeProperty(), 0)); ++ protected CropBlock(BlockBehaviour.Properties properties) { ++ super(properties); ++ this.registerDefaultState((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(this.getAgeProperty(), 0)); + } + + @Override +- @Override +- public VoxelShape getShape(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos, CollisionContext collisioncontext) { +- return CropBlock.SHAPE_BY_AGE[this.getAge(blockstate)]; ++ public VoxelShape getShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) { ++ return CropBlock.SHAPE_BY_AGE[this.getAge(state)]; + } + + @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); + } + + protected IntegerProperty getAgeProperty() { +@@ -60,68 +58,66 @@ + return 7; + } + +- public int getAge(BlockState blockstate) { +- return (Integer) blockstate.getValue(this.getAgeProperty()); ++ public int getAge(IBlockData state) { ++ return (Integer) state.getValue(this.getAgeProperty()); + } + +- public BlockState getStateForAge(int i) { +- return (BlockState) this.defaultBlockState().setValue(this.getAgeProperty(), i); ++ public IBlockData getStateForAge(int age) { ++ return (IBlockData) this.defaultBlockState().setValue(this.getAgeProperty(), age); + } + +- public final boolean isMaxAge(BlockState blockstate) { +- return this.getAge(blockstate) >= this.getMaxAge(); ++ public final boolean isMaxAge(IBlockData state) { ++ return this.getAge(state) >= this.getMaxAge(); + } + + @Override +- @Override +- public boolean isRandomlyTicking(BlockState blockstate) { +- return !this.isMaxAge(blockstate); ++ public boolean isRandomlyTicking(IBlockData state) { ++ return !this.isMaxAge(state); + } + + @Override +- @Override +- public void randomTick(BlockState blockstate, ServerLevel serverlevel, BlockPos blockpos, RandomSource randomsource) { +- if (serverlevel.getRawBrightness(blockpos, 0) >= 9) { +- int i = this.getAge(blockstate); ++ public void randomTick(IBlockData state, ServerLevel level, BlockPos pos, RandomSource random) { ++ if (level.getRawBrightness(pos, 0) >= 9) { ++ int i = this.getAge(state); + + if (i < this.getMaxAge()) { +- float f = getGrowthSpeed(this, serverlevel, blockpos); ++ float f = getGrowthSpeed(this, level, pos); + +- if (randomsource.nextInt((int) (25.0F / f) + 1) == 0) { +- serverlevel.setBlock(blockpos, this.getStateForAge(i + 1), 2); ++ 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 blockpos, BlockState blockstate) { +- int i = this.getAge(blockstate) + this.getBonemealAgeIncrease(level); ++ public void growCrops(Level level, BlockPos pos, IBlockData state) { ++ int i = this.getAge(state) + this.getBonemealAgeIncrease(level); + int j = this.getMaxAge(); + + if (i > j) { + i = j; + } + +- level.setBlock(blockpos, this.getStateForAge(i), 2); ++ CraftEventFactory.handleBlockGrowEvent(level, pos, this.getStateForAge(i), 2); // CraftBukkit + } + + protected int getBonemealAgeIncrease(Level level) { + return Mth.nextInt(level.random, 2, 5); + } + +- protected static float getGrowthSpeed(Block block, BlockGetter blockgetter, BlockPos blockpos) { ++ protected static float getGrowthSpeed(Block block, BlockGetter level, BlockPos pos) { + float f = 1.0F; +- BlockPos blockpos1 = blockpos.below(); ++ BlockPos blockposition1 = pos.below(); + + for (int i = -1; i <= 1; ++i) { + for (int j = -1; j <= 1; ++j) { + float f1 = 0.0F; +- BlockState blockstate = blockgetter.getBlockState(blockpos1.offset(i, 0, j)); ++ IBlockData iblockdata = level.getBlockState(blockposition1.offset(i, 0, j)); + +- if (blockstate.is(Blocks.FARMLAND)) { ++ if (iblockdata.is(Blocks.FARMLAND)) { + f1 = 1.0F; +- if ((Integer) blockstate.getValue(FarmBlock.MOISTURE) > 0) { ++ if ((Integer) iblockdata.getValue(FarmBlock.MOISTURE) > 0) { + f1 = 3.0F; + } + } +@@ -134,17 +130,17 @@ + } + } + +- BlockPos blockpos2 = blockpos.north(); +- BlockPos blockpos3 = blockpos.south(); +- BlockPos blockpos4 = blockpos.west(); +- BlockPos blockpos5 = blockpos.east(); +- boolean flag = blockgetter.getBlockState(blockpos4).is(block) || blockgetter.getBlockState(blockpos5).is(block); +- boolean flag1 = blockgetter.getBlockState(blockpos2).is(block) || blockgetter.getBlockState(blockpos3).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 = blockgetter.getBlockState(blockpos4.north()).is(block) || blockgetter.getBlockState(blockpos5.north()).is(block) || blockgetter.getBlockState(blockpos5.south()).is(block) || blockgetter.getBlockState(blockpos4.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; +@@ -155,56 +151,49 @@ + } + + @Override +- @Override +- public boolean canSurvive(BlockState blockstate, LevelReader levelreader, BlockPos blockpos) { +- return hasSufficientLight(levelreader, blockpos) && super.canSurvive(blockstate, levelreader, blockpos); ++ 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 +- @Override +- public void entityInside(BlockState blockstate, Level level, BlockPos blockpos, Entity entity) { +- if (entity instanceof Ravager && level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { +- level.destroyBlock(blockpos, true, entity); ++ 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(blockstate, level, blockpos, entity); ++ super.entityInside(state, level, pos, entity); + } + +- protected ItemLike getBaseSeedId() { ++ protected IMaterial getBaseSeedId() { + return Items.WHEAT_SEEDS; + } + + @Override +- @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 +- @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 +- @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) { +- this.growCrops(serverlevel, blockpos, blockstate); ++ public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, IBlockData state) { ++ this.growCrops(level, pos, state); + } + + @Override +- @Override +- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> statedefinition_builder) { +- statedefinition_builder.add(CropBlock.AGE); ++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) { ++ builder.add(CropBlock.AGE); + } + } |