From a5e209952e0a2f9f8b92a105a7e251a95a5a9a17 Mon Sep 17 00:00:00 2001 From: LexManos Date: Wed, 22 Feb 2012 16:49:57 -0800 Subject: [PATCH] Added new Item.getIconIndex context sensitive version. --- .../net/minecraft/src/EntityPlayer.java.patch | 10 ++++++- .../net/minecraft/src/Item.java.patch | 27 ++++++++++++++++++- .../net/minecraft/src/Item.java.patch | 18 ++++++++++++- 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/forge/patches/minecraft/net/minecraft/src/EntityPlayer.java.patch b/forge/patches/minecraft/net/minecraft/src/EntityPlayer.java.patch index 6be2acfae..69d31abf7 100644 --- a/forge/patches/minecraft/net/minecraft/src/EntityPlayer.java.patch +++ b/forge/patches/minecraft/net/minecraft/src/EntityPlayer.java.patch @@ -142,7 +142,15 @@ if (!worldObj.isRemote) { if (isPlayerSleeping() || !isEntityAlive()) -@@ -1473,4 +1547,30 @@ +@@ -1341,6 +1415,7 @@ + return 101; + } + } ++ j = itemstack.getItem().getIconIndex(itemstack, i, this, itemInUse, itemInUseCount); + } + return j; + } +@@ -1473,4 +1548,30 @@ experience = entityplayer.experience; score = entityplayer.score; } diff --git a/forge/patches/minecraft/net/minecraft/src/Item.java.patch b/forge/patches/minecraft/net/minecraft/src/Item.java.patch index df0f16738..00f7532c9 100644 --- a/forge/patches/minecraft/net/minecraft/src/Item.java.patch +++ b/forge/patches/minecraft/net/minecraft/src/Item.java.patch @@ -27,7 +27,7 @@ Vec3D vec3d1 = vec3d.addVector((double)f7 * d3, (double)f8 * d3, (double)f9 * d3); MovingObjectPosition movingobjectposition = world.rayTraceBlocks_do_do(vec3d, vec3d1, flag, !flag); return movingobjectposition; -@@ -469,6 +473,124 @@ +@@ -469,6 +473,149 @@ { return getIconFromDamage(i); } @@ -148,6 +148,31 @@ + public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) + { + return false; ++ } ++ ++ /** ++ * 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 renderPass The pass to get the icon for, 0 is default. ++ * @param player The player holding the item ++ * @param usingItem The item the player is actively using. Can be null if not using anything. ++ * @param useRemaining The ticks remaining for the active item. ++ * @return The icon index ++ */ ++ public int getIconIndex(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) ++ { ++ /* ++ * Here is an example usage for Vanilla bows. ++ if (usingItem != null && usingItem.getItem().shiftedIndex == Item.bow.shiftedIndex) ++ { ++ int k = usingItem.getMaxItemUseDuration() - useRemaining; ++ if (k >= 18) return 133; ++ if (k > 13) return 117; ++ if (k > 0) return 101; ++ } ++ */ ++ return getIconIndex(stack); + } static diff --git a/forge/patches/minecraft_server/net/minecraft/src/Item.java.patch b/forge/patches/minecraft_server/net/minecraft/src/Item.java.patch index 08c4d062d..51d80f7db 100644 --- a/forge/patches/minecraft_server/net/minecraft/src/Item.java.patch +++ b/forge/patches/minecraft_server/net/minecraft/src/Item.java.patch @@ -18,7 +18,7 @@ protected Item(int i) { maxStackSize = 64; -@@ -389,10 +393,132 @@ +@@ -389,10 +393,148 @@ float f8 = f6; float f9 = f3 * f5; double d3 = 5D; @@ -147,6 +147,22 @@ + public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) + { + return false; ++ } ++ ++ /** ++ * 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 renderPass The pass to get the icon for, 0 is default. ++ * @param player The player holding the item ++ * @param usingItem The item the player is actively using. Can be null if not using anything. ++ * @param useRemaining The ticks remaining for the active item. ++ * @return The icon index ++ */ ++ public int getIconIndex(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) ++ { ++ //This is here server side for compilation compatibility ++ return 0; + } public int getItemEnchantability()