use of am2.api.power.IPowerNode in project ArsMagica2 by Mithion.
the class AMClientEventHandler method renderPowerFloatingText.
private void renderPowerFloatingText(DrawBlockHighlightEvent event, TileEntity te) {
PowerNodeEntry data = AMCore.proxy.getTrackedData();
Block block = event.player.worldObj.getBlock(event.target.blockX, event.target.blockY, event.target.blockZ);
float yOff = 0.5f;
if (data != null) {
GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_LIGHTING_BIT);
for (PowerTypes type : ((IPowerNode) te).getValidPowerTypes()) {
float pwr = data.getPower(type);
float pct = pwr / ((IPowerNode) te).getCapacity() * 100;
AMVector3 offset = new AMVector3(event.target.blockX + 0.5, event.target.blockY + 0.5, event.target.blockZ + 0.5).sub(new AMVector3((event.player.prevPosX - (event.player.prevPosX - event.player.posX) * event.partialTicks), (event.player.prevPosY - (event.player.prevPosY - event.player.posY) * event.partialTicks) + event.player.getEyeHeight(), (event.player.prevPosZ - (event.player.prevPosZ - event.player.posZ) * event.partialTicks)));
offset = offset.normalize();
if (event.target.blockY <= event.player.posY - 0.5) {
RenderUtilities.drawTextInWorldAtOffset(String.format("%s%.2f (%.2f%%)", type.chatColor(), pwr, pct), event.target.blockX - (event.player.prevPosX - (event.player.prevPosX - event.player.posX) * event.partialTicks) + 0.5f - offset.x, event.target.blockY + yOff - (event.player.prevPosY - (event.player.prevPosY - event.player.posY) * event.partialTicks) + block.getBlockBoundsMaxY() * 0.8f, event.target.blockZ - (event.player.prevPosZ - (event.player.prevPosZ - event.player.posZ) * event.partialTicks) + 0.5f - offset.z, 0xFFFFFF);
yOff += 0.12f;
} else {
RenderUtilities.drawTextInWorldAtOffset(String.format("%s%.2f (%.2f%%)", type.chatColor(), pwr, pct), event.target.blockX - (event.player.prevPosX - (event.player.prevPosX - event.player.posX) * event.partialTicks) + 0.5f - offset.x, event.target.blockY - yOff - (event.player.prevPosY - (event.player.prevPosY - event.player.posY) * event.partialTicks) - block.getBlockBoundsMaxY() * 0.2f, event.target.blockZ - (event.player.prevPosZ - (event.player.prevPosZ - event.player.posZ) * event.partialTicks) + 0.5f - offset.z, 0xFFFFFF);
yOff -= 0.12f;
}
}
GL11.glPopAttrib();
}
}
use of am2.api.power.IPowerNode in project ArsMagica2 by Mithion.
the class ItemSpellStaff method onItemUseFirst.
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
if (isMagiTechStaff()) {
if (!world.isRemote) {
TileEntity te = world.getTileEntity(x, y, z);
if (te != null && te instanceof IPowerNode) {
if (player.isSneaking()) {
AMNetHandler.INSTANCE.syncPowerPaths((IPowerNode) te, (EntityPlayerMP) player);
} else {
PowerTypes[] types = ((IPowerNode) te).getValidPowerTypes();
for (PowerTypes type : types) {
float power = PowerNodeRegistry.For(world).getPower((IPowerNode) te, type);
player.addChatMessage(new ChatComponentText(String.format(StatCollector.translateToLocal("am2.tooltip.det_eth"), type.chatColor(), type.name(), String.format("%.2f", power))));
}
}
return true;
}
}
}
return false;
}
Aggregations