use of club.nsdn.nyasamarailway.entity.LocoBase in project NyaSamaRailway by NSDN.
the class ChunkLoaderHandler method ticketsLoaded.
@Override
public void ticketsLoaded(List<ForgeChunkManager.Ticket> tickets, World world) {
for (ForgeChunkManager.Ticket ticket : tickets) {
if (ticket.isPlayerTicket())
continue;
Entity entity = ticket.getEntity();
if (entity instanceof LocoBase) {
LocoBase anchor = (LocoBase) entity;
anchor.setChunkTicket(ticket);
anchor.forceChunkLoading(anchor.chunkCoordX, anchor.chunkCoordZ);
}
}
}
use of club.nsdn.nyasamarailway.entity.LocoBase in project NyaSamaRailway by NSDN.
the class BlockRailNoSleeperRFID method onMinecartPass.
@Override
public void onMinecartPass(World world, EntityMinecart cart, int x, int y, int z) {
if (world.getTileEntity(x, y, z) instanceof TileEntityRailRFID) {
TileEntityRailRFID rfid = (TileEntityRailRFID) world.getTileEntity(x, y, z);
if (cart instanceof LocoBase) {
LocoBase loco = (LocoBase) cart;
if (isRailPowered(world, x, y, z) || rfid.senderIsPowered()) {
loco.setEnginePower(rfid.P);
loco.setEngineBrake(rfid.R);
}
} else if (cart instanceof IMotorCart) {
IMotorCart motorCart = (IMotorCart) cart;
if (isRailPowered(world, x, y, z) || rfid.senderIsPowered()) {
motorCart.setMotorPower(rfid.P);
motorCart.setMotorBrake(rfid.R);
motorCart.setMotorState(rfid.state);
}
}
if (cart instanceof ILimitVelCart) {
ILimitVelCart limitVelCart = (ILimitVelCart) cart;
if (isRailPowered(world, x, y, z) || rfid.senderIsPowered()) {
limitVelCart.setMaxVelocity(rfid.vel);
}
}
if (cart instanceof IExtendedInfoCart) {
IExtendedInfoCart infoCart = (IExtendedInfoCart) cart;
if (isRailPowered(world, x, y, z) || rfid.senderIsPowered()) {
if (!rfid.cartSide.equals("null"))
infoCart.setExtendedInfo("side", rfid.cartSide);
if (!rfid.cartStr.equals("null"))
infoCart.setExtendedInfo("str", rfid.cartStr);
if (!rfid.cartJet.equals("null"))
infoCart.setExtendedInfo("jet", rfid.cartJet);
}
}
}
}
use of club.nsdn.nyasamarailway.entity.LocoBase in project NyaSamaRailway by NSDN.
the class BlockRailRFID method onMinecartPass.
@Override
public void onMinecartPass(World world, EntityMinecart cart, int x, int y, int z) {
if (world.getTileEntity(x, y, z) instanceof TileEntityRailRFID) {
TileEntityRailRFID rfid = (TileEntityRailRFID) world.getTileEntity(x, y, z);
if (cart instanceof LocoBase) {
LocoBase loco = (LocoBase) cart;
if (isRailPowered(world, x, y, z) || rfid.senderIsPowered()) {
loco.setEnginePower(rfid.P);
loco.setEngineBrake(rfid.R);
}
} else if (cart instanceof IMotorCart) {
IMotorCart motorCart = (IMotorCart) cart;
if (isRailPowered(world, x, y, z) || rfid.senderIsPowered()) {
motorCart.setMotorPower(rfid.P);
motorCart.setMotorBrake(rfid.R);
motorCart.setMotorState(rfid.state);
}
}
if (cart instanceof ILimitVelCart) {
ILimitVelCart limitVelCart = (ILimitVelCart) cart;
if (isRailPowered(world, x, y, z) || rfid.senderIsPowered()) {
limitVelCart.setMaxVelocity(rfid.vel);
}
}
if (cart instanceof IExtendedInfoCart) {
IExtendedInfoCart infoCart = (IExtendedInfoCart) cart;
if (isRailPowered(world, x, y, z) || rfid.senderIsPowered()) {
if (!rfid.cartSide.equals("null"))
infoCart.setExtendedInfo("side", rfid.cartSide);
if (!rfid.cartStr.equals("null"))
infoCart.setExtendedInfo("str", rfid.cartStr);
if (!rfid.cartJet.equals("null"))
infoCart.setExtendedInfo("jet", rfid.cartJet);
}
}
}
}
use of club.nsdn.nyasamarailway.entity.LocoBase in project NyaSamaRailway by NSDN.
the class ItemNSC3BM method onItemUse.
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float px, float py, float pz) {
if (BlockRailBase.func_150051_a(world.getBlock(x, y, z)) && world.getBlock(x, y, z) instanceof RailMonoMagnetBase) {
if (!world.isRemote) {
LocoBase entityminecart = new NSC3BM(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5);
if (itemStack.hasDisplayName()) {
entityminecart.setMinecartName(itemStack.getDisplayName());
}
world.spawnEntityInWorld(entityminecart);
}
--itemStack.stackSize;
return true;
} else {
return false;
}
}
use of club.nsdn.nyasamarailway.entity.LocoBase in project NyaSamaRailway by NSDN.
the class ItemNTP32Bit method onUpdate.
@Override
public void onUpdate(ItemStack itemStack, World world, Entity entity, int index, boolean inHand) {
if (!world.isRemote && inHand) {
if (entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
TrainPacket packet = new TrainPacket();
packet.P = this.power.get(itemStack);
packet.R = this.brake.get(itemStack);
packet.Dir = this.dir.get(itemStack);
packet.dimensionID = player.dimension;
int[] carts = this.carts.get(itemStack);
if (carts.length == 1 && carts[0] == -1)
return;
EntityMinecart cart;
for (int i : carts) {
cart = packet.getCartInServer(i);
if (cart != null) {
if (cart instanceof LocoBase)
continue;
if (Traincraft.getInstance() != null) {
if (Traincraft.instance.isLocomotive(cart)) {
Traincraft.instance.Locomotive_setIsLocoTurnedOn(cart, true);
}
}
packet.Velocity = Dynamics.vel(cart.motionX, cart.motionZ);
TrainController.doMotion(packet, cart);
}
}
}
}
}
Aggregations