use of org.thewdj.physics.Point3D in project NyaSamaRailway by NSDN.
the class RailMonoMagnetDetector method setRailOutput.
public void setRailOutput(World world, int x, int y, int z, int meta) {
boolean isPowered = (meta & 8) != 0;
boolean hasCart = false;
boolean isEnabled = false;
float bBoxSize = 0.125F;
List bBox = world.getEntitiesWithinAABB(EntityMinecart.class, AxisAlignedBB.getBoundingBox((double) ((float) x + bBoxSize), (double) y, (double) ((float) z + bBoxSize), (double) ((float) (x + 1) - bBoxSize), (double) ((float) (y + 1) - bBoxSize), (double) ((float) (z + 1) - bBoxSize)));
if (!bBox.isEmpty()) {
hasCart = true;
}
if (hasCart && !isPowered) {
if (delaySecond != 0) {
Point3D p = new Point3D(x, y, z);
if (!tmpDelay.containsKey(p)) {
tmpDelay.put(p, 0);
}
if (tmpDelay.get(p) < delaySecond * 20)
tmpDelay.put(p, tmpDelay.get(p) + 1);
else {
if (getRailDirection(world, x, y, z) == RailDirection.NS) {
if (world.isBlockIndirectlyGettingPowered(x - 1, y, z) || world.isBlockIndirectlyGettingPowered(x + 1, y, z) || world.isBlockIndirectlyGettingPowered(x - 1, y - 1, z) || world.isBlockIndirectlyGettingPowered(x + 1, y - 1, z)) {
isEnabled = true;
}
} else {
if (world.isBlockIndirectlyGettingPowered(x, y, z - 1) || world.isBlockIndirectlyGettingPowered(x, y, z + 1) || world.isBlockIndirectlyGettingPowered(x, y - 1, z - 1) || world.isBlockIndirectlyGettingPowered(x, y - 1, z + 1)) {
isEnabled = true;
}
}
if (world.getTileEntity(x, y, z) instanceof TileEntityReceiver) {
TileEntityReceiver railReceiver = (TileEntityReceiver) world.getTileEntity(x, y, z);
if (railReceiver.senderIsPowered())
isEnabled = true;
}
if (!isEnabled) {
world.setBlockMetadataWithNotify(x, y, z, meta | 8, 3);
world.notifyBlocksOfNeighborChange(x, y, z, this);
world.notifyBlocksOfNeighborChange(x, y - 1, z, this);
world.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
tmpDelay.put(p, 0);
}
}
} else {
world.setBlockMetadataWithNotify(x, y, z, meta | 8, 3);
world.notifyBlocksOfNeighborChange(x, y, z, this);
world.notifyBlocksOfNeighborChange(x, y - 1, z, this);
world.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
}
} else if (!hasCart && !isPowered && delaySecond != 0) {
if (tmpDelay.containsKey(new Point3D(x, y, z)))
tmpDelay.put(new Point3D(x, y, z), 0);
}
if (!hasCart && isPowered) {
world.setBlockMetadataWithNotify(x, y, z, meta & 7, 3);
world.notifyBlocksOfNeighborChange(x, y, z, this);
world.notifyBlocksOfNeighborChange(x, y - 1, z, this);
world.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
}
if (hasCart) {
world.scheduleBlockUpdate(x, y, z, this, 20);
}
world.func_147453_f(x, y, z, this);
}
use of org.thewdj.physics.Point3D in project NyaSamaRailway by NSDN.
the class BlockRailDetectorBase method setRailOutput.
public void setRailOutput(World world, int x, int y, int z, int meta) {
boolean isPowered = (meta & 8) != 0;
boolean hasCart = false;
boolean isEnabled = false;
float bBoxSize = 0.125F;
List bBox = world.getEntitiesWithinAABB(EntityMinecart.class, AxisAlignedBB.getBoundingBox((double) ((float) x + bBoxSize), (double) y, (double) ((float) z + bBoxSize), (double) ((float) (x + 1) - bBoxSize), (double) ((float) (y + 1) - bBoxSize), (double) ((float) (z + 1) - bBoxSize)));
if (!bBox.isEmpty()) {
hasCart = true;
}
if (hasCart && !isPowered) {
if (delaySecond != 0) {
Point3D p = new Point3D(x, y, z);
if (!tmpDelay.containsKey(p)) {
tmpDelay.put(p, 0);
}
if (tmpDelay.get(p) < delaySecond * 20)
tmpDelay.put(p, tmpDelay.get(p) + 1);
else {
if (getRailDirection(world, x, y, z) == RailDirection.NS) {
if (world.isBlockIndirectlyGettingPowered(x - 1, y, z) || world.isBlockIndirectlyGettingPowered(x + 1, y, z) || world.isBlockIndirectlyGettingPowered(x - 1, y - 1, z) || world.isBlockIndirectlyGettingPowered(x + 1, y - 1, z)) {
isEnabled = true;
}
} else {
if (world.isBlockIndirectlyGettingPowered(x, y, z - 1) || world.isBlockIndirectlyGettingPowered(x, y, z + 1) || world.isBlockIndirectlyGettingPowered(x, y - 1, z - 1) || world.isBlockIndirectlyGettingPowered(x, y - 1, z + 1)) {
isEnabled = true;
}
}
if (world.getTileEntity(x, y, z) instanceof RailDetector) {
RailDetector detector = (RailDetector) world.getTileEntity(x, y, z);
if (detector.senderIsPowered())
isEnabled = true;
}
if (!isEnabled) {
world.setBlockMetadataWithNotify(x, y, z, meta | 8, 3);
world.notifyBlocksOfNeighborChange(x, y, z, this);
world.notifyBlocksOfNeighborChange(x, y - 1, z, this);
world.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
tmpDelay.put(p, 0);
}
}
} else {
world.setBlockMetadataWithNotify(x, y, z, meta | 8, 3);
world.notifyBlocksOfNeighborChange(x, y, z, this);
world.notifyBlocksOfNeighborChange(x, y - 1, z, this);
world.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
}
} else if (!hasCart && !isPowered && delaySecond != 0) {
if (tmpDelay.containsKey(new Point3D(x, y, z)))
tmpDelay.put(new Point3D(x, y, z), 0);
}
if (!hasCart && isPowered) {
world.setBlockMetadataWithNotify(x, y, z, meta & 7, 3);
world.notifyBlocksOfNeighborChange(x, y, z, this);
world.notifyBlocksOfNeighborChange(x, y - 1, z, this);
world.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
}
if (hasCart) {
world.scheduleBlockUpdate(x, y, z, this, 20);
}
world.func_147453_f(x, y, z, this);
}
Aggregations