Added a HUD to when something can be read into with the lexicon.

This commit is contained in:
Vasco Lavos committed 2014-02-16 16:39:42 +00:00
1 parent f39cfd0dfd
commit ae7362742e
1 file changed
+34 -1
@@ -16,6 +16,8 @@ import java.awt.Color;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
@@ -25,7 +27,9 @@ import net.minecraftforge.event.ForgeSubscribe;
import org.lwjgl.opengl.GL11;
import vazkii.botania.api.ILexiconable;
import vazkii.botania.api.IWandHUD;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.item.ModItems;
@@ -33,7 +37,8 @@ import vazkii.botania.common.item.ModItems;
public final class HUDHandler {
private static final ResourceLocation manaBar = new ResourceLocation(LibResources.GUI_MANA_HUD);
private static final RenderItem itemRender = new RenderItem();
@ForgeSubscribe
public void onDrawScreen(RenderGameOverlayEvent.Post event) {
if(event.type == ElementType.ALL) {
@@ -44,8 +49,36 @@ public final class HUDHandler {
if(Block.blocksList[id] != null && Block.blocksList[id] instanceof IWandHUD)
((IWandHUD) Block.blocksList[id]).renderHUD(mc, event.resolution, mc.theWorld, pos.blockX, pos.blockY, pos.blockZ);
}
else if(pos != null && mc.thePlayer.getCurrentEquippedItem() != null && mc.thePlayer.getCurrentEquippedItem().itemID == ModItems.lexicon.itemID) {
int id = mc.theWorld.getBlockId(pos.blockX, pos.blockY, pos.blockZ);
if(Block.blocksList[id] != null && Block.blocksList[id] instanceof ILexiconable) {
LexiconEntry entry = ((ILexiconable) Block.blocksList[id]).getEntry(mc.theWorld, pos.blockX, pos.blockY, pos.blockZ, mc.thePlayer, mc.thePlayer.getCurrentEquippedItem());
if(entry != null)
drawLexiconGUI(entry, event.resolution);
}
}
}
}
private void drawLexiconGUI(LexiconEntry entry, ScaledResolution res) {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
Minecraft mc = Minecraft.getMinecraft();
int x = res.getScaledWidth() / 2 + 8;
int y = res.getScaledHeight() / 2 - 4;
int color = 0x2200FF00;
mc.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal(entry.getUnlocalizedName()), x + 18, y, color);
mc.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal("botaniamisc.shiftToRead"), x + 18, y + 11, color);
itemRender.renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, new ItemStack(ModItems.lexicon), x, y);
GL11.glDisable(GL11.GL_LIGHTING);
mc.fontRenderer.drawStringWithShadow("?", x + 10, y + 8, 0xFFFFFF);
GL11.glDisable(GL11.GL_BLEND);
GL11.glColor4f(1F, 1F, 1F, 1F);
}
public static void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res) {
GL11.glEnable(GL11.GL_BLEND);