Search in sources :

Example 16 with LocoBase

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

the class ItemNTP32Bit method addCart.

public void addCart(ItemStack itemStack, EntityPlayer player, Entity entity) {
    if (entity instanceof LocoBase) {
        player.addChatComponentMessage(new ChatComponentTranslation("info.ntp.error"));
        return;
    }
    int[] array = carts.get(itemStack);
    ArrayList<Integer> list = new ArrayList<>();
    for (int i : array) list.add(i);
    int id = entity.getEntityId();
    if (!list.contains(id)) {
        list.add(id);
        player.addChatComponentMessage(new ChatComponentTranslation("info.ntp.controlled"));
    }
    array = new int[list.size()];
    for (int i = 0; i < list.size(); i++) array[i] = list.get(i);
    carts.set(itemStack, array);
}
Also used : ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) LocoBase(club.nsdn.nyasamarailway.entity.LocoBase) ArrayList(java.util.ArrayList)

Example 17 with LocoBase

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

the class ItemNSPCT8M 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 NSPCT8M(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) NSPCT8M(club.nsdn.nyasamarailway.entity.loco.NSPCT8M)

Example 18 with LocoBase

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

the class ItemNSET2 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 NSET2(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) NSET2(club.nsdn.nyasamarailway.entity.loco.NSET2)

Example 19 with LocoBase

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

the class ItemNSPCT10M 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 NSPCT10M(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) NSPCT10M(club.nsdn.nyasamarailway.entity.loco.NSPCT10M)

Example 20 with LocoBase

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

the class ItemNSET1 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 NSET1(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) NSET1(club.nsdn.nyasamarailway.entity.loco.NSET1)

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