aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/SaplingBlock.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/SaplingBlock.java.patch')
-rw-r--r--patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/SaplingBlock.java.patch62
1 files changed, 62 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/SaplingBlock.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/SaplingBlock.java.patch
new file mode 100644
index 0000000000..3e4dc6d7c8
--- /dev/null
+++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/SaplingBlock.java.patch
@@ -0,0 +1,62 @@
+--- a/net/minecraft/world/level/block/SaplingBlock.java
++++ b/net/minecraft/world/level/block/SaplingBlock.java
+@@ -17,6 +16,13 @@
+ import net.minecraft.world.level.block.state.properties.IntegerProperty;
+ import net.minecraft.world.phys.shapes.CollisionContext;
+ import net.minecraft.world.phys.shapes.VoxelShape;
++// 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 SaplingBlock extends BushBlock implements BonemealableBlock {
+ public static final MapCodec<SaplingBlock> CODEC = RecordCodecBuilder.mapCodec(
+@@ -25,8 +33,9 @@
+ );
+ public static final IntegerProperty STAGE = BlockStateProperties.STAGE;
+ protected static final float AABB_OFFSET = 6.0F;
+- protected static final VoxelShape SHAPE = Block.box(2.0, 0.0, 2.0, 14.0, 12.0, 14.0);
+- protected final TreeGrower treeGrower;
++ 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 SaplingBlock> codec() {
+@@ -55,7 +65,32 @@
+ if (state.getValue(STAGE) == 0) {
+ level.setBlock(pos, state.cycle(STAGE), 4);
+ } else {
+- this.treeGrower.growTree(level, level.getChunkSource().getGenerator(), pos, state, random);
++ // CraftBukkit start
++ if (level.captureTreeGeneration) {
++ this.treeGrower.growTree(level, level.getChunkSource().getGenerator(), pos, state, random);
++ } else {
++ level.captureTreeGeneration = true;
++ this.treeGrower.growTree(level, level.getChunkSource().getGenerator(), pos, state, random);
++ level.captureTreeGeneration = false;
++ if (level.capturedBlockStates.size() > 0) {
++ TreeType treeType = SaplingBlock.treeType;
++ SaplingBlock.treeType = null;
++ Location location = CraftLocation.toBukkit(pos, level.getWorld());
++ java.util.List<BlockState> blocks = new java.util.ArrayList<>(level.capturedBlockStates.values());
++ level.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
+ }
+ }
+