2021-03-16 09:00:00 +11:00
|
|
|
--- a/net/minecraft/world/level/block/BlockSapling.java
|
|
|
|
+++ b/net/minecraft/world/level/block/BlockSapling.java
|
2021-11-22 09:00:00 +11:00
|
|
|
@@ -14,12 +14,20 @@
|
2021-03-16 09:00:00 +11:00
|
|
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
|
|
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
|
2014-11-26 08:32:16 +11:00
|
|
|
|
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.Location;
|
|
|
|
+import org.bukkit.TreeType;
|
|
|
|
+import org.bukkit.block.BlockState;
|
|
|
|
+import org.bukkit.event.world.StructureGrowEvent;
|
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
|
|
|
public class BlockSapling extends BlockPlant implements IBlockFragilePlantElement {
|
|
|
|
|
2021-06-11 15:00:00 +10:00
|
|
|
public static final BlockStateInteger STAGE = BlockProperties.STAGE;
|
|
|
|
protected static final float AABB_OFFSET = 6.0F;
|
2021-11-22 09:00:00 +11:00
|
|
|
protected static final VoxelShape SHAPE = Block.box(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D);
|
2021-06-11 15:00:00 +10:00
|
|
|
private final WorldGenTreeProvider treeGrower;
|
2014-11-26 08:32:16 +11:00
|
|
|
+ public static TreeType treeType; // CraftBukkit
|
|
|
|
|
2020-06-25 10:00:00 +10:00
|
|
|
protected BlockSapling(WorldGenTreeProvider worldgentreeprovider, BlockBase.Info blockbase_info) {
|
|
|
|
super(blockbase_info);
|
2022-07-10 14:12:30 +10:00
|
|
|
@@ -44,7 +52,30 @@
|
|
|
|
if ((Integer) iblockdata.getValue(BlockSapling.STAGE) == 0) {
|
|
|
|
worldserver.setBlock(blockposition, (IBlockData) iblockdata.cycle(BlockSapling.STAGE), 4);
|
|
|
|
} else {
|
2018-07-15 10:00:00 +10:00
|
|
|
+ // CraftBukkit start
|
2019-12-11 09:00:00 +11:00
|
|
|
+ worldserver.captureTreeGeneration = true;
|
2018-07-15 10:00:00 +10:00
|
|
|
+ // CraftBukkit end
|
2022-07-10 14:12:30 +10:00
|
|
|
this.treeGrower.growTree(worldserver, worldserver.getChunkSource().getGenerator(), blockposition, iblockdata, randomsource);
|
2018-07-15 10:00:00 +10:00
|
|
|
+ // CraftBukkit start
|
2019-12-11 09:00:00 +11:00
|
|
|
+ worldserver.captureTreeGeneration = false;
|
|
|
|
+ if (worldserver.capturedBlockStates.size() > 0) {
|
2018-07-15 10:00:00 +10:00
|
|
|
+ TreeType treeType = BlockSapling.treeType;
|
|
|
|
+ BlockSapling.treeType = null;
|
2019-12-11 09:00:00 +11:00
|
|
|
+ Location location = new Location(worldserver.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
2020-01-28 09:48:28 +11:00
|
|
|
+ java.util.List<BlockState> blocks = new java.util.ArrayList<>(worldserver.capturedBlockStates.values());
|
2019-12-11 09:00:00 +11:00
|
|
|
+ worldserver.capturedBlockStates.clear();
|
2018-07-15 10:00:00 +10:00
|
|
|
+ StructureGrowEvent event = null;
|
|
|
|
+ if (treeType != null) {
|
|
|
|
+ event = new StructureGrowEvent(location, treeType, false, null, blocks);
|
|
|
|
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
|
|
|
|
+ }
|
|
|
|
+ if (event == null || !event.isCancelled()) {
|
|
|
|
+ for (BlockState blockstate : blocks) {
|
|
|
|
+ blockstate.update(true);
|
2014-11-26 08:32:16 +11:00
|
|
|
+ }
|
|
|
|
+ }
|
2018-07-15 10:00:00 +10:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2014-11-26 08:32:16 +11:00
|
|
|
}
|
|
|
|
|
2018-07-15 10:00:00 +10:00
|
|
|
}
|