Search in sources :

Example 11 with IExtendedInfoCart

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

the class ItemNSPCT9M 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) {
            NSPCT9M cart = new NSPCT9M(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5);
            if (itemStack.hasDisplayName()) {
                cart.setMinecartName(itemStack.getDisplayName());
            }
            ItemStack stack;
            for (int i = 0; i < 9; i++) {
                stack = player.inventory.mainInventory[i];
                if (stack == null)
                    continue;
                if (stack.getItem() == null)
                    continue;
                if (stack.getItem() instanceof NGTablet) {
                    NBTTagList list = Util.getTagListFromNGT(stack);
                    if (list != null) {
                        String[][] code = NSASM.getCode(list);
                        new ExtInfoCore(code) {

                            @Override
                            public World getWorld() {
                                return world;
                            }

                            @Override
                            public double getX() {
                                return x;
                            }

                            @Override
                            public double getY() {
                                return y;
                            }

                            @Override
                            public double getZ() {
                                return z;
                            }

                            @Override
                            public EntityPlayer getPlayer() {
                                return player;
                            }

                            @Override
                            public IExtendedInfoCart getCart() {
                                return cart;
                            }
                        }.run();
                    }
                }
            }
            world.spawnEntityInWorld(cart);
        }
        --itemStack.stackSize;
        return true;
    } else {
        return false;
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) EntityPlayer(net.minecraft.entity.player.EntityPlayer) IExtendedInfoCart(club.nsdn.nyasamarailway.entity.IExtendedInfoCart) ItemStack(net.minecraft.item.ItemStack) World(net.minecraft.world.World) NGTablet(club.nsdn.nyasamatelecom.api.tool.NGTablet) NSPCT9M(club.nsdn.nyasamarailway.entity.loco.NSPCT9M) ExtInfoCore(club.nsdn.nyasamarailway.util.ExtInfoCore)

Example 12 with IExtendedInfoCart

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

the class ItemNSC2AM 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) {
            NSC2AM cart = new NSC2AM(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5);
            if (itemStack.hasDisplayName()) {
                cart.setMinecartName(itemStack.getDisplayName());
            }
            ItemStack stack;
            for (int i = 0; i < 9; i++) {
                stack = player.inventory.mainInventory[i];
                if (stack == null)
                    continue;
                if (stack.getItem() == null)
                    continue;
                if (stack.getItem() instanceof NGTablet) {
                    NBTTagList list = Util.getTagListFromNGT(stack);
                    if (list != null) {
                        String[][] code = NSASM.getCode(list);
                        new ExtInfoCore(code) {

                            @Override
                            public World getWorld() {
                                return world;
                            }

                            @Override
                            public double getX() {
                                return x;
                            }

                            @Override
                            public double getY() {
                                return y;
                            }

                            @Override
                            public double getZ() {
                                return z;
                            }

                            @Override
                            public EntityPlayer getPlayer() {
                                return player;
                            }

                            @Override
                            public IExtendedInfoCart getCart() {
                                return cart;
                            }
                        }.run();
                    }
                }
            }
            world.spawnEntityInWorld(cart);
        }
        --itemStack.stackSize;
        return true;
    } else {
        return false;
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) EntityPlayer(net.minecraft.entity.player.EntityPlayer) IExtendedInfoCart(club.nsdn.nyasamarailway.entity.IExtendedInfoCart) NSC2AM(club.nsdn.nyasamarailway.entity.nsc.NSC2AM) ItemStack(net.minecraft.item.ItemStack) World(net.minecraft.world.World) NGTablet(club.nsdn.nyasamatelecom.api.tool.NGTablet) ExtInfoCore(club.nsdn.nyasamarailway.util.ExtInfoCore)

Aggregations

IExtendedInfoCart (club.nsdn.nyasamarailway.entity.IExtendedInfoCart)12 EntityPlayer (net.minecraft.entity.player.EntityPlayer)10 ExtInfoCore (club.nsdn.nyasamarailway.util.ExtInfoCore)8 NGTablet (club.nsdn.nyasamatelecom.api.tool.NGTablet)8 ItemStack (net.minecraft.item.ItemStack)8 NBTTagList (net.minecraft.nbt.NBTTagList)8 World (net.minecraft.world.World)8 ILimitVelCart (club.nsdn.nyasamarailway.entity.ILimitVelCart)2 IMotorCart (club.nsdn.nyasamarailway.entity.IMotorCart)2 LocoBase (club.nsdn.nyasamarailway.entity.LocoBase)2 IMonoRailCart (club.nsdn.nyasamarailway.entity.nsc.IMonoRailCart)2 IRotaCart (club.nsdn.nyasamarailway.entity.nsc.IRotaCart)2 ItemToolBase (club.nsdn.nyasamarailway.item.tool.ItemToolBase)2 Block (net.minecraft.block.Block)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 Vec3 (net.minecraft.util.Vec3)2 NSPCT9 (club.nsdn.nyasamarailway.entity.cart.NSPCT9)1 NSPCT9M (club.nsdn.nyasamarailway.entity.loco.NSPCT9M)1 NSC1A (club.nsdn.nyasamarailway.entity.nsc.NSC1A)1 NSC1AM (club.nsdn.nyasamarailway.entity.nsc.NSC1AM)1