Added some missing air checks to world gen features.
This commit is contained in:
parent
1a6743331b
commit
43a16d5389
6 changed files with 82 additions and 41 deletions
|
@ -7,7 +7,7 @@
|
|||
- if (i2 != 0 && i2 != Block.leaves.blockID)
|
||||
+ Block block = Block.blocksList[i2];
|
||||
+
|
||||
+ if (i2 != 0 && block != null && !block.isLeaves(par1World, k1, j1, l1))
|
||||
+ if (block != null && !block.isAirBlock(par1World, k1, j1, l1) && !block.isLeaves(par1World, k1, j1, l1))
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,35 @@
|
|||
|
||||
public class WorldGenBigTree extends WorldGenerator
|
||||
{
|
||||
@@ -442,7 +445,9 @@
|
||||
@@ -163,8 +166,11 @@
|
||||
{
|
||||
aint1[b2] = aint[b2] + k1;
|
||||
int l1 = this.worldObj.getBlockId(aint1[0], aint1[1], aint1[2]);
|
||||
-
|
||||
- if (l1 != 0 && l1 != Block.leaves.blockID)
|
||||
+ Block block = Block.blocksList[l1];
|
||||
+
|
||||
+ if (block != null &&
|
||||
+ !block.isAirBlock(worldObj, aint1[0], aint1[1], aint1[2]) &&
|
||||
+ !block.isLeaves(worldObj, aint1[0], aint1[1], aint1[2]))
|
||||
{
|
||||
++k1;
|
||||
}
|
||||
@@ -421,8 +427,11 @@
|
||||
aint3[b2] = MathHelper.floor_double((double)par1ArrayOfInteger[b2] + (double)i * d0);
|
||||
aint3[b3] = MathHelper.floor_double((double)par1ArrayOfInteger[b3] + (double)i * d1);
|
||||
int k = this.worldObj.getBlockId(aint3[0], aint3[1], aint3[2]);
|
||||
-
|
||||
- if (k != 0 && k != Block.leaves.blockID)
|
||||
+ Block block = Block.blocksList[k];
|
||||
+
|
||||
+ if (block != null &&
|
||||
+ !block.isAirBlock(worldObj, aint3[0], aint3[1], aint3[2]) &&
|
||||
+ !block.isLeaves(worldObj, aint3[0], aint3[1], aint3[2]))
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -442,7 +451,9 @@
|
||||
int[] aint1 = new int[] {this.basePos[0], this.basePos[1] + this.heightLimit - 1, this.basePos[2]};
|
||||
int i = this.worldObj.getBlockId(this.basePos[0], this.basePos[1] - 1, this.basePos[2]);
|
||||
|
||||
|
|
|
@ -10,18 +10,20 @@
|
|||
|
||||
public class WorldGenForest extends WorldGenerator
|
||||
{
|
||||
@@ -45,7 +47,9 @@
|
||||
@@ -45,7 +47,11 @@
|
||||
{
|
||||
l1 = par1World.getBlockId(j1, i1, k1);
|
||||
|
||||
- if (l1 != 0 && l1 != Block.leaves.blockID)
|
||||
+ Block block = Block.blocksList[l1];
|
||||
+
|
||||
+ if (l1 != 0 && (block != null && !block.isLeaves(par1World, j1, i1, k1)))
|
||||
+ if (block != null &&
|
||||
+ !block.isAirBlock(par1World, j1, i1, k1) &&
|
||||
+ !block.isLeaves(par1World, j1, i1, k1))
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
@@ -65,10 +69,12 @@
|
||||
@@ -65,10 +71,12 @@
|
||||
else
|
||||
{
|
||||
i1 = par1World.getBlockId(par3, par4 - 1, par5);
|
||||
|
@ -36,7 +38,7 @@
|
|||
int i2;
|
||||
|
||||
for (i2 = par4 - 3 + l; i2 <= par4 + l; ++i2)
|
||||
@@ -87,8 +93,9 @@
|
||||
@@ -87,8 +95,9 @@
|
||||
if (Math.abs(j2) != k1 || Math.abs(l2) != k1 || par2Random.nextInt(2) != 0 && j1 != 0)
|
||||
{
|
||||
int i3 = par1World.getBlockId(l1, i2, k2);
|
||||
|
@ -47,14 +49,16 @@
|
|||
{
|
||||
this.setBlockAndMetadata(par1World, l1, i2, k2, Block.leaves.blockID, 2);
|
||||
}
|
||||
@@ -101,7 +108,9 @@
|
||||
@@ -101,7 +110,11 @@
|
||||
{
|
||||
j1 = par1World.getBlockId(par3, par4 + i2, par5);
|
||||
|
||||
- if (j1 == 0 || j1 == Block.leaves.blockID)
|
||||
+ Block block = Block.blocksList[j1];
|
||||
+
|
||||
+ if (j1 == 0 || block == null || block.isLeaves(par1World, par3, par4 + i2, par5))
|
||||
+ if (block == null ||
|
||||
+ block.isAirBlock(par1World, par3, par4 + i2, par5) ||
|
||||
+ block.isLeaves(par1World, par3, par4 + i2, par5))
|
||||
{
|
||||
this.setBlockAndMetadata(par1World, par3, par4 + i2, par5, Block.wood.blockID, 2);
|
||||
}
|
||||
|
|
|
@ -11,21 +11,25 @@
|
|||
|
||||
public class WorldGenHugeTrees extends WorldGenerator
|
||||
{
|
||||
@@ -58,7 +60,12 @@
|
||||
@@ -57,8 +59,15 @@
|
||||
if (i1 >= 0 && i1 < 256)
|
||||
{
|
||||
l1 = par1World.getBlockId(j1, i1, k1);
|
||||
|
||||
-
|
||||
- if (l1 != 0 && l1 != Block.leaves.blockID && l1 != Block.grass.blockID && l1 != Block.dirt.blockID && l1 != Block.wood.blockID && l1 != Block.sapling.blockID)
|
||||
+ if (l1 != 0 &&
|
||||
+ (Block.blocksList[l1] != null && !Block.blocksList[l1].isLeaves(par1World, j1, i1, k1)) &&
|
||||
+ l1 != Block.grass.blockID &&
|
||||
+ l1 != Block.dirt.blockID &&
|
||||
+ (Block.blocksList[l1] != null && !Block.blocksList[l1].isWood(par1World, j1, i1, k1)) &&
|
||||
+ l1 != Block.sapling.blockID)
|
||||
+ Block block = Block.blocksList[l1];
|
||||
+
|
||||
+ if (block != null &&
|
||||
+ !block.isAirBlock(par1World, j1, i1, k1) &&
|
||||
+ !block.isLeaves(par1World, j1, i1, k1) &&
|
||||
+ !block.isWood(par1World, j1, i1, k1) &&
|
||||
+ block != Block.grass &&
|
||||
+ block != Block.dirt &&
|
||||
+ block != Block.sapling)
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
@@ -79,12 +86,15 @@
|
||||
@@ -79,12 +88,15 @@
|
||||
{
|
||||
i1 = par1World.getBlockId(par3, par4 - 1, par5);
|
||||
|
||||
|
@ -47,43 +51,43 @@
|
|||
this.growLeaves(par1World, par3, par5, par4 + l, 2, par2Random);
|
||||
|
||||
for (int i2 = par4 + l - 2 - par2Random.nextInt(4); i2 > par4 + l / 2; i2 -= 2 + par2Random.nextInt(4))
|
||||
@@ -106,7 +116,7 @@
|
||||
@@ -106,7 +118,7 @@
|
||||
{
|
||||
k1 = par1World.getBlockId(par3, par4 + j1, par5);
|
||||
|
||||
- if (k1 == 0 || k1 == Block.leaves.blockID)
|
||||
+ if (k1 == 0 || Block.blocksList[k1] == null || Block.blocksList[k1].isLeaves(par1World, par3, par4 + j1, par5))
|
||||
+ if (isReplaceable(par1World, par3, par4 + j1, par5))
|
||||
{
|
||||
this.setBlockAndMetadata(par1World, par3, par4 + j1, par5, Block.wood.blockID, this.woodMetadata);
|
||||
|
||||
@@ -128,7 +138,7 @@
|
||||
@@ -128,7 +140,7 @@
|
||||
{
|
||||
k1 = par1World.getBlockId(par3 + 1, par4 + j1, par5);
|
||||
|
||||
- if (k1 == 0 || k1 == Block.leaves.blockID)
|
||||
+ if (k1 == 0 || Block.blocksList[k1] == null || Block.blocksList[k1].isLeaves(par1World, par3 + 1, par4 + j1, par5))
|
||||
+ if (isReplaceable(par1World, par3 + 1, par4 + j1, par5))
|
||||
{
|
||||
this.setBlockAndMetadata(par1World, par3 + 1, par4 + j1, par5, Block.wood.blockID, this.woodMetadata);
|
||||
|
||||
@@ -148,7 +158,7 @@
|
||||
@@ -148,7 +160,7 @@
|
||||
|
||||
k1 = par1World.getBlockId(par3 + 1, par4 + j1, par5 + 1);
|
||||
|
||||
- if (k1 == 0 || k1 == Block.leaves.blockID)
|
||||
+ if (k1 == 0 || Block.blocksList[k1] == null || Block.blocksList[k1].isLeaves(par1World, par3 + 1, par4 + j1, par5 + 1))
|
||||
+ if (isReplaceable(par1World, par3 + 1, par4 + j1, par5 + 1))
|
||||
{
|
||||
this.setBlockAndMetadata(par1World, par3 + 1, par4 + j1, par5 + 1, Block.wood.blockID, this.woodMetadata);
|
||||
|
||||
@@ -168,7 +178,7 @@
|
||||
@@ -168,7 +180,7 @@
|
||||
|
||||
k1 = par1World.getBlockId(par3, par4 + j1, par5 + 1);
|
||||
|
||||
- if (k1 == 0 || k1 == Block.leaves.blockID)
|
||||
+ if (k1 == 0 || Block.blocksList[k1] == null || Block.blocksList[k1].isLeaves(par1World, par3, par4 + j1, par5 + 1))
|
||||
+ if (isReplaceable(par1World, par3, par4 + j1, par5 + 1))
|
||||
{
|
||||
this.setBlockAndMetadata(par1World, par3, par4 + j1, par5 + 1, Block.wood.blockID, this.woodMetadata);
|
||||
|
||||
@@ -222,8 +232,9 @@
|
||||
@@ -222,8 +234,9 @@
|
||||
if ((i2 >= 0 || k2 >= 0 || i2 * i2 + k2 * k2 <= k1 * k1) && (i2 <= 0 && k2 <= 0 || i2 * i2 + k2 * k2 <= (k1 + 1) * (k1 + 1)) && (par6Random.nextInt(4) != 0 || i2 * i2 + k2 * k2 <= (k1 - 1) * (k1 - 1)))
|
||||
{
|
||||
int l2 = par1World.getBlockId(l1, i1, j2);
|
||||
|
@ -95,7 +99,7 @@
|
|||
{
|
||||
this.setBlockAndMetadata(par1World, l1, i1, j2, Block.leaves.blockID, this.leavesMetadata);
|
||||
}
|
||||
@@ -232,4 +243,13 @@
|
||||
@@ -232,4 +245,19 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -107,5 +111,11 @@
|
|||
+ {
|
||||
+ block.onPlantGrow(world, x, y, z, sourceX, sourceY, sourceZ);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private boolean isReplaceable(World world, int x, int y, int z)
|
||||
+ {
|
||||
+ Block block = Block.blocksList[world.getBlockId(x, y, z)];
|
||||
+ return (block == null || block.isAirBlock(world, x, y, z) || block.isLeaves(world, x, y, z));
|
||||
+ }
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
- ;
|
||||
- }
|
||||
+ block = Block.blocksList[par1World.getBlockId(par3, par4, par5)];
|
||||
+ if (block != null && !block.isLeaves(par1World, par3, par4, par5))
|
||||
+ if (block != null && !block.isAirBlock(par1World, par3, par4, par5) && !block.isLeaves(par1World, par3, par4, par5))
|
||||
+ {
|
||||
+ break;
|
||||
+ }
|
||||
|
|
|
@ -11,23 +11,22 @@
|
|||
|
||||
public class WorldGenTrees extends WorldGenerator
|
||||
{
|
||||
@@ -67,7 +69,14 @@
|
||||
@@ -67,7 +69,13 @@
|
||||
{
|
||||
k1 = par1World.getBlockId(l1, i1, j1);
|
||||
|
||||
- if (k1 != 0 && k1 != Block.leaves.blockID && k1 != Block.grass.blockID && k1 != Block.dirt.blockID && k1 != Block.wood.blockID)
|
||||
+ Block block = Block.blocksList[k1];
|
||||
+ boolean isAir = par1World.isAirBlock(l1, i1, j1);
|
||||
+
|
||||
+ if (!isAir &&
|
||||
+ !block.isLeaves(par1World, l1, i1, j1) &&
|
||||
+ k1 != Block.grass.blockID &&
|
||||
+ k1 != Block.dirt.blockID &&
|
||||
+ !block.isWood(par1World, l1, i1, j1))
|
||||
+ if (!par1World.isAirBlock(l1, i1, j1) &&
|
||||
+ !block.isLeaves(par1World, l1, i1, j1) &&
|
||||
+ k1 != Block.grass.blockID &&
|
||||
+ k1 != Block.dirt.blockID &&
|
||||
+ !block.isWood(par1World, l1, i1, j1))
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
@@ -87,10 +96,12 @@
|
||||
@@ -87,10 +95,12 @@
|
||||
else
|
||||
{
|
||||
i1 = par1World.getBlockId(par3, par4 - 1, par5);
|
||||
|
@ -44,7 +43,7 @@
|
|||
b0 = 3;
|
||||
byte b1 = 0;
|
||||
int i2;
|
||||
@@ -113,8 +124,9 @@
|
||||
@@ -113,8 +123,9 @@
|
||||
if (Math.abs(k2) != i2 || Math.abs(i3) != i2 || par2Random.nextInt(2) != 0 && k1 != 0)
|
||||
{
|
||||
int j3 = par1World.getBlockId(j2, j1, l2);
|
||||
|
@ -56,18 +55,18 @@
|
|||
{
|
||||
this.setBlockAndMetadata(par1World, j2, j1, l2, Block.leaves.blockID, this.metaLeaves);
|
||||
}
|
||||
@@ -127,7 +139,9 @@
|
||||
@@ -127,7 +138,9 @@
|
||||
{
|
||||
k1 = par1World.getBlockId(par3, par4 + j1, par5);
|
||||
|
||||
- if (k1 == 0 || k1 == Block.leaves.blockID)
|
||||
+ Block block = Block.blocksList[k1];
|
||||
+
|
||||
+ if (k1 == 0 || block == null || block.isLeaves(par1World, par3, par4 + j1, par5))
|
||||
+ if (block == null || block.isAirBlock(par1World, par3, par4 + j1, par5) || block.isLeaves(par1World, par3, par4 + j1, par5))
|
||||
{
|
||||
this.setBlockAndMetadata(par1World, par3, par4 + j1, par5, Block.wood.blockID, this.metaWood);
|
||||
|
||||
@@ -167,24 +181,25 @@
|
||||
@@ -167,24 +180,25 @@
|
||||
{
|
||||
for (k2 = par5 - i2; k2 <= par5 + i2; ++k2)
|
||||
{
|
||||
|
@ -98,7 +97,7 @@
|
|||
{
|
||||
this.growVines(par1World, j2, j1, k2 + 1, 4);
|
||||
}
|
||||
@@ -235,7 +250,7 @@
|
||||
@@ -235,7 +249,7 @@
|
||||
{
|
||||
--par3;
|
||||
|
||||
|
|
Loading…
Reference in a new issue