String str0 = "No link";
String str1 = "";
String str2 = "";
String str3 = "";
String str4 = "";
Render renderEntity = null;
Entity entity = null;
float Xmargin = 0;
if (telemeter != null && telemeter.clientData.length >= 3)
{
if (telemeter.clientClass != null)
{
if (telemeter.clientClass == screen.telemetryLastClass && (telemeter.clientClass != EntityPlayerMP.class || telemeter.clientName.equals(screen.telemetryLastName)))
{
//Used cached data from last time if possible
entity = screen.telemetryLastEntity;
renderEntity = screen.telemetryLastRender;
strName = screen.telemetryLastName;
}
else
{
//Create an entity to render, based on class, and get its name
entity = null;
if (telemeter.clientClass == EntityPlayerMP.class)
{
strName = telemeter.clientName;
entity = new EntityOtherPlayerMP(screen.driver.getWorldObj(), telemeter.clientGameProfile);
renderEntity = (Render) RenderManager.instance.entityRenderMap.get(EntityPlayer.class);
}
else
{
try {
entity = (Entity) telemeter.clientClass.getConstructor(World.class).newInstance(screen.driver.getWorldObj());
} catch (Exception ex) { }
if (entity != null) strName = entity.getCommandSenderName();
renderEntity = (Render) RenderManager.instance.entityRenderMap.get(telemeter.clientClass);
}
}
}
if (entity instanceof EntityLivingBase)
{
//Living entity:
// data0 = time to show red damage
// data1 = health in half-hearts
// data2 = pulse
// data3 = hunger
// data4 = oxygen
str0 = telemeter.clientData[0] > 0 ? "ouch!!!!" : "";
if (telemeter.clientData[1] >= 0)
{
str1 = "Health: " + telemeter.clientData[1] + "%";
}
else
str1 = "";
str2 = "" + telemeter.clientData[2] + " bpm";
if (telemeter.clientData[3] > -1)
{
str3 = "Food: " + telemeter.clientData[3] + "%";
}
if (telemeter.clientData[4] > -1)
{
int oxygen = telemeter.clientData[4];
oxygen = (oxygen % 4096) + (oxygen / 4096);
if (oxygen == 180 || oxygen == 90)
str4 = "Oxygen: OK";
else
str4 = "Oxygen: " + this.makeOxygenString(oxygen) + GCCoreUtil.translate("gui.seconds");
}
}
else if (entity instanceof EntitySpaceshipBase)
{
//Spaceships:
// data0 = launch countdown
// data1 = height
// data2 = speed
// data3 = fuel remaining
// data4 = pitch angle
int countdown = telemeter.clientData[0];
str0 = "";
str1 = (countdown == 400) ? "On launchpad" : ((countdown > 0) ? "Countdown: " + countdown / 20 : "Launched");
str2 = "Height: " + telemeter.clientData[1];
str3 = "Speed: " + this.makeSpeedString(telemeter.clientData[2]);
str4 = "Fuel: " + telemeter.clientData[3] + "%";
}
else
//Generic - could be boats or minecarts etc - just show the speed
//TODO can add more here, e.g. position data?
if (telemeter.clientData[2] >= 0)
{
str2 = "Speed: " + makeSpeedString(telemeter.clientData[2]);
}
}
else
{
//Default - draw a simple time display just to show the Display Screen is working
World w1 = screen.driver.getWorldObj();
int time1 = w1 != null ? (int) ((w1.getWorldTime() + 6000L) % 24000L) : 0;
str2 = makeTimeString(time1 * 360);
}
int textWidthPixels = 155;
int textHeightPixels = 60; //1 lines
if (str3.isEmpty()) textHeightPixels -= 10;
if (str4.isEmpty()) textHeightPixels -= 10;
//First pass - approximate border size
float borders = frameA * 2 + 0.05F * Math.min(sizeX, sizeY);
float scaleXTest = (sizeX - borders) / textWidthPixels;
float scaleYTest = (sizeY - borders) / textHeightPixels;
float scale = sizeX;
if (scaleYTest < scaleXTest)
scale = sizeY;
//Second pass - the border size may be more accurate now
borders = frameA * 2 + 0.05F * scale;
scaleXTest = (sizeX - borders) / textWidthPixels;
scaleYTest = (sizeY - borders) / textHeightPixels;
scale = sizeX;
float scaleText = scaleXTest;
if (scaleYTest < scaleXTest)
{
scale = sizeY;
scaleText = scaleYTest;
}
//Centre the text in the display
float border = frameA + 0.025F * scale;
if (entity != null && renderEntity != null) Xmargin = (sizeX - borders) / 2;
float Xoffset = (sizeX - borders - textWidthPixels * scaleText) / 2 + Xmargin;
float Yoffset = (sizeY - borders - textHeightPixels * scaleText) / 2 + scaleText;
GL11.glTranslatef(border + Xoffset, border + Yoffset, 0.0F);
GL11.glScalef(scaleText, scaleText, 1.0F);
//Actually draw the text
int whiteColour = GCCoreUtil.to32BitColor(255, 240, 216, 255);
drawText(strName, whiteColour);
drawText(str0, whiteColour);
drawText(str1, whiteColour);
drawText(str2, whiteColour);
drawText(str3, whiteColour);
drawText(str4, whiteColour);
//If there is an entity to render, draw it on the left of the text
if (renderEntity != null && entity != null )
{
GL11.glTranslatef(-Xmargin / 2 / scaleText, textHeightPixels / 2 + (-Yoffset + (sizeY - borders) / 2) / scaleText, -0.0005F);
float scalefactor = 38F / (float) Math.pow(Math.max(entity.height, entity.width), 0.65);
GL11.glScalef(scalefactor, scalefactor, 0.0015F);
GL11.glRotatef(180F, 0, 0, 1);
GL11.glRotatef(180F, 0, 1, 0);
if (entity instanceof EntitySpaceshipBase)
{
GL11.glRotatef(telemeter.clientData[4], -1, 0, 0);
GL11.glTranslatef(0, entity.height / 4, 0);
}
RenderPlayerGC.flagThermalOverride = true;
renderEntity.doRender(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F);
RenderPlayerGC.flagThermalOverride = false;
}
//TODO Cross-dimensional tracking (i.e. old entity setDead, new entity created)
//TODO Deal with text off screen (including where localizations longer than English)