use of mods.railcraft.api.core.WorldCoordinate in project Trains-In-Motion-1.7.10 by EternalBlueFlame.
the class SignalBlock method tickServer.
@Override
public void tickServer() {
super.tickServer();
update++;
try {
if (!isLoaded())
return;
} catch (Throwable ex) {
// Game.logErrorAPI("Railcraft", ex, AbstractPair.class);
}
if (update % SignalTools.signalUpdateInterval == 0) {
SignalAspect prev = getSignalAspect();
if (prev != SignalAspect.BLINK_RED)
changedAspect = true;
updateSignalAspect();
if (getSignalAspect() == SignalAspect.BLINK_RED && prev != SignalAspect.BLINK_RED)
printDebug("Signal Block changed aspect to BLINK_RED: source:[{0}, {1}, {2}] pairs: {3}", tile.xCoord, tile.yCoord, tile.zCoord, pairings);
}
if (update % VALIDATION_CHECK_INTERVAL == 0) {
Status trackStatus = getTrackStatus();
switch(trackStatus) {
case INVALID:
clearSignalBlockPairing(null, "Signal Block dropped because no track was found near Signal. [{0}, {1}, {2}]", tile.xCoord, tile.yCoord, tile.zCoord);
break;
case VALID:
for (WorldCoordinate otherCoord : waitingForRetest) {
TrackValidationStatus status = isSignalBlockValid(otherCoord);
if (!status.isValid)
clearSignalBlockPairing(otherCoord, "Signal Block dropped because track between Signals was invalid. source:[{0}, {1}, {2}] target:[{3}, {4}, {5}] reason:{6}", tile.xCoord, tile.yCoord, tile.zCoord, otherCoord.x, otherCoord.y, otherCoord.z, status.message);
}
waitingForRetest.clear();
for (WorldCoordinate otherCoord : getPairs()) {
if (!isSignalBlockValid(otherCoord).isValid)
waitingForRetest.add(otherCoord);
}
break;
}
}
}
use of mods.railcraft.api.core.WorldCoordinate in project Trains-In-Motion-1.7.10 by EternalBlueFlame.
the class SignalBlock method getOrCreateTrackScan.
private TrackScanner.ScanResult getOrCreateTrackScan(WorldCoordinate otherTrack) {
TrackScanner.ScanResult scan = trackScans.get(otherTrack);
if (scan == null) {
WorldCoordinate myTrack = getTrackLocation();
scan = TrackScanner.scanStraightTrackSection(tile.getWorldObj(), myTrack.x, myTrack.y, myTrack.z, otherTrack.x, otherTrack.y, otherTrack.z);
trackScans.put(otherTrack, scan);
}
return scan;
}
use of mods.railcraft.api.core.WorldCoordinate in project Trains-In-Motion-1.7.10 by EternalBlueFlame.
the class AbstractPair method loadNBT.
protected void loadNBT(NBTTagCompound data) {
NBTTagList list = data.getTagList("pairings", 10);
for (byte entry = 0; entry < list.tagCount(); entry++) {
NBTTagCompound tag = list.getCompoundTagAt(entry);
int[] c = tag.getIntArray("coords");
pairings.add(new WorldCoordinate(c[0], c[1], c[2], c[3]));
}
this.name = data.getString("name");
if (this.name.isEmpty()) {
this.name = null;
}
}
use of mods.railcraft.api.core.WorldCoordinate in project Trains-In-Motion-1.7.10 by EternalBlueFlame.
the class AbstractPair method saveNBT.
protected void saveNBT(NBTTagCompound data) {
NBTTagList list = new NBTTagList();
for (WorldCoordinate c : pairings) {
NBTTagCompound tag = new NBTTagCompound();
tag.setIntArray("coords", new int[] { c.dimension, c.x, c.y, c.z });
list.appendTag(tag);
}
data.setTag("pairings", list);
if (this.name != null) {
data.setString("name", this.name);
}
}
use of mods.railcraft.api.core.WorldCoordinate in project Railcraft by Railcraft.
the class GridTools method getMutuallyConnectedObjects.
public static Set<IElectricGrid> getMutuallyConnectedObjects(IElectricGrid gridObject) {
Set<IElectricGrid> connectedObjects = new HashSet<IElectricGrid>();
WorldCoordinate myPos = new WorldCoordinate(gridObject.getTile());
for (Map.Entry<BlockPos, EnumSet<ConnectType>> position : gridObject.getChargeHandler().getPossibleConnectionLocations().entrySet()) {
Optional<IElectricGrid> otherObj = getGridObjectAt(gridObject.getTile().getWorld(), position.getKey());
if (otherObj.isPresent() && position.getValue().contains(otherObj.get().getChargeHandler().getType())) {
EnumSet<ConnectType> otherType = otherObj.get().getChargeHandler().getPossibleConnectionLocations().get(myPos);
if (otherType != null && otherType.contains(gridObject.getChargeHandler().getType()))
connectedObjects.add(otherObj.get());
}
}
return connectedObjects;
}
Aggregations