Various Fixes #124

Merged
SenseiKiwi merged 8 commits from master into master 2014-01-06 04:16:28 +00:00
Showing only changes of commit a5e5ea3921 - Show all commits

View File

@@ -30,16 +30,19 @@ import StevenDimDoors.mod_pocketDim.util.Point4D;
public class TileEntityRift extends TileEntity public class TileEntityRift extends TileEntity
{ {
private static final int ENDERMAN_SPAWNING_CHANCE = 1;
private static final int MAX_ENDERMAN_SPAWNING_CHANCE = 32;
private static Random random = new Random(); private static Random random = new Random();
public int xOffset = 0; public int xOffset = 0;
public int yOffset = 0; public int yOffset = 0;
public int zOffset = 0; public int zOffset = 0;
public boolean hasGrownRifts=false; private boolean hasGrownRifts = false;
public boolean shouldClose = false; public boolean shouldClose = false;
private int count = 0; private int count = 0;
private int count2 = 0; private int count2 = 0;
public int age = 0; private int age = 0;
private boolean hasUpdated = false; private boolean hasUpdated = false;
public HashMap<Integer, double[]> renderingCenters = new HashMap<Integer, double[]>(); public HashMap<Integer, double[]> renderingCenters = new HashMap<Integer, double[]>();
@@ -68,10 +71,6 @@ public class TileEntityRift extends TileEntity
return; return;
} }
//The code for the new rift rendering hooks in here, as well as in the ClientProxy to bind the TESR to the rift. //The code for the new rift rendering hooks in here, as well as in the ClientProxy to bind the TESR to the rift.
//It is inactive for now. //It is inactive for now.
/** /**
@@ -108,12 +107,9 @@ public class TileEntityRift extends TileEntity
return true; return true;
} }
private void clearBlocksOnRift()
public void clearBlocksOnRift()
{ {
//clears blocks for the new rending effect //clears blocks for the new rending effect
for(double[] coord: this.renderingCenters.values()) for(double[] coord: this.renderingCenters.values())
{ {
int x = MathHelper.floor_double(coord[0]+.5); int x = MathHelper.floor_double(coord[0]+.5);
@@ -129,11 +125,10 @@ public class TileEntityRift extends TileEntity
{ {
worldObj.setBlockToAir(this.xCoord-x, this.yCoord-y, this.zCoord-z); worldObj.setBlockToAir(this.xCoord-x, this.yCoord-y, this.zCoord-z);
} }
} }
} }
public void spawnEndermen() private void spawnEndermen()
{ {
if (worldObj.isRemote) if (worldObj.isRemote)
{ {
@@ -150,10 +145,9 @@ public class TileEntityRift extends TileEntity
} }
//enderman will only spawn in groups of rifts //enderman will only spawn in groups of rifts
nearestRiftData = dimension.findNearestRift(worldObj, 5, xCoord, yCoord, zCoord); if (random.nextInt(MAX_ENDERMAN_SPAWNING_CHANCE) < ENDERMAN_SPAWNING_CHANCE)
if (nearestRiftData != null)
{ {
if (random.nextInt(30) == 0) if (isNearRift())
{ {
List<Entity> list = worldObj.getEntitiesWithinAABB(EntityEnderman.class, List<Entity> list = worldObj.getEntitiesWithinAABB(EntityEnderman.class,
AxisAlignedBB.getBoundingBox(xCoord - 9, yCoord - 3, zCoord - 9, xCoord + 9, yCoord + 3, zCoord + 9)); AxisAlignedBB.getBoundingBox(xCoord - 9, yCoord - 3, zCoord - 9, xCoord + 9, yCoord + 3, zCoord + 9));
@@ -168,7 +162,13 @@ public class TileEntityRift extends TileEntity
} }
} }
public void closeRift() public boolean isNearRift()
{
nearestRiftData = PocketManager.getDimensionData(worldObj).findNearestRift(this.worldObj, 5, xCoord, yCoord, zCoord);
return (nearestRiftData != null);
}
private void closeRift()
{ {
NewDimData dimension = PocketManager.getDimensionData(worldObj); NewDimData dimension = PocketManager.getDimensionData(worldObj);
if (count2 > 20 && count2 < 22) if (count2 > 20 && count2 < 22)
@@ -206,7 +206,7 @@ public class TileEntityRift extends TileEntity
} }
public void calculateOldParticleOffset() private void calculateOldParticleOffset()
{ {
nearestRiftData = PocketManager.getDimensionData(worldObj).findNearestRift(worldObj, 5, xCoord, yCoord, zCoord); nearestRiftData = PocketManager.getDimensionData(worldObj).findNearestRift(worldObj, 5, xCoord, yCoord, zCoord);
if (nearestRiftData != null) if (nearestRiftData != null)
@@ -226,7 +226,7 @@ public class TileEntityRift extends TileEntity
this.onInventoryChanged(); this.onInventoryChanged();
} }
public void calculateNextRenderQuad(float age, Random rand) private void calculateNextRenderQuad(float age, Random rand)
{ {
int maxSize = MathHelper.floor_double((Math.log(Math.pow(age+1,2)))); int maxSize = MathHelper.floor_double((Math.log(Math.pow(age+1,2))));
int iteration=0; int iteration=0;
@@ -322,9 +322,6 @@ public class TileEntityRift extends TileEntity
} }
if (growCount < 100) if (growCount < 100)
{ {
//look to see if there is a block inbetween the rift and the spread location that should interrupt the spread. With this change, //look to see if there is a block inbetween the rift and the spread location that should interrupt the spread. With this change,
//rifts cannot spread if there are any blocks nearby that are invularble to rift destruction //rifts cannot spread if there are any blocks nearby that are invularble to rift destruction
//TODO- make this look for blocks breaking line of sight with the rift //TODO- make this look for blocks breaking line of sight with the rift
@@ -360,7 +357,6 @@ public class TileEntityRift extends TileEntity
} }
} }
@Override @Override
public void readFromNBT(NBTTagCompound nbt) public void readFromNBT(NBTTagCompound nbt)
{ {
@@ -407,14 +403,4 @@ public class TileEntityRift extends TileEntity
{ {
readFromNBT(pkt.data); readFromNBT(pkt.data);
} }
public boolean isNearRift()
{
if(PocketManager.getDimensionData(worldObj).findNearestRift(this.worldObj, 5, xCoord, yCoord, zCoord)==null)
{
return false;
}
return true;
}
} }