diff --git a/ee3_client/ee3/client/core/ClientProxy.java b/ee3_client/ee3/client/core/ClientProxy.java index 46b823a1..c974814f 100644 --- a/ee3_client/ee3/client/core/ClientProxy.java +++ b/ee3_client/ee3/client/core/ClientProxy.java @@ -9,6 +9,7 @@ import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.KeyBindingRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; +import ee3.client.core.handlers.DrawBlockHighlightHandler; import ee3.client.core.handlers.KeyBindingHandler; import ee3.client.core.handlers.SoundHandler; import ee3.client.core.helper.KeyBindingHelper; @@ -38,6 +39,11 @@ public class ClientProxy extends CommonProxy { public void registerKeyBindingHandler() { KeyBindingRegistry.registerKeyBinding(new KeyBindingHandler()); } + + @Override + public void registerDrawBlockHighlightHandler() { + MinecraftForge.EVENT_BUS.register(new DrawBlockHighlightHandler()); + } @Override public void setKeyBinding(String name, int value) { diff --git a/ee3_client/ee3/client/core/handlers/DrawBlockHighlightHandler.java b/ee3_client/ee3/client/core/handlers/DrawBlockHighlightHandler.java new file mode 100644 index 00000000..0f84211f --- /dev/null +++ b/ee3_client/ee3/client/core/handlers/DrawBlockHighlightHandler.java @@ -0,0 +1,17 @@ +package ee3.client.core.handlers; + +import net.minecraft.src.RenderEngine; +import net.minecraftforge.client.event.DrawBlockHighlightEvent; +import net.minecraftforge.event.ForgeSubscribe; + +public class DrawBlockHighlightHandler { + + + @ForgeSubscribe + public void onDrawBlockHighlightEvent(DrawBlockHighlightEvent event) { + RenderEngine renderEngine = event.context.renderEngine; + + // TODO Magic happens here + } + +} diff --git a/ee3_client/ee3/client/core/handlers/KeyBindingHandler.java b/ee3_client/ee3/client/core/handlers/KeyBindingHandler.java index e53a60ae..7552f1be 100644 --- a/ee3_client/ee3/client/core/handlers/KeyBindingHandler.java +++ b/ee3_client/ee3/client/core/handlers/KeyBindingHandler.java @@ -17,6 +17,7 @@ import ee3.common.EquivalentExchange3; import ee3.common.core.helper.LogHelper; import ee3.common.item.ITransmutationStone; import ee3.common.item.ModItems; +import ee3.common.lib.ConfigurationSettings; import ee3.common.lib.GuiIds; import ee3.common.lib.Reference; import ee3.common.network.PacketEE; @@ -49,7 +50,7 @@ public class KeyBindingHandler extends KeyBindingRegistry.KeyHandler { if (tickEnd) { // If we are not in a GUI of any kind, continue execution if (FMLClientHandler.instance().getClient().currentScreen == null) { - System.out.println(kb.keyDescription); + // TODO Clean this up properly if (kb.keyDescription == Reference.KEYBINDING_EXTRA) { ItemStack currentItem = FMLClientHandler.instance().getClient().thePlayer.getCurrentEquippedItem(); @@ -59,6 +60,15 @@ public class KeyBindingHandler extends KeyBindingRegistry.KeyHandler { } } } + else if (kb.keyDescription == Reference.KEYBINDING_TOGGLE) { + ItemStack currentItem = FMLClientHandler.instance().getClient().thePlayer.getCurrentEquippedItem(); + + if (currentItem != null) { + if (currentItem.getItem() instanceof ITransmutationStone) { + ConfigurationSettings.ENABLE_OVERLAY_PHILOSOPHER_STONE = !ConfigurationSettings.ENABLE_OVERLAY_PHILOSOPHER_STONE; + } + } + } } } diff --git a/ee3_client/ee3/client/core/helper/RenderUtils.java b/ee3_client/ee3/client/core/helper/RenderUtils.java index 01e54caa..c3be40ae 100644 --- a/ee3_client/ee3/client/core/helper/RenderUtils.java +++ b/ee3_client/ee3/client/core/helper/RenderUtils.java @@ -2,15 +2,48 @@ package ee3.client.core.helper; import org.lwjgl.opengl.GL11; +import net.minecraft.src.Block; import net.minecraft.src.FontRenderer; import net.minecraft.src.Item; import net.minecraft.src.ItemStack; +import net.minecraft.src.RenderBlocks; 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) { + private static int rotationAngle = 0; + + public static void renderRotatingBlockIntoGUI(FontRenderer fontRenderer, RenderEngine renderEngine, ItemStack stack, int x, int y, float zLevel, float scale) { + + RenderBlocks renderBlocks = new RenderBlocks(); + + Block block = Block.blocksList[stack.itemID]; + renderEngine.bindTexture(renderEngine.getTexture(block.getTextureFile())); + GL11.glPushMatrix(); + GL11.glTranslatef((float)(x - 2), (float)(y + 3), -3.0F + zLevel); + GL11.glScalef(10.0F, 10.0F, 10.0F); + GL11.glTranslatef(1.0F, 0.5F, 1.0F); + GL11.glScalef(1.0F * scale, 1.0F * scale, -1.0F); + GL11.glRotatef(210.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(0F + 1 * rotationAngle, 0.0F, 1.0F, 0.0F); + rotationAngle = (rotationAngle + 1) % 360; + + int var10 = Item.itemsList[stack.itemID].getColorFromItemStack(stack, 0); + float var16 = (float)(var10 >> 16 & 255) / 255.0F; + float var12 = (float)(var10 >> 8 & 255) / 255.0F; + float var13 = (float)(var10 & 255) / 255.0F; + + GL11.glColor4f(var16, var12, var13, 1.0F); + + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + renderBlocks.useInventoryTint = true; + renderBlocks.renderBlockAsItem(block, stack.getItemDamage(), 1.0F); + renderBlocks.useInventoryTint = true; + GL11.glPopMatrix(); + } + + public static void renderItemIntoGUI(FontRenderer fontRenderer, RenderEngine renderEngine, ItemStack stack, int x, int y, float opacity, float scale) { int itemID = stack.itemID; int meta = stack.getItemDamage(); @@ -25,16 +58,20 @@ public class RenderUtils { float var16 = (float) (overlayColour >> 8 & 255) / 255.0F; float var12 = (float) (overlayColour & 255) / 255.0F; - GL11.glColor4f(var17, var16, var12, 1.0F); + GL11.glColor4f(var17, var16, var12, opacity); - drawTexturedQuad(x, y, iconIndex % 16 * 16*4, iconIndex / 16 * 16*4, 16*4, 16*4, -90); + drawTexturedQuad(x, y, iconIndex % 16 * 16, iconIndex / 16 * 16, 16, 16, -90, scale); GL11.glEnable(GL11.GL_LIGHTING); } - public static void drawTexturedQuad(int x, int y, int u, int v, int width, int height, double zLevel) { + public static void drawTexturedQuad(int x, int y, int u, int v, int width, int height, double zLevel, float scale) { - float var7 = 0.00390625F/4; - float var8 = 0.00390625F/4; + u = (int) (u * scale); + v = (int) (v * scale); + width = (int) (width * scale); + height = (int) (height * scale); + float var7 = 0.00390625F/scale; + float var8 = 0.00390625F/scale; Tessellator var9 = Tessellator.instance; var9.startDrawingQuads(); var9.addVertexWithUV(x + 0, y + height, zLevel, (u + 0) * var7, (v + height) * var8); diff --git a/ee3_common/ee3/common/EquivalentExchange3.java b/ee3_common/ee3/common/EquivalentExchange3.java index 27462f8f..b9aa4319 100644 --- a/ee3_common/ee3/common/EquivalentExchange3.java +++ b/ee3_common/ee3/common/EquivalentExchange3.java @@ -107,6 +107,9 @@ public class EquivalentExchange3 { // Register the EntityLiving Handler MinecraftForge.EVENT_BUS.register(new EntityLivingHandler()); + + // Register the DrawBlockHighlight Handler + proxy.registerDrawBlockHighlightHandler(); // Initialize mod blocks ModBlocks.init(); diff --git a/ee3_common/ee3/common/core/CommonProxy.java b/ee3_common/ee3/common/core/CommonProxy.java index ac1f1f75..232e4207 100644 --- a/ee3_common/ee3/common/core/CommonProxy.java +++ b/ee3_common/ee3/common/core/CommonProxy.java @@ -10,6 +10,7 @@ import ee3.client.gui.GuiPortableCrafting; import ee3.common.container.ContainerCalcinator; import ee3.common.container.ContainerPortableCrafting; import ee3.common.lib.GuiIds; +import ee3.common.lib.Strings; import ee3.common.tile.TileCalcinator; /** @@ -25,6 +26,8 @@ import ee3.common.tile.TileCalcinator; public class CommonProxy implements IGuiHandler { public void registerKeyBindingHandler() {} + + public void registerDrawBlockHighlightHandler() {} public void setKeyBinding(String name, int value) {} @@ -39,8 +42,7 @@ public class CommonProxy implements IGuiHandler { public void initRenderingAndTextures() {} public void initTileEntities() { - // TODO: Constant - GameRegistry.registerTileEntity(TileCalcinator.class, "tileCalcinator"); + GameRegistry.registerTileEntity(TileCalcinator.class, Strings.TE_CALCINATOR_NAME); } @Override diff --git a/ee3_common/ee3/common/core/handlers/RenderTickHandler.java b/ee3_common/ee3/common/core/handlers/RenderTickHandler.java index 53c1e04f..b58c79cd 100644 --- a/ee3_common/ee3/common/core/handlers/RenderTickHandler.java +++ b/ee3_common/ee3/common/core/handlers/RenderTickHandler.java @@ -6,8 +6,12 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; import net.minecraft.client.Minecraft; +import net.minecraft.src.Block; +import net.minecraft.src.EntityItem; import net.minecraft.src.EntityPlayer; +import net.minecraft.src.ItemBlock; import net.minecraft.src.ItemStack; +import net.minecraft.src.MovingObjectPosition; import net.minecraft.src.RenderHelper; import net.minecraft.src.RenderItem; import net.minecraft.src.ScaledResolution; @@ -15,7 +19,9 @@ 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.handlers.DrawBlockHighlightHandler; import ee3.client.core.helper.RenderUtils; +import ee3.common.core.helper.TransmutationHelper; import ee3.common.core.helper.VersionHelper; import ee3.common.item.ItemPhilosopherStone; import ee3.common.lib.ConfigurationSettings; @@ -40,7 +46,7 @@ public class RenderTickHandler implements ITickHandler { currentItemStack = player.inventory.getCurrentItem(); } - if ((player != null) && (currentItemStack != null) && (minecraft.inGameHasFocus) && (currentItemStack.getItem() instanceof ItemPhilosopherStone)) { + if ((player != null) && (currentItemStack != null) && (minecraft.inGameHasFocus) && (currentItemStack.getItem() instanceof ItemPhilosopherStone) && (ConfigurationSettings.ENABLE_OVERLAY_PHILOSOPHER_STONE)) { renderStoneHUD(minecraft, player, currentItemStack, (Float) tickData[0]); } } @@ -59,11 +65,19 @@ public class RenderTickHandler implements ITickHandler { } 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(); + + float overlayScale = 2F; + float blockScale = overlayScale / 2; + float overlayOpacity = 1F; + MovingObjectPosition rayTrace = minecraft.objectMouseOver; + ItemStack currentBlock = null; + + if ((player.worldObj != null) && (rayTrace != null)) { + currentBlock = TransmutationHelper.getNextBlock(player.worldObj.getBlockId(rayTrace.blockX, rayTrace.blockY, rayTrace.blockZ), player.worldObj.getBlockMetadata(rayTrace.blockX, rayTrace.blockY, rayTrace.blockZ), true); + } + + GL11.glPushMatrix(); ScaledResolution sr = new ScaledResolution(minecraft.gameSettings, minecraft.displayWidth, minecraft.displayHeight); GL11.glClear(256); GL11.glMatrixMode(GL11.GL_PROJECTION); @@ -72,21 +86,20 @@ public class RenderTickHandler implements ITickHandler { 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); + RenderItem renderItem = new RenderItem(); + RenderUtils.renderItemIntoGUI(minecraft.fontRenderer, minecraft.renderEngine, stack, (int) (sr.getScaledWidth() - (16 * overlayScale)), (int) (sr.getScaledHeight() - (16 * overlayScale)), overlayOpacity / 2, overlayScale); + if ((currentBlock != null) && (currentBlock.getItem() instanceof ItemBlock)) { + RenderUtils.renderRotatingBlockIntoGUI(minecraft.fontRenderer, minecraft.renderEngine, currentBlock, (int) (sr.getScaledWidth() - (16 * overlayScale) / 2 - 8), (int) (sr.getScaledHeight() - (16 * overlayScale) / 2 - 8), -90, blockScale); + } GL11.glDisable(GL11.GL_LIGHTING); GL11.glPopMatrix(); - GL11.glPopMatrix(); } diff --git a/ee3_common/ee3/common/lib/ConfigurationSettings.java b/ee3_common/ee3/common/lib/ConfigurationSettings.java index f24f917b..f2c9bee9 100644 --- a/ee3_common/ee3/common/lib/ConfigurationSettings.java +++ b/ee3_common/ee3/common/lib/ConfigurationSettings.java @@ -32,6 +32,10 @@ public class ConfigurationSettings { public static boolean ENABLE_VERSION_CHECK; public static final boolean ENABLE_VERSION_CHECK_DEFAULT = true; + // Whether or not the Philosopher Stone overlay is enabled + // TODO Do a proper overlay toggle that is saved between sessions + public static boolean ENABLE_OVERLAY_PHILOSOPHER_STONE = false; + /* * Minium stone config settings */ diff --git a/ee3_common/ee3/common/lib/Strings.java b/ee3_common/ee3/common/lib/Strings.java index 8e31eda1..9eb60933 100644 --- a/ee3_common/ee3/common/lib/Strings.java +++ b/ee3_common/ee3/common/lib/Strings.java @@ -25,5 +25,8 @@ public class Strings { public static final String MINIUM_STONE_NAME = "miniumStone"; public static final String PHILOSOPHER_STONE_NAME = "philStone"; public static final String ALCHEMY_DUST_NAME = "alchemyDust"; + + /* TileEntity name constants */ + public static final String TE_CALCINATOR_NAME = "tileCalcinator"; }