Fixed NPE in yCoordHelper, Other Bugs, Reimplemented Limbo Decay #52

Merged
SenseiKiwi merged 8 commits from 1.4.1fixes into master 2013-07-26 19:32:37 +00:00
Showing only changes of commit eb9c8822d9 - Show all commits

View File

@@ -2,66 +2,71 @@ package StevenDimDoors.mod_pocketDim.helpers;
import StevenDimDoors.mod_pocketDim.LinkData; import StevenDimDoors.mod_pocketDim.LinkData;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.Chunk;
public class yCoordHelper public class yCoordHelper
{ {
private static final int MAXIMUM_UNCOVERED_Y = 245;
public static int getFirstUncovered(LinkData pointerLink) public static int getFirstUncovered(LinkData pointerLink)
{ {
return yCoordHelper.getFirstUncovered(pointerLink.destDimID, pointerLink.destXCoord,pointerLink.destYCoord, pointerLink.destZCoord); return yCoordHelper.getFirstUncovered(
pointerLink.destDimID,
pointerLink.destXCoord,
pointerLink.destYCoord,
pointerLink.destZCoord);
} }
public static int getFirstUncovered(int worldID, int x, int yStart, int z) public static int getFirstUncovered(int worldID, int x, int yStart, int z)
{ {
if(dimHelper.getWorld(worldID)==null||dimHelper.getWorld(worldID).provider==null) if (dimHelper.getWorld(worldID) == null ||
dimHelper.getWorld(worldID).provider == null)
{ {
dimHelper.initDimension(worldID); dimHelper.initDimension(worldID);
} }
return yCoordHelper.getFirstUncovered(dimHelper.getWorld(worldID),x,yStart,z); return yCoordHelper.getFirstUncovered(dimHelper.getWorld(worldID), x, yStart, z);
} }
public static int getFirstUncovered(World world, int x, int yStart, int z) public static int getFirstUncovered(World world, int x, int yStart, int z)
{ {
int yCoord=yStart; Chunk chunk = world.getChunkProvider().loadChunk(x >> 4, z >> 4);
Chunk chunk = world.getChunkProvider().loadChunk(x >> 4, z >> 4); int localX = x < 0 ? (x % 16) + 16 : (x % 16);
int localZ = z < 0 ? (z % 16) + 16 : (z % 16);
int height = MAXIMUM_UNCOVERED_Y; //world.getHeight();
int y;
int xC=(x % 16)< 0 ? (x % 16)+16 : (x % 16); boolean covered = true;
int yC=yCoord; for (y = yStart; y < height && covered; y++)
int zC=(z % 16)< 0 ? (z % 16)+16 : (z % 16); {
covered = IsCoveredBlock(chunk, localX, y - 1, localZ) || IsCoveredBlock(chunk, localX, y, localZ);
}
return y;
}
boolean flag=false; public static boolean IsCoveredBlock(Chunk chunk, int localX, int y, int localZ)
{
int blockID;
Block block;
Material material;
do if (y < 0)
{ return false;
flag=false;
if(yC>0&&chunk.getBlockID(xC, yC-1, zC)!=0)
{
if(!Block.blocksList[chunk.getBlockID(xC, yC-1, zC)].blockMaterial.isReplaceable()||Block.blocksList[chunk.getBlockID(xC, yC-1, zC)].blockMaterial.isLiquid())
{
flag=true; blockID = chunk.getBlockID(localX, y, localZ);
if (blockID == 0)
return false;
} block = Block.blocksList[blockID];
} if (block == null)
return false;
if(yC>0&&chunk.getBlockID(xC, yC, zC)!=0) material = block.blockMaterial;
{ return (!material.isLiquid() && !material.isReplaceable());
if(!Block.blocksList[chunk.getBlockID(xC, yC, zC)].blockMaterial.isReplaceable()||Block.blocksList[chunk.getBlockID(xC, yC, zC)].blockMaterial.isLiquid())
{
flag=true;
}
}
yC++;
}
while(flag&&yC<245);
return yC-1;
} }
} }