Search in sources :

Example 11 with LocoBase

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);
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) ForgeChunkManager(net.minecraftforge.common.ForgeChunkManager) LocoBase(club.nsdn.nyasamarailway.entity.LocoBase)

Example 12 with LocoBase

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);
            }
        }
    }
}
Also used : IMotorCart(club.nsdn.nyasamarailway.entity.IMotorCart) ILimitVelCart(club.nsdn.nyasamarailway.entity.ILimitVelCart) LocoBase(club.nsdn.nyasamarailway.entity.LocoBase) IExtendedInfoCart(club.nsdn.nyasamarailway.entity.IExtendedInfoCart)

Example 13 with LocoBase

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);
            }
        }
    }
}
Also used : IMotorCart(club.nsdn.nyasamarailway.entity.IMotorCart) ILimitVelCart(club.nsdn.nyasamarailway.entity.ILimitVelCart) LocoBase(club.nsdn.nyasamarailway.entity.LocoBase) IExtendedInfoCart(club.nsdn.nyasamarailway.entity.IExtendedInfoCart)

Example 14 with LocoBase

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;
    }
}
Also used : RailMonoMagnetBase(club.nsdn.nyasamarailway.tileblock.rail.mono.RailMonoMagnetBase) LocoBase(club.nsdn.nyasamarailway.entity.LocoBase) NSC3BM(club.nsdn.nyasamarailway.entity.nsc.NSC3BM)

Example 15 with LocoBase

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);
                }
            }
        }
    }
}
Also used : LocoBase(club.nsdn.nyasamarailway.entity.LocoBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityMinecart(net.minecraft.entity.item.EntityMinecart) TrainPacket(club.nsdn.nyasamarailway.network.TrainPacket)

Aggregations

LocoBase (club.nsdn.nyasamarailway.entity.LocoBase)24 EntityMinecart (net.minecraft.entity.item.EntityMinecart)5 RailMonoMagnetBase (club.nsdn.nyasamarailway.tileblock.rail.mono.RailMonoMagnetBase)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 TrainPacket (club.nsdn.nyasamarailway.network.TrainPacket)3 IExtendedInfoCart (club.nsdn.nyasamarailway.entity.IExtendedInfoCart)2 ILimitVelCart (club.nsdn.nyasamarailway.entity.ILimitVelCart)2 IMotorCart (club.nsdn.nyasamarailway.entity.IMotorCart)2 MinecartBase (club.nsdn.nyasamarailway.entity.MinecartBase)2 Entity (net.minecraft.entity.Entity)2 ForgeChunkManager (net.minecraftforge.common.ForgeChunkManager)2 IRailReception (club.nsdn.nyasamarailway.block.rail.IRailReception)1 IHighSpeedCart (club.nsdn.nyasamarailway.entity.IHighSpeedCart)1 NSET1 (club.nsdn.nyasamarailway.entity.loco.NSET1)1 NSET2 (club.nsdn.nyasamarailway.entity.loco.NSET2)1 NSPCT10J (club.nsdn.nyasamarailway.entity.loco.NSPCT10J)1 NSPCT10M (club.nsdn.nyasamarailway.entity.loco.NSPCT10M)1 NSPCT4M (club.nsdn.nyasamarailway.entity.loco.NSPCT4M)1 NSPCT6L (club.nsdn.nyasamarailway.entity.loco.NSPCT6L)1 NSPCT7 (club.nsdn.nyasamarailway.entity.loco.NSPCT7)1