689 lines
24 KiB
Diff
689 lines
24 KiB
Diff
--- ../src-base/minecraft/net/minecraft/item/Item.java
|
|
+++ ../src-work/minecraft/net/minecraft/item/Item.java
|
|
@@ -47,8 +47,8 @@
|
|
|
|
public class Item
|
|
{
|
|
- public static final RegistryNamespaced field_150901_e = new RegistryNamespaced();
|
|
- private static final Map field_179220_a = Maps.newHashMap();
|
|
+ public static final RegistryNamespaced field_150901_e = net.minecraftforge.fml.common.registry.GameData.getItemRegistry();
|
|
+ private static final Map field_179220_a = net.minecraftforge.fml.common.registry.GameData.getBlockItemMap();
|
|
protected static final UUID field_111210_e = UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF");
|
|
private CreativeTabs field_77701_a;
|
|
protected static Random field_77697_d = new Random();
|
|
@@ -61,6 +61,9 @@
|
|
private String field_77774_bZ;
|
|
private static final String __OBFID = "CL_00000041";
|
|
|
|
+ public final net.minecraftforge.fml.common.registry.RegistryDelegate<Item> delegate =
|
|
+ ((net.minecraftforge.fml.common.registry.FMLControlledNamespacedRegistry)field_150901_e).getDelegate(this, Item.class);
|
|
+
|
|
public static int func_150891_b(Item p_150891_0_)
|
|
{
|
|
return p_150891_0_ == null ? 0 : field_150901_e.func_148757_b(p_150891_0_);
|
|
@@ -126,6 +129,7 @@
|
|
return p_77654_1_;
|
|
}
|
|
|
|
+ @Deprecated // Use ItemStack sensitive version below.
|
|
public int func_77639_j()
|
|
{
|
|
return this.field_77777_bU;
|
|
@@ -239,6 +243,7 @@
|
|
return this.field_77700_c;
|
|
}
|
|
|
|
+ @Deprecated // Use ItemStack sensitive version below.
|
|
public boolean func_77634_r()
|
|
{
|
|
return this.field_77700_c != null;
|
|
@@ -308,7 +313,7 @@
|
|
|
|
public boolean func_77616_k(ItemStack p_77616_1_)
|
|
{
|
|
- return this.func_77639_j() == 1 && this.func_77645_m();
|
|
+ return this.getItemStackLimit(p_77616_1_) == 1 && this.func_77645_m();
|
|
}
|
|
|
|
protected MovingObjectPosition func_77621_a(World p_77621_1_, EntityPlayer p_77621_2_, boolean p_77621_3_)
|
|
@@ -326,6 +331,10 @@
|
|
float f6 = f3 * f4;
|
|
float f7 = f2 * f4;
|
|
double d3 = 5.0D;
|
|
+ if (p_77621_2_ instanceof net.minecraft.entity.player.EntityPlayerMP)
|
|
+ {
|
|
+ d3 = ((net.minecraft.entity.player.EntityPlayerMP)p_77621_2_).field_71134_c.getBlockReachDistance();
|
|
+ }
|
|
Vec3 vec31 = vec3.func_72441_c((double)f6 * d3, (double)f5 * d3, (double)f7 * d3);
|
|
return p_77621_1_.func_147447_a(vec3, vec31, p_77621_3_, !p_77621_3_, false);
|
|
}
|
|
@@ -363,11 +372,579 @@
|
|
return false;
|
|
}
|
|
|
|
+ @Deprecated // Use ItemStack sensitive version below.
|
|
public Multimap func_111205_h()
|
|
{
|
|
return HashMultimap.create();
|
|
}
|
|
|
|
+ /* ======================================== FORGE START =====================================*/
|
|
+ /**
|
|
+ * ItemStack sensitive version of getItemAttributeModifiers
|
|
+ */
|
|
+ public Multimap getAttributeModifiers(ItemStack stack)
|
|
+ {
|
|
+ return this.func_111205_h();
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * 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 pos Target 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, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
|
|
+ {
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Metadata-sensitive version of getStrVsBlock
|
|
+ * @param itemstack The Item Stack
|
|
+ * @param state The block state
|
|
+ * @return The damage strength
|
|
+ */
|
|
+ public float getDigSpeed(ItemStack itemstack, net.minecraft.block.state.IBlockState state)
|
|
+ {
|
|
+ return func_150893_a(itemstack, state.func_177230_c());
|
|
+ }
|
|
+
|
|
+
|
|
+ protected boolean canRepair = true;
|
|
+ /**
|
|
+ * Called by CraftingManager to determine if an item is reparable.
|
|
+ * @return True if reparable
|
|
+ */
|
|
+ public boolean isRepairable()
|
|
+ {
|
|
+ return canRepair && func_77645_m();
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * 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 pos Block's position in world
|
|
+ * @param player The Player that is wielding the item
|
|
+ * @return True to prevent harvesting, false to continue as normal
|
|
+ */
|
|
+ public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, 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 onUsingTick(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.
|
|
+ * @param player The player holding the item
|
|
+ * @param useRemaining The ticks remaining for the active item.
|
|
+ * @return Null to use default model, or a custom ModelResourceLocation for the stage of use.
|
|
+ */
|
|
+ @SideOnly(Side.CLIENT)
|
|
+ public net.minecraft.client.resources.model.ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining)
|
|
+ {
|
|
+ return null;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * ItemStack sensitive version of getContainerItem.
|
|
+ * Returns a full ItemStack instance of the result.
|
|
+ *
|
|
+ * @param itemStack The current ItemStack
|
|
+ * @return The resulting ItemStack
|
|
+ */
|
|
+ public ItemStack getContainerItem(ItemStack itemStack)
|
|
+ {
|
|
+ if (!hasContainerItem(itemStack))
|
|
+ {
|
|
+ return null;
|
|
+ }
|
|
+ return new ItemStack(func_77668_q());
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * ItemStack sensitive version of hasContainerItem
|
|
+ * @param stack The current item stack
|
|
+ * @return True if this item has a 'container'
|
|
+ */
|
|
+ public boolean hasContainerItem(ItemStack stack)
|
|
+ {
|
|
+ return func_77634_r();
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * 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.
|
|
+ *
|
|
+ * @param itemStack The current ItemStack
|
|
+ * @param world The world the entity is in
|
|
+ * @return The normal lifespan in ticks.
|
|
+ */
|
|
+ public int getEntityLifespan(ItemStack itemStack, World world)
|
|
+ {
|
|
+ return 6000;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * 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
|
|
+ * returns non null, the EntityItem will be destroyed and the new Entity will be added to the world.
|
|
+ *
|
|
+ * @param stack The current item stack
|
|
+ * @return True of the item has a custom entity, If true, Item#createCustomEntity will be called
|
|
+ */
|
|
+ public boolean hasCustomEntity(ItemStack stack)
|
|
+ {
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * 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.
|
|
+ * Called when the item it placed in a world.
|
|
+ *
|
|
+ * @param world The world object
|
|
+ * @param location The EntityItem object, useful for getting the position of the entity
|
|
+ * @param itemstack The current item stack
|
|
+ * @return A new Entity object to spawn or null
|
|
+ */
|
|
+ public Entity createEntity(World world, Entity location, ItemStack itemstack)
|
|
+ {
|
|
+ return null;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Called by the default implemetation of EntityItem's onUpdate method, allowing for cleaner
|
|
+ * control over the update of the item without having to write a subclass.
|
|
+ *
|
|
+ * @param entityItem The entity Item
|
|
+ * @return Return true to skip any further update code.
|
|
+ */
|
|
+ public boolean onEntityItemUpdate(net.minecraft.entity.item.EntityItem entityItem)
|
|
+ {
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * 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
|
|
+ * many sub-items across many tabs.
|
|
+ *
|
|
+ * @return A list of all tabs that this item could possibly be one.
|
|
+ */
|
|
+ public CreativeTabs[] getCreativeTabs()
|
|
+ {
|
|
+ return new CreativeTabs[]{ func_77640_w() };
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * 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 will be multiplied by the stack size to get the total experience.
|
|
+ *
|
|
+ * @param item The item stack the player is picking up.
|
|
+ * @return The amount to award for each item.
|
|
+ */
|
|
+ public float getSmeltingExperience(ItemStack item)
|
|
+ {
|
|
+ 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
|
|
+ * /
|
|
+ public IIcon getIcon(ItemStack stack, int pass)
|
|
+ {
|
|
+ return func_77618_c(stack.getMetadata(), pass);
|
|
+ }
|
|
+ */
|
|
+
|
|
+ /**
|
|
+ * Generates the base Random item for a specific instance of the chest gen,
|
|
+ * Enchanted books use this to pick a random enchantment.
|
|
+ *
|
|
+ * @param chest The chest category to generate for
|
|
+ * @param rnd World RNG
|
|
+ * @param original Original result registered with the chest gen hooks.
|
|
+ * @return New values to use as the random item, typically this will be original
|
|
+ */
|
|
+ public net.minecraft.util.WeightedRandomChestContent getChestGenBase(net.minecraftforge.common.ChestGenHooks chest, Random rnd, net.minecraft.util.WeightedRandomChestContent original)
|
|
+ {
|
|
+ if (this instanceof ItemEnchantedBook)
|
|
+ {
|
|
+ return ((ItemEnchantedBook)this).func_92112_a(rnd,
|
|
+ original.field_76295_d,
|
|
+ original.field_76296_e, original.field_76292_a);
|
|
+ }
|
|
+ return original;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ *
|
|
+ * Should this item, when held, allow sneak-clicks to pass through to the underlying block?
|
|
+ *
|
|
+ * @param world The world
|
|
+ * @param pos Block position in world
|
|
+ * @param player The Player that is wielding the item
|
|
+ * @return
|
|
+ */
|
|
+ public boolean doesSneakBypassUse(World world, BlockPos pos, EntityPlayer player)
|
|
+ {
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Called to tick armor in the armor slot. Override to do something
|
|
+ */
|
|
+ public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack){}
|
|
+
|
|
+ /**
|
|
+ * Determines if the specific ItemStack can be placed in the specified armor slot.
|
|
+ *
|
|
+ * @param stack The ItemStack
|
|
+ * @param armorType Armor slot ID: 0: Helmet, 1: Chest, 2: Legs, 3: Boots
|
|
+ * @param entity The entity trying to equip the armor
|
|
+ * @return True if the given ItemStack can be inserted in the slot
|
|
+ */
|
|
+ public boolean isValidArmor(ItemStack stack, int armorType, Entity entity)
|
|
+ {
|
|
+ if (this instanceof ItemArmor)
|
|
+ {
|
|
+ return ((ItemArmor)this).field_77881_a == armorType;
|
|
+ }
|
|
+
|
|
+ if (armorType == 0)
|
|
+ {
|
|
+ return this == Item.func_150898_a(Blocks.field_150423_aK) || this == Items.field_151144_bL;
|
|
+ }
|
|
+
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Allow or forbid the specific book/item combination as an anvil enchant
|
|
+ *
|
|
+ * @param stack The item
|
|
+ * @param book The book
|
|
+ * @return if the enchantment is allowed
|
|
+ */
|
|
+ public boolean isBookEnchantable(ItemStack stack, ItemStack book)
|
|
+ {
|
|
+ return true;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Called by RenderBiped and RenderPlayer to determine the armor texture that
|
|
+ * should be use for the currently equipped item.
|
|
+ * This will only be called on instances of ItemArmor.
|
|
+ *
|
|
+ * Returning null from this function will use the default value.
|
|
+ *
|
|
+ * @param stack ItemStack for the equipped armor
|
|
+ * @param entity The entity wearing the armor
|
|
+ * @param slot The slot the armor is in
|
|
+ * @param type The subtype, can be null or "overlay"
|
|
+ * @return Path of texture to bind, or null to use default
|
|
+ */
|
|
+ public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
|
|
+ {
|
|
+ return null;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Returns the font renderer used to render tooltips and overlays for this item.
|
|
+ * Returning null will use the standard font renderer.
|
|
+ *
|
|
+ * @param stack The current item stack
|
|
+ * @return A instance of FontRenderer or null to use default
|
|
+ */
|
|
+ @SideOnly(Side.CLIENT)
|
|
+ public net.minecraft.client.gui.FontRenderer getFontRenderer(ItemStack stack)
|
|
+ {
|
|
+ return null;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Override this method to have an item handle its own armor rendering.
|
|
+ *
|
|
+ * @param entityLiving The entity wearing the armor
|
|
+ * @param itemStack The itemStack to render the model of
|
|
+ * @param armorSlot 0=head, 1=torso, 2=legs, 3=feet
|
|
+ *
|
|
+ * @return A ModelBiped to render instead of the default
|
|
+ */
|
|
+ @SideOnly(Side.CLIENT)
|
|
+ public net.minecraft.client.model.ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot)
|
|
+ {
|
|
+ return null;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Called when a entity tries to play the 'swing' animation.
|
|
+ *
|
|
+ * @param entityLiving The entity swinging the item.
|
|
+ * @param stack The Item stack
|
|
+ * @return True to cancel any further processing by EntityLiving
|
|
+ */
|
|
+ public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack)
|
|
+ {
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Called when the client starts rendering the HUD, for whatever item the player currently has as a helmet.
|
|
+ * This is where pumpkins would render there overlay.
|
|
+ *
|
|
+ * @param stack The ItemStack that is equipped
|
|
+ * @param player Reference to the current client entity
|
|
+ * @param resolution Resolution information about the current viewport and configured GUI Scale
|
|
+ * @param partialTicks Partial ticks for the renderer, useful for interpolation
|
|
+ */
|
|
+ @SideOnly(Side.CLIENT)
|
|
+ public void renderHelmetOverlay(ItemStack stack, EntityPlayer player, net.minecraft.client.gui.ScaledResolution resolution, float partialTicks){}
|
|
+
|
|
+ /**
|
|
+ * Return the itemDamage represented by this ItemStack. Defaults to the itemDamage field on ItemStack, but can be overridden here for other sources such as NBT.
|
|
+ *
|
|
+ * @param stack The itemstack that is damaged
|
|
+ * @return the damage value
|
|
+ */
|
|
+ public int getDamage(ItemStack stack)
|
|
+ {
|
|
+ return stack.field_77991_e;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * This used to be 'display damage' but its really just 'aux' data in the ItemStack, usually shares the same variable as damage.
|
|
+ * @param stack
|
|
+ * @return
|
|
+ */
|
|
+ public int getMetadata(ItemStack stack)
|
|
+ {
|
|
+ return stack.field_77991_e;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Determines if the durability bar should be rendered for this item.
|
|
+ * Defaults to vanilla stack.isDamaged behavior.
|
|
+ * But modders can use this for any data they wish.
|
|
+ *
|
|
+ * @param stack The current Item Stack
|
|
+ * @return True if it should render the 'durability' bar.
|
|
+ */
|
|
+ public boolean showDurabilityBar(ItemStack stack)
|
|
+ {
|
|
+ return stack.func_77951_h();
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Queries the percentage of the 'Durability' bar that should be drawn.
|
|
+ *
|
|
+ * @param stack The current ItemStack
|
|
+ * @return 1.0 for 100% 0 for 0%
|
|
+ */
|
|
+ public double getDurabilityForDisplay(ItemStack stack)
|
|
+ {
|
|
+ return (double)stack.func_77952_i() / (double)stack.func_77958_k();
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Return the maxDamage for this ItemStack. Defaults to the maxDamage field in this item,
|
|
+ * but can be overridden here for other sources such as NBT.
|
|
+ *
|
|
+ * @param stack The itemstack that is damaged
|
|
+ * @return the damage value
|
|
+ */
|
|
+ public int getMaxDamage(ItemStack stack)
|
|
+ {
|
|
+ return func_77612_l();
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Return if this itemstack is damaged. Note only called if {@link #isDamageable()} is true.
|
|
+ * @param stack the stack
|
|
+ * @return if the stack is damaged
|
|
+ */
|
|
+ public boolean isDamaged(ItemStack stack)
|
|
+ {
|
|
+ return stack.field_77991_e > 0;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Set the damage for this itemstack. Note, this method is responsible for zero checking.
|
|
+ * @param stack the stack
|
|
+ * @param damage the new damage value
|
|
+ */
|
|
+ public void setDamage(ItemStack stack, int damage)
|
|
+ {
|
|
+ stack.field_77991_e = damage;
|
|
+
|
|
+ if (stack.field_77991_e < 0)
|
|
+ {
|
|
+ stack.field_77991_e = 0;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * ItemStack sensitive version of {@link #canHarvestBlock(Block)}
|
|
+ * @param par1Block The block trying to harvest
|
|
+ * @param itemStack The itemstack used to harvest the block
|
|
+ * @return true if can harvest the block
|
|
+ */
|
|
+ public boolean canHarvestBlock(Block par1Block, ItemStack itemStack)
|
|
+ {
|
|
+ return func_150897_b(par1Block);
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Gets the maximum number of items that this stack should be able to hold.
|
|
+ * This is a ItemStack (and thus NBT) sensitive version of Item.getItemStackLimit()
|
|
+ *
|
|
+ * @param stack The ItemStack
|
|
+ * @return THe maximum number this item can be stacked to
|
|
+ */
|
|
+ public int getItemStackLimit(ItemStack stack)
|
|
+ {
|
|
+ return this.func_77639_j();
|
|
+ }
|
|
+
|
|
+ private java.util.Map<String, Integer> toolClasses = new java.util.HashMap<String, Integer>();
|
|
+ /**
|
|
+ * Sets or removes the harvest level for the specified tool class.
|
|
+ *
|
|
+ * @param toolClass Class
|
|
+ * @param level Harvest level:
|
|
+ * Wood: 0
|
|
+ * Stone: 1
|
|
+ * Iron: 2
|
|
+ * Diamond: 3
|
|
+ * Gold: 0
|
|
+ */
|
|
+ public void setHarvestLevel(String toolClass, int level)
|
|
+ {
|
|
+ if (level < 0)
|
|
+ toolClasses.remove(toolClass);
|
|
+ else
|
|
+ toolClasses.put(toolClass, level);
|
|
+ }
|
|
+
|
|
+ public java.util.Set<String> getToolClasses(ItemStack stack)
|
|
+ {
|
|
+ return toolClasses.keySet();
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Queries the harvest level of this item stack for the specifred tool class,
|
|
+ * Returns -1 if this tool is not of the specified type
|
|
+ *
|
|
+ * @param stack This item stack instance
|
|
+ * @param toolClass Tool Class
|
|
+ * @return Harvest level, or -1 if not the specified tool type.
|
|
+ */
|
|
+ public int getHarvestLevel(ItemStack stack, String toolClass)
|
|
+ {
|
|
+ Integer ret = toolClasses.get(toolClass);
|
|
+ return ret == null ? -1 : ret;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * ItemStack sensitive version of getItemEnchantability
|
|
+ *
|
|
+ * @param stack The ItemStack
|
|
+ * @return the item echantability value
|
|
+ */
|
|
+ public int getItemEnchantability(ItemStack stack)
|
|
+ {
|
|
+ return func_77619_b();
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Whether this Item can be used as a payment to activate the vanilla beacon.
|
|
+ * @param stack the ItemStack
|
|
+ * @return true if this Item can be used
|
|
+ */
|
|
+ public boolean isBeaconPayment(ItemStack stack)
|
|
+ {
|
|
+ return this == Items.field_151166_bC || this == Items.field_151045_i || this == Items.field_151043_k || this == Items.field_151042_j;
|
|
+ }
|
|
+
|
|
+
|
|
+ /**
|
|
+ * Determine if the player switching between these two item stacks
|
|
+ * @param oldStack The old stack that was equipped
|
|
+ * @param newStack The new stack
|
|
+ * @param slotChanged If the current equipped slot was changed,
|
|
+ * Vanilla does not play the animation if you switch between two
|
|
+ * slots that hold the exact same item.
|
|
+ * @return True to play the item change animation
|
|
+ */
|
|
+ public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
|
|
+ {
|
|
+ return !ItemStack.func_77989_b(oldStack, newStack);
|
|
+ }
|
|
+ /* ======================================== FORGE END =====================================*/
|
|
+
|
|
+
|
|
public static void func_150900_l()
|
|
{
|
|
func_179214_a(Blocks.field_150348_b, (new ItemMultiTexture(Blocks.field_150348_b, Blocks.field_150348_b, new Function()
|
|
@@ -933,6 +1510,10 @@
|
|
|
|
private static final String __OBFID = "CL_00000042";
|
|
|
|
+ //Added by forge for custom Tool materials.
|
|
+ @Deprecated public Item customCraftingMaterial = null; // Remote in 1.8.1
|
|
+ private ItemStack repairMaterial = null;
|
|
+
|
|
private ToolMaterial(int p_i1874_3_, int p_i1874_4_, float p_i1874_5_, float p_i1874_6_, int p_i1874_7_)
|
|
{
|
|
this.field_78001_f = p_i1874_3_;
|
|
@@ -967,9 +1548,36 @@
|
|
return this.field_78008_j;
|
|
}
|
|
|
|
+ @Deprecated // Use getRepairItemStack below
|
|
public Item func_150995_f()
|
|
{
|
|
- return this == WOOD ? Item.func_150898_a(Blocks.field_150344_f) : (this == STONE ? Item.func_150898_a(Blocks.field_150347_e) : (this == GOLD ? Items.field_151043_k : (this == IRON ? Items.field_151042_j : (this == EMERALD ? Items.field_151045_i : null))));
|
|
+ switch (this)
|
|
+ {
|
|
+ case WOOD: return Item.func_150898_a(Blocks.field_150344_f);
|
|
+ case STONE: return Item.func_150898_a(Blocks.field_150347_e);
|
|
+ case GOLD: return Items.field_151043_k;
|
|
+ case IRON: return Items.field_151042_j;
|
|
+ case EMERALD: return Items.field_151045_i;
|
|
+ default: return customCraftingMaterial;
|
|
+ }
|
|
}
|
|
+
|
|
+ public ToolMaterial setRepairItem(ItemStack stack)
|
|
+ {
|
|
+ if (this.repairMaterial != null || customCraftingMaterial != null) throw new RuntimeException("Can not change already set repair material");
|
|
+ if (this == WOOD || this == STONE || this == GOLD || this == IRON || this == EMERALD) throw new RuntimeException("Can not change vanilla tool repair materials");
|
|
+ this.repairMaterial = stack;
|
|
+ this.customCraftingMaterial = stack.func_77973_b();
|
|
+ return this;
|
|
+ }
|
|
+
|
|
+ public ItemStack getRepairItemStack()
|
|
+ {
|
|
+ if (repairMaterial != null) return repairMaterial;
|
|
+ Item ret = this.func_150995_f();
|
|
+ if (ret == null) return null;
|
|
+ repairMaterial = new ItemStack(ret, 1, net.minecraftforge.oredict.OreDictionary.WILDCARD_VALUE);
|
|
+ return repairMaterial;
|
|
+ }
|
|
}
|
|
}
|