aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/og/net/minecraft/world/level/block/BlockSapling.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/og/net/minecraft/world/level/block/BlockSapling.patch')
-rw-r--r--patch-remap/og/net/minecraft/world/level/block/BlockSapling.patch59
1 files changed, 59 insertions, 0 deletions
diff --git a/patch-remap/og/net/minecraft/world/level/block/BlockSapling.patch b/patch-remap/og/net/minecraft/world/level/block/BlockSapling.patch
new file mode 100644
index 0000000000..1814898e5b
--- /dev/null
+++ b/patch-remap/og/net/minecraft/world/level/block/BlockSapling.patch
@@ -0,0 +1,59 @@
+--- a/net/minecraft/world/level/block/BlockSapling.java
++++ b/net/minecraft/world/level/block/BlockSapling.java
+@@ -17,6 +17,14 @@
+ import net.minecraft.world.phys.shapes.VoxelShape;
+ import net.minecraft.world.phys.shapes.VoxelShapeCollision;
+
++// CraftBukkit start
++import org.bukkit.Location;
++import org.bukkit.TreeType;
++import org.bukkit.block.BlockState;
++import org.bukkit.craftbukkit.util.CraftLocation;
++import org.bukkit.event.world.StructureGrowEvent;
++// CraftBukkit end
++
+ public class BlockSapling extends BlockPlant implements IBlockFragilePlantElement {
+
+ public static final MapCodec<BlockSapling> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
+@@ -28,6 +36,7 @@
+ protected static final float AABB_OFFSET = 6.0F;
+ protected static final VoxelShape SHAPE = Block.box(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D);
+ protected final WorldGenTreeProvider treeGrower;
++ public static TreeType treeType; // CraftBukkit
+
+ @Override
+ public MapCodec<? extends BlockSapling> codec() {
+@@ -57,7 +66,32 @@
+ if ((Integer) iblockdata.getValue(BlockSapling.STAGE) == 0) {
+ worldserver.setBlock(blockposition, (IBlockData) iblockdata.cycle(BlockSapling.STAGE), 4);
+ } else {
+- this.treeGrower.growTree(worldserver, worldserver.getChunkSource().getGenerator(), blockposition, iblockdata, randomsource);
++ // CraftBukkit start
++ 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 = CraftLocation.toBukkit(blockposition, worldserver.getWorld());
++ 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);
++ }
++ }
++ }
++ }
++ // CraftBukkit end
+ }
+
+ }