Search in sources :

Example 1 with NSPCT8

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

the class NSPCT8Renderer method doRenderHUD.

private void doRenderHUD(EntityMinecart cart) {
    if (cart instanceof NSPCT8) {
        NSPCT8 loco = (NSPCT8) cart;
        float v = (float) loco.getMotorVel();
        float lim = (float) loco.getMaxVelocity();
        float a = Math.signum(v) / 3;
        float angle;
        int d = loco.getMotorDir(), p = loco.getMotorPower(), r = loco.getMotorBrake();
        boolean isOff = !loco.getMotorState();
        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 sl = String.format("%1.2f", lim);
        // HUD1406
        doRenderText(0, "-= NSR--NTP =-");
        doRenderText(1, "dir:  " + dir);
        doRenderText(2, "pwr: " + pwr + (isOff ? " IDLE" : "  RUN"));
        doRenderText(3, "brk: " + brk + (r == 1 ? " EME" : ""));
        doRenderText(4, "vel:" + sv + "m/t");
        doRenderText(5, "lim:" + sl + "m/t");
        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 : NSPCT8(club.nsdn.nyasamarailway.entity.cart.NSPCT8)

Example 2 with NSPCT8

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

the class ItemNSPCT8 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) {
            MinecartBase entityminecart = new NSPCT8(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 : MinecartBase(club.nsdn.nyasamarailway.entity.MinecartBase) NSPCT8(club.nsdn.nyasamarailway.entity.cart.NSPCT8)

Aggregations

NSPCT8 (club.nsdn.nyasamarailway.entity.cart.NSPCT8)2 MinecartBase (club.nsdn.nyasamarailway.entity.MinecartBase)1