Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.47 KB | None | 0 0
  1. package com.celestiam.mod.client.overlay;
  2.  
  3. import java.util.Iterator;
  4. import java.util.Map;
  5.  
  6. import org.lwjgl.opengl.GL11;
  7.  
  8. import com.celestiam.mod.client.render.RenderChestRadar;
  9. import com.celestiam.mod.common.item.ItemChestRadar;
  10.  
  11. import cpw.mods.fml.common.eventhandler.EventPriority;
  12. import cpw.mods.fml.common.eventhandler.SubscribeEvent;
  13. import net.minecraft.client.Minecraft;
  14. import net.minecraft.client.gui.FontRenderer;
  15. import net.minecraft.client.gui.Gui;
  16. import net.minecraft.client.renderer.entity.RenderItem;
  17. import net.minecraft.init.Blocks;
  18. import net.minecraft.item.ItemStack;
  19. import net.minecraft.tileentity.TileEntity;
  20. import net.minecraft.util.ResourceLocation;
  21. import net.minecraftforge.client.event.RenderGameOverlayEvent;
  22.  
  23. public class OverlayChestRadar extends Gui {
  24. private Minecraft mc;
  25. private String show;
  26. final ResourceLocation location = new ResourceLocation("celestiammod", "textures/overlay/chest_radar.png");
  27. FontRenderer fontRender;
  28. RenderItem itemRenderer = new RenderItem();
  29.  
  30. public OverlayChestRadar() {
  31. this.mc = Minecraft.getMinecraft();
  32. this.show = "0%";
  33. this.fontRender = this.mc.fontRenderer;
  34. }
  35.  
  36. @SubscribeEvent(priority = EventPriority.NORMAL)
  37. public void onRender(RenderGameOverlayEvent.Post event) {
  38. if (event.type != RenderGameOverlayEvent.ElementType.HOTBAR) {
  39. return;
  40. }
  41. if ((this.mc.thePlayer.getHeldItem() != null)
  42. && ((this.mc.thePlayer.getHeldItem().getItem() instanceof ItemChestRadar))
  43. && (this.mc.theWorld.isRemote)) {
  44. this.mc.renderEngine.bindTexture(this.location);
  45.  
  46. GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
  47. GL11.glDisable(2896);
  48. GL11.glEnable(3042);
  49. GL11.glBlendFunc(770, 771);
  50.  
  51. RenderChestRadar.drawTexturedQuadFit(5.0D, 5.0D, 32.0D, 32.0D, 0.0D);
  52.  
  53. int amountTiles = this.mc.theWorld.getChunkFromChunkCoords(this.mc.thePlayer.chunkCoordX + 0,
  54. this.mc.thePlayer.chunkCoordZ + 0).chunkTileEntityMap.values().size();
  55.  
  56. amountTiles = amountTiles + this.mc.theWorld.getChunkFromChunkCoords(this.mc.thePlayer.chunkCoordX + 0,
  57. this.mc.thePlayer.chunkCoordZ + 1).chunkTileEntityMap.values().size();
  58.  
  59. amountTiles = amountTiles + this.mc.theWorld.getChunkFromChunkCoords(this.mc.thePlayer.chunkCoordX + 0,
  60. this.mc.thePlayer.chunkCoordZ - 1).chunkTileEntityMap.values().size();
  61.  
  62. amountTiles = amountTiles + this.mc.theWorld.getChunkFromChunkCoords(this.mc.thePlayer.chunkCoordX + 1,
  63. this.mc.thePlayer.chunkCoordZ).chunkTileEntityMap.values().size();
  64.  
  65. amountTiles = amountTiles + this.mc.theWorld.getChunkFromChunkCoords(this.mc.thePlayer.chunkCoordX - 1,
  66. this.mc.thePlayer.chunkCoordZ).chunkTileEntityMap.values().size();
  67. if (this.mc.thePlayer.getHeldItem().getItemDamage() >= 1) {
  68. int[] y = { -2, -1, 0, 1, 2, -2, 2, -2, 2, -2, 2, -2, -1, 0, 1, 2 };
  69. int[] x = { -2, -2, -2, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 2, 2, 2 };
  70. for (int i = 0; i < y.length; i++) {
  71. amountTiles = amountTiles
  72. + this.mc.theWorld.getChunkFromChunkCoords(this.mc.thePlayer.chunkCoordX + x[i],
  73. this.mc.thePlayer.chunkCoordZ + y[i]).chunkTileEntityMap.values().size();
  74. }
  75. }
  76. if (this.mc.thePlayer.getHeldItem().getItemDamage() >= 2) {
  77. int[] y = { -3, -2, -1, 0, 1, 2, 0, 3, -3, 3, -3, 3, -3, 3, -3, 3, -3, -2, -1, 0, 1, 2, 3 };
  78. int[] x = { -3, -3, -3, -3, -3, -3, -5, -2, -1, -1, 0, 0, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3 };
  79. for (int i = 0; i < y.length; i++) {
  80. amountTiles = amountTiles
  81. + this.mc.theWorld.getChunkFromChunkCoords(this.mc.thePlayer.chunkCoordX + x[i],
  82. this.mc.thePlayer.chunkCoordZ + y[i]).chunkTileEntityMap.values().size();
  83. }
  84. }
  85. if (this.mc.thePlayer.getHeldItem().getItemDamage() >= 0) {
  86. int tileAmmount = 0;
  87. int items = 0;
  88. int chests = 0;
  89. int moddedChests = 0;
  90. for (int x = -3; x < 3; x++) {
  91. for (int z = -3; z < 3; z++) {
  92. Map tileMap = this.mc.theWorld.getChunkFromChunkCoords(this.mc.thePlayer.chunkCoordX + x,
  93. this.mc.thePlayer.chunkCoordZ + z).chunkTileEntityMap;
  94.  
  95. Iterator entries = tileMap.entrySet().iterator();
  96. while (entries.hasNext()) {
  97. Map.Entry e = (Map.Entry) entries.next();
  98. TileEntity tile = (TileEntity) e.getValue();
  99. if (tile != null) {
  100. if (tile.getClass().toString().contains("net.minecraft.tileentity.TileEntityChest")) {
  101. chests++;
  102. } else if ((tile.getClass().toString().contains("Chest"))
  103. || (tile.getClass().toString().contains("chest"))) {
  104. moddedChests++;
  105. }
  106. }
  107. }
  108. }
  109. }
  110. ItemStack stackChest = new ItemStack(Blocks.chest);
  111. GL11.glPushMatrix();
  112. GL11.glEnable(2929);
  113. GL11.glScaled(1.5D, 1.5D, 1.5D);
  114. this.itemRenderer.renderItemAndEffectIntoGUI(this.mc.fontRenderer, this.mc.renderEngine, stackChest, 30,
  115. 5);
  116.  
  117. GL11.glDisable(2929);
  118. GL11.glDisable(2896);
  119. GL11.glPopMatrix();
  120.  
  121. int xChests = 53;
  122. if (chests > 100) {
  123. chests = 100;
  124. }
  125. if (moddedChests > 100) {
  126. moddedChests = 100;
  127. }
  128. String showChests = chests + "%";
  129. if (chests > 9) {
  130. xChests -= 3;
  131. }
  132. if (moddedChests > 9) {
  133. }
  134. this.fontRender.drawStringWithShadow(showChests, xChests, 37, -1);
  135. }
  136. if (amountTiles > 100) {
  137. amountTiles = 100;
  138. }
  139. this.show = (amountTiles + "%");
  140. int x = 0;
  141. if (amountTiles > 9) {
  142. x = 12;
  143. } else {
  144. x = 15;
  145. }
  146. this.fontRender.drawStringWithShadow(this.show, x, 37, -1);
  147. }
  148. }
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement