Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 34 additions & 31 deletions patches/net/minecraft/block/BlockSapling.java.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
--- ../src-base/minecraft/net/minecraft/block/BlockSapling.java
+++ ../src-work/minecraft/net/minecraft/block/BlockSapling.java
@@ -22,10 +22,19 @@
@@ -4,6 +4,8 @@
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import java.util.Random;
+
+import io.github.crucible.util.WorldChangeHolder;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
@@ -22,10 +24,19 @@
import net.minecraft.world.gen.feature.WorldGenTrees;
import net.minecraft.world.gen.feature.WorldGenerator;

Expand All @@ -20,48 +29,42 @@
private static final String __OBFID = "CL_00000305";

protected BlockSapling()
@@ -41,9 +50,39 @@
@@ -41,9 +52,32 @@
{
super.updateTick(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, p_149674_5_);

- if (p_149674_1_.getBlockLightValue(p_149674_2_, p_149674_3_ + 1, p_149674_4_) >= 9 && p_149674_5_.nextInt(7) == 0)
+ if (p_149674_1_.getBlockLightValue(p_149674_2_, p_149674_3_ + 1, p_149674_4_) >= 9 && (p_149674_5_.nextInt(Math.max(2, (int)((p_149674_1_.growthOdds / p_149674_1_.getSpigotConfig().saplingModifier * 7) + 0.5F))) == 0)) // Spigot // Cauldron
{
- this.func_149879_c(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, p_149674_5_);
+ // Cauldron start
+ p_149674_1_.captureTreeGeneration = true;
this.func_149879_c(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, p_149674_5_);
+ p_149674_1_.captureTreeGeneration = false;
+ if (p_149674_1_.capturedBlockSnapshots.size() > 0)
+ {
+ // If there's no bukkit tree type, changes will be implicitly applied
+ try (WorldChangeHolder.CaptureContext context = p_149674_1_.worldChangeHolder.startCapture()) {
+ this.func_149879_c(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, p_149674_5_);
+ context.pauseCapture();
+
+ TreeType treeType = BlockSapling.treeType;
+ BlockSapling.treeType = null;
+ Location location = new Location(p_149674_1_.getWorld(), p_149674_2_, p_149674_3_, p_149674_4_);
+ List<net.minecraftforge.common.util.BlockSnapshot> blocks = (List) p_149674_1_.capturedBlockSnapshots.clone();
+ List<BlockState> blockstates = new java.util.ArrayList();
+ for (net.minecraftforge.common.util.BlockSnapshot snapshot : blocks)
+ {
+ blockstates.add(new CraftBlockState(snapshot));
+ }
+ p_149674_1_.capturedBlockSnapshots.clear();
+ StructureGrowEvent event = null;
+ if (treeType != null)
+ {
+ event = new StructureGrowEvent(location, treeType, false, null, blockstates);
+
+ if (treeType != null && context.hasChanges()) {
+ List<BlockState> blockstates = context.asBukkitBlockState();
+ context.discardChanges(); // Changes applied through the event and bukkit BlockState
+ Location location = new Location(p_149674_1_.getWorld(), p_149674_2_, p_149674_3_, p_149674_4_);
+
+ StructureGrowEvent event = new StructureGrowEvent(location, treeType, false, null, blockstates);;
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
+ }
+ if (event == null || !event.isCancelled())
+ {
+ for (BlockState blockstate : blockstates)
+ {
+ blockstate.update(true);
+ if (!event.isCancelled()) {
+ for (BlockState blockstate : blockstates) {
+ blockstate.update(true);
+ }
+ }
+ }
+ }
+ // Cauldron end
}
}
}
@@ -73,7 +112,20 @@
@@ -73,7 +107,20 @@
{
if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(p_149878_1_, p_149878_5_, p_149878_2_, p_149878_3_, p_149878_4_)) return;
int l = p_149878_1_.getBlockMetadata(p_149878_2_, p_149878_3_, p_149878_4_) & 7;
Expand All @@ -83,31 +86,31 @@
int i1 = 0;
int j1 = 0;
boolean flag = false;
@@ -84,6 +136,7 @@
@@ -84,6 +131,7 @@
default:
break;
case 1:
+ treeType = TreeType.REDWOOD; // CraftBukkit
label78:

for (i1 = 0; i1 >= -1; --i1)
@@ -108,6 +161,7 @@
@@ -108,6 +156,7 @@

break;
case 2:
+ treeType = TreeType.BIRCH; // CraftBukkit
object = new WorldGenForest(true, false);
break;
case 3:
@@ -119,6 +173,7 @@
@@ -119,6 +168,7 @@
{
if (this.func_149880_a(p_149878_1_, p_149878_2_ + i1, p_149878_3_, p_149878_4_ + j1, 3) && this.func_149880_a(p_149878_1_, p_149878_2_ + i1 + 1, p_149878_3_, p_149878_4_ + j1, 3) && this.func_149880_a(p_149878_1_, p_149878_2_ + i1, p_149878_3_, p_149878_4_ + j1 + 1, 3) && this.func_149880_a(p_149878_1_, p_149878_2_ + i1 + 1, p_149878_3_, p_149878_4_ + j1 + 1, 3))
{
+ treeType = TreeType.JUNGLE; // CraftBukkit
object = new WorldGenMegaJungle(true, 10, 20, 3, 3);
flag = true;
break label93;
@@ -130,11 +185,13 @@
@@ -130,11 +180,13 @@
{
j1 = 0;
i1 = 0;
Expand All @@ -121,7 +124,7 @@
object = new WorldGenSavannaTree(true);
break;
case 5:
@@ -147,6 +204,7 @@
@@ -147,6 +199,7 @@
if (this.func_149880_a(p_149878_1_, p_149878_2_ + i1, p_149878_3_, p_149878_4_ + j1, 5) && this.func_149880_a(p_149878_1_, p_149878_2_ + i1 + 1, p_149878_3_, p_149878_4_ + j1, 5) && this.func_149880_a(p_149878_1_, p_149878_2_ + i1, p_149878_3_, p_149878_4_ + j1 + 1, 5) && this.func_149880_a(p_149878_1_, p_149878_2_ + i1 + 1, p_149878_3_, p_149878_4_ + j1 + 1, 5))
{
object = new WorldGenCanopyTree(true);
Expand Down
Loading