3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-20 21:40:06 +01:00
Paper/nms-patches/BlockSapling.patch

54 Zeilen
2.3 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/BlockSapling.java
+++ b/net/minecraft/server/BlockSapling.java
@@ -2,11 +2,19 @@
import java.util.Random;
+// 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 {
2020-06-25 02:00:00 +02:00
public static final BlockStateInteger STAGE = BlockProperties.aA;
2018-07-15 02:00:00 +02:00
protected static final VoxelShape b = Block.a(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D);
private final WorldGenTreeProvider c;
+ public static TreeType treeType; // CraftBukkit
2020-06-25 02:00:00 +02:00
protected BlockSapling(WorldGenTreeProvider worldgentreeprovider, BlockBase.Info blockbase_info) {
super(blockbase_info);
@@ -22,7 +30,30 @@
@Override
2019-12-10 23:00:00 +01:00
public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) {
if (worldserver.getLightLevel(blockposition.up()) >= 9 && random.nextInt(7) == 0) {
2018-07-15 02:00:00 +02:00
+ // CraftBukkit start
2019-12-10 23:00:00 +01:00
+ worldserver.captureTreeGeneration = true;
2018-07-15 02:00:00 +02:00
+ // CraftBukkit end
2019-12-10 23:00:00 +01:00
this.grow(worldserver, blockposition, iblockdata, random);
2018-07-15 02:00:00 +02:00
+ // CraftBukkit start
2019-12-10 23:00:00 +01:00
+ worldserver.captureTreeGeneration = false;
+ if (worldserver.capturedBlockStates.size() > 0) {
2018-07-15 02:00:00 +02:00
+ TreeType treeType = BlockSapling.treeType;
+ BlockSapling.treeType = null;
2019-12-10 23:00:00 +01:00
+ Location location = new Location(worldserver.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ java.util.List<BlockState> blocks = new java.util.ArrayList<>(worldserver.capturedBlockStates.values());
2019-12-10 23:00:00 +01:00
+ worldserver.capturedBlockStates.clear();
2018-07-15 02:00:00 +02: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);
+ }
+ }
2018-07-15 02:00:00 +02:00
+ }
+ // CraftBukkit end
}
2018-07-15 02:00:00 +02:00
}