Rewrote IItemRenderer to be a more generic and expandable version, Breaks previous interfaces, but this should be the last time the interface changes.

Implemented the MapRender hook ChickenBones requested.
This commit is contained in:
LexManos committed 2012-04-09 22:57:52 -07:00
1 parent e400b2df4e
commit 20e264f9ee
7 files changed
+164 -94

No files matched your search

@@ -19,6 +19,9 @@ import java.util.*;
import net.minecraft.src.*;
import org.lwjgl.opengl.GL12;
import static net.minecraft.src.forge.IItemRenderer.ItemRenderType.*;
import static net.minecraft.src.forge.IItemRenderer.ItemRendererHelper.*;
public class ForgeHooksClient
{
@@ -261,18 +264,13 @@ public class ForgeHooksClient
}
}
public static void renderEntityItem(IItemRenderer customRenderer, RenderBlocks renderBlocks, EntityItem item)
{
customRenderer.renderEntityItem(renderBlocks, item);
}
public static void renderEquippedItem(IItemRenderer customRenderer, RenderBlocks renderBlocks, EntityLiving entity, ItemStack item)
{
if (customRenderer.renderEquippedItemAsBlock(item))
if (customRenderer.shouldUseRenderHelper(EQUIPPED, item, EQUIPPED_BLOCK))
{
GL11.glPushMatrix();
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
customRenderer.renderEquippedItem(renderBlocks, entity, item);
customRenderer.renderItem(EQUIPPED, item, renderBlocks, entity);
GL11.glPopMatrix();
}
else
@@ -284,14 +282,9 @@ public class ForgeHooksClient
GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F);
GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F);
customRenderer.renderEquippedItem(renderBlocks, entity, item);
customRenderer.renderItem(EQUIPPED, item, renderBlocks, entity);
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
}
}
public static void renderInventoryItem(IItemRenderer customRenderer, RenderBlocks renderBlocks, ItemStack item)
{
customRenderer.renderInventoryItem(renderBlocks, item);
}
}
@@ -7,7 +7,86 @@ import net.minecraft.src.RenderBlocks;
public interface IItemRenderer
{
/** Checks if this renderer should handle a specific item's render type
public enum ItemRenderType
{
/**
* Called to render an in-world item, e.g. one that has been thrown or
* dropped. The appropriate OpenGL transformations and scaling have already
* been applied, so Tessellator location (0,0,0) is the center of the
* EntityItem.
*
* Data parameters:
* RenderBlocks render - The RenderBlocks instance
* EntityItem entity - The in-world item to be rendered
*/
ENTITY,
/**
* Called to render an item currently held in-hand by a living entity. If
* rendering as a 3D block, the item will be rotated to a 45-degree angle.
* To render a 2D texture with some thickness (like default items), see
* net.minecraft.src.ItemRenderer. In either case, rendering should be done
* in local coordinates from (0,0,0)-(1,1,1).
*
* Data parameters:
* RenderBlocks render - The RenderBlocks instance
* EntityLiving entity - The entity holding this item
*/
EQUIPPED,
/**
* Called to render an item in a GUI inventory slot. If rendering as a 3D
* block, the appropriate OpenGL translations and scaling have already been
* applied, and the rendering should be done in local coordinates from
* (0,0,0)-(1,1,1). If rendering as a 2D texture, the rendering should be in
* GUI pixel coordinates from (0, 0, 0)-(16, 16, 0).
*
* Data parameters:
* RenderBlocks render - The RenderBlocks instance
*/
INVENTORY,
/**
* The render type used for when a ItemMap is rendered in first person,
* All appropriate rotations have been applied, and the player's hands,
* and the map BG are already rendered.
*
* Data Parameters:
* EntityPlayer player - The player holding the map
* RenderEngine engine - The RenderEngine instance
* MapData mapData - The map data
*/
FIRST_PERSON_MAP
}
public enum ItemRendererHelper
{
/**
* Determines if a rotation effect should be used when rendering an
* EntityItem, like most default blocks do.
*/
ENTITY_ROTATION,
/**
* Determines if an up-and-down bobbing effect should be used when
*/
ENTITY_BOBBING,
/**
* Determines if the currently equipped item should be rendered as a 3D
* block or as a 2D texture.
*/
EQUIPPED_BLOCK,
/**
* Determines if the item should be rendered in GUI inventory slots as a 3D
* block or as a 2D texture.
*/
INVENTORY_BLOCK
}
/**
* Checks if this renderer should handle a specific item's render type
* @param item The item we are trying to render
* @param type A render type to check if this renderer handles
* @return true if this renderer should handle the given render type,
@@ -15,64 +94,24 @@ public interface IItemRenderer
*/
public boolean handleRenderType(ItemStack item, ItemRenderType type);
/** Called to render an in-world item, e.g. one that has been thrown or
* dropped. The appropriate OpenGL transformations and scaling have already
* been applied, so Tessellator location (0,0,0) is the center of the
* EntityItem.
* @param render The RenderBlocks instance
* @param item The in-world item to be rendered
/**
* Checks if certain helper functionality should be executed for this renderer.
* See ItemRendererHelper for more info
*
* @param type The render type
* @param item The ItemStack being rendered
* @param helper The type of helper functionality to be ran
* @return True to run the helper functionality, false to not.
*/
public void renderEntityItem(RenderBlocks render, EntityItem item);
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper);
/** Determines if a rotation effect should be used when rendering an
* EntityItem, like most default blocks do.
* @param item the item we are trying to render
* @return true if the EntityItem should rotate, otherwise false
/**
* Called to do the actual rendering, see ItemRenderType for details on when specific
* types are run, and what extra data is passed into the data parameter.
*
* @param type The render type
* @param item The ItemStack being rendered
* @param data Extra Type specific data
*/
public boolean useEntityItemRotationEffect(ItemStack item);
/** Determines if an up-and-down bobbing effect should be used when
* rendering an EntityItem, like all default blocks and items do.
* @param item the item we are trying to render
* @return true if the EntityItem should bob up and down, otherwise false
*/
public boolean useEntityItemBobbingEffect(ItemStack item);
/** Called to render an item currently held in-hand by a living entity. If
* rendering as a 3D block, the item will be rotated to a 45-degree angle.
* To render a 2D texture with some thickness (like default items), see
* net.minecraft.src.ItemRenderer. In either case, rendering should be done
* in local coordinates from (0,0,0)-(1,1,1).
* @param render The RenderBlocks instance
* @param entity The entity holding this item
* @param item The equipped item to be rendered
*/
public void renderEquippedItem(RenderBlocks render, EntityLiving entity, ItemStack item);
/** Determines if the currently equipped item should be rendered as a 3D
* block or as a 2D texture.
* @param item the item we are trying to render
* @return true if the equipped item should be rendered as a 3D block,
* otherwise false
*/
public boolean renderEquippedItemAsBlock(ItemStack item);
/** Called to render an item in a GUI inventory slot. If rendering as a 3D
* block, the appropriate OpenGL translations and scaling have already been
* applied, and the rendering should be done in local coordinates from
* (0,0,0)-(1,1,1). If rendering as a 2D texture, the rendering should be in
* GUI pixel coordinates from (0, 0, 0)-(16, 16, 0).
* @param render The RenderBlocks instance
* @param item The item stack to render
*/
public void renderInventoryItem(RenderBlocks render, ItemStack item);
/** Determines if the item should be rendered in GUI inventory slots as a 3D
* block or as a 2D texture.
* @param item the item we are trying to render
* @return true if the inventory item should be rendered as a 3D block,
* otherwise false
*/
public boolean renderInventoryItemAsBlock(ItemStack item);
public void renderItem(ItemRenderType type, ItemStack item, Object... data);
}
@@ -1,5 +1,6 @@
package net.minecraft.src.forge;
@Deprecated //Now consolidated into IITemRenderer
public enum ItemRenderType
{
ENTITY, // Render type for in-world EntityItems
@@ -12,6 +12,7 @@ import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.ModLoader;
import net.minecraft.src.RenderBlocks;
import net.minecraft.src.forge.IItemRenderer.ItemRenderType;
public class MinecraftForgeClient
{