Commits

md_5 authored 8468e167efa
SPIGOT-7137: StructureGrowEvent isFromBonemeal and getPlayer have incorrect values
No tags

nms-patches/net/minecraft/world/level/block/BlockSapling.patch

Modified
14 14 public class BlockSapling extends BlockPlant implements IBlockFragilePlantElement {
15 15
16 16 public static final BlockStateInteger STAGE = BlockProperties.STAGE;
17 17 protected static final float AABB_OFFSET = 6.0F;
18 18 protected static final VoxelShape SHAPE = Block.box(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D);
19 19 private final WorldGenTreeProvider treeGrower;
20 20 + public static TreeType treeType; // CraftBukkit
21 21
22 22 protected BlockSapling(WorldGenTreeProvider worldgentreeprovider, BlockBase.Info blockbase_info) {
23 23 super(blockbase_info);
24 -@@ -44,7 +52,30 @@
24 +@@ -44,7 +52,32 @@
25 25 if ((Integer) iblockdata.getValue(BlockSapling.STAGE) == 0) {
26 26 worldserver.setBlock(blockposition, (IBlockData) iblockdata.cycle(BlockSapling.STAGE), 4);
27 27 } else {
28 +- this.treeGrower.growTree(worldserver, worldserver.getChunkSource().getGenerator(), blockposition, iblockdata, randomsource);
28 29 + // CraftBukkit start
29 -+ worldserver.captureTreeGeneration = true;
30 -+ // CraftBukkit end
31 - this.treeGrower.growTree(worldserver, worldserver.getChunkSource().getGenerator(), blockposition, iblockdata, randomsource);
32 -+ // CraftBukkit start
33 -+ worldserver.captureTreeGeneration = false;
34 -+ if (worldserver.capturedBlockStates.size() > 0) {
35 -+ TreeType treeType = BlockSapling.treeType;
36 -+ BlockSapling.treeType = null;
37 -+ Location location = new Location(worldserver.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ());
38 -+ java.util.List<BlockState> blocks = new java.util.ArrayList<>(worldserver.capturedBlockStates.values());
39 -+ worldserver.capturedBlockStates.clear();
40 -+ StructureGrowEvent event = null;
41 -+ if (treeType != null) {
42 -+ event = new StructureGrowEvent(location, treeType, false, null, blocks);
43 -+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
44 -+ }
45 -+ if (event == null || !event.isCancelled()) {
46 -+ for (BlockState blockstate : blocks) {
47 -+ blockstate.update(true);
30 ++ if (worldserver.captureTreeGeneration) {
31 ++ this.treeGrower.growTree(worldserver, worldserver.getChunkSource().getGenerator(), blockposition, iblockdata, randomsource);
32 ++ } else {
33 ++ worldserver.captureTreeGeneration = true;
34 ++ this.treeGrower.growTree(worldserver, worldserver.getChunkSource().getGenerator(), blockposition, iblockdata, randomsource);
35 ++ worldserver.captureTreeGeneration = false;
36 ++ if (worldserver.capturedBlockStates.size() > 0) {
37 ++ TreeType treeType = BlockSapling.treeType;
38 ++ BlockSapling.treeType = null;
39 ++ Location location = new Location(worldserver.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ());
40 ++ java.util.List<BlockState> blocks = new java.util.ArrayList<>(worldserver.capturedBlockStates.values());
41 ++ worldserver.capturedBlockStates.clear();
42 ++ StructureGrowEvent event = null;
43 ++ if (treeType != null) {
44 ++ event = new StructureGrowEvent(location, treeType, false, null, blocks);
45 ++ org.bukkit.Bukkit.getPluginManager().callEvent(event);
46 ++ }
47 ++ if (event == null || !event.isCancelled()) {
48 ++ for (BlockState blockstate : blocks) {
49 ++ blockstate.update(true);
50 ++ }
48 51 + }
49 52 + }
50 53 + }
51 54 + // CraftBukkit end
52 55 }
53 56
54 57 }

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut