WorldGen*Trees shoud not respect custom soils. Closes #355
This commit is contained in:
parent
0396ba2252
commit
a7cdcc1f33
6 changed files with 206 additions and 26 deletions
|
@ -156,7 +156,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
@@ -1364,4 +1381,839 @@
|
||||
@@ -1364,4 +1381,864 @@
|
||||
canBlockGrass[0] = true;
|
||||
StatList.initBreakableStats();
|
||||
}
|
||||
|
@ -925,6 +925,31 @@
|
|||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Called when a plant grows on this block, only implemented for saplings using the WorldGen*Trees classes right now.
|
||||
+ * Modder may implement this for custom plants.
|
||||
+ * This does not use ForgeDirection, because large/huge trees can be located in non-representable direction,
|
||||
+ * so the source location is specified.
|
||||
+ * Currently this just changes the block to dirt if it was grass.
|
||||
+ *
|
||||
+ * Note: This happens DURING the generation, the generation may not be complete when this is called.
|
||||
+ *
|
||||
+ * @param world Current world
|
||||
+ * @param x Soil X
|
||||
+ * @param y Soil Y
|
||||
+ * @param z Soil Z
|
||||
+ * @param sourceX Plant growth location X
|
||||
+ * @param sourceY Plant growth location Y
|
||||
+ * @param sourceZ Plant growth location Z
|
||||
+ */
|
||||
+ public void onPlantGrow(World world, int x, int y, int z, int sourceX, int sourceY, int sourceZ)
|
||||
+ {
|
||||
+ if (blockID == grass.blockID)
|
||||
+ {
|
||||
+ world.setBlock(x, y, z, dirt.blockID);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Checks if this soil is fertile, typically this means that growth rates
|
||||
+ * of plants on this soil will be slightly sped up.
|
||||
+ * Only vanilla case is tilledField when it is within range of water.
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
--- ../src_base/minecraft/net/minecraft/world/gen/feature/WorldGenBigTree.java
|
||||
+++ ../src_work/minecraft/net/minecraft/world/gen/feature/WorldGenBigTree.java
|
||||
@@ -1,9 +1,12 @@
|
||||
package net.minecraft.world.gen.feature;
|
||||
|
||||
import java.util.Random;
|
||||
+
|
||||
import net.minecraft.block.Block;
|
||||
+import net.minecraft.block.BlockSapling;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
+import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class WorldGenBigTree extends WorldGenerator
|
||||
{
|
||||
@@ -442,7 +445,9 @@
|
||||
int[] var2 = new int[] {this.basePos[0], this.basePos[1] + this.heightLimit - 1, this.basePos[2]};
|
||||
int var3 = this.worldObj.getBlockId(this.basePos[0], this.basePos[1] - 1, this.basePos[2]);
|
||||
|
||||
- if (var3 != 2 && var3 != 3)
|
||||
+ Block soil = Block.blocksList[var3];
|
||||
+ boolean isValidSoil = (soil != null && soil.canSustainPlant(worldObj, basePos[0], basePos[1] - 1, basePos[2], ForgeDirection.UP, (BlockSapling)Block.sapling));
|
||||
+ if (!isValidSoil)
|
||||
{
|
||||
return false;
|
||||
}
|
|
@ -1,6 +1,18 @@
|
|||
--- ../src_base/minecraft/net/minecraft/world/gen/feature/WorldGenForest.java
|
||||
+++ ../src_work/minecraft/net/minecraft/world/gen/feature/WorldGenForest.java
|
||||
@@ -45,7 +45,9 @@
|
||||
@@ -1,8 +1,11 @@
|
||||
package net.minecraft.world.gen.feature;
|
||||
|
||||
import java.util.Random;
|
||||
+
|
||||
import net.minecraft.block.Block;
|
||||
+import net.minecraft.block.BlockSapling;
|
||||
import net.minecraft.world.World;
|
||||
+import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class WorldGenForest extends WorldGenerator
|
||||
{
|
||||
@@ -45,7 +48,9 @@
|
||||
{
|
||||
var12 = par1World.getBlockId(var10, var8, var11);
|
||||
|
||||
|
@ -11,7 +23,22 @@
|
|||
{
|
||||
var7 = false;
|
||||
}
|
||||
@@ -84,7 +86,10 @@
|
||||
@@ -65,10 +70,12 @@
|
||||
else
|
||||
{
|
||||
var8 = par1World.getBlockId(par3, par4 - 1, par5);
|
||||
+ Block soil = Block.blocksList[var8];
|
||||
+ boolean isValidSoil = soil != null && soil.canSustainPlant(par1World, par3, par4 - 1, par5, ForgeDirection.UP, (BlockSapling)Block.sapling);
|
||||
|
||||
- if ((var8 == Block.grass.blockID || var8 == Block.dirt.blockID) && par4 < 256 - var6 - 1)
|
||||
+ if (isValidSoil && par4 < 256 - var6 - 1)
|
||||
{
|
||||
- this.setBlock(par1World, par3, par4 - 1, par5, Block.dirt.blockID);
|
||||
+ soil.onPlantGrow(par1World, par3, par4 - 1, par5, par3, par4, par5);
|
||||
int var16;
|
||||
|
||||
for (var16 = par4 - 3 + var6; var16 <= par4 + var6; ++var16)
|
||||
@@ -84,7 +91,10 @@
|
||||
{
|
||||
int var15 = var14 - par5;
|
||||
|
||||
|
@ -23,7 +50,7 @@
|
|||
{
|
||||
this.setBlockAndMetadata(par1World, var12, var16, var14, Block.leaves.blockID, 2);
|
||||
}
|
||||
@@ -96,7 +101,9 @@
|
||||
@@ -96,7 +106,9 @@
|
||||
{
|
||||
var10 = par1World.getBlockId(par3, par4 + var16, par5);
|
||||
|
||||
|
|
|
@ -1,20 +1,56 @@
|
|||
--- ../src_base/minecraft/net/minecraft/world/gen/feature/WorldGenHugeTrees.java
|
||||
+++ ../src_work/minecraft/net/minecraft/world/gen/feature/WorldGenHugeTrees.java
|
||||
@@ -58,7 +58,12 @@
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
import java.util.Random;
|
||||
import net.minecraft.block.Block;
|
||||
+import net.minecraft.block.BlockSapling;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
+import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class WorldGenHugeTrees extends WorldGenerator
|
||||
{
|
||||
@@ -57,8 +59,13 @@
|
||||
if (var8 >= 0 && var8 < 256)
|
||||
{
|
||||
var12 = par1World.getBlockId(var10, var8, var11);
|
||||
|
||||
-
|
||||
- if (var12 != 0 && var12 != Block.leaves.blockID && var12 != Block.grass.blockID && var12 != Block.dirt.blockID && var12 != Block.wood.blockID && var12 != Block.sapling.blockID)
|
||||
+ if (var12 != 0 &&
|
||||
+ (Block.blocksList[var12] != null && !Block.blocksList[var12].isLeaves(par1World, var10, var8, var11)) &&
|
||||
+ var12 != Block.grass.blockID &&
|
||||
+ var12 != Block.dirt.blockID &&
|
||||
+ (Block.blocksList[var12] != null && !Block.blocksList[var12].isWood(par1World, var10, var8, var11)) &&
|
||||
+ Block block = Block.blocksList[var12];
|
||||
+
|
||||
+ if (block != null &&
|
||||
+ !block.isLeaves(par1World, var10, var8, var11) &&
|
||||
+ !block.canSustainPlant(par1World, var10, var8, var11, ForgeDirection.UP, (BlockSapling)Block.sapling) &&
|
||||
+ !block.isWood(par1World, var10, var8, var11) &&
|
||||
+ var12 != Block.sapling.blockID)
|
||||
{
|
||||
var7 = false;
|
||||
}
|
||||
@@ -106,7 +111,7 @@
|
||||
@@ -78,13 +85,15 @@
|
||||
else
|
||||
{
|
||||
var8 = par1World.getBlockId(par3, par4 - 1, par5);
|
||||
-
|
||||
- if ((var8 == Block.grass.blockID || var8 == Block.dirt.blockID) && par4 < 256 - var6 - 1)
|
||||
- {
|
||||
- par1World.setBlock(par3, par4 - 1, par5, Block.dirt.blockID);
|
||||
- par1World.setBlock(par3 + 1, par4 - 1, par5, Block.dirt.blockID);
|
||||
- par1World.setBlock(par3, par4 - 1, par5 + 1, Block.dirt.blockID);
|
||||
- par1World.setBlock(par3 + 1, par4 - 1, par5 + 1, Block.dirt.blockID);
|
||||
+ Block soil = Block.blocksList[var8];
|
||||
+ boolean isValidSoil = soil != null && soil.canSustainPlant(par1World, par3, par4 - 1, par5, ForgeDirection.UP, (BlockSapling)Block.sapling);
|
||||
+
|
||||
+ if (isValidSoil && par4 < 256 - var6 - 1)
|
||||
+ {
|
||||
+ onPlantGrow(par1World, par3, par4 - 1, par5, par3, par4, par5);
|
||||
+ onPlantGrow(par1World, par3 + 1, par4 - 1, par5, par3, par4, par5);
|
||||
+ onPlantGrow(par1World, par3, par4 - 1, par5 + 1, par3, par4, par5);
|
||||
+ onPlantGrow(par1World, par3 + 1, par4 - 1, par5 + 1, par3, par4, par5);
|
||||
this.growLeaves(par1World, par3, par5, par4 + var6, 2, par2Random);
|
||||
|
||||
for (int var14 = par4 + var6 - 2 - par2Random.nextInt(4); var14 > par4 + var6 / 2; var14 -= 2 + par2Random.nextInt(4))
|
||||
@@ -106,7 +115,7 @@
|
||||
{
|
||||
var11 = par1World.getBlockId(par3, par4 + var10, par5);
|
||||
|
||||
|
@ -23,7 +59,7 @@
|
|||
{
|
||||
this.setBlockAndMetadata(par1World, par3, par4 + var10, par5, Block.wood.blockID, this.woodMetadata);
|
||||
|
||||
@@ -128,7 +133,7 @@
|
||||
@@ -128,7 +137,7 @@
|
||||
{
|
||||
var11 = par1World.getBlockId(par3 + 1, par4 + var10, par5);
|
||||
|
||||
|
@ -32,7 +68,7 @@
|
|||
{
|
||||
this.setBlockAndMetadata(par1World, par3 + 1, par4 + var10, par5, Block.wood.blockID, this.woodMetadata);
|
||||
|
||||
@@ -148,7 +153,7 @@
|
||||
@@ -148,7 +157,7 @@
|
||||
|
||||
var11 = par1World.getBlockId(par3 + 1, par4 + var10, par5 + 1);
|
||||
|
||||
|
@ -41,7 +77,7 @@
|
|||
{
|
||||
this.setBlockAndMetadata(par1World, par3 + 1, par4 + var10, par5 + 1, Block.wood.blockID, this.woodMetadata);
|
||||
|
||||
@@ -168,7 +173,7 @@
|
||||
@@ -168,7 +177,7 @@
|
||||
|
||||
var11 = par1World.getBlockId(par3, par4 + var10, par5 + 1);
|
||||
|
||||
|
@ -50,7 +86,7 @@
|
|||
{
|
||||
this.setBlockAndMetadata(par1World, par3, par4 + var10, par5 + 1, Block.wood.blockID, this.woodMetadata);
|
||||
|
||||
@@ -219,7 +224,12 @@
|
||||
@@ -219,7 +228,12 @@
|
||||
{
|
||||
int var14 = var13 - par3;
|
||||
|
||||
|
@ -64,3 +100,17 @@
|
|||
{
|
||||
this.setBlockAndMetadata(par1World, var11, var8, var13, Block.leaves.blockID, this.leavesMetadata);
|
||||
}
|
||||
@@ -227,4 +241,13 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
+
|
||||
+ private void onPlantGrow(World world, int x, int y, int z, int sourceX, int sourceY, int sourceZ)
|
||||
+ {
|
||||
+ Block block = Block.blocksList[world.getBlockId(x, y, z)];
|
||||
+ if (block != null)
|
||||
+ {
|
||||
+ block.onPlantGrow(world, x, y, z, sourceX, sourceY, sourceZ);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
|
|
@ -1,6 +1,16 @@
|
|||
--- ../src_base/minecraft/net/minecraft/world/gen/feature/WorldGenTaiga2.java
|
||||
+++ ../src_work/minecraft/net/minecraft/world/gen/feature/WorldGenTaiga2.java
|
||||
@@ -47,7 +47,9 @@
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
import java.util.Random;
|
||||
import net.minecraft.block.Block;
|
||||
+import net.minecraft.block.BlockSapling;
|
||||
import net.minecraft.world.World;
|
||||
+import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class WorldGenTaiga2 extends WorldGenerator
|
||||
{
|
||||
@@ -47,7 +49,9 @@
|
||||
{
|
||||
var15 = par1World.getBlockId(var13, var11, var14);
|
||||
|
||||
|
@ -11,7 +21,22 @@
|
|||
{
|
||||
var10 = false;
|
||||
}
|
||||
@@ -89,7 +91,10 @@
|
||||
@@ -67,10 +71,12 @@
|
||||
else
|
||||
{
|
||||
var11 = par1World.getBlockId(par3, par4 - 1, par5);
|
||||
+ Block soil = Block.blocksList[var11];
|
||||
+ boolean isValidSoil = soil != null && soil.canSustainPlant(par1World, par3, par4 - 1, par5, ForgeDirection.UP, (BlockSapling)Block.sapling);
|
||||
|
||||
- if ((var11 == Block.grass.blockID || var11 == Block.dirt.blockID) && par4 < 256 - var6 - 1)
|
||||
+ if (isValidSoil && par4 < 256 - var6 - 1)
|
||||
{
|
||||
- this.setBlock(par1World, par3, par4 - 1, par5, Block.dirt.blockID);
|
||||
+ soil.onPlantGrow(par1World, par3, par4 - 1, par5, par3, par4, par5);
|
||||
var21 = par2Random.nextInt(2);
|
||||
var13 = 1;
|
||||
byte var22 = 0;
|
||||
@@ -89,7 +95,10 @@
|
||||
{
|
||||
int var20 = var19 - par5;
|
||||
|
||||
|
@ -23,7 +48,7 @@
|
|||
{
|
||||
this.setBlockAndMetadata(par1World, var17, var16, var19, Block.leaves.blockID, 1);
|
||||
}
|
||||
@@ -119,7 +124,9 @@
|
||||
@@ -119,7 +128,9 @@
|
||||
{
|
||||
var17 = par1World.getBlockId(par3, par4 + var16, par5);
|
||||
|
||||
|
|
|
@ -1,21 +1,48 @@
|
|||
--- ../src_base/minecraft/net/minecraft/world/gen/feature/WorldGenTrees.java
|
||||
+++ ../src_work/minecraft/net/minecraft/world/gen/feature/WorldGenTrees.java
|
||||
@@ -67,7 +67,13 @@
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
import java.util.Random;
|
||||
import net.minecraft.block.Block;
|
||||
+import net.minecraft.block.BlockSapling;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.world.World;
|
||||
+import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class WorldGenTrees extends WorldGenerator
|
||||
{
|
||||
@@ -67,7 +69,12 @@
|
||||
{
|
||||
var12 = par1World.getBlockId(var10, var8, var11);
|
||||
|
||||
- if (var12 != 0 && var12 != Block.leaves.blockID && var12 != Block.grass.blockID && var12 != Block.dirt.blockID && var12 != Block.wood.blockID)
|
||||
+ Block block = Block.blocksList[var12];
|
||||
+
|
||||
+ if (var12 != 0 &&
|
||||
+ if (block != null &&
|
||||
+ !block.isLeaves(par1World, var10, var8, var11) &&
|
||||
+ var12 != Block.grass.blockID &&
|
||||
+ var12 != Block.dirt.blockID &&
|
||||
+ !block.canSustainPlant(par1World, var10, var8, var11, ForgeDirection.UP, (BlockSapling)Block.sapling) &&
|
||||
+ !block.isWood(par1World, var10, var8, var11))
|
||||
{
|
||||
var7 = false;
|
||||
}
|
||||
@@ -110,7 +116,10 @@
|
||||
@@ -87,10 +94,12 @@
|
||||
else
|
||||
{
|
||||
var8 = par1World.getBlockId(par3, par4 - 1, par5);
|
||||
-
|
||||
- if ((var8 == Block.grass.blockID || var8 == Block.dirt.blockID) && par4 < 256 - var6 - 1)
|
||||
- {
|
||||
- this.setBlock(par1World, par3, par4 - 1, par5, Block.dirt.blockID);
|
||||
+ Block soil = Block.blocksList[var8];
|
||||
+ boolean isSoil = (soil != null && soil.canSustainPlant(par1World, par3, par4 - 1, par5, ForgeDirection.UP, (BlockSapling)Block.sapling));
|
||||
+
|
||||
+ if (isSoil && par4 < 256 - var6 - 1)
|
||||
+ {
|
||||
+ soil.onPlantGrow(par1World, par3, par4 - 1, par5, par3, par4, par5);
|
||||
var9 = 3;
|
||||
byte var18 = 0;
|
||||
int var13;
|
||||
@@ -110,7 +119,10 @@
|
||||
{
|
||||
int var17 = var16 - par5;
|
||||
|
||||
|
@ -27,7 +54,7 @@
|
|||
{
|
||||
this.setBlockAndMetadata(par1World, var14, var11, var16, Block.leaves.blockID, this.metaLeaves);
|
||||
}
|
||||
@@ -122,7 +131,9 @@
|
||||
@@ -122,7 +134,9 @@
|
||||
{
|
||||
var12 = par1World.getBlockId(par3, par4 + var11, par5);
|
||||
|
||||
|
@ -38,7 +65,7 @@
|
|||
{
|
||||
this.setBlockAndMetadata(par1World, par3, par4 + var11, par5, Block.wood.blockID, this.metaWood);
|
||||
|
||||
@@ -162,7 +173,8 @@
|
||||
@@ -162,7 +176,8 @@
|
||||
{
|
||||
for (var15 = par5 - var13; var15 <= par5 + var13; ++var15)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue