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();
}
}
}
}
}
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;
}
}
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();
}
}
Aggregations