use of mods.railcraft.api.core.WorldCoordinate in project Trains-In-Motion-1.7.10 by EternalBlueFlame.
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<WorldCoordinate, EnumSet<ConnectType>> position : gridObject.getChargeHandler().getPossibleConnectionLocations().entrySet()) {
IElectricGrid otherObj = getGridObjectAt(gridObject.getTile().getWorldObj(), position.getKey());
if (otherObj != null && position.getValue().contains(otherObj.getChargeHandler().getType())) {
EnumSet<ConnectType> otherType = otherObj.getChargeHandler().getPossibleConnectionLocations().get(myPos);
if (otherType != null && otherType.contains(gridObject.getChargeHandler().getType()))
connectedObjects.add(otherObj);
}
}
return connectedObjects;
}
use of mods.railcraft.api.core.WorldCoordinate in project Trains-In-Motion-1.7.10 by EternalBlueFlame.
the class AbstractPair method validatePairings.
protected void validatePairings() {
if (!pairingsToTestNext.isEmpty()) {
pairingsToTestNext.retainAll(pairings);
for (WorldCoordinate coord : pairingsToTestNext) {
int x = coord.x;
int y = coord.y;
int z = coord.z;
World world = tile.getWorldObj();
if (!world.blockExists(x, y, z))
continue;
Block block = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
if (!block.hasTileEntity(meta)) {
clearPairing(coord);
continue;
}
TileEntity target = world.getTileEntity(x, y, z);
if (target != null && !isValidPair(coord, target))
clearPairing(coord);
}
pairingsToTestNext.clear();
}
cleanPairings();
for (WorldCoordinate coord : pairings) {
getPairAt(coord);
}
pairingsToTestNext.addAll(pairingsToTest);
pairingsToTest.clear();
}
use of mods.railcraft.api.core.WorldCoordinate in project Trains-In-Motion-1.7.10 by EternalBlueFlame.
the class SignalBlock method createSignalBlock.
// @Override
// public void startPairing() {
// clearSignalBlockPairing("Signal Block pairing cleared in preparation to start a new pairing. [{0}, {1}, {2}]", tile.xCoord, tile.yCoord, tile.zCoord);
// super.startPairing();
// }
public boolean createSignalBlock(SignalBlock other) {
if (other == this) {
printDebugPair("Signal Block creation was aborted, cannot pair with self.", other.tile);
return false;
}
printDebugPair("Signal Block creation being attempted.", other.tile);
Status myTrackStatus = getTrackStatus();
Status otherTrackStatus = other.getTrackStatus();
if (myTrackStatus == Status.INVALID || otherTrackStatus == Status.INVALID) {
printDebugPair("Signal Block creation failed, could not find Track.", other.tile);
return false;
}
WorldCoordinate myTrack = getTrackLocation();
WorldCoordinate otherTrack = other.getTrackLocation();
TrackScanner.ScanResult scan = TrackScanner.scanStraightTrackSection(tile.getWorldObj(), myTrack.x, myTrack.y, myTrack.z, otherTrack.x, otherTrack.y, otherTrack.z);
if (!scan.areConnected) {
printDebugPair("Signal Block creation failed, could not find Path.", other.tile);
return false;
}
addPairing(other.getCoords());
other.addPairing(getCoords());
endPairing();
other.endPairing();
trackScans.put(otherTrack, scan);
printDebugPair("Signal Block created successfully.", other.tile);
return true;
}
use of mods.railcraft.api.core.WorldCoordinate in project Trains-In-Motion-1.7.10 by EternalBlueFlame.
the class SignalBlockRelay method saveNBT.
@Override
protected void saveNBT(NBTTagCompound data) {
super.saveNBT(data);
NBTTagList tagList = data.getTagList("aspects", 10);
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound nbt = tagList.getCompoundTagAt(i);
WorldCoordinate coord = WorldCoordinate.readFromNBT(nbt, "coord");
SignalAspect aspect = SignalAspect.readFromNBT(nbt, "aspect");
aspects.put(coord, aspect);
}
}
use of mods.railcraft.api.core.WorldCoordinate in project Trains-In-Motion-1.7.10 by EternalBlueFlame.
the class DualSignalReceiver method onControllerAspectChange.
@Override
public void onControllerAspectChange(SignalController con, @Nonnull SignalAspect aspect) {
WorldCoordinate coord = pairings.peekFirst();
if (coord == null) {
return;
}
if (coord.equals(con.getCoords())) {
if (aspect != topAspect) {
topAspect = aspect;
super.onControllerAspectChange(con, aspect);
}
} else {
if (aspect != bottomAspect) {
bottomAspect = aspect;
super.onControllerAspectChange(con, aspect);
}
}
}
Aggregations