Search in sources :

Example 1 with NSPCT8J

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

the class EntityInteractHandler method onEntityInteract.

@SubscribeEvent
public void onEntityInteract(EntityInteractEvent event) {
    if (event.entityLiving instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.entityLiving;
        if (player.worldObj.isRemote)
            return;
        Entity entity = event.target;
        ItemStack stack = player.getCurrentEquippedItem();
        if (stack != null) {
            if (stack.getItem() instanceof ItemNTP8Bit) {
                if (player.isSneaking()) {
                    ((ItemNTP8Bit) stack.getItem()).clearCart(stack, player);
                    return;
                }
                if (entity instanceof EntityMinecart) {
                    ((ItemNTP8Bit) stack.getItem()).addCart(stack, player, entity);
                }
            } else if (stack.getItem() instanceof ItemNTP32Bit) {
                if (player.isSneaking()) {
                    ((ItemNTP32Bit) stack.getItem()).clearCart(stack, player);
                    return;
                }
                if (entity instanceof EntityMinecart) {
                    ((ItemNTP32Bit) stack.getItem()).addCart(stack, player, entity);
                } else {
                    if (ExRollerCoaster.getInstance() != null) {
                        if (ExRollerCoaster.getInstance().verifyEntity(entity)) {
                            ((ItemNTP32Bit) stack.getItem()).addCart(stack, player, entity);
                        }
                    }
                    if (RailsOfWar.getInstance() != null) {
                        if (RailsOfWar.getInstance().verifyEntity(entity)) {
                            ((ItemNTP32Bit) stack.getItem()).addCart(stack, player, entity);
                        }
                    }
                }
            } else if (stack.getItem() instanceof Item1N4148) {
                if (entity instanceof NSPCT8J) {
                    NSPCT8J loco = (NSPCT8J) entity;
                    loco.modifyHighSpeedMode(player);
                }
            } else if (stack.getItem() instanceof ItemNSPCT5) {
                if (entity instanceof NSPCT5) {
                    ((NSPCT5) entity).modifyLength();
                }
            } else if (stack.getItem() instanceof ItemNSPCT5L) {
                if (entity instanceof NSPCT5L) {
                    ((NSPCT5L) entity).modifyLength();
                }
            }
        }
    }
}
Also used : ItemNTP32Bit(club.nsdn.nyasamarailway.item.tool.ItemNTP32Bit) Entity(net.minecraft.entity.Entity) ItemNTP8Bit(club.nsdn.nyasamarailway.item.tool.ItemNTP8Bit) NSPCT8J(club.nsdn.nyasamarailway.entity.loco.NSPCT8J) Item1N4148(club.nsdn.nyasamarailway.item.tool.Item1N4148) NSPCT5(club.nsdn.nyasamarailway.entity.cart.NSPCT5) ItemNSPCT5(club.nsdn.nyasamarailway.item.cart.ItemNSPCT5) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) NSPCT5L(club.nsdn.nyasamarailway.entity.cart.NSPCT5L) ItemNSPCT5L(club.nsdn.nyasamarailway.item.cart.ItemNSPCT5L) EntityMinecart(net.minecraft.entity.item.EntityMinecart) ItemNSPCT5L(club.nsdn.nyasamarailway.item.cart.ItemNSPCT5L) ItemNSPCT5(club.nsdn.nyasamarailway.item.cart.ItemNSPCT5) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 2 with NSPCT8J

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

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

Example 3 with NSPCT8J

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

the class NSPCT8JRenderer method doRenderHUD.

private void doRenderHUD(EntityMinecart cart) {
    if (cart instanceof NSPCT8J) {
        NSPCT8J loco = (NSPCT8J) cart;
        float v = (float) loco.getEngineVel();
        float a = v - (float) loco.getEnginePrevVel();
        float angle;
        int d = loco.getEngineDir(), p = loco.getEnginePower(), r = loco.getEngineBrake();
        boolean high = loco.getHighSpeedMode();
        RendererHelper.renderPartWithResource(modelScreen, "base", textureScreen);
        String dir = d == 1 ? "F" : (d == 0 ? "N" : "R");
        String pwr = String.format("%2d", p);
        String brk = String.format("%2d", 10 - r);
        String sv = String.format("%1.2f", v);
        String sa = String.format("%1.2f", a * 100);
        // HUD1406
        doRenderText(0, "-= NSR--NTP =-");
        doRenderText(1, "dir:  " + dir);
        doRenderText(2, "pwr: " + pwr + (r <= 1 ? " STOP" : (high ? " HIGH" : "  RUN")));
        doRenderText(3, "brk: " + brk + (r == 1 ? " EME" : ""));
        doRenderText(4, "vel:" + sv + "m/t");
        doRenderText(5, "acc:" + sa + "cm/t2");
        RendererHelper.renderWithResource(modelMeterV, textureMeterV);
        angle = v / 6.0F * ANGLE_HALF * 2 - ANGLE_HALF;
        if (angle > ANGLE_HALF)
            angle = ANGLE_HALF;
        GL11.glPushMatrix();
        GL11.glTranslatef(0.625F, 0.9375F, -0.625F);
        GL11.glTranslatef(-0.00625F, 0.0F, 0.00625F);
        GL11.glPushMatrix();
        GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
        GL11.glPushMatrix();
        GL11.glRotatef(angle, 1.0F, 0.0F, 0.0F);
        RendererHelper.renderWithResource(modelMeterPointer, textureMeterPointer);
        GL11.glPopMatrix();
        GL11.glPopMatrix();
        GL11.glPopMatrix();
        RendererHelper.renderWithResource(modelMeterA, textureMeterA);
        angle = a / 0.03F * ANGLE_HALF;
        if (Math.abs(angle) > ANGLE_HALF)
            angle = Math.signum(angle) * ANGLE_HALF;
        GL11.glPushMatrix();
        GL11.glTranslatef(0.625F, 0.9375F, 0.625F);
        GL11.glTranslatef(-0.00625F, 0.0F, -0.00625F);
        GL11.glPushMatrix();
        GL11.glRotatef(-45.0F, 0.0F, 1.0F, 0.0F);
        GL11.glPushMatrix();
        GL11.glRotatef(angle, 1.0F, 0.0F, 0.0F);
        RendererHelper.renderWithResource(modelMeterPointer, textureMeterPointer);
        GL11.glPopMatrix();
        GL11.glPopMatrix();
        GL11.glPopMatrix();
    }
}
Also used : NSPCT8J(club.nsdn.nyasamarailway.entity.loco.NSPCT8J)

Aggregations

NSPCT8J (club.nsdn.nyasamarailway.entity.loco.NSPCT8J)3 LocoBase (club.nsdn.nyasamarailway.entity.LocoBase)1 NSPCT5 (club.nsdn.nyasamarailway.entity.cart.NSPCT5)1 NSPCT5L (club.nsdn.nyasamarailway.entity.cart.NSPCT5L)1 ItemNSPCT5 (club.nsdn.nyasamarailway.item.cart.ItemNSPCT5)1 ItemNSPCT5L (club.nsdn.nyasamarailway.item.cart.ItemNSPCT5L)1 Item1N4148 (club.nsdn.nyasamarailway.item.tool.Item1N4148)1 ItemNTP32Bit (club.nsdn.nyasamarailway.item.tool.ItemNTP32Bit)1 ItemNTP8Bit (club.nsdn.nyasamarailway.item.tool.ItemNTP8Bit)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 Entity (net.minecraft.entity.Entity)1 EntityMinecart (net.minecraft.entity.item.EntityMinecart)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1