Search in sources :

Example 1 with IExtendedInfoCart

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

the class NSCxRenderer method doRender.

@Override
public void doRender(EntityMinecart minecart, double x, double y, double z, float Yaw, float p_doRender_9_) {
    GL11.glPushMatrix();
    this.bindEntityTexture(minecart);
    long var10 = (long) minecart.getEntityId() * 493286711L;
    var10 = var10 * var10 * 4392167121L + var10 * 98761L;
    float var12 = (((float) (var10 >> 16 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
    float var13 = (((float) (var10 >> 20 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
    float var14 = (((float) (var10 >> 24 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
    GL11.glTranslatef(var12, var13, var14);
    double var15 = minecart.lastTickPosX + (minecart.posX - minecart.lastTickPosX) * (double) p_doRender_9_;
    double var17 = minecart.lastTickPosY + (minecart.posY - minecart.lastTickPosY) * (double) p_doRender_9_;
    double var19 = minecart.lastTickPosZ + (minecart.posZ - minecart.lastTickPosZ) * (double) p_doRender_9_;
    double var21 = 0.30000001192092896D;
    Vec3 var23 = minecart.func_70489_a(var15, var17, var19);
    float var24 = minecart.prevRotationPitch + (minecart.rotationPitch - minecart.prevRotationPitch) * p_doRender_9_;
    if (var23 != null) {
        Vec3 var25 = minecart.func_70495_a(var15, var17, var19, var21);
        Vec3 var26 = minecart.func_70495_a(var15, var17, var19, -var21);
        if (var25 == null) {
            var25 = var23;
        }
        if (var26 == null) {
            var26 = var23;
        }
        x += var23.xCoord - var15;
        y += (var25.yCoord + var26.yCoord) / 2.0D - var17;
        z += var23.zCoord - var19;
        Vec3 var27 = var26.addVector(-var25.xCoord, -var25.yCoord, -var25.zCoord);
        if (var27.lengthVector() != 0.0D) {
            var27 = var27.normalize();
            Yaw = (float) (Math.atan2(var27.zCoord, var27.xCoord) * 180.0D / 3.141592653589793D);
            var24 = (float) (Math.atan(var27.yCoord) * 73.0D);
        }
    }
    GL11.glTranslatef((float) x, (float) y, (float) z);
    GL11.glRotatef(180.0F - Yaw, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(-var24, 0.0F, 0.0F, 1.0F);
    float var31 = (float) minecart.getRollingAmplitude() - p_doRender_9_;
    float var32 = minecart.getDamage() - p_doRender_9_;
    if (var32 < 0.0F) {
        var32 = 0.0F;
    }
    if (var31 > 0.0F) {
        GL11.glRotatef(MathHelper.sin(var31) * var31 * var32 / 10.0F * (float) minecart.getRollingDirection(), 1.0F, 0.0F, 0.0F);
    }
    int var33 = minecart.getDisplayTileOffset();
    Block var28 = minecart.func_145820_n();
    int var29 = minecart.getDisplayTileData();
    if (var28.getRenderType() != -1) {
        GL11.glPushMatrix();
        this.bindTexture(TextureMap.locationBlocksTexture);
        float var30 = 0.75F;
        GL11.glScalef(var30, var30, var30);
        GL11.glTranslatef(0.0F, (float) var33 / 16.0F, 0.0F);
        this.func_147910_a(minecart, p_doRender_9_, var28, var29);
        GL11.glPopMatrix();
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        this.bindEntityTexture(minecart);
    }
    ResourceLocation print = texturePrint, jet = null;
    String str = "";
    if (minecart instanceof IExtendedInfoCart) {
        IExtendedInfoCart cart = (IExtendedInfoCart) minecart;
        String info = cart.getExtendedInfo("side");
        if (!info.isEmpty())
            print = new ResourceLocation("nsr", "pics/" + info + ".png");
        info = cart.getExtendedInfo("jet");
        if (!info.isEmpty())
            jet = new ResourceLocation("nsr", "pics/" + info + ".png");
        str = cart.getExtendedInfo("str");
    }
    GL11.glPushMatrix();
    if (minecart instanceof IMonoRailCart)
        GL11.glTranslated(0.0, -((IMonoRailCart) minecart).getShiftY() - 1.3125, 0.0);
    RendererHelper.beginSpecialLighting();
    if (minecart instanceof IRotaCart) {
        IRotaCart rotaCart = (IRotaCart) minecart;
        float angle = rotaCart.getAngle() + 1;
        rotaCart.setAngle(angle);
        if (minecart.riddenByEntity != null)
            angle = 90.0F;
        RendererHelper.renderPartWithResourceAndRotation(modelBase, "Top", angle, textureBase);
        RendererHelper.renderOtherPartWithResourceAndRotation(modelBase, "Top", 90.0F, textureBase);
    } else
        RendererHelper.renderWithResourceAndRotation(modelBase, 90.0F, textureBase);
    RendererHelper.endSpecialLighting();
    if (modelPrint != null)
        RendererHelper.renderWithResourceAndRotation(modelPrint, 90.0F, print);
    if (minecart.riddenByEntity != null) {
        if (minecart.riddenByEntity instanceof EntityPlayer) {
            if (jet != null)
                RendererHelper.renderWithResourceAndRotation(modelJet, -90.0F, jet);
            boolean shouldRenderHUD = false;
            EntityPlayer player = (EntityPlayer) minecart.riddenByEntity;
            if (player.getCurrentEquippedItem() != null) {
                if (player.getCurrentEquippedItem().getItem() instanceof ItemToolBase) {
                    shouldRenderHUD = true;
                }
            }
            GL11.glPushMatrix();
            GL11.glRotatef(180.0F - Yaw, 0.0F, -1.0F, 0.0F);
            GL11.glRotated(90.0 - player.rotationYaw, 0, 1, 0);
            GL11.glTranslated(0, 0.125, 0);
            if (shouldRenderHUD)
                renderHUD(minecart);
            else
                renderStr(str);
            GL11.glPopMatrix();
        }
    }
    GL11.glPopMatrix();
    GL11.glPopMatrix();
}
Also used : IExtendedInfoCart(club.nsdn.nyasamarailway.entity.IExtendedInfoCart) ItemToolBase(club.nsdn.nyasamarailway.item.tool.ItemToolBase) IRotaCart(club.nsdn.nyasamarailway.entity.nsc.IRotaCart) IMonoRailCart(club.nsdn.nyasamarailway.entity.nsc.IMonoRailCart) Vec3(net.minecraft.util.Vec3) ResourceLocation(net.minecraft.util.ResourceLocation) Block(net.minecraft.block.Block) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 2 with IExtendedInfoCart

use of club.nsdn.nyasamarailway.entity.IExtendedInfoCart 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 3 with IExtendedInfoCart

use of club.nsdn.nyasamarailway.entity.IExtendedInfoCart 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 4 with IExtendedInfoCart

use of club.nsdn.nyasamarailway.entity.IExtendedInfoCart 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 5 with IExtendedInfoCart

use of club.nsdn.nyasamarailway.entity.IExtendedInfoCart 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)

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