mirror of
https://github.com/barkeser2002/CatServer.git
synced 2026-09-25 11:25:55 +03:00
132 lines
6.1 KiB
Diff
132 lines
6.1 KiB
Diff
--- ../src-base/minecraft/net/minecraft/block/BlockSapling.java
|
|
+++ ../src-work/minecraft/net/minecraft/block/BlockSapling.java
|
|
@@ -27,12 +27,17 @@
|
|
import net.minecraft.world.gen.feature.WorldGenerator;
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
+import org.bukkit.Location;
|
|
+import org.bukkit.TreeType;
|
|
+import org.bukkit.block.BlockState;
|
|
+import org.bukkit.event.world.StructureGrowEvent;
|
|
|
|
public class BlockSapling extends BlockBush implements IGrowable
|
|
{
|
|
public static final PropertyEnum<BlockPlanks.EnumType> TYPE = PropertyEnum.<BlockPlanks.EnumType>create("type", BlockPlanks.EnumType.class);
|
|
public static final PropertyInteger STAGE = PropertyInteger.create("stage", 0, 1);
|
|
protected static final AxisAlignedBB SAPLING_AABB = new AxisAlignedBB(0.09999999403953552D, 0.0D, 0.09999999403953552D, 0.8999999761581421D, 0.800000011920929D, 0.8999999761581421D);
|
|
+ public static TreeType treeType; // CraftBukkit
|
|
|
|
protected BlockSapling()
|
|
{
|
|
@@ -56,9 +61,36 @@
|
|
{
|
|
super.updateTick(worldIn, pos, state, rand);
|
|
|
|
- if (worldIn.getLightFromNeighbors(pos.up()) >= 9 && rand.nextInt(7) == 0)
|
|
+ if (worldIn.getLightFromNeighbors(pos.up()) >= 9 && rand.nextInt(Math.max(2, (int) (((100.0F / worldIn.spigotConfig.saplingModifier) * 7) + 0.5F))) == 0) //Spigot
|
|
{
|
|
+ // CraftBukkit start
|
|
+ worldIn.captureTreeGeneration = true;
|
|
+ // CraftBukkit end
|
|
this.grow(worldIn, pos, state, rand);
|
|
+ // CraftBukkit start
|
|
+ worldIn.captureTreeGeneration = false;
|
|
+ if (worldIn.capturedBlockSnapshots.size() > 0) {
|
|
+ TreeType treeType = BlockSapling.treeType;
|
|
+ BlockSapling.treeType = null;
|
|
+ Location location = new Location(worldIn.getWorld(), pos.getX(), pos.getY(), pos.getZ());
|
|
+ List<net.minecraftforge.common.util.BlockSnapshot> blocks = (List) worldIn.capturedBlockSnapshots.clone();
|
|
+ List<BlockState> blockstates = new java.util.ArrayList();
|
|
+ for (net.minecraftforge.common.util.BlockSnapshot snapshot : blocks) {
|
|
+ blockstates.add(new org.bukkit.craftbukkit.block.CraftBlockState(snapshot));
|
|
+ }
|
|
+ worldIn.capturedBlockSnapshots.clear();
|
|
+ StructureGrowEvent event = null;
|
|
+ if (treeType != null) {
|
|
+ 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);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // CraftBukkit end
|
|
}
|
|
}
|
|
}
|
|
@@ -78,7 +110,19 @@
|
|
public void generateTree(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
|
{
|
|
if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(worldIn, rand, pos)) return;
|
|
- WorldGenerator worldgenerator = (WorldGenerator)(rand.nextInt(10) == 0 ? new WorldGenBigTree(true) : new WorldGenTrees(true));
|
|
+ // CraftBukkit start
|
|
+ WorldGenerator worldgenerator = null;
|
|
+ if (rand.nextInt(10) == 0)
|
|
+ {
|
|
+ treeType = TreeType.BIG_TREE; // CraftBukkit
|
|
+ worldgenerator = new WorldGenBigTree(true);
|
|
+ }
|
|
+ else
|
|
+ {
|
|
+ treeType = TreeType.TREE; // CraftBukkit
|
|
+ worldgenerator = new WorldGenTrees(true);
|
|
+ }
|
|
+ // CraftBukkit end
|
|
int i = 0;
|
|
int j = 0;
|
|
boolean flag = false;
|
|
@@ -94,6 +138,7 @@
|
|
{
|
|
if (this.isTwoByTwoOfType(worldIn, pos, i, j, BlockPlanks.EnumType.SPRUCE))
|
|
{
|
|
+ treeType = TreeType.MEGA_REDWOOD; // CraftBukkit
|
|
worldgenerator = new WorldGenMegaPineTree(false, rand.nextBoolean());
|
|
flag = true;
|
|
break label114;
|
|
@@ -105,11 +150,13 @@
|
|
{
|
|
i = 0;
|
|
j = 0;
|
|
+ treeType = TreeType.REDWOOD; // CraftBukkit
|
|
worldgenerator = new WorldGenTaiga2(true);
|
|
}
|
|
|
|
break;
|
|
case BIRCH:
|
|
+ treeType = TreeType.BIRCH; // CraftBukkit
|
|
worldgenerator = new WorldGenBirchTree(true, false);
|
|
break;
|
|
case JUNGLE:
|
|
@@ -123,6 +170,7 @@
|
|
{
|
|
if (this.isTwoByTwoOfType(worldIn, pos, i, j, BlockPlanks.EnumType.JUNGLE))
|
|
{
|
|
+ treeType = TreeType.JUNGLE; // CraftBukkit
|
|
worldgenerator = new WorldGenMegaJungle(true, 10, 20, iblockstate, iblockstate1);
|
|
flag = true;
|
|
break label269;
|
|
@@ -134,11 +182,13 @@
|
|
{
|
|
i = 0;
|
|
j = 0;
|
|
+ treeType = TreeType.SMALL_JUNGLE; // CraftBukkit
|
|
worldgenerator = new WorldGenTrees(true, 4 + rand.nextInt(7), iblockstate, iblockstate1, false);
|
|
}
|
|
|
|
break;
|
|
case ACACIA:
|
|
+ treeType = TreeType.ACACIA; // CraftBukkit
|
|
worldgenerator = new WorldGenSavannaTree(true);
|
|
break;
|
|
case DARK_OAK:
|
|
@@ -150,6 +200,7 @@
|
|
{
|
|
if (this.isTwoByTwoOfType(worldIn, pos, i, j, BlockPlanks.EnumType.DARK_OAK))
|
|
{
|
|
+ treeType = TreeType.DARK_OAK; // CraftBukkit
|
|
worldgenerator = new WorldGenCanopyTree(true);
|
|
flag = true;
|
|
break label390;
|