Add an ItemStack sensitive version of getIconForRenderPass, defers to

existing by default. Should allow NBT data to affect multipass icon rendering.
This commit is contained in:
Christian 2012-11-13 16:01:57 -05:00
parent 2fb5ea1008
commit 5f2d1d1fc0
3 changed files with 59 additions and 31 deletions

View File

@ -299,6 +299,15 @@
switch (var2) switch (var2)
{ {
@@ -1774,7 +1874,7 @@
{
if (par1ItemStack.getItem().requiresMultipleRenderPasses())
{
- return par1ItemStack.getItem().getIconFromDamageForRenderPass(par1ItemStack.getItemDamage(), par2);
+ return par1ItemStack.getItem().getIconFromItemStackForMultiplePasses(par1ItemStack, par2);
}
if (this.itemInUse != null && par1ItemStack.itemID == Item.bow.shiftedIndex)
@@ -1796,6 +1896,7 @@ @@ -1796,6 +1896,7 @@
return 101; return 101;
} }

View File

@ -37,7 +37,7 @@
Vec3 var23 = var13.addVector((double)var18 * var21, (double)var17 * var21, (double)var20 * var21); Vec3 var23 = var13.addVector((double)var18 * var21, (double)var17 * var21, (double)var20 * var21);
return par1World.rayTraceBlocks_do_do(var13, var23, par3, !par3); return par1World.rayTraceBlocks_do_do(var13, var23, par3, !par3);
} }
@@ -678,4 +690,266 @@ @@ -678,4 +690,279 @@
{ {
StatList.initStats(); StatList.initStats();
} }
@ -51,7 +51,7 @@
+ * returning false from this will prevent the item from + * returning false from this will prevent the item from
+ * being removed from the players inventory and spawning + * being removed from the players inventory and spawning
+ * in the world + * in the world
+ * + *
+ * @param player The player that dropped the item + * @param player The player that dropped the item
+ * @param item The item stack, before the item is removed. + * @param item The item stack, before the item is removed.
+ */ + */
@ -71,17 +71,17 @@
+ * @param side The side of the target hit + * @param side The side of the target hit
+ * @return Return true to prevent any further processing. + * @return Return true to prevent any further processing.
+ */ + */
+ public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) + public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
+ { + {
+ return onItemUseFirst(stack, player, world, x, y, z, side); + return onItemUseFirst(stack, player, world, x, y, z, side);
+ } + }
+ +
+ /** + /**
+ * See onItemUseFirst above, this is deprecated in favor of the more aware version. + * See onItemUseFirst above, this is deprecated in favor of the more aware version.
+ * Only here for compaibility. + * Only here for compaibility.
+ */ + */
+ @Deprecated + @Deprecated
+ public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side) + public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side)
+ { + {
+ return false; + return false;
+ } + }
@ -102,7 +102,7 @@
+ * Called by CraftingManager to determine if an item is reparable. + * Called by CraftingManager to determine if an item is reparable.
+ * @return True if reparable + * @return True if reparable
+ */ + */
+ public boolean isRepairable() + public boolean isRepairable()
+ { + {
+ return canRepair && isDamageable(); + return canRepair && isDamageable();
+ } + }
@ -111,7 +111,7 @@
+ * Call to disable repair recipes. + * Call to disable repair recipes.
+ * @return The current Item instance + * @return The current Item instance
+ */ + */
+ public Item setNoRepair() + public Item setNoRepair()
+ { + {
+ canRepair = false; + canRepair = false;
+ return this; + return this;
@ -121,7 +121,7 @@
+ * Called before a block is broken. Return true to prevent default block harvesting. + * Called before a block is broken. Return true to prevent default block harvesting.
+ * + *
+ * Note: In SMP, this is called on both client and server sides! + * Note: In SMP, this is called on both client and server sides!
+ * + *
+ * @param itemstack The current ItemStack + * @param itemstack The current ItemStack
+ * @param X The X Position + * @param X The X Position
+ * @param Y The X Position + * @param Y The X Position
@ -129,7 +129,7 @@
+ * @param player The Player that is wielding the item + * @param player The Player that is wielding the item
+ * @return True to prevent harvesting, false to continue as normal + * @return True to prevent harvesting, false to continue as normal
+ */ + */
+ public boolean onBlockStartBreak(ItemStack itemstack, int X, int Y, int Z, EntityPlayer player) + public boolean onBlockStartBreak(ItemStack itemstack, int X, int Y, int Z, EntityPlayer player)
+ { + {
+ return false; + return false;
+ } + }
@ -140,7 +140,7 @@
+ * @param player The Player using the item + * @param player The Player using the item
+ * @param count The amount of time in tick the item has been used for continuously + * @param count The amount of time in tick the item has been used for continuously
+ */ + */
+ public void onUsingItemTick(ItemStack stack, EntityPlayer player, int count) + public void onUsingItemTick(ItemStack stack, EntityPlayer player, int count)
+ { + {
+ } + }
+ +
@ -148,20 +148,20 @@
+ * Called when the player Left Clicks (attacks) an entity. + * Called when the player Left Clicks (attacks) an entity.
+ * Processed before damage is done, if return value is true further processing is canceled + * Processed before damage is done, if return value is true further processing is canceled
+ * and the entity is not attacked. + * and the entity is not attacked.
+ * + *
+ * @param stack The Item being used + * @param stack The Item being used
+ * @param player The player that is attacking + * @param player The player that is attacking
+ * @param entity The entity being attacked + * @param entity The entity being attacked
+ * @return True to cancel the rest of the interaction. + * @return True to cancel the rest of the interaction.
+ */ + */
+ public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) + public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
+ { + {
+ return false; + return false;
+ } + }
+ +
+ /** + /**
+ * Player, Render pass, and item usage sensitive version of getIconIndex. + * Player, Render pass, and item usage sensitive version of getIconIndex.
+ * + *
+ * @param stack The item stack to get the icon for. (Usually this, and usingItem will be the same if usingItem is not null) + * @param stack The item stack to get the icon for. (Usually this, and usingItem will be the same if usingItem is not null)
+ * @param renderPass The pass to get the icon for, 0 is default. + * @param renderPass The pass to get the icon for, 0 is default.
+ * @param player The player holding the item + * @param player The player holding the item
@ -188,7 +188,7 @@
+ * Returns the number of render passes/layers this item has. + * Returns the number of render passes/layers this item has.
+ * Usually equates to ItemRenderer.renderItem being called for this many passes. + * Usually equates to ItemRenderer.renderItem being called for this many passes.
+ * Does not get called unless requiresMultipleRenderPasses() is true; + * Does not get called unless requiresMultipleRenderPasses() is true;
+ * + *
+ * @param metadata The item's metadata + * @param metadata The item's metadata
+ * @return The number of passes to run. + * @return The number of passes to run.
+ */ + */
@ -212,7 +212,7 @@
+ /** + /**
+ * Sets the current texture file for this item, used when rendering. + * Sets the current texture file for this item, used when rendering.
+ * Default is "/gui/items.png" + * Default is "/gui/items.png"
+ * + *
+ * @param texture The texture file + * @param texture The texture file
+ */ + */
+ public Item setTextureFile(String texture) + public Item setTextureFile(String texture)
@ -225,7 +225,7 @@
+ /** + /**
+ * ItemStack sensitive version of getContainerItem. + * ItemStack sensitive version of getContainerItem.
+ * Returns a full ItemStack instance of the result. + * Returns a full ItemStack instance of the result.
+ * + *
+ * @param itemStack The current ItemStack + * @param itemStack The current ItemStack
+ * @return The resulting ItemStack + * @return The resulting ItemStack
+ */ + */
@ -241,7 +241,7 @@
+ /** + /**
+ * Retrieves the normal 'lifespan' of this item when it is dropped on the ground as a EntityItem. + * Retrieves the normal 'lifespan' of this item when it is dropped on the ground as a EntityItem.
+ * This is in ticks, standard result is 6000, or 5 mins. + * This is in ticks, standard result is 6000, or 5 mins.
+ * + *
+ * @param itemStack The current ItemStack + * @param itemStack The current ItemStack
+ * @param world The world the entity is in + * @param world The world the entity is in
+ * @return The normal lifespan in ticks. + * @return The normal lifespan in ticks.
@ -253,9 +253,9 @@
+ +
+ /** + /**
+ * Determines if this Item has a special entity for when they are in the world. + * Determines if this Item has a special entity for when they are in the world.
+ * Is called when a EntityItem is spawned in the world, if true and Item#createCustomEntity + * Is called when a EntityItem is spawned in the world, if true and Item#createCustomEntity
+ * returns non null, the EntityItem will be destroyed and the new Entity will be added to the world. + * returns non null, the EntityItem will be destroyed and the new Entity will be added to the world.
+ * + *
+ * @param stack The current item stack + * @param stack The current item stack
+ * @return True of the item has a custom entity, If true, Item#createCustomEntity will be called + * @return True of the item has a custom entity, If true, Item#createCustomEntity will be called
+ */ + */
@ -268,7 +268,7 @@
+ * This function should return a new entity to replace the dropped item. + * This function should return a new entity to replace the dropped item.
+ * Returning null here will not kill the EntityItem and will leave it to function normally. + * Returning null here will not kill the EntityItem and will leave it to function normally.
+ * Called when the item it placed in a world. + * Called when the item it placed in a world.
+ * + *
+ * @param world The world object + * @param world The world object
+ * @param location The EntityItem object, useful for getting the position of the entity + * @param location The EntityItem object, useful for getting the position of the entity
+ * @param itemstack The current item stack + * @param itemstack The current item stack
@ -280,10 +280,10 @@
+ } + }
+ +
+ /** + /**
+ * Gets a list of tabs that items belonging to this class can display on, + * Gets a list of tabs that items belonging to this class can display on,
+ * combined properly with getSubItems allows for a single item to span + * combined properly with getSubItems allows for a single item to span
+ * many sub-items across many tabs. + * many sub-items across many tabs.
+ * + *
+ * @return A list of all tabs that this item could possibly be one. + * @return A list of all tabs that this item could possibly be one.
+ */ + */
+ public CreativeTabs[] getCreativeTabs() + public CreativeTabs[] getCreativeTabs()
@ -293,14 +293,27 @@
+ +
+ /** + /**
+ * Determines the base experience for a player when they remove this item from a furnace slot. + * Determines the base experience for a player when they remove this item from a furnace slot.
+ * This number must be between 0 and 1 for it to be valid. + * This number must be between 0 and 1 for it to be valid.
+ * This number will be multiplied by the stack size to get the total experience. + * This number will be multiplied by the stack size to get the total experience.
+ * + *
+ * @param item The item stack the player is picking up. + * @param item The item stack the player is picking up.
+ * @return The amount to award for each item. + * @return The amount to award for each item.
+ */ + */
+ public float getSmeltingExperience(ItemStack item) + public float getSmeltingExperience(ItemStack item)
+ { + {
+ return -1; //-1 will default to the old lookups. + return -1; //-1 will default to the old lookups.
+ }
+
+ /**
+ * Return the correct icon for rendering based on the supplied ItemStack and render pass.
+ *
+ * Defers to {@link #getIconFromDamageForRenderPass(int, int)}
+ * @param stack to render for
+ * @param pass the multi-render pass
+ * @return the icon index
+ */
+ public int getIconFromItemStackForMultiplePasses(ItemStack stack, int pass)
+ {
+ return getIconFromDamageForRenderPass(stack.getItemDamage(), pass);
+ } + }
} }

