use of club.nsdn.nyasamarailway.tileblock.signal.TileEntityRailSniffer in project NyaSamaRailway by NSDN.
the class RailMonoMagnetSniffer method setRailOutput.
@Override
public void setRailOutput(World world, int x, int y, int z, int meta) {
RailSniffer sniffer = null;
if (world.getTileEntity(x, y, z) instanceof RailSniffer)
sniffer = (RailSniffer) world.getTileEntity(x, y, z);
if (sniffer != null) {
if (railHasCart(world, x, y, z) && sniffer.nsasmState == RailSniffer.NSASM_IDLE) {
sniffer.nsasmState = RailSniffer.NSASM_DONE;
EntityMinecart cart = getCart(world, x, y, z);
EntityPlayer player;
if (!(cart.riddenByEntity instanceof EntityPlayer))
player = null;
else
player = (EntityPlayer) cart.riddenByEntity;
RailSniffer rail = sniffer;
new RailSnifferCore(rail.nsasmCode) {
@Override
public World getWorld() {
return world;
}
@Override
public double getX() {
return x;
}
@Override
public double getY() {
return y;
}
@Override
public double getZ() {
return z;
}
@Override
public EntityPlayer getPlayer() {
return player;
}
@Override
public TileEntityRailSniffer getRail() {
return rail;
}
@Override
public EntityMinecart getCart() {
return cart;
}
}.run();
}
if (!railHasCart(world, x, y, z) && sniffer.nsasmState == RailSniffer.NSASM_DONE) {
sniffer.nsasmState = RailSniffer.NSASM_IDLE;
sniffer.enable = false;
}
if (railHasCart(world, x, y, z) && !railHasPowered(world, x, y, z) && !sniffer.enable) {
setOutputSignal(sniffer, true);
if (sniffer.getTransceiver() != null)
setOutputSignal(sniffer.getTransceiver(), true);
}
if (!railHasCart(world, x, y, z) && railHasPowered(world, x, y, z)) {
setOutputSignal(sniffer, false);
if (sniffer.getTransceiver() != null)
setOutputSignal(sniffer.getTransceiver(), false);
}
if (railHasCart(world, x, y, z)) {
world.scheduleBlockUpdate(x, y, z, this, sniffer.keep);
}
}
}
use of club.nsdn.nyasamarailway.tileblock.signal.TileEntityRailSniffer in project NyaSamaRailway by NSDN.
the class BlockRailSniffer method setRailOutput.
@Override
public void setRailOutput(World world, int x, int y, int z, int meta) {
RailSniffer sniffer = null;
if (world.getTileEntity(x, y, z) instanceof RailSniffer)
sniffer = (RailSniffer) world.getTileEntity(x, y, z);
if (sniffer != null) {
if (railHasCart(world, x, y, z) && sniffer.nsasmState == RailSniffer.NSASM_IDLE) {
sniffer.nsasmState = RailSniffer.NSASM_DONE;
EntityMinecart cart = getCart(world, x, y, z);
EntityPlayer player;
if (!(cart.riddenByEntity instanceof EntityPlayer))
player = null;
else
player = (EntityPlayer) cart.riddenByEntity;
RailSniffer rail = sniffer;
new RailSnifferCore(rail.nsasmCode) {
@Override
public World getWorld() {
return world;
}
@Override
public double getX() {
return x;
}
@Override
public double getY() {
return y;
}
@Override
public double getZ() {
return z;
}
@Override
public EntityPlayer getPlayer() {
return player;
}
@Override
public TileEntityRailSniffer getRail() {
return rail;
}
@Override
public EntityMinecart getCart() {
return cart;
}
}.run();
}
if (!railHasCart(world, x, y, z) && sniffer.nsasmState == RailSniffer.NSASM_DONE) {
sniffer.nsasmState = RailSniffer.NSASM_IDLE;
sniffer.enable = false;
}
if (railHasCart(world, x, y, z) && !railHasPowered(world, x, y, z) && !sniffer.enable) {
setOutputSignal(sniffer, true);
if (sniffer.getTransceiver() != null)
setOutputSignal(sniffer.getTransceiver(), true);
}
if (!railHasCart(world, x, y, z) && railHasPowered(world, x, y, z)) {
setOutputSignal(sniffer, false);
if (sniffer.getTransceiver() != null)
setOutputSignal(sniffer.getTransceiver(), false);
}
if (railHasCart(world, x, y, z)) {
world.scheduleBlockUpdate(x, y, z, this, sniffer.keep);
}
}
}
Aggregations