A little enitty code cleanup.

This commit is contained in:
Kyprus 2012-06-19 21:13:33 -04:00
parent b11d806fd2
commit e193bdbf46
2 changed files with 442 additions and 435 deletions

View file

@ -29,8 +29,6 @@ public class EntityLaser extends Entity implements ISpawnHandler {
protected double angleZ = 0;
protected String texture;
double lastY;
public EntityLaser(World world) {
super(world);
@ -43,6 +41,8 @@ public class EntityLaser extends Entity implements ISpawnHandler {
this.head = head;
this.tail = tail;
setPosition(head.x, head.y, head.z);
init();
}
@ -63,8 +63,6 @@ public class EntityLaser extends Entity implements ISpawnHandler {
dataWatcher.addObject(13, Integer.valueOf(encodeDouble(tail.z)));
dataWatcher.addObject(14, Byte.valueOf((byte) 0));
lastY = head.y;
}
@Override
@ -104,8 +102,6 @@ public class EntityLaser extends Entity implements ISpawnHandler {
boundingBox.maxY = Math.max(head.y, tail.y);
boundingBox.maxZ = Math.max(head.z, tail.z);
if (!APIProxy.isClient(worldObj)) {
boundingBox.minX--;
boundingBox.minY--;
boundingBox.minZ--;
@ -113,7 +109,6 @@ public class EntityLaser extends Entity implements ISpawnHandler {
boundingBox.maxX++;
boundingBox.maxY++;
boundingBox.maxZ++;
}
double dx = head.x - tail.x;
double dy = head.y - tail.y;
@ -138,6 +133,11 @@ public class EntityLaser extends Entity implements ISpawnHandler {
@Override
public void setPosition(double x, double y, double z) {
if (x == 0)
new Exception().printStackTrace();
System.out.println(new Position(x, y, z));
posX = x;
posY = y;
posZ = z;

View file

@ -45,7 +45,9 @@ public class TileLaser extends TileEntity implements IPowerReceptor {
@Override
public void updateEntity() {
if (powerProvider.energyStored == 0) {
if (laser != null) {
deleteLaser();
}
@ -75,6 +77,7 @@ public class TileLaser extends TileEntity implements IPowerReceptor {
}
private void deleteLaser() {
if (laser != null) {
laser.setDead();
laser = null;
@ -142,20 +145,24 @@ public class TileLaser extends TileEntity implements IPowerReceptor {
assemblyTable = (TileAssemblyTable) worldObj.getBlockTileEntity(b.i, b.j, b.k);
if (laser == null) {
laser = new EntityEnergyLaser(worldObj, new Position(xCoord, yCoord, zCoord), new Position(xCoord, yCoord, zCoord));
setLaserPosition();
worldObj.spawnEntityInWorld(laser);
laser.show();
} else {
setLaserPosition();
}
}
private void setLaserPosition() {
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
double px = 0, py = 0, pz = 0;
switch (Orientations.values()[meta]) {
case XNeg:
px = -0.3;
break;