View File

@ -49,7 +49,7 @@
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
} }
@@ -121,10 +126,11 @@ @@ -121,11 +126,12 @@
GL11.glScalef(0.5F, 0.5F, 0.5F); GL11.glScalef(0.5F, 0.5F, 0.5F);
} }
@ -57,14 +57,16 @@
- -
- for (var15 = 0; var15 <= 1; ++var15) - for (var15 = 0; var15 <= 1; ++var15)
- { - {
- var16 = var10.getItem().getIconFromDamageForRenderPass(var10.getItemDamage(), var15);
+ this.loadTexture(Item.itemsList[var10.itemID].getTextureFile()); + this.loadTexture(Item.itemsList[var10.itemID].getTextureFile());
+ +
+ for (var15 = 0; var15 < var10.getItem().getRenderPasses(var10.getItemDamage()); ++var15) + for (var15 = 0; var15 < var10.getItem().getRenderPasses(var10.getItemDamage()); ++var15)
+ { + {
+ this.random.setSeed(187L); //Fixes Vanilla bug where layers would not render aligns properly. + this.random.setSeed(187L); //Fixes Vanilla bug where layers would not render aligns properly.
var16 = var10.getItem().getIconFromDamageForRenderPass(var10.getItemDamage(), var15); + var16 = var10.getItem().getIconFromItemStackForMultiplePasses(var10, var15);
var17 = 1.0F; var17 = 1.0F;
if (this.field_77024_a)
@@ -155,14 +161,7 @@ @@ -155,14 +161,7 @@
var15 = var10.getIconIndex(); var15 = var10.getIconIndex();
@ -95,19 +97,23 @@
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslatef((float)(par4 - 2), (float)(par5 + 3), -3.0F + this.zLevel); GL11.glTranslatef((float)(par4 - 2), (float)(par5 + 3), -3.0F + this.zLevel);
GL11.glScalef(10.0F, 10.0F, 10.0F); GL11.glScalef(10.0F, 10.0F, 10.0F);
@@ -265,9 +264,9 @@ @@ -265,11 +264,11 @@
if (Item.itemsList[var6].requiresMultipleRenderPasses()) if (Item.itemsList[var6].requiresMultipleRenderPasses())
{ {
GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_LIGHTING);
- par2RenderEngine.bindTexture(par2RenderEngine.getTexture("/gui/items.png")); - par2RenderEngine.bindTexture(par2RenderEngine.getTexture("/gui/items.png"));
- -
- for (var9 = 0; var9 <= 1; ++var9) - for (var9 = 0; var9 <= 1; ++var9)
- {
- var10 = Item.itemsList[var6].getIconFromDamageForRenderPass(var7, var9);
+ par2RenderEngine.bindTexture(par2RenderEngine.getTexture(Item.itemsList[var6].getTextureFile())); + par2RenderEngine.bindTexture(par2RenderEngine.getTexture(Item.itemsList[var6].getTextureFile()));
+ +
+ for (var9 = 0; var9 < Item.itemsList[var6].getRenderPasses(var7); ++var9) + for (var9 = 0; var9 < Item.itemsList[var6].getRenderPasses(var7); ++var9)
{ + {
var10 = Item.itemsList[var6].getIconFromDamageForRenderPass(var7, var9); + var10 = Item.itemsList[var6].getIconFromItemStackForMultiplePasses(par3ItemStack, var9);
int var11 = Item.itemsList[var6].getColorFromItemStack(par3ItemStack, var9); int var11 = Item.itemsList[var6].getColorFromItemStack(par3ItemStack, var9);
var12 = (float)(var11 >> 16 & 255) / 255.0F;
var13 = (float)(var11 >> 8 & 255) / 255.0F;
@@ -289,14 +288,7 @@ @@ -289,14 +288,7 @@
{ {
GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_LIGHTING);