Getting into some rendering; fun stuff!
This commit is contained in:
parent
b1ddd713e6
commit
4ca464e072
9 changed files with 116 additions and 21 deletions
|
@ -9,6 +9,7 @@ import cpw.mods.fml.client.registry.ClientRegistry;
|
||||||
import cpw.mods.fml.client.registry.KeyBindingRegistry;
|
import cpw.mods.fml.client.registry.KeyBindingRegistry;
|
||||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||||
|
import ee3.client.core.handlers.DrawBlockHighlightHandler;
|
||||||
import ee3.client.core.handlers.KeyBindingHandler;
|
import ee3.client.core.handlers.KeyBindingHandler;
|
||||||
import ee3.client.core.handlers.SoundHandler;
|
import ee3.client.core.handlers.SoundHandler;
|
||||||
import ee3.client.core.helper.KeyBindingHelper;
|
import ee3.client.core.helper.KeyBindingHelper;
|
||||||
|
@ -39,6 +40,11 @@ public class ClientProxy extends CommonProxy {
|
||||||
KeyBindingRegistry.registerKeyBinding(new KeyBindingHandler());
|
KeyBindingRegistry.registerKeyBinding(new KeyBindingHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerDrawBlockHighlightHandler() {
|
||||||
|
MinecraftForge.EVENT_BUS.register(new DrawBlockHighlightHandler());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setKeyBinding(String name, int value) {
|
public void setKeyBinding(String name, int value) {
|
||||||
KeyBindingHelper.addKeyBinding(name, value);
|
KeyBindingHelper.addKeyBinding(name, value);
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -17,6 +17,7 @@ import ee3.common.EquivalentExchange3;
|
||||||
import ee3.common.core.helper.LogHelper;
|
import ee3.common.core.helper.LogHelper;
|
||||||
import ee3.common.item.ITransmutationStone;
|
import ee3.common.item.ITransmutationStone;
|
||||||
import ee3.common.item.ModItems;
|
import ee3.common.item.ModItems;
|
||||||
|
import ee3.common.lib.ConfigurationSettings;
|
||||||
import ee3.common.lib.GuiIds;
|
import ee3.common.lib.GuiIds;
|
||||||
import ee3.common.lib.Reference;
|
import ee3.common.lib.Reference;
|
||||||
import ee3.common.network.PacketEE;
|
import ee3.common.network.PacketEE;
|
||||||
|
@ -49,7 +50,7 @@ public class KeyBindingHandler extends KeyBindingRegistry.KeyHandler {
|
||||||
if (tickEnd) {
|
if (tickEnd) {
|
||||||
// If we are not in a GUI of any kind, continue execution
|
// If we are not in a GUI of any kind, continue execution
|
||||||
if (FMLClientHandler.instance().getClient().currentScreen == null) {
|
if (FMLClientHandler.instance().getClient().currentScreen == null) {
|
||||||
System.out.println(kb.keyDescription);
|
// TODO Clean this up properly
|
||||||
if (kb.keyDescription == Reference.KEYBINDING_EXTRA) {
|
if (kb.keyDescription == Reference.KEYBINDING_EXTRA) {
|
||||||
ItemStack currentItem = FMLClientHandler.instance().getClient().thePlayer.getCurrentEquippedItem();
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,48 @@ package ee3.client.core.helper;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import net.minecraft.src.Block;
|
||||||
import net.minecraft.src.FontRenderer;
|
import net.minecraft.src.FontRenderer;
|
||||||
import net.minecraft.src.Item;
|
import net.minecraft.src.Item;
|
||||||
import net.minecraft.src.ItemStack;
|
import net.minecraft.src.ItemStack;
|
||||||
|
import net.minecraft.src.RenderBlocks;
|
||||||
import net.minecraft.src.RenderEngine;
|
import net.minecraft.src.RenderEngine;
|
||||||
import net.minecraft.src.Tessellator;
|
import net.minecraft.src.Tessellator;
|
||||||
|
|
||||||
public class RenderUtils {
|
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 itemID = stack.itemID;
|
||||||
int meta = stack.getItemDamage();
|
int meta = stack.getItemDamage();
|
||||||
|
@ -25,16 +58,20 @@ public class RenderUtils {
|
||||||
float var16 = (float) (overlayColour >> 8 & 255) / 255.0F;
|
float var16 = (float) (overlayColour >> 8 & 255) / 255.0F;
|
||||||
float var12 = (float) (overlayColour & 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);
|
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;
|
u = (int) (u * scale);
|
||||||
float var8 = 0.00390625F/4;
|
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;
|
Tessellator var9 = Tessellator.instance;
|
||||||
var9.startDrawingQuads();
|
var9.startDrawingQuads();
|
||||||
var9.addVertexWithUV(x + 0, y + height, zLevel, (u + 0) * var7, (v + height) * var8);
|
var9.addVertexWithUV(x + 0, y + height, zLevel, (u + 0) * var7, (v + height) * var8);
|
||||||
|
|
|
@ -108,6 +108,9 @@ public class EquivalentExchange3 {
|
||||||
// Register the EntityLiving Handler
|
// Register the EntityLiving Handler
|
||||||
MinecraftForge.EVENT_BUS.register(new EntityLivingHandler());
|
MinecraftForge.EVENT_BUS.register(new EntityLivingHandler());
|
||||||
|
|
||||||
|
// Register the DrawBlockHighlight Handler
|
||||||
|
proxy.registerDrawBlockHighlightHandler();
|
||||||
|
|
||||||
// Initialize mod blocks
|
// Initialize mod blocks
|
||||||
ModBlocks.init();
|
ModBlocks.init();
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import ee3.client.gui.GuiPortableCrafting;
|
||||||
import ee3.common.container.ContainerCalcinator;
|
import ee3.common.container.ContainerCalcinator;
|
||||||
import ee3.common.container.ContainerPortableCrafting;
|
import ee3.common.container.ContainerPortableCrafting;
|
||||||
import ee3.common.lib.GuiIds;
|
import ee3.common.lib.GuiIds;
|
||||||
|
import ee3.common.lib.Strings;
|
||||||
import ee3.common.tile.TileCalcinator;
|
import ee3.common.tile.TileCalcinator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,6 +27,8 @@ public class CommonProxy implements IGuiHandler {
|
||||||
|
|
||||||
public void registerKeyBindingHandler() {}
|
public void registerKeyBindingHandler() {}
|
||||||
|
|
||||||
|
public void registerDrawBlockHighlightHandler() {}
|
||||||
|
|
||||||
public void setKeyBinding(String name, int value) {}
|
public void setKeyBinding(String name, int value) {}
|
||||||
|
|
||||||
public void registerSoundHandler() {}
|
public void registerSoundHandler() {}
|
||||||
|
@ -39,8 +42,7 @@ public class CommonProxy implements IGuiHandler {
|
||||||
public void initRenderingAndTextures() {}
|
public void initRenderingAndTextures() {}
|
||||||
|
|
||||||
public void initTileEntities() {
|
public void initTileEntities() {
|
||||||
// TODO: Constant
|
GameRegistry.registerTileEntity(TileCalcinator.class, Strings.TE_CALCINATOR_NAME);
|
||||||
GameRegistry.registerTileEntity(TileCalcinator.class, "tileCalcinator");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,8 +6,12 @@ import org.lwjgl.opengl.GL11;
|
||||||
import org.lwjgl.opengl.GL12;
|
import org.lwjgl.opengl.GL12;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.src.Block;
|
||||||
|
import net.minecraft.src.EntityItem;
|
||||||
import net.minecraft.src.EntityPlayer;
|
import net.minecraft.src.EntityPlayer;
|
||||||
|
import net.minecraft.src.ItemBlock;
|
||||||
import net.minecraft.src.ItemStack;
|
import net.minecraft.src.ItemStack;
|
||||||
|
import net.minecraft.src.MovingObjectPosition;
|
||||||
import net.minecraft.src.RenderHelper;
|
import net.minecraft.src.RenderHelper;
|
||||||
import net.minecraft.src.RenderItem;
|
import net.minecraft.src.RenderItem;
|
||||||
import net.minecraft.src.ScaledResolution;
|
import net.minecraft.src.ScaledResolution;
|
||||||
|
@ -15,7 +19,9 @@ import net.minecraft.src.ScaledResolution;
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
import cpw.mods.fml.client.FMLClientHandler;
|
||||||
import cpw.mods.fml.common.ITickHandler;
|
import cpw.mods.fml.common.ITickHandler;
|
||||||
import cpw.mods.fml.common.TickType;
|
import cpw.mods.fml.common.TickType;
|
||||||
|
import ee3.client.core.handlers.DrawBlockHighlightHandler;
|
||||||
import ee3.client.core.helper.RenderUtils;
|
import ee3.client.core.helper.RenderUtils;
|
||||||
|
import ee3.common.core.helper.TransmutationHelper;
|
||||||
import ee3.common.core.helper.VersionHelper;
|
import ee3.common.core.helper.VersionHelper;
|
||||||
import ee3.common.item.ItemPhilosopherStone;
|
import ee3.common.item.ItemPhilosopherStone;
|
||||||
import ee3.common.lib.ConfigurationSettings;
|
import ee3.common.lib.ConfigurationSettings;
|
||||||
|
@ -40,7 +46,7 @@ public class RenderTickHandler implements ITickHandler {
|
||||||
currentItemStack = player.inventory.getCurrentItem();
|
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]);
|
renderStoneHUD(minecraft, player, currentItemStack, (Float) tickData[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,10 +66,18 @@ public class RenderTickHandler implements ITickHandler {
|
||||||
|
|
||||||
private static void renderStoneHUD(Minecraft minecraft, EntityPlayer player, ItemStack stack, float partialTicks) {
|
private static void renderStoneHUD(Minecraft minecraft, EntityPlayer player, ItemStack stack, float partialTicks) {
|
||||||
|
|
||||||
int loc = player.inventory.currentItem*20;
|
float overlayScale = 2F;
|
||||||
int shift = player.capabilities.isCreativeMode?0:20;
|
float blockScale = overlayScale / 2;
|
||||||
GL11.glPushMatrix();
|
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);
|
ScaledResolution sr = new ScaledResolution(minecraft.gameSettings, minecraft.displayWidth, minecraft.displayHeight);
|
||||||
GL11.glClear(256);
|
GL11.glClear(256);
|
||||||
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
||||||
|
@ -72,8 +86,6 @@ public class RenderTickHandler implements ITickHandler {
|
||||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||||
GL11.glLoadIdentity();
|
GL11.glLoadIdentity();
|
||||||
GL11.glTranslatef(0.0F, 0.0F, -2000.0F);
|
GL11.glTranslatef(0.0F, 0.0F, -2000.0F);
|
||||||
int k = sr.getScaledWidth();
|
|
||||||
int l = sr.getScaledHeight();
|
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
RenderHelper.enableGUIStandardItemLighting();
|
RenderHelper.enableGUIStandardItemLighting();
|
||||||
|
@ -81,12 +93,13 @@ public class RenderTickHandler implements ITickHandler {
|
||||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||||
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
|
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
RenderItem itemRenderer = new RenderItem();
|
RenderItem renderItem = new RenderItem();
|
||||||
RenderUtils.renderItemIntoGUI(minecraft.fontRenderer, minecraft.renderEngine, stack, 0, 0);
|
RenderUtils.renderItemIntoGUI(minecraft.fontRenderer, minecraft.renderEngine, stack, (int) (sr.getScaledWidth() - (16 * overlayScale)), (int) (sr.getScaledHeight() - (16 * overlayScale)), overlayOpacity / 2, overlayScale);
|
||||||
//itemRenderer.renderItemIntoGUI(minecraft.fontRenderer, minecraft.renderEngine, stack, 0, 0);
|
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.glDisable(GL11.GL_LIGHTING);
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,10 @@ public class ConfigurationSettings {
|
||||||
public static boolean ENABLE_VERSION_CHECK;
|
public static boolean ENABLE_VERSION_CHECK;
|
||||||
public static final boolean ENABLE_VERSION_CHECK_DEFAULT = true;
|
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
|
* Minium stone config settings
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -26,4 +26,7 @@ public class Strings {
|
||||||
public static final String PHILOSOPHER_STONE_NAME = "philStone";
|
public static final String PHILOSOPHER_STONE_NAME = "philStone";
|
||||||
public static final String ALCHEMY_DUST_NAME = "alchemyDust";
|
public static final String ALCHEMY_DUST_NAME = "alchemyDust";
|
||||||
|
|
||||||
|
/* TileEntity name constants */
|
||||||
|
public static final String TE_CALCINATOR_NAME = "tileCalcinator";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue