use of club.nsdn.nyasamarailway.entity.loco.NSPCT8M in project NyaSamaRailway by NSDN.
the class NSPCT8MRenderer method doRenderHUD.
private void doRenderHUD(EntityMinecart cart) {
if (cart instanceof NSPCT8M) {
NSPCT8M loco = (NSPCT8M) cart;
float v = (float) loco.getEngineVel();
float lim = (float) loco.getMaxVelocity();
float a = v - (float) loco.getEnginePrevVel();
float angle;
int d = loco.getEngineDir(), p = loco.getEnginePower(), r = loco.getEngineBrake();
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 + (r <= 1 ? " STOP" : " 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();
}
}
use of club.nsdn.nyasamarailway.entity.loco.NSPCT8M in project NyaSamaRailway by NSDN.
the class ItemNSPCT8M 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 NSPCT8M(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;
}
}