use of club.nsdn.nyasamarailway.entity.LocoBase in project NyaSamaRailway by NSDN.
the class TileEntityRailReception method tick.
public static void tick(boolean isAnti, List bBox, TileEntityRailReception rail, boolean playerDetectable) {
if (rail == null)
return;
World world = rail.worldObj;
int x = rail.xCoord, y = rail.yCoord, z = rail.zCoord;
boolean hasCart = !bBox.isEmpty();
if (!playerDetectable) {
if (rail.getSender() != null && rail.getBlockType() instanceof IRailReception) {
IRailReception blockRail = (IRailReception) rail.getBlockType();
if (!isRailPowered(world, x, y, z) && rail.senderIsPowered()) {
blockRail.setRailState(world, x, y, z, true);
} else if (isRailPowered(world, x, y, z) && !rail.senderIsPowered()) {
blockRail.setRailState(world, x, y, z, false);
}
}
} else {
if (rail.cartType.equals("loco")) {
if (!hasCart) {
rail.reset();
} else {
if (rail.getTarget() != null) {
rail.controlTarget(rail.doorCtrl);
}
for (Object obj : bBox) {
if (obj instanceof LocoBase) {
loco(isAnti, (LocoBase) obj, rail);
break;
}
}
}
} else {
if (hasCart) {
if (rail.getTarget() != null) {
rail.controlTarget(rail.doorCtrl);
}
for (Object obj : bBox) {
if (obj instanceof EntityMinecart) {
if (((EntityMinecart) obj).riddenByEntity == null) {
EntityMinecart cart = (EntityMinecart) obj;
cart.motionX = 0.0D;
cart.motionZ = 0.0D;
cart.setPosition(x + 0.5, y + 0.5, z + 0.5);
rail.reset();
rail.prev = true;
} else if (rail.prev) {
rail.prev = false;
// rail.delay = DELAY_TIME * 15 - 1;
}
break;
}
}
} else {
rail.count += 1;
if (rail.count >= TileEntityRailReception.SPAWN_DELAY * 20) {
rail.reset();
rail.spawn(rail.worldObj, x, y, z);
}
}
}
}
}
use of club.nsdn.nyasamarailway.entity.LocoBase in project NyaSamaRailway by NSDN.
the class TileEntityTrackSideReception method core.
protected static void core(EntityMinecart cart, TileEntityTrackSideReception reception) {
if (reception == null)
return;
boolean hasCart = (cart != null);
ForgeDirection railPos = reception.direction.getRotation(ITrackSide.getAxis());
int x = reception.xCoord + railPos.offsetX, y = reception.yCoord, z = reception.zCoord + railPos.offsetZ;
if (reception.cartType.equals("loco")) {
if (!hasCart) {
reception.reset();
} else {
if (reception.getTarget() != null) {
reception.controlTarget(reception.doorCtrl);
}
if (cart instanceof LocoBase)
loco((LocoBase) cart, reception);
}
} else {
if (!hasCart) {
reception.count += 1;
if (reception.count >= SPAWN_DELAY * 20) {
reception.reset();
reception.spawn();
}
} else {
if (reception.getTarget() != null) {
reception.controlTarget(reception.doorCtrl);
}
if (cart.riddenByEntity == null) {
cart.motionX = 0.0D;
cart.motionZ = 0.0D;
cart.setPosition(x + 0.5, y + 0.5, z + 0.5);
reception.reset();
if (ITrackSide.hasMultiMinecart(reception, reception.direction)) {
LinkedList<EntityMinecart> carts = ITrackSide.getMinecarts(reception, reception.direction);
for (int i = 1; i < carts.size(); i++) carts.get(i).killMinecart(new DamageSource("nsr"));
}
reception.prev = true;
} else if (reception.prev) {
reception.prev = false;
// reception.delay = DELAY_TIME * 15 - 1;
}
EntityPlayer player = null;
if (cart.riddenByEntity instanceof EntityPlayer)
player = (EntityPlayer) cart.riddenByEntity;
cart(cart, reception, player);
}
tri(cart, reception);
}
}
use of club.nsdn.nyasamarailway.entity.LocoBase in project NyaSamaRailway by NSDN.
the class ItemNTP8Bit 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.Mode = this.mode.get(itemStack);
packet.dimensionID = player.dimension;
EntityMinecart cart = packet.getCartInServer(this.cart.get(itemStack));
if (cart != null) {
if (cart instanceof IHighSpeedCart) {
((IHighSpeedCart) cart).setHighSpeedMode(packet.Mode);
}
if (cart instanceof LocoBase) {
((LocoBase) cart).setTrainPacket(packet);
return;
}
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);
}
}
}
}
use of club.nsdn.nyasamarailway.entity.LocoBase in project NyaSamaRailway by NSDN.
the class NSPCT8C method doSpawn.
public static void doSpawn(World world, int x, int y, int z, String name) {
LocoBase head = new NSPCT8C(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5);
if (!name.isEmpty())
head.setMinecartName(name);
world.spawnEntityInWorld(head);
MinecartBase container = new NSPCT8C.Container(world, (double) x + 0.5, (double) y + 0.5 - 3.0, (double) z + 0.5);
world.spawnEntityInWorld(container);
container.mountEntity(head);
}
use of club.nsdn.nyasamarailway.entity.LocoBase in project NyaSamaRailway by NSDN.
the class ItemNSPCT7 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))) {
if (!world.isRemote) {
LocoBase entityminecart = new NSPCT7(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;
}
}
Aggregations