2018-10-13 20:35:18 +02:00
|
|
|
package de.ellpeck.naturesaura.events;
|
|
|
|
|
2018-10-19 14:35:25 +02:00
|
|
|
import baubles.api.BaublesApi;
|
2018-12-04 13:38:46 +01:00
|
|
|
import de.ellpeck.naturesaura.ModConfig;
|
2018-10-13 20:35:18 +02:00
|
|
|
import de.ellpeck.naturesaura.NaturesAura;
|
2018-11-12 22:04:40 +01:00
|
|
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
2018-11-11 13:26:19 +01:00
|
|
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
|
|
|
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
|
2018-11-12 01:29:33 +01:00
|
|
|
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
2018-10-20 21:19:08 +02:00
|
|
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityNatureAltar;
|
2019-01-26 00:34:05 +01:00
|
|
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityRFConverter;
|
2018-10-19 14:35:25 +02:00
|
|
|
import de.ellpeck.naturesaura.compat.Compat;
|
2018-10-14 17:46:00 +02:00
|
|
|
import de.ellpeck.naturesaura.items.ModItems;
|
2018-10-13 20:35:18 +02:00
|
|
|
import de.ellpeck.naturesaura.particles.ParticleHandler;
|
|
|
|
import de.ellpeck.naturesaura.particles.ParticleMagic;
|
2018-10-18 19:08:15 +02:00
|
|
|
import net.minecraft.block.state.IBlockState;
|
2018-10-13 20:35:18 +02:00
|
|
|
import net.minecraft.client.Minecraft;
|
2018-10-18 19:08:15 +02:00
|
|
|
import net.minecraft.client.gui.Gui;
|
2018-10-14 17:46:00 +02:00
|
|
|
import net.minecraft.client.gui.ScaledResolution;
|
2018-10-18 19:08:15 +02:00
|
|
|
import net.minecraft.client.renderer.GlStateManager;
|
|
|
|
import net.minecraft.client.resources.I18n;
|
2018-10-14 17:46:00 +02:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2018-10-18 19:08:15 +02:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
2018-10-14 17:46:00 +02:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2018-10-18 19:08:15 +02:00
|
|
|
import net.minecraft.util.math.MathHelper;
|
2018-10-13 20:35:18 +02:00
|
|
|
import net.minecraft.util.text.TextFormatting;
|
|
|
|
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
2018-10-14 17:46:00 +02:00
|
|
|
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
|
2018-10-13 20:35:18 +02:00
|
|
|
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
|
|
|
import net.minecraftforge.client.event.TextureStitchEvent;
|
2019-01-26 00:34:05 +01:00
|
|
|
import net.minecraftforge.energy.EnergyStorage;
|
2018-10-13 20:35:18 +02:00
|
|
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|
|
|
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;
|
2018-11-04 18:42:35 +01:00
|
|
|
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;
|
2018-10-13 20:35:18 +02:00
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
2018-11-02 21:10:53 +01:00
|
|
|
import net.minecraftforge.items.IItemHandler;
|
2018-10-21 12:51:13 +02:00
|
|
|
import org.apache.commons.lang3.mutable.MutableInt;
|
2018-12-04 13:38:46 +01:00
|
|
|
import org.lwjgl.opengl.GL11;
|
2018-10-13 20:35:18 +02:00
|
|
|
|
2018-12-04 13:38:46 +01:00
|
|
|
import java.util.HashMap;
|
2018-10-13 20:35:18 +02:00
|
|
|
import java.util.List;
|
2018-12-04 13:38:46 +01:00
|
|
|
import java.util.Map;
|
2018-10-13 20:35:18 +02:00
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public class ClientEvents {
|
|
|
|
|
2018-10-20 21:19:08 +02:00
|
|
|
public static final ResourceLocation OVERLAYS = new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/overlays.png");
|
2018-10-18 19:08:15 +02:00
|
|
|
|
2018-10-13 20:35:18 +02:00
|
|
|
@SubscribeEvent
|
|
|
|
public void onDebugRender(RenderGameOverlayEvent.Text event) {
|
2018-10-21 12:51:13 +02:00
|
|
|
Minecraft mc = Minecraft.getMinecraft();
|
2018-12-02 18:33:04 +01:00
|
|
|
mc.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":onDebugRender");
|
2018-12-04 13:38:46 +01:00
|
|
|
if (mc.gameSettings.showDebugInfo && ModConfig.client.debugText) {
|
2018-10-13 20:35:18 +02:00
|
|
|
String prefix = TextFormatting.GREEN + "[" + NaturesAura.MOD_NAME + "]" + TextFormatting.RESET + " ";
|
|
|
|
List<String> left = event.getLeft();
|
|
|
|
left.add("");
|
2018-10-26 20:25:21 +02:00
|
|
|
left.add(prefix + "Particles: " + ParticleHandler.getParticleAmount());
|
2018-10-21 12:51:13 +02:00
|
|
|
|
2018-10-26 20:25:21 +02:00
|
|
|
if (mc.player.capabilities.isCreativeMode) {
|
2018-12-02 18:33:04 +01:00
|
|
|
left.add(prefix + "Aura (range 35)");
|
2018-11-11 13:26:19 +01:00
|
|
|
MutableInt amount = new MutableInt(IAuraChunk.DEFAULT_AURA);
|
2018-10-26 20:25:21 +02:00
|
|
|
MutableInt spots = new MutableInt();
|
2018-12-04 13:38:46 +01:00
|
|
|
IAuraChunk.getSpotsInArea(mc.world, mc.player.getPosition(), 35, (blockPos, drainSpot) -> {
|
2018-10-26 20:25:21 +02:00
|
|
|
spots.increment();
|
2018-12-02 01:36:41 +01:00
|
|
|
amount.add(drainSpot);
|
2018-11-18 20:34:57 +01:00
|
|
|
if (mc.player.isSneaking())
|
2018-12-02 01:36:41 +01:00
|
|
|
left.add(prefix + drainSpot + " @ " + blockPos.getX() + " " + blockPos.getY() + " " + blockPos.getZ());
|
2018-12-04 13:38:46 +01:00
|
|
|
});
|
2018-10-26 20:25:21 +02:00
|
|
|
left.add(prefix + "Total: " + amount.intValue() + " in " + spots.intValue() + " spots");
|
2018-11-12 01:29:33 +01:00
|
|
|
left.add(prefix + "Type: " + IAuraType.forWorld(mc.world).getName());
|
2018-10-26 20:25:21 +02:00
|
|
|
}
|
2018-10-13 20:35:18 +02:00
|
|
|
}
|
2018-12-02 18:33:04 +01:00
|
|
|
mc.profiler.endSection();
|
2018-10-13 20:35:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
public void onRenderLast(RenderWorldLastEvent event) {
|
|
|
|
ParticleHandler.renderParticles(event.getPartialTicks());
|
|
|
|
}
|
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
public void onTextureStitch(TextureStitchEvent event) {
|
2018-10-13 20:45:32 +02:00
|
|
|
event.getMap().registerSprite(ParticleMagic.TEXTURE);
|
2018-10-13 20:35:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
public void onClientTick(ClientTickEvent event) {
|
2018-11-04 18:42:35 +01:00
|
|
|
if (event.phase == Phase.END) {
|
|
|
|
Minecraft mc = Minecraft.getMinecraft();
|
|
|
|
if (!mc.isGamePaused()) {
|
|
|
|
ParticleHandler.updateParticles();
|
|
|
|
}
|
|
|
|
if (mc.world == null) {
|
|
|
|
ParticleHandler.clearParticles();
|
|
|
|
}
|
2018-10-13 20:35:18 +02:00
|
|
|
}
|
|
|
|
}
|
2018-10-14 17:46:00 +02:00
|
|
|
|
2018-12-04 13:38:46 +01:00
|
|
|
@SubscribeEvent
|
|
|
|
public void onWorldRender(RenderWorldLastEvent event) {
|
|
|
|
Minecraft mc = Minecraft.getMinecraft();
|
|
|
|
mc.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":onWorldRender");
|
|
|
|
if (mc.gameSettings.showDebugInfo && mc.player.capabilities.isCreativeMode && ModConfig.client.debugWorld) {
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
|
|
|
float partial = event.getPartialTicks();
|
|
|
|
GL11.glTranslated(
|
|
|
|
-mc.player.prevPosX - (mc.player.posX - mc.player.prevPosX) * partial,
|
|
|
|
-mc.player.prevPosY - (mc.player.posY - mc.player.prevPosY) * partial,
|
|
|
|
-mc.player.prevPosZ - (mc.player.posZ - mc.player.prevPosZ) * partial);
|
|
|
|
|
|
|
|
Map<BlockPos, Integer> spots = new HashMap<>();
|
|
|
|
|
|
|
|
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
|
|
|
GL11.glEnable(GL11.GL_BLEND);
|
|
|
|
GL11.glBegin(GL11.GL_QUADS);
|
|
|
|
IAuraChunk.getSpotsInArea(mc.world, mc.player.getPosition(), 64, (pos, spot) -> {
|
|
|
|
spots.put(pos, spot);
|
|
|
|
|
2018-12-05 01:12:53 +01:00
|
|
|
GlStateManager.color(spot > 0 ? 0F : 1F, spot > 0 ? 1F : 0F, 0F, 0.35F);
|
2018-12-04 13:38:46 +01:00
|
|
|
int x = pos.getX();
|
|
|
|
int y = pos.getY();
|
|
|
|
int z = pos.getZ();
|
|
|
|
GL11.glVertex3d(x, y + 1, z);
|
|
|
|
GL11.glVertex3d(x + 1, y + 1, z);
|
|
|
|
GL11.glVertex3d(x + 1, y, z);
|
|
|
|
GL11.glVertex3d(x, y, z);
|
|
|
|
GL11.glVertex3d(x + 1, y, z + 1);
|
|
|
|
GL11.glVertex3d(x + 1, y, z);
|
|
|
|
GL11.glVertex3d(x + 1, y + 1, z);
|
|
|
|
GL11.glVertex3d(x + 1, y + 1, z + 1);
|
|
|
|
GL11.glVertex3d(x + 1, y + 1, z + 1);
|
|
|
|
GL11.glVertex3d(x, y + 1, z + 1);
|
|
|
|
GL11.glVertex3d(x, y, z + 1);
|
|
|
|
GL11.glVertex3d(x + 1, y, z + 1);
|
|
|
|
GL11.glVertex3d(x, y + 1, z + 1);
|
|
|
|
GL11.glVertex3d(x, y + 1, z);
|
|
|
|
GL11.glVertex3d(x, y, z);
|
|
|
|
GL11.glVertex3d(x, y, z + 1);
|
|
|
|
GL11.glVertex3d(x, y + 1, z);
|
|
|
|
GL11.glVertex3d(x, y + 1, z + 1);
|
|
|
|
GL11.glVertex3d(x + 1, y + 1, z + 1);
|
|
|
|
GL11.glVertex3d(x + 1, y + 1, z);
|
|
|
|
GL11.glVertex3d(x + 1, y, z);
|
|
|
|
GL11.glVertex3d(x + 1, y, z + 1);
|
|
|
|
GL11.glVertex3d(x, y, z + 1);
|
|
|
|
GL11.glVertex3d(x, y, z);
|
|
|
|
});
|
|
|
|
GL11.glEnd();
|
|
|
|
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
GL11.glPopAttrib();
|
|
|
|
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
float scale = 0.03F;
|
|
|
|
GlStateManager.scale(scale, scale, scale);
|
|
|
|
for (Map.Entry<BlockPos, Integer> spot : spots.entrySet()) {
|
|
|
|
BlockPos pos = spot.getKey();
|
|
|
|
GlStateManager.pushMatrix();
|
|
|
|
GlStateManager.translate((pos.getX() + 0.1) / scale, (pos.getY() + 1) / scale, (pos.getZ() + 0.1) / scale);
|
|
|
|
GlStateManager.rotate(90F, 1F, 0F, 0F);
|
|
|
|
mc.fontRenderer.drawString(spot.getValue().toString(), 0, 0, 0);
|
|
|
|
GlStateManager.popMatrix();
|
|
|
|
}
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
|
|
|
|
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
}
|
|
|
|
mc.profiler.endSection();
|
|
|
|
}
|
|
|
|
|
2018-10-14 17:46:00 +02:00
|
|
|
@SubscribeEvent
|
|
|
|
public void onOverlayRender(RenderGameOverlayEvent.Post event) {
|
|
|
|
Minecraft mc = Minecraft.getMinecraft();
|
2018-12-02 18:33:04 +01:00
|
|
|
mc.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":onOverlayRender");
|
2018-10-20 21:19:08 +02:00
|
|
|
if (event.getType() == ElementType.ALL) {
|
2018-10-14 17:46:00 +02:00
|
|
|
ScaledResolution res = event.getResolution();
|
|
|
|
if (mc.player != null) {
|
2018-11-02 21:10:53 +01:00
|
|
|
ItemStack cache = ItemStack.EMPTY;
|
|
|
|
ItemStack eye = ItemStack.EMPTY;
|
2018-12-25 19:38:25 +01:00
|
|
|
ItemStack eyeImproved = ItemStack.EMPTY;
|
2018-11-02 21:10:53 +01:00
|
|
|
|
|
|
|
if (Compat.baubles) {
|
|
|
|
IItemHandler baubles = BaublesApi.getBaublesHandler(mc.player);
|
|
|
|
for (int i = 0; i < baubles.getSlots(); i++) {
|
|
|
|
ItemStack slot = baubles.getStackInSlot(i);
|
|
|
|
if (!slot.isEmpty()) {
|
2018-11-04 17:48:04 +01:00
|
|
|
if (slot.getItem() == ModItems.AURA_CACHE)
|
2018-11-02 21:10:53 +01:00
|
|
|
cache = slot;
|
2018-11-04 17:48:04 +01:00
|
|
|
else if (slot.getItem() == ModItems.EYE)
|
2018-11-02 21:10:53 +01:00
|
|
|
eye = slot;
|
2018-12-25 19:38:25 +01:00
|
|
|
else if (slot.getItem() == ModItems.EYE_IMPROVED)
|
|
|
|
eyeImproved = slot;
|
2018-10-14 17:46:00 +02:00
|
|
|
}
|
2018-11-02 21:10:53 +01:00
|
|
|
}
|
|
|
|
}
|
2018-10-18 19:08:15 +02:00
|
|
|
|
2018-12-25 19:38:25 +01:00
|
|
|
for (int i = 0; i < mc.player.inventory.getSizeInventory(); i++) {
|
|
|
|
ItemStack slot = mc.player.inventory.getStackInSlot(i);
|
|
|
|
if (!slot.isEmpty()) {
|
|
|
|
if (slot.getItem() == ModItems.AURA_CACHE)
|
|
|
|
cache = slot;
|
|
|
|
else if (slot.getItem() == ModItems.EYE && i <= 8)
|
|
|
|
eye = slot;
|
|
|
|
else if (slot.getItem() == ModItems.EYE_IMPROVED)
|
|
|
|
eyeImproved = slot;
|
2018-10-20 21:19:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-02 21:10:53 +01:00
|
|
|
if (!cache.isEmpty()) {
|
2018-11-12 22:04:40 +01:00
|
|
|
IAuraContainer container = cache.getCapability(NaturesAuraAPI.capAuraContainer, null);
|
2018-11-02 21:10:53 +01:00
|
|
|
int width = MathHelper.ceil(container.getStoredAura() / (float) container.getMaxAura() * 80);
|
|
|
|
int x = res.getScaledWidth() / 2 - 173 - (mc.player.getHeldItemOffhand().isEmpty() ? 0 : 29);
|
|
|
|
int y = res.getScaledHeight() - 8;
|
|
|
|
|
|
|
|
GlStateManager.pushMatrix();
|
|
|
|
|
|
|
|
int color = container.getAuraColor();
|
|
|
|
GlStateManager.color((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F);
|
|
|
|
mc.getTextureManager().bindTexture(OVERLAYS);
|
|
|
|
if (width < 80)
|
|
|
|
Gui.drawModalRectWithCustomSizedTexture(x + width, y, width, 0, 80 - width, 6, 256, 256);
|
|
|
|
if (width > 0)
|
|
|
|
Gui.drawModalRectWithCustomSizedTexture(x, y, 0, 6, width, 6, 256, 256);
|
|
|
|
|
|
|
|
float scale = 0.75F;
|
|
|
|
GlStateManager.scale(scale, scale, scale);
|
|
|
|
String s = cache.getDisplayName();
|
|
|
|
mc.fontRenderer.drawString(s, (x + 80) / scale - mc.fontRenderer.getStringWidth(s), (y - 7) / scale, color, true);
|
|
|
|
|
|
|
|
GlStateManager.color(1F, 1F, 1F);
|
|
|
|
GlStateManager.popMatrix();
|
|
|
|
}
|
2018-10-20 21:19:08 +02:00
|
|
|
|
2018-12-25 19:38:25 +01:00
|
|
|
if (!eye.isEmpty() || !eyeImproved.isEmpty()) {
|
2018-11-02 21:10:53 +01:00
|
|
|
GlStateManager.pushMatrix();
|
|
|
|
mc.getTextureManager().bindTexture(OVERLAYS);
|
|
|
|
|
2018-11-04 12:43:22 +01:00
|
|
|
if (!mc.gameSettings.showDebugInfo) {
|
2018-11-07 20:08:22 +01:00
|
|
|
GlStateManager.color(83 / 255F, 160 / 255F, 8 / 255F);
|
2018-12-02 18:33:04 +01:00
|
|
|
|
2018-12-05 11:21:08 +01:00
|
|
|
int totalAmount = IAuraChunk.triangulateAuraInArea(mc.world, mc.player.getPosition(), 35);
|
|
|
|
float totalPercentage = totalAmount / (IAuraChunk.DEFAULT_AURA * 2F);
|
2018-12-02 18:33:04 +01:00
|
|
|
|
2018-11-04 12:43:22 +01:00
|
|
|
int tHeight = MathHelper.ceil(MathHelper.clamp(totalPercentage, 0F, 1F) * 50);
|
2018-12-26 12:10:41 +01:00
|
|
|
int y = !eyeImproved.isEmpty() && totalPercentage > 1F ? 36 : 10;
|
2018-11-04 12:43:22 +01:00
|
|
|
if (tHeight < 50)
|
2018-12-25 19:38:25 +01:00
|
|
|
Gui.drawModalRectWithCustomSizedTexture(3, y, 6, 12, 6, 50 - tHeight, 256, 256);
|
2018-11-04 12:43:22 +01:00
|
|
|
if (tHeight > 0)
|
2018-12-25 19:38:25 +01:00
|
|
|
Gui.drawModalRectWithCustomSizedTexture(3, y + 50 - tHeight, 0, 12 + 50 - tHeight, 6, tHeight, 256, 256);
|
|
|
|
|
|
|
|
if (!eyeImproved.isEmpty()) {
|
|
|
|
GlStateManager.color(160 / 255F, 83 / 255F, 8 / 255F);
|
|
|
|
|
|
|
|
int topHeight = MathHelper.ceil(MathHelper.clamp((totalPercentage - 1F) * 2F, 0F, 1F) * 25);
|
2018-12-26 12:10:41 +01:00
|
|
|
if (topHeight > 0) {
|
|
|
|
if (topHeight < 25)
|
|
|
|
Gui.drawModalRectWithCustomSizedTexture(3, 10, 18, 12, 6, 25 - topHeight, 256, 256);
|
2018-12-25 19:38:25 +01:00
|
|
|
Gui.drawModalRectWithCustomSizedTexture(3, 10 + 25 - topHeight, 12, 12 + 25 - topHeight, 6, topHeight, 256, 256);
|
2018-12-26 12:10:41 +01:00
|
|
|
}
|
2018-12-25 19:38:25 +01:00
|
|
|
int bottomHeight = MathHelper.ceil(MathHelper.clamp((totalPercentage + 1F) * 2F - 1F, 0F, 1F) * 25);
|
2018-12-26 12:10:41 +01:00
|
|
|
if (bottomHeight < 25) {
|
|
|
|
Gui.drawModalRectWithCustomSizedTexture(3, 61, 18, 12, 6, 25 - bottomHeight, 256, 256);
|
|
|
|
if (bottomHeight > 0)
|
|
|
|
Gui.drawModalRectWithCustomSizedTexture(3, 61 + 25 - bottomHeight, 12, 12 + 25 - bottomHeight, 6, bottomHeight, 256, 256);
|
|
|
|
}
|
2018-12-25 19:38:25 +01:00
|
|
|
}
|
2018-11-04 12:43:22 +01:00
|
|
|
|
2018-12-25 19:38:25 +01:00
|
|
|
int color = eyeImproved.isEmpty() ? 0x53a008 : 0xa05308;
|
|
|
|
if (totalPercentage > (eyeImproved.isEmpty() ? 1F : 1.5F))
|
|
|
|
mc.fontRenderer.drawString("+", 10F, 9.5F, color, true);
|
|
|
|
if (totalPercentage < (eyeImproved.isEmpty() ? 0F : -0.5F))
|
2018-12-26 12:10:41 +01:00
|
|
|
mc.fontRenderer.drawString("-", 10F, eyeImproved.isEmpty() ? 53.5F : 79.5F, color, true);
|
2018-11-04 12:43:22 +01:00
|
|
|
|
|
|
|
GlStateManager.pushMatrix();
|
|
|
|
float scale = 0.75F;
|
|
|
|
GlStateManager.scale(scale, scale, scale);
|
2018-11-07 20:08:22 +01:00
|
|
|
mc.fontRenderer.drawString(I18n.format("info." + NaturesAura.MOD_ID + ".aura_in_area"), 3 / scale, 3 / scale, 0x53a008, true);
|
2018-11-04 12:43:22 +01:00
|
|
|
GlStateManager.popMatrix();
|
|
|
|
}
|
2018-11-02 21:10:53 +01:00
|
|
|
|
|
|
|
if (mc.objectMouseOver != null) {
|
|
|
|
BlockPos pos = mc.objectMouseOver.getBlockPos();
|
|
|
|
if (pos != null) {
|
|
|
|
TileEntity tile = mc.world.getTileEntity(pos);
|
2018-11-12 22:04:40 +01:00
|
|
|
if (tile != null && tile.hasCapability(NaturesAuraAPI.capAuraContainer, null)) {
|
|
|
|
IAuraContainer container = tile.getCapability(NaturesAuraAPI.capAuraContainer, null);
|
2018-11-02 21:10:53 +01:00
|
|
|
|
|
|
|
IBlockState state = mc.world.getBlockState(pos);
|
|
|
|
ItemStack blockStack = state.getBlock().getPickBlock(state, mc.objectMouseOver, mc.world, pos, mc.player);
|
2019-01-26 00:34:05 +01:00
|
|
|
this.drawContainerInfo(container.getStoredAura(), container.getMaxAura(), container.getAuraColor(),
|
|
|
|
mc, res, 35, blockStack.getDisplayName(), null);
|
2018-11-02 21:10:53 +01:00
|
|
|
|
|
|
|
if (tile instanceof TileEntityNatureAltar) {
|
|
|
|
ItemStack tileStack = ((TileEntityNatureAltar) tile).getItemHandler(null).getStackInSlot(0);
|
2018-11-12 22:04:40 +01:00
|
|
|
if (!tileStack.isEmpty() && tileStack.hasCapability(NaturesAuraAPI.capAuraContainer, null)) {
|
2019-01-26 00:34:05 +01:00
|
|
|
IAuraContainer stackCont = tileStack.getCapability(NaturesAuraAPI.capAuraContainer, null);
|
|
|
|
this.drawContainerInfo(stackCont.getStoredAura(), stackCont.getMaxAura(), stackCont.getAuraColor(),
|
|
|
|
mc, res, 55, tileStack.getDisplayName(), null);
|
2018-11-02 21:10:53 +01:00
|
|
|
}
|
|
|
|
}
|
2019-01-26 00:34:05 +01:00
|
|
|
} else if (tile instanceof TileEntityRFConverter) {
|
|
|
|
EnergyStorage storage = ((TileEntityRFConverter) tile).storage;
|
|
|
|
this.drawContainerInfo(storage.getEnergyStored(), storage.getMaxEnergyStored(), 0xcc4916,
|
|
|
|
mc, res, 35, I18n.format("tile.naturesaura.rf_converter.name"),
|
|
|
|
storage.getEnergyStored() + " / " + storage.getMaxEnergyStored() + " RF");
|
2018-11-02 21:10:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-10-20 21:19:08 +02:00
|
|
|
|
2018-11-02 21:10:53 +01:00
|
|
|
GlStateManager.color(1F, 1F, 1F);
|
|
|
|
GlStateManager.popMatrix();
|
2018-10-14 17:46:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-12-02 18:33:04 +01:00
|
|
|
mc.profiler.endSection();
|
2018-10-14 17:46:00 +02:00
|
|
|
}
|
2018-10-20 21:19:08 +02:00
|
|
|
|
2019-01-26 00:34:05 +01:00
|
|
|
private void drawContainerInfo(int stored, int max, int color, Minecraft mc, ScaledResolution res, int yOffset, String name, String textBelow) {
|
2018-10-20 21:19:08 +02:00
|
|
|
GlStateManager.color((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F);
|
|
|
|
|
|
|
|
int x = res.getScaledWidth() / 2 - 40;
|
|
|
|
int y = res.getScaledHeight() / 2 + yOffset;
|
2019-01-26 00:34:05 +01:00
|
|
|
int width = MathHelper.ceil(stored / (float) max * 80);
|
2018-10-20 21:19:08 +02:00
|
|
|
|
|
|
|
mc.getTextureManager().bindTexture(OVERLAYS);
|
|
|
|
if (width < 80)
|
|
|
|
Gui.drawModalRectWithCustomSizedTexture(x + width, y, width, 0, 80 - width, 6, 256, 256);
|
|
|
|
if (width > 0)
|
|
|
|
Gui.drawModalRectWithCustomSizedTexture(x, y, 0, 6, width, 6, 256, 256);
|
|
|
|
|
|
|
|
mc.fontRenderer.drawString(name, x + 40 - mc.fontRenderer.getStringWidth(name) / 2F, y - 9, color, true);
|
2019-01-26 00:34:05 +01:00
|
|
|
|
|
|
|
if (textBelow != null)
|
|
|
|
mc.fontRenderer.drawString(textBelow, x + 40 - mc.fontRenderer.getStringWidth(textBelow) / 2F, y + 7, color, true);
|
2018-10-20 21:19:08 +02:00
|
|
|
}
|
2018-10-13 20:35:18 +02:00
|
|
|
}
|