Search in sources :

Example 6 with LocoBase

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

the class ItemNSC1BM 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 NSC1BM(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 : NSC1BM(club.nsdn.nyasamarailway.entity.nsc.NSC1BM) RailMonoMagnetBase(club.nsdn.nyasamarailway.tileblock.rail.mono.RailMonoMagnetBase) LocoBase(club.nsdn.nyasamarailway.entity.LocoBase)

Example 7 with LocoBase

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

the class ItemNSC2BM 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 NSC2BM(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 : NSC2BM(club.nsdn.nyasamarailway.entity.nsc.NSC2BM) RailMonoMagnetBase(club.nsdn.nyasamarailway.tileblock.rail.mono.RailMonoMagnetBase) LocoBase(club.nsdn.nyasamarailway.entity.LocoBase)

Example 8 with LocoBase

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

the class NTPCtrlHandler method tick.

@SubscribeEvent
public void tick(TickEvent.ClientTickEvent event) {
    EntityPlayer player = Minecraft.getMinecraft().thePlayer;
    if (player == null)
        return;
    if (PacketStCHandler.player == null)
        PacketStCHandler.player = player;
    if (Minecraft.getMinecraft().currentScreen instanceof GuiChat)
        return;
    ItemStack stack = player.getCurrentEquippedItem();
    if (stack != null) {
        TrainPacket packet = new TrainPacket();
        if (stack.getItem() instanceof ItemNTP8Bit) {
            ItemNTP8Bit ntp8Bit = (ItemNTP8Bit) stack.getItem();
            packet.fromStack(stack);
            EntityMinecart cart = packet.getCartInClient(ntp8Bit.cart.get(stack));
            if (cart != null) {
                if (cart instanceof LocoBase) {
                    TrainController.doControl(packet, player);
                    NetworkWrapper.instance.sendToServer(packet);
                    packet.toStack(stack);
                    return;
                }
                TrainController.doControl(packet, player);
                NetworkWrapper.instance.sendToServer(packet);
                packet.toStack(stack);
            }
        } else if (stack.getItem() instanceof ItemNTP32Bit) {
            ItemNTP32Bit ntp32Bit = (ItemNTP32Bit) stack.getItem();
            packet.fromStack(stack);
            int[] carts = ntp32Bit.carts.get(stack);
            if (carts.length == 1 && carts[0] == -1)
                return;
            TrainController.doControl(packet, player);
            NetworkWrapper.instance.sendToServer(packet);
            packet.toStack(stack);
        }
    }
}
Also used : ItemNTP32Bit(club.nsdn.nyasamarailway.item.tool.ItemNTP32Bit) ItemNTP8Bit(club.nsdn.nyasamarailway.item.tool.ItemNTP8Bit) LocoBase(club.nsdn.nyasamarailway.entity.LocoBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) GuiChat(net.minecraft.client.gui.GuiChat) ItemStack(net.minecraft.item.ItemStack) EntityMinecart(net.minecraft.entity.item.EntityMinecart) TrainPacket(club.nsdn.nyasamarailway.network.TrainPacket) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 9 with LocoBase

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

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

Example 10 with LocoBase

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

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

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