Some work on what I hope could be a cool overlay for managing the different modes of the P Stone/etc. Thanks Azanor for the concept
This commit is contained in:
parent
218fc8ceef
commit
659b2a9620
3 changed files with 144 additions and 0 deletions
47
ee3_client/ee3/client/core/helper/RenderUtils.java
Normal file
47
ee3_client/ee3/client/core/helper/RenderUtils.java
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
package ee3.client.core.helper;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import net.minecraft.src.FontRenderer;
|
||||||
|
import net.minecraft.src.Item;
|
||||||
|
import net.minecraft.src.ItemStack;
|
||||||
|
import net.minecraft.src.RenderEngine;
|
||||||
|
import net.minecraft.src.Tessellator;
|
||||||
|
|
||||||
|
public class RenderUtils {
|
||||||
|
|
||||||
|
public static void renderItemIntoGUI(FontRenderer fontRenderer, RenderEngine renderEngine, ItemStack stack, int x, int y) {
|
||||||
|
|
||||||
|
int itemID = stack.itemID;
|
||||||
|
int meta = stack.getItemDamage();
|
||||||
|
int iconIndex = stack.getIconIndex();
|
||||||
|
|
||||||
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
|
|
||||||
|
renderEngine.bindTexture(renderEngine.getTexture(stack.getItem().getTextureFile()));
|
||||||
|
|
||||||
|
int overlayColour = Item.itemsList[itemID].getColorFromItemStack(stack, 0);
|
||||||
|
float var17 = (float) (overlayColour >> 16 & 255) / 255.0F;
|
||||||
|
float var16 = (float) (overlayColour >> 8 & 255) / 255.0F;
|
||||||
|
float var12 = (float) (overlayColour & 255) / 255.0F;
|
||||||
|
|
||||||
|
GL11.glColor4f(var17, var16, var12, 1.0F);
|
||||||
|
|
||||||
|
drawTexturedQuad(x, y, iconIndex % 16 * 16*4, iconIndex / 16 * 16*4, 16*4, 16*4, -90);
|
||||||
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void drawTexturedQuad(int x, int y, int u, int v, int width, int height, double zLevel) {
|
||||||
|
|
||||||
|
float var7 = 0.00390625F/4;
|
||||||
|
float var8 = 0.00390625F/4;
|
||||||
|
Tessellator var9 = Tessellator.instance;
|
||||||
|
var9.startDrawingQuads();
|
||||||
|
var9.addVertexWithUV(x + 0, y + height, zLevel, (u + 0) * var7, (v + height) * var8);
|
||||||
|
var9.addVertexWithUV(x + width, y + height, zLevel, (u + width) * var7, (v + height) * var8);
|
||||||
|
var9.addVertexWithUV(x + width, y + 0, zLevel, (u + width) * var7, (v + 0) * var8);
|
||||||
|
var9.addVertexWithUV(x + 0, y + 0, zLevel, (u + 0) * var7, (v + 0) * var8);
|
||||||
|
var9.draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -28,6 +28,7 @@ import ee3.common.core.handlers.ItemPickupHandler;
|
||||||
import ee3.common.core.handlers.LocalizationHandler;
|
import ee3.common.core.handlers.LocalizationHandler;
|
||||||
import ee3.common.core.handlers.PacketHandler;
|
import ee3.common.core.handlers.PacketHandler;
|
||||||
import ee3.common.core.handlers.PlayerDestroyItemHandler;
|
import ee3.common.core.handlers.PlayerDestroyItemHandler;
|
||||||
|
import ee3.common.core.handlers.RenderTickHandler;
|
||||||
import ee3.common.core.handlers.VersionCheckTickHandler;
|
import ee3.common.core.handlers.VersionCheckTickHandler;
|
||||||
import ee3.common.core.helper.LogHelper;
|
import ee3.common.core.helper.LogHelper;
|
||||||
import ee3.common.core.helper.VersionHelper;
|
import ee3.common.core.helper.VersionHelper;
|
||||||
|
@ -78,6 +79,9 @@ public class EquivalentExchange3 {
|
||||||
// Initialize the Version Check Tick Handler (Client only)
|
// Initialize the Version Check Tick Handler (Client only)
|
||||||
TickRegistry.registerTickHandler(new VersionCheckTickHandler(), Side.CLIENT);
|
TickRegistry.registerTickHandler(new VersionCheckTickHandler(), Side.CLIENT);
|
||||||
|
|
||||||
|
// Initialize the Render Tick Handler (Client only)
|
||||||
|
TickRegistry.registerTickHandler(new RenderTickHandler(), Side.CLIENT);
|
||||||
|
|
||||||
// Register the KeyBinding Handler (Client only)
|
// Register the KeyBinding Handler (Client only)
|
||||||
proxy.registerKeyBindingHandler();
|
proxy.registerKeyBindingHandler();
|
||||||
|
|
||||||
|
|
93
ee3_common/ee3/common/core/handlers/RenderTickHandler.java
Normal file
93
ee3_common/ee3/common/core/handlers/RenderTickHandler.java
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
package ee3.common.core.handlers;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
import org.lwjgl.opengl.GL12;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.src.EntityPlayer;
|
||||||
|
import net.minecraft.src.ItemStack;
|
||||||
|
import net.minecraft.src.RenderHelper;
|
||||||
|
import net.minecraft.src.RenderItem;
|
||||||
|
import net.minecraft.src.ScaledResolution;
|
||||||
|
|
||||||
|
import cpw.mods.fml.client.FMLClientHandler;
|
||||||
|
import cpw.mods.fml.common.ITickHandler;
|
||||||
|
import cpw.mods.fml.common.TickType;
|
||||||
|
import ee3.client.core.helper.RenderUtils;
|
||||||
|
import ee3.common.core.helper.VersionHelper;
|
||||||
|
import ee3.common.item.ItemPhilosopherStone;
|
||||||
|
import ee3.common.lib.ConfigurationSettings;
|
||||||
|
import ee3.common.lib.Reference;
|
||||||
|
|
||||||
|
public class RenderTickHandler implements ITickHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tickStart(EnumSet<TickType> type, Object... tickData) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
|
||||||
|
|
||||||
|
Minecraft minecraft = FMLClientHandler.instance().getClient();
|
||||||
|
EntityPlayer player = minecraft.thePlayer;
|
||||||
|
ItemStack currentItemStack = null;
|
||||||
|
|
||||||
|
if (type.contains(TickType.RENDER)) {
|
||||||
|
if (player != null) {
|
||||||
|
currentItemStack = player.inventory.getCurrentItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((player != null) && (currentItemStack != null) && (minecraft.inGameHasFocus) && (currentItemStack.getItem() instanceof ItemPhilosopherStone)) {
|
||||||
|
renderStoneHUD(minecraft, player, currentItemStack, (Float) tickData[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnumSet<TickType> ticks() {
|
||||||
|
|
||||||
|
return EnumSet.of(TickType.CLIENT, TickType.CLIENTGUI, TickType.RENDER);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLabel() {
|
||||||
|
|
||||||
|
return Reference.MOD_NAME + ": " + this.getClass().getSimpleName();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void renderStoneHUD(Minecraft minecraft, EntityPlayer player, ItemStack stack, float partialTicks) {
|
||||||
|
|
||||||
|
int loc = player.inventory.currentItem*20;
|
||||||
|
int shift = player.capabilities.isCreativeMode?0:20;
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
|
||||||
|
ScaledResolution sr = new ScaledResolution(minecraft.gameSettings, minecraft.displayWidth, minecraft.displayHeight);
|
||||||
|
GL11.glClear(256);
|
||||||
|
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
||||||
|
GL11.glLoadIdentity();
|
||||||
|
GL11.glOrtho(0.0D, sr.getScaledWidth_double(), sr.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D);
|
||||||
|
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||||
|
GL11.glLoadIdentity();
|
||||||
|
GL11.glTranslatef(0.0F, 0.0F, -2000.0F);
|
||||||
|
int k = sr.getScaledWidth();
|
||||||
|
int l = sr.getScaledHeight();
|
||||||
|
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
RenderHelper.enableGUIStandardItemLighting();
|
||||||
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
|
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||||
|
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
|
||||||
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
|
RenderItem itemRenderer = new RenderItem();
|
||||||
|
RenderUtils.renderItemIntoGUI(minecraft.fontRenderer, minecraft.renderEngine, stack, 0, 0);
|
||||||
|
//itemRenderer.renderItemIntoGUI(minecraft.fontRenderer, minecraft.renderEngine, stack, 0, 0);
|
||||||
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue