wasliebob

?

Apr 13th, 2014
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. package thaumcraftextras.handlers.events;
  2.  
  3. import java.awt.Color;
  4.  
  5. import net.minecraft.client.Minecraft;
  6. import net.minecraft.client.gui.FontRenderer;
  7. import net.minecraft.client.gui.ScaledResolution;
  8. import net.minecraft.entity.player.EntityPlayer;
  9. import net.minecraft.tileentity.TileEntity;
  10. import net.minecraftforge.client.event.RenderGameOverlayEvent;
  11.  
  12. import org.lwjgl.opengl.GL11;
  13.  
  14. import thaumcraftextras.api.misc.MagicEnergyTile;
  15. import thaumcraftextras.blocks.tiles.TileEntityMagicWandCharger;
  16. import thaumcraftextras.items.ItemMagicEnergyReader;
  17. import wasliecore.helpers.ColorHelper;
  18. import cpw.mods.fml.common.eventhandler.SubscribeEvent;
  19. import cpw.mods.fml.relauncher.Side;
  20. import cpw.mods.fml.relauncher.SideOnly;
  21.  
  22. public class PlayerRenderTick{
  23.  
  24. @SideOnly(Side.CLIENT)
  25. @SubscribeEvent
  26. public void playerRender(RenderGameOverlayEvent.Post event){
  27. if(Minecraft.getMinecraft().thePlayer != null){
  28. Minecraft mc = Minecraft.getMinecraft();
  29. EntityPlayer player = Minecraft.getMinecraft().thePlayer ;
  30. if(player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemMagicEnergyReader){
  31. if(mc.renderViewEntity != null && mc.renderViewEntity.rayTrace(200, 1.0F) != null){
  32. int blockX = mc.renderViewEntity.rayTrace(200, 1.0F).blockX;
  33. int blockY = mc.renderViewEntity.rayTrace(200, 1.0F).blockY;
  34. int blockZ = mc.renderViewEntity.rayTrace(200, 1.0F).blockZ;
  35. TileEntity tile = player.worldObj.getTileEntity(blockX, blockY, blockZ);
  36. if(tile != null){
  37. if(tile instanceof MagicEnergyTile){
  38. MagicEnergyTile magic = (MagicEnergyTile)tile;
  39. ScaledResolution res = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
  40. int width = res.getScaledWidth();
  41. int height = res.getScaledHeight();
  42. FontRenderer font = mc.fontRenderer;
  43. int stringLengthX = (width - font.getStringWidth("Energy Stored: 00")) / 2;
  44. int stringLengthY = height - 60;
  45. GL11.glPushMatrix();
  46. GL11.glEnable(GL11.GL_BLEND);
  47. GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
  48.  
  49. if(magic != null){
  50. String s;
  51. s = "Energy Stored: " + magic.getEnergy() + "/" + magic.getMaxEnergy();
  52. stringLengthY = height - 80;
  53. stringLengthX = (width - font.getStringWidth(s)) / 2;
  54. font.drawString(s, stringLengthX, stringLengthY, ColorHelper.getColorCodeFromColor(Color.red));
  55.  
  56. s = "Input/Output: " + magic.getMaxTransfer();
  57. stringLengthY = height - 70;
  58. stringLengthX = (width - font.getStringWidth(s)) / 2;
  59. font.drawString(s, stringLengthX, stringLengthY, ColorHelper.getColorCodeFromColor(Color.red));
  60.  
  61. if(tile instanceof TileEntityMagicWandCharger){
  62. TileEntityMagicWandCharger wandCharger = (TileEntityMagicWandCharger)tile;
  63. if(wandCharger.getStackInSlot(0) != null){
  64. s = "Item Containing: " + wandCharger.getStackInSlot(0).getDisplayName();
  65. stringLengthY = height - 60;
  66. stringLengthX = (width - font.getStringWidth(s)) / 2;
  67. font.drawString(s, stringLengthX, stringLengthY, ColorHelper.getColorCodeFromColor(Color.red));
  68. }
  69. }
  70. }
  71. GL11.glDisable(GL11.GL_BLEND);
  72. GL11.glPopMatrix();
  73. }
  74. }
  75. }
  76. }
  77. }
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment