2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/level/block/BlockSapling.java
|
|
|
|
+++ b/net/minecraft/world/level/block/BlockSapling.java
|
2022-12-07 17:00:00 +01:00
|
|
|
@@ -15,12 +15,20 @@
|
2021-03-15 23:00:00 +01:00
|
|
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
|
|
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
|
2014-11-25 22:32:16 +01: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 07:00:00 +02:00
|
|
|
public static final BlockStateInteger STAGE = BlockProperties.STAGE;
|
|
|
|
protected static final float AABB_OFFSET = 6.0F;
|
2021-11-21 23:00:00 +01:00
|
|
|
protected static final VoxelShape SHAPE = Block.box(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D);
|
2021-06-11 07:00:00 +02:00
|
|
|
private final WorldGenTreeProvider treeGrower;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ public static TreeType treeType; // CraftBukkit
|
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
protected BlockSapling(WorldGenTreeProvider worldgentreeprovider, BlockBase.Info blockbase_info) {
|
|
|
|
super(blockbase_info);
|
2022-12-07 17:00:00 +01:00
|
|
|
@@ -45,7 +53,32 @@
|
2022-07-10 06:12:30 +02:00
|
|
|
if ((Integer) iblockdata.getValue(BlockSapling.STAGE) == 0) {
|
|
|
|
worldserver.setBlock(blockposition, (IBlockData) iblockdata.cycle(BlockSapling.STAGE), 4);
|
|
|
|
} else {
|
2022-08-14 02:54:23 +02:00
|
|
|
- this.treeGrower.growTree(worldserver, worldserver.getChunkSource().getGenerator(), blockposition, iblockdata, randomsource);
|
2018-07-15 02:00:00 +02:00
|
|
|
+ // CraftBukkit start
|
2022-08-14 02:54:23 +02:00
|
|
|
+ if (worldserver.captureTreeGeneration) {
|
|
|
|
+ this.treeGrower.growTree(worldserver, worldserver.getChunkSource().getGenerator(), blockposition, iblockdata, randomsource);
|
|
|
|
+ } else {
|
|
|
|
+ worldserver.captureTreeGeneration = true;
|
|
|
|
+ this.treeGrower.growTree(worldserver, worldserver.getChunkSource().getGenerator(), blockposition, iblockdata, randomsource);
|
|
|
|
+ worldserver.captureTreeGeneration = false;
|
|
|
|
+ if (worldserver.capturedBlockStates.size() > 0) {
|
|
|
|
+ TreeType treeType = BlockSapling.treeType;
|
|
|
|
+ BlockSapling.treeType = null;
|
|
|
|
+ Location location = new Location(worldserver.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
|
|
|
+ java.util.List<BlockState> blocks = new java.util.ArrayList<>(worldserver.capturedBlockStates.values());
|
|
|
|
+ worldserver.capturedBlockStates.clear();
|
|
|
|
+ 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-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
2018-07-15 02:00:00 +02:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2018-07-15 02:00:00 +02:00
|
|
|
}
|