Search in sources :

Example 1 with ExtInfoCore

use of club.nsdn.nyasamarailway.util.ExtInfoCore in project NyaSamaRailway by NSDN.

the class ItemNSC1AM 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) {
            NSC1AM cart = new NSC1AM(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) NSC1AM(club.nsdn.nyasamarailway.entity.nsc.NSC1AM) 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) ExtInfoCore(club.nsdn.nyasamarailway.util.ExtInfoCore)

Example 2 with ExtInfoCore

use of club.nsdn.nyasamarailway.util.ExtInfoCore in project NyaSamaRailway by NSDN.

the class ItemNSC3A 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) {
            NSC3A cart = new NSC3A(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) NSC3A(club.nsdn.nyasamarailway.entity.nsc.NSC3A) NGTablet(club.nsdn.nyasamatelecom.api.tool.NGTablet) ExtInfoCore(club.nsdn.nyasamarailway.util.ExtInfoCore)

Example 3 with ExtInfoCore

use of club.nsdn.nyasamarailway.util.ExtInfoCore in project NyaSamaRailway by NSDN.

the class ItemNSPCT9 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) {
            NSPCT9 cart = new NSPCT9(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) NSPCT9(club.nsdn.nyasamarailway.entity.cart.NSPCT9) ItemStack(net.minecraft.item.ItemStack) World(net.minecraft.world.World) NGTablet(club.nsdn.nyasamatelecom.api.tool.NGTablet) ExtInfoCore(club.nsdn.nyasamarailway.util.ExtInfoCore)

Example 4 with ExtInfoCore

use of club.nsdn.nyasamarailway.util.ExtInfoCore in project NyaSamaRailway by NSDN.

the class ItemNSC1A 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) {
            NSC1A cart = new NSC1A(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) NSC1A(club.nsdn.nyasamarailway.entity.nsc.NSC1A) ExtInfoCore(club.nsdn.nyasamarailway.util.ExtInfoCore)

Example 5 with ExtInfoCore

use of club.nsdn.nyasamarailway.util.ExtInfoCore in project NyaSamaRailway by NSDN.

the class ItemNSC3AM 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) {
            NSC3AM cart = new NSC3AM(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) NSC3AM(club.nsdn.nyasamarailway.entity.nsc.NSC3AM) 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)8 ExtInfoCore (club.nsdn.nyasamarailway.util.ExtInfoCore)8 NGTablet (club.nsdn.nyasamatelecom.api.tool.NGTablet)8 EntityPlayer (net.minecraft.entity.player.EntityPlayer)8 ItemStack (net.minecraft.item.ItemStack)8 NBTTagList (net.minecraft.nbt.NBTTagList)8 World (net.minecraft.world.World)8 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 NSC2A (club.nsdn.nyasamarailway.entity.nsc.NSC2A)1 NSC2AM (club.nsdn.nyasamarailway.entity.nsc.NSC2AM)1 NSC3A (club.nsdn.nyasamarailway.entity.nsc.NSC3A)1 NSC3AM (club.nsdn.nyasamarailway.entity.nsc.NSC3AM)1