Updated registries to static (?)

This commit is contained in:
LemADEC 2014-08-23 12:28:48 +02:00
parent 4284984439
commit 2a88825542
9 changed files with 28 additions and 26 deletions

View file

@ -15,7 +15,7 @@ public class CloakChunkWatcher {
ChunkCoordIntPair chunk = event.chunk;
// Check chunk for locating in cloaked areas
ArrayList<CloakedArea> cloaks = WarpDrive.instance.cloaks.getCloaksForPoint(p.worldObj.provider.dimensionId, chunk.getCenterXPos(), 0, chunk.getCenterZPosition(), true);
ArrayList<CloakedArea> cloaks = WarpDrive.cloaks.getCloaksForPoint(p.worldObj.provider.dimensionId, chunk.getCenterXPos(), 0, chunk.getCenterZPosition(), true);
if (cloaks.size() == 0)
return;

View file

@ -530,7 +530,7 @@ public class EntityJump extends Entity
e.printStackTrace();
}
} else if (te instanceof TileEntityReactor) {
WarpDrive.instance.warpCores.removeFromRegistry((TileEntityReactor)te);
WarpDrive.warpCores.removeFromRegistry((TileEntityReactor)te);
}
teSuperclass = teClass.getSuperclass();

View file

@ -191,7 +191,7 @@ public class SpaceEventHandler {
if (cloakTicks >= CLOAK_CHECK_TIMEOUT_TICKS) {
player_cloakTicks.put(player.username, 0);
List<CloakedArea> cloaks = WarpDrive.instance.cloaks.getCloaksForPoint(player.worldObj.provider.dimensionId, MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY), MathHelper.floor_double(player.posZ), false);
List<CloakedArea> cloaks = WarpDrive.cloaks.getCloaksForPoint(player.worldObj.provider.dimensionId, MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY), MathHelper.floor_double(player.posZ), false);
if (cloaks.size() != 0) {
//WarpDrive.debugPrint("[Cloak] Player inside " + cloaks.size() + " cloaked areas");
for (CloakedArea area : cloaks) {
@ -202,7 +202,7 @@ public class SpaceEventHandler {
}
} else {
//WarpDrive.debugPrint("[Cloak] Player is not inside any cloak fields. Check, which field player may left...");
WarpDrive.instance.cloaks.checkPlayerLeftArea(player);
WarpDrive.cloaks.checkPlayerLeftArea(player);
}
} else {
player_cloakTicks.put(player.username, cloakTicks + 1);

View file

@ -83,7 +83,7 @@ public class GenerateCommand extends CommandBase
if (params.length == 2) {
notifyAdmins(icommandsender, "/generate: creating jumpgate at " + x + ", " + y + ", " + z, new Object[0]);
if (WarpDrive.instance.jumpgates.addGate(params[1], x, y, z)) {
if (WarpDrive.jumpgates.addGate(params[1], x, y, z)) {
JumpgateGenerator.generate(player.worldObj, x, Math.min(y,255-JumpgateGenerator.GATE_SIZE_HALF - 1), z);
} else {
notifyAdmins(icommandsender, "/generate: jumpgate '" + params[1] + "' already exists.", new Object[0]);

View file

@ -29,6 +29,6 @@ public class JumpgateCommand extends CommandBase
public void processCommand(ICommandSender icommandsender, String[] astring)
{
EntityPlayerMP player = (EntityPlayerMP)icommandsender;
player.addChatMessage(WarpDrive.instance.jumpgates.commaList());
player.addChatMessage(WarpDrive.jumpgates.commaList());
}
}

View file

@ -103,10 +103,10 @@ public class BlockReactor extends BlockContainer {
public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) {
TileEntity te = par1World.getBlockTileEntity(par2, par3, par4);
if (te != null && te instanceof TileEntityReactor) {
WarpDrive.instance.warpCores.removeFromRegistry((TileEntityReactor)te);
WarpDrive.warpCores.removeFromRegistry((TileEntityReactor)te);
}
WarpDrive.instance.warpCores.removeDeadCores();
WarpDrive.warpCores.removeDeadCores();
super.breakBlock(par1World, par2, par3, par4, par5, par6);
}
}

View file

@ -442,7 +442,7 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral
setFront(((Double)arguments[0]).intValue());
setRight(((Double)arguments[1]).intValue());
setUp(((Double)arguments[2]).intValue());
WarpDrive.instance.warpCores.removeDeadCores();
WarpDrive.warpCores.removeDeadCores();
break;
case 2: // dim_getn ()
@ -467,7 +467,7 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral
setBack(argInt0);
setLeft(argInt1);
setDown(argInt2);
WarpDrive.instance.warpCores.removeDeadCores();
WarpDrive.warpCores.removeDeadCores();
break;
case 4: // set_mode (mode)

View file

@ -40,8 +40,8 @@ public class TileEntityRadar extends WarpEnergyTE implements IPeripheral {
cooldownTime++;
if (cooldownTime > (20 * ((scanRadius / 1000) + 1))) {
WarpDrive.debugPrint("" + this + " Scanning over " + scanRadius + " radius...");
WarpDrive.instance.warpCores.removeDeadCores();
results = WarpDrive.instance.warpCores.searchWarpCoresInRadius(xCoord, yCoord, zCoord, scanRadius);
WarpDrive.warpCores.removeDeadCores();
results = WarpDrive.warpCores.searchWarpCoresInRadius(xCoord, yCoord, zCoord, scanRadius);
WarpDrive.debugPrint("" + this + " Scan found " + results.size() + " results");
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 + 2);
cooldownTime = 0;

View file

@ -104,10 +104,11 @@ public class TileEntityReactor extends WarpEnergyTE
}
// Update warp core in cores registry
if (++registryUpdateTicks > WarpDriveConfig.WC_CORES_REGISTRY_UPDATE_INTERVAL_SECONDS * 20) {
registryUpdateTicks++;
if (registryUpdateTicks > WarpDriveConfig.WC_CORES_REGISTRY_UPDATE_INTERVAL_SECONDS * 20) {
registryUpdateTicks = 0;
WarpDrive.instance.warpCores.updateInRegistry(this);
// WarpDrive.instance.registry.printRegistry();
WarpDrive.warpCores.updateInRegistry(this);
// WarpDrive.warpCores.printRegistry();
// WarpDrive.debugPrint("" + this + " controller is " + controller + ", warmupTime " + warmupTime + ", currentMode " + currentMode + ", jumpFlag " + (controller == null ? "NA" : controller.isJumpFlag()) + ", cooldownTime " + cooldownTime);
TileEntity c = findControllerBlock();
@ -120,7 +121,8 @@ public class TileEntityReactor extends WarpEnergyTE
controller = (TileEntityProtocol)c;
}
if (++isolationUpdateTicks > WarpDriveConfig.WC_ISOLATION_UPDATE_INTERVAL_SECONDS * 20) {
isolationUpdateTicks++;
if (isolationUpdateTicks > WarpDriveConfig.WC_ISOLATION_UPDATE_INTERVAL_SECONDS * 20) {
isolationUpdateTicks = 0;
updateIsolationState();
}
@ -255,13 +257,13 @@ public class TileEntityReactor extends WarpEnergyTE
return;
}
if (WarpDrive.instance.warpCores.isWarpCoreIntersectsWithOthers(this)) {
if (WarpDrive.warpCores.isWarpCoreIntersectsWithOthers(this)) {
controller.setJumpFlag(false);
messageToAllPlayersOnShip("Warp field intersects with other ship's field. Cannot jump.");
return;
}
if (WarpDrive.instance.cloaks.isInCloak(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, false)) {
if (WarpDrive.cloaks.isInCloak(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, false)) {
controller.setJumpFlag(false);
messageToAllPlayersOnShip("Core is inside a cloaking field. Aborting. Disable cloaking field to jump!");
return;
@ -659,7 +661,7 @@ public class TileEntityReactor extends WarpEnergyTE
{
// Search nearest jump-gate
String gateName = controller.getTargetJumpgateName();
Jumpgate targetGate = WarpDrive.instance.jumpgates.findGateByName(gateName);
Jumpgate targetGate = WarpDrive.jumpgates.findGateByName(gateName);
if (targetGate == null)
{
@ -675,7 +677,7 @@ public class TileEntityReactor extends WarpEnergyTE
int destX = gateX;
int destY = gateY;
int destZ = gateZ;
Jumpgate nearestGate = WarpDrive.instance.jumpgates.findNearestGate(xCoord, yCoord, zCoord);
Jumpgate nearestGate = WarpDrive.jumpgates.findNearestGate(xCoord, yCoord, zCoord);
StringBuilder reason = new StringBuilder();
if (!isShipInJumpgate(nearestGate, reason))
@ -761,10 +763,10 @@ public class TileEntityReactor extends WarpEnergyTE
// Check ship size for hyper-space jump
if (shipVolume < WarpDriveConfig.WC_MIN_SHIP_VOLUME_FOR_HYPERSPACE) {
Jumpgate nearestGate = null;
if (WarpDrive.instance.jumpgates == null) {
if (WarpDrive.jumpgates == null) {
System.out.println("" + this + " WarpDrive.instance.jumpGates is NULL!");
} else {
nearestGate = WarpDrive.instance.jumpgates.findNearestGate(xCoord, yCoord, zCoord);
nearestGate = WarpDrive.jumpgates.findNearestGate(xCoord, yCoord, zCoord);
}
StringBuilder reason = new StringBuilder();
@ -1063,7 +1065,7 @@ public class TileEntityReactor extends WarpEnergyTE
coreFrequency = tag.getString("corefrequency");
isolationBlocksCount = tag.getInteger("isolation");
cooldownTime = tag.getInteger("cooldownTime");
WarpDrive.instance.warpCores.updateInRegistry(this);
WarpDrive.warpCores.updateInRegistry(this);
}
@Override
@ -1077,19 +1079,19 @@ public class TileEntityReactor extends WarpEnergyTE
@Override
public void onChunkUnload() {
WarpDrive.instance.warpCores.removeFromRegistry(this);
WarpDrive.warpCores.removeFromRegistry(this);
super.onChunkUnload();
}
@Override
public void validate() {
super.validate();
WarpDrive.instance.warpCores.updateInRegistry(this);
WarpDrive.warpCores.updateInRegistry(this);
}
@Override
public void invalidate() {
WarpDrive.instance.warpCores.removeFromRegistry(this);
WarpDrive.warpCores.removeFromRegistry(this);
super.invalidate();
}