ForgePatch/patches/common/net/minecraft/src/Item.java.patch

218 lines
7.3 KiB
Diff
Raw Normal View History

--- ../src_base/common/net/minecraft/src/Item.java
+++ ../src_work/common/net/minecraft/src/Item.java
@@ -196,13 +196,16 @@
/** full name of item from language file */
private String itemName;
+ /** FORGE: To disable repair recipes. */
+ protected boolean canRepair = true;
+
protected Item(int par1)
{
this.shiftedIndex = 256 + par1;
if (itemsList[256 + par1] != null)
{
- System.out.println("CONFLICT @ " + par1);
+ System.out.println("CONFLICT @ " + par1 + " item slot already occupied by " + itemsList[256 + par1] + " while adding " + this);
}
itemsList[256 + par1] = this;
@@ -589,6 +592,10 @@
float var18 = var15 * var16;
float var20 = var14 * var16;
double var21 = 5.0D;
+ if (par2EntityPlayer instanceof EntityPlayerMP)
+ {
+ var21 = ((EntityPlayerMP)par2EntityPlayer).theItemInWorldManager.getBlockReachDistance();
+ }
Vec3 var23 = var13.addVector((double)var18 * var21, (double)var17 * var21, (double)var20 * var21);
return par1World.rayTraceBlocks_do_do(var13, var23, par3, !par3);
}
@@ -650,4 +657,185 @@
2012-08-06 10:54:57 +00:00
{
StatList.initStats();
}
+
+ /* =========================================================== FORGE START ===============================================================*/
+ public boolean isDefaultTexture = true;
+ private String currentTexture = "/gui/items.png";
+
+ /**
+ * Called when a player drops the item into the world,
+ * returning false from this will prevent the item from
+ * being removed from the players inventory and spawning
+ * in the world
+ *
+ * @param player The player that dropped the item
+ * @param item The item stack, before the item is removed.
+ */
+ public boolean onDroppedByPlayer(ItemStack item, EntityPlayer player)
+ {
+ return true;
+ }
+
+ /**
+ * This is called when the item is used, before the block is activated.
+ * @param stack The Item Stack
+ * @param player The Player that used the item
+ * @param world The Current World
+ * @param X Target X Position
+ * @param Y Target Y Position
+ * @param Z Target Z Position
+ * @param side The side of the target hit
+ * @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)
+ {
+ return false;
+ }
+
+ /**
+ * Metadata-sensitive version of getStrVsBlock
+ * @param itemstack The Item Stack
+ * @param block The block the item is trying to break
+ * @param metadata The items current metadata
+ * @return The damage strength
+ */
+ public float getStrVsBlock(ItemStack itemstack, Block block, int metadata)
+ {
+ return getStrVsBlock(itemstack, block);
+ }
+
+ /**
+ * Called by CraftingManager to determine if an item is reparable.
+ * @return True if reparable
+ */
+ public boolean isRepairable()
+ {
+ return canRepair && isDamageable();
+ }
+
+ /**
+ * Call to disable repair recipes.
+ * @return The current Item instance
+ */
+ public Item setNoRepair()
+ {
+ canRepair = false;
+ return this;
+ }
+
+ /**
+ * 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!
+ *
+ * @param itemstack The current ItemStack
+ * @param X The X Position
+ * @param Y The X Position
+ * @param Z The X Position
+ * @param player The Player that is wielding the item
+ * @return True to prevent harvesting, false to continue as normal
+ */
+ public boolean onBlockStartBreak(ItemStack itemstack, int X, int Y, int Z, EntityPlayer player)
+ {
+ return false;
+ }
+
+ /**
+ * Called each tick while using an item.
+ * @param stack The Item being used
+ * @param player The Player using the item
+ * @param count The amount of time in tick the item has been used for continuously
+ */
+ public void onUsingItemTick(ItemStack stack, EntityPlayer player, int count)
+ {
+ }
+
+ /**
+ * Called when the player Left Clicks (attacks) an entity.
+ * Processed before damage is done, if return value is true further processing is canceled
+ * and the entity is not attacked.
+ *
+ * @param stack The Item being used
+ * @param player The player that is attacking
+ * @param entity The entity being attacked
+ * @return True to cancel the rest of the interaction.
+ */
+ 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);
+ }
+
+ /**
+ * Returns the number of render passes/layers this item has.
+ * Usually equates to ItemRenderer.renderItem being called for this many passes.
+ * Does not get called unless requiresMultipleRenderPasses() is true;
+ *
+ * @param metadata The item's metadata
+ * @return The number of passes to run.
+ */
+ public int getRenderPasses(int metadata)
+ {
+ return requiresMultipleRenderPasses() ? 2 : 1;
+ }
+
+ /**
+ * Grabs the current texture file used for this block
+ */
+ public String getTextureFile()
+ {
+ if (this instanceof ItemBlock)
+ {
+ return Block.blocksList[((ItemBlock)this).getBlockID()].getTextureFile();
+ }
+ return currentTexture;
+ }
+
+ /**
+ * Sets the current texture file for this item, used when rendering.
+ * Default is "/gui/items.png"
+ *
+ * @param texture The texture file
+ */
+ public void setTextureFile(String texture)
+ {
+ currentTexture = texture;
+ isDefaultTexture = false;
+ }
2012-08-06 10:54:57 +00:00
+
+ /**
+ * ItemStack sensitive version of getContainerItem.
+ * Returns a full ItemStack instance of the result.
+ *
+ * @param itemStack The current ItemStack
+ * @return The resulting ItemStack
+ */
+ public ItemStack getContainerItemStack(ItemStack itemStack)
+ {
+ return new ItemStack(getContainerItem());
+ }
}