wasliebob

D

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