Files
CatServer/patches/net/minecraft/block/BlockChorusFlower.java.patch
2019-02-24 22:29:41 +08:00

97 lines
5.0 KiB
Diff

--- ../src-base/minecraft/net/minecraft/block/BlockChorusFlower.java
+++ ../src-work/minecraft/net/minecraft/block/BlockChorusFlower.java
@@ -23,6 +23,7 @@
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
public class BlockChorusFlower extends Block
{
@@ -55,7 +56,7 @@
{
int i = ((Integer)state.getValue(AGE)).intValue();
- if (i < 5 && rand.nextInt(1) == 0)
+ if (i < 5 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(worldIn, blockpos, state, rand.nextInt(1) == 0))
{
boolean flag = false;
boolean flag1 = false;
@@ -106,8 +107,18 @@
if (flag && areAllNeighborsEmpty(worldIn, blockpos, (EnumFacing)null) && worldIn.isAirBlock(pos.up(2)))
{
- worldIn.setBlockState(pos, Blocks.CHORUS_PLANT.getDefaultState(), 2);
- this.placeGrownFlower(worldIn, blockpos, i);
+// worldIn.setBlockState(pos, Blocks.CHORUS_PLANT.getDefaultState(), 2);
+// this.placeGrownFlower(worldIn, blockpos, i);
+ BlockPos target = blockpos;
+ if (CraftEventFactory.handleBlockSpreadEvent(
+ worldIn.getWorld().getBlockAt(target.getX(), target.getY(), target.getZ()),
+ worldIn.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()),
+ this,
+ getMetaFromState(this.getDefaultState().withProperty(BlockChorusFlower.AGE, Integer.valueOf(i)))
+ )) {
+ worldIn.setBlockState(pos, Blocks.CHORUS_PLANT.getDefaultState(), 2);
+ worldIn.playEvent(1033, pos, 0);
+ }
}
else if (i < 4)
{
@@ -126,7 +137,17 @@
if (worldIn.isAirBlock(blockpos1) && worldIn.isAirBlock(blockpos1.down()) && areAllNeighborsEmpty(worldIn, blockpos1, enumfacing.getOpposite()))
{
- this.placeGrownFlower(worldIn, blockpos1, i + 1);
+// this.placeGrownFlower(worldIn, blockpos1, i + 1);
+ BlockPos target = blockpos1;
+ if (CraftEventFactory.handleBlockSpreadEvent(
+ worldIn.getWorld().getBlockAt(target.getX(), target.getY(), target.getZ()),
+ worldIn.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()),
+ this,
+ getMetaFromState(this.getDefaultState().withProperty(BlockChorusFlower.AGE, Integer.valueOf(i + 1)))
+ )) {
+ worldIn.playEvent(1033, pos, 0);
+ flag2 = true;
+ }
flag2 = true;
}
}
@@ -137,13 +158,34 @@
}
else
{
- this.placeDeadFlower(worldIn, pos);
+// this.placeDeadFlower(worldIn, pos);
+ if (CraftEventFactory.handleBlockGrowEvent(
+ worldIn,
+ pos.getX(),
+ pos.getY(),
+ pos.getZ(),
+ this,
+ getMetaFromState(state.withProperty(BlockChorusFlower.AGE, Integer.valueOf(5)))
+ )) {
+ worldIn.playEvent(1034, pos, 0);
+ }
}
}
else if (i == 4)
{
- this.placeDeadFlower(worldIn, pos);
+// this.placeDeadFlower(worldIn, pos);
+ if (CraftEventFactory.handleBlockGrowEvent(
+ worldIn,
+ pos.getX(),
+ pos.getY(),
+ pos.getZ(),
+ this,
+ getMetaFromState(state.withProperty(BlockChorusFlower.AGE, Integer.valueOf(5)))
+ )) {
+ worldIn.playEvent(1034, pos, 0);
+ }
}
+ net.minecraftforge.common.ForgeHooks.onCropsGrowPost(worldIn, pos, state, worldIn.getBlockState(pos));
}
}
}