mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-22 05:02:18 +00:00
718 lines
26 KiB
Diff
718 lines
26 KiB
Diff
--- ../src-base/minecraft/net/minecraft/item/Item.java
|
|
+++ ../src-work/minecraft/net/minecraft/item/Item.java
|
|
@@ -57,10 +57,10 @@
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
|
|
-public class Item
|
|
+public class Item extends net.minecraftforge.fml.common.registry.IForgeRegistryEntry.Impl<Item>
|
|
{
|
|
- public static final RegistryNamespaced<ResourceLocation, Item> field_150901_e = new RegistryNamespaced();
|
|
- private static final Map<Block, Item> field_179220_a = Maps.<Block, Item>newHashMap();
|
|
+ public static final RegistryNamespaced<ResourceLocation, Item> field_150901_e = net.minecraftforge.fml.common.registry.GameData.getItemRegistry();;
|
|
+ private static final Map<Block, Item> field_179220_a = net.minecraftforge.fml.common.registry.GameData.getBlockItemMap();
|
|
private static final IItemPropertyGetter field_185046_b = new IItemPropertyGetter()
|
|
{
|
|
@SideOnly(Side.CLIENT)
|
|
@@ -202,6 +202,7 @@
|
|
return p_77654_1_;
|
|
}
|
|
|
|
+ @Deprecated // Use ItemStack sensitive version below.
|
|
public int func_77639_j()
|
|
{
|
|
return this.field_77777_bU;
|
|
@@ -223,6 +224,7 @@
|
|
return this;
|
|
}
|
|
|
|
+ @Deprecated
|
|
public int func_77612_l()
|
|
{
|
|
return this.field_77699_b;
|
|
@@ -322,6 +324,7 @@
|
|
return this.field_77700_c;
|
|
}
|
|
|
|
+ @Deprecated // Use ItemStack sensitive version below.
|
|
public boolean func_77634_r()
|
|
{
|
|
return this.field_77700_c != null;
|
|
@@ -377,7 +380,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 RayTraceResult func_77621_a(World p_77621_1_, EntityPlayer p_77621_2_, boolean p_77621_3_)
|
|
@@ -395,7 +398,11 @@
|
|
float f6 = f3 * f4;
|
|
float f7 = f2 * f4;
|
|
double d3 = 5.0D;
|
|
- Vec3d vec3d1 = vec3d.func_72441_c((double)f6 * 5.0D, (double)f5 * 5.0D, (double)f7 * 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();
|
|
+ }
|
|
+ Vec3d vec3d1 = vec3d.func_72441_c((double)f6 * d3, (double)f5 * d3, (double)f7 * d3);
|
|
return p_77621_1_.func_147447_a(vec3d, vec3d1, p_77621_3_, !p_77621_3_, false);
|
|
}
|
|
|
|
@@ -433,11 +440,605 @@
|
|
return false;
|
|
}
|
|
|
|
+ @Deprecated // Use ItemStack sensitive version below.
|
|
public Multimap<String, AttributeModifier> func_111205_h(EntityEquipmentSlot p_111205_1_)
|
|
{
|
|
return HashMultimap.<String, AttributeModifier>create();
|
|
}
|
|
|
|
+ /* ======================================== FORGE START =====================================*/
|
|
+ /**
|
|
+ * ItemStack sensitive version of getItemAttributeModifiers
|
|
+ */
|
|
+ public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack)
|
|
+ {
|
|
+ return this.func_111205_h(slot);
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * 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;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Allow the item one last chance to modify its name used for the
|
|
+ * tool highlight useful for adding something extra that can't be removed
|
|
+ * by a user in the displayed name, such as a mode of operation.
|
|
+ *
|
|
+ * @param item the ItemStack for the item.
|
|
+ * @param displayName the name that will be displayed unless it is changed in this method.
|
|
+ */
|
|
+ public String getHighlightTip( ItemStack item, String displayName )
|
|
+ {
|
|
+ return displayName;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * 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
|
|
+ * @param hand Which hand the item is being held in.
|
|
+ * @return Return PASS to allow vanilla handling, any other to skip normal code.
|
|
+ */
|
|
+ public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand)
|
|
+ {
|
|
+ return EnumActionResult.PASS;
|
|
+ }
|
|
+
|
|
+ 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;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Override this method to change the NBT data being sent to the client.
|
|
+ * You should ONLY override this when you have no other choice, as this might change behavior client side!
|
|
+ *
|
|
+ * @param stack The stack to send the NBT tag for
|
|
+ * @return The NBT tag
|
|
+ */
|
|
+ public NBTTagCompound getNBTShareTag(ItemStack stack)
|
|
+ {
|
|
+ return stack.func_77978_p();
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * 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, EntityLivingBase 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;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * 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 ItemStack.field_190927_a;
|
|
+ }
|
|
+ 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.
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ *
|
|
+ * 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(ItemStack stack, net.minecraft.world.IBlockAccess 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, EntityEquipmentSlot armorType, Entity entity)
|
|
+ {
|
|
+ return net.minecraft.entity.EntityLiving.func_184640_d(stack) == armorType;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * 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, EntityEquipmentSlot 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)
|
|
+ @Nullable
|
|
+ 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 The slot the armor is in
|
|
+ * @param _default Original armor model. Will have attributes set.
|
|
+ * @return A ModelBiped to render instead of the default
|
|
+ */
|
|
+ @SideOnly(Side.CLIENT)
|
|
+ public net.minecraft.client.model.ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, net.minecraft.client.model.ModelBiped _default)
|
|
+ {
|
|
+ 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();
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Returns the packed int RGB value used to render the durability bar in the GUI.
|
|
+ * Defaults to a value based on the hue scaled as the damage decreases, but can be overriden.
|
|
+ *
|
|
+ * @param stack Stack to get durability from
|
|
+ * @return A packed RGB value for the durability colour (0x00RRGGBB)
|
|
+ */
|
|
+ public int getRGBDurabilityForDisplay(ItemStack stack)
|
|
+ {
|
|
+ return MathHelper.func_181758_c(Math.max(0.0F, (stack.func_77958_k() - stack.func_77952_i()) / stack.func_77958_k()) / 3.0F, 1.0F, 1.0F);
|
|
+ }
|
|
+ /**
|
|
+ * 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(IBlockState)}
|
|
+ * @param state The block trying to harvest
|
|
+ * @param stack The itemstack used to harvest the block
|
|
+ * @return true if can harvest the block
|
|
+ */
|
|
+ public boolean canHarvestBlock(IBlockState state, ItemStack stack)
|
|
+ {
|
|
+ return func_150897_b(state);
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * 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();
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Deprecated, Use the position aware variant instead
|
|
+ */
|
|
+ @Deprecated
|
|
+ public int getHarvestLevel(ItemStack stack, String toolClass)
|
|
+ {
|
|
+ Integer ret = toolClasses.get(toolClass);
|
|
+ return ret == null ? -1 : ret;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Queries the harvest level of this item stack for the specified tool class,
|
|
+ * Returns -1 if this tool is not of the specified type
|
|
+ *
|
|
+ * @param stack This item stack instance
|
|
+ * @param toolClass Tool Class
|
|
+ * @param player The player trying to harvest the given blockstate
|
|
+ * @param blockState The block to harvest
|
|
+ * @return Harvest level, or -1 if not the specified tool type.
|
|
+ */
|
|
+ public int getHarvestLevel(ItemStack stack, String toolClass, @Nullable EntityPlayer player, @Nullable IBlockState blockState)
|
|
+ {
|
|
+ return getHarvestLevel(stack, toolClass);
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * 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 !oldStack.equals(newStack); //!ItemStack.areItemStacksEqual(oldStack, newStack);
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Called when the player is mining a block and the item in his hand changes.
|
|
+ * Allows to not reset blockbreaking if only NBT or similar changes.
|
|
+ * @param oldStack The old stack that was used for mining. Item in players main hand
|
|
+ * @param newStack The new stack
|
|
+ * @return True to reset block break progress
|
|
+ */
|
|
+ public boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack)
|
|
+ {
|
|
+ return !(newStack.func_77973_b() == oldStack.func_77973_b() && ItemStack.func_77970_a(newStack, oldStack) && (newStack.func_77984_f() || newStack.func_77960_j() == oldStack.func_77960_j()));
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Called from ItemStack.setItem, will hold extra data for the life of this ItemStack.
|
|
+ * Can be retrieved from stack.getCapabilities()
|
|
+ * The NBT can be null if this is not called from readNBT or if the item the stack is
|
|
+ * changing FROM is different then this item, or the previous item had no capabilities.
|
|
+ *
|
|
+ * This is called BEFORE the stacks item is set so you can use stack.getItem() to see the OLD item.
|
|
+ * Remember that getItem CAN return null.
|
|
+ *
|
|
+ * @param stack The ItemStack
|
|
+ * @param nbt NBT of this item serialized, or null.
|
|
+ * @return A holder instance associated with this ItemStack where you can hold capabilities for the life of this item.
|
|
+ */
|
|
+ @Nullable
|
|
+ public net.minecraftforge.common.capabilities.ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt)
|
|
+ {
|
|
+ return null;
|
|
+ }
|
|
+
|
|
+ public com.google.common.collect.ImmutableMap<String, net.minecraftforge.common.animation.ITimeValue> getAnimationParameters(final ItemStack stack, final World world, final EntityLivingBase entity)
|
|
+ {
|
|
+ com.google.common.collect.ImmutableMap.Builder<String, net.minecraftforge.common.animation.ITimeValue> builder = com.google.common.collect.ImmutableMap.builder();
|
|
+ for(ResourceLocation location : field_185051_m.func_148742_b())
|
|
+ {
|
|
+ final IItemPropertyGetter parameter = field_185051_m.func_82594_a(location);
|
|
+ builder.put(location.toString(), new net.minecraftforge.common.animation.ITimeValue()
|
|
+ {
|
|
+ public float apply(float input)
|
|
+ {
|
|
+ return parameter.func_185085_a(stack, world, entity);
|
|
+ }
|
|
+ });
|
|
+ }
|
|
+ return builder.build();
|
|
+ }
|
|
+
|
|
+ /* ======================================== FORGE END =====================================*/
|
|
+
|
|
public static void func_150900_l()
|
|
{
|
|
func_179214_a(Blocks.field_150350_a, new ItemAir(Blocks.field_150350_a));
|
|
@@ -972,6 +1573,10 @@
|
|
private final float field_78011_i;
|
|
private final int field_78008_j;
|
|
|
|
+ //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_;
|
|
@@ -1006,9 +1611,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 == DIAMOND ? 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 DIAMOND: 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 == DIAMOND) 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;
|
|
+ }
|
|
}
|
|
}
|