Search in sources :

Example 21 with LocoBase

use of club.nsdn.nyasamarailway.entity.LocoBase in project NyaSamaRailway by NSDN.

the class ItemNSPCT6L 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 NSPCT6L(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 : LocoBase(club.nsdn.nyasamarailway.entity.LocoBase) NSPCT6L(club.nsdn.nyasamarailway.entity.loco.NSPCT6L)

Example 22 with LocoBase

use of club.nsdn.nyasamarailway.entity.LocoBase in project NyaSamaRailway by NSDN.

the class ItemNSPCT8J 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 NSPCT8J(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 : NSPCT8J(club.nsdn.nyasamarailway.entity.loco.NSPCT8J) LocoBase(club.nsdn.nyasamarailway.entity.LocoBase)

Example 23 with LocoBase

use of club.nsdn.nyasamarailway.entity.LocoBase in project NyaSamaRailway by NSDN.

the class NSPCT6C method doSpawn.

public static void doSpawn(World world, int x, int y, int z, String name) {
    LocoBase head = new NSPCT6C(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 NSPCT6C.Container(world, (double) x + 0.5, (double) y + 0.5 - 2.0, (double) z + 0.5);
    world.spawnEntityInWorld(container);
    container.mountEntity(head);
}
Also used : MinecartBase(club.nsdn.nyasamarailway.entity.MinecartBase) LocoBase(club.nsdn.nyasamarailway.entity.LocoBase)

Example 24 with LocoBase

use of club.nsdn.nyasamarailway.entity.LocoBase in project NyaSamaRailway by NSDN.

the class ChunkLoaderHandler method ticketsLoaded.

@Override
public List<ForgeChunkManager.Ticket> ticketsLoaded(List<ForgeChunkManager.Ticket> tickets, World world, int maxTicketCount) {
    Set<ForgeChunkManager.Ticket> worldTickets = new HashSet<ForgeChunkManager.Ticket>();
    Set<ForgeChunkManager.Ticket> cartTickets = new HashSet<ForgeChunkManager.Ticket>();
    for (ForgeChunkManager.Ticket ticket : tickets) {
        Entity entity = ticket.getEntity();
        if (entity == null) {
            int y = ticket.getModData().getInteger("yCoord");
            if (y >= 0) {
                worldTickets.add(ticket);
            }
        } else {
            if (entity instanceof LocoBase) {
                cartTickets.add(ticket);
            }
        }
    }
    List<ForgeChunkManager.Ticket> claimedTickets = new LinkedList<ForgeChunkManager.Ticket>();
    claimedTickets.addAll(cartTickets);
    claimedTickets.addAll(worldTickets);
    return claimedTickets;
}
Also used : Entity(net.minecraft.entity.Entity) ForgeChunkManager(net.minecraftforge.common.ForgeChunkManager) LocoBase(club.nsdn.nyasamarailway.entity.LocoBase) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

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