Class SwordItem

All Implemented Interfaces:
ItemConvertible, Vanishable, ToggleableFeature

public class SwordItem extends ToolItem implements Vanishable
Mappings:
Namespace Name
official cfc
intermediary net/minecraft/class_1829
named net/minecraft/item/SwordItem
  • Field Details

    • attackDamage

      private final float attackDamage
      Mappings:
      Namespace Name Mixin selector
      official a Lcfc;a:F
      intermediary field_8920 Lnet/minecraft/class_1829;field_8920:F
      named attackDamage Lnet/minecraft/item/SwordItem;attackDamage:F
    • attributeModifiers

      private final Multimap<EntityAttribute,EntityAttributeModifier> attributeModifiers
      Mappings:
      Namespace Name Mixin selector
      official b Lcfc;b:Lcom/google/common/collect/Multimap;
      intermediary field_23745 Lnet/minecraft/class_1829;field_23745:Lcom/google/common/collect/Multimap;
      named attributeModifiers Lnet/minecraft/item/SwordItem;attributeModifiers:Lcom/google/common/collect/Multimap;
  • Constructor Details

    • SwordItem

      public SwordItem(ToolMaterial toolMaterial, int attackDamage, float attackSpeed, Item.Settings settings)
      Mappings:
      Namespace Name Mixin selector
      official <init> Lcfc;<init>(Lcfe;IFLcdp$a;)V
      intermediary <init> Lnet/minecraft/class_1829;<init>(Lnet/minecraft/class_1832;IFLnet/minecraft/class_1792$class_1793;)V
      named <init> Lnet/minecraft/item/SwordItem;<init>(Lnet/minecraft/item/ToolMaterial;IFLnet/minecraft/item/Item$Settings;)V
  • Method Details

    • getAttackDamage

      public float getAttackDamage()
      Mappings:
      Namespace Name Mixin selector
      official i Lcfc;i()F
      intermediary method_8020 Lnet/minecraft/class_1829;method_8020()F
      named getAttackDamage Lnet/minecraft/item/SwordItem;getAttackDamage()F
    • canMine

      public boolean canMine(BlockState state, World world, BlockPos pos, PlayerEntity miner)
      Returns whether a player can break a block while holding the item.

      This is to check whether the player can start breaking the block in the first place; this does not check if the item is a correct tool to mine the block. Melee weapons should override this to return false, unless it is also intended to be used as a tool.

      Overrides:
      canMine in class Item
      Returns:
      whether a player can break a block while holding the item
      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a(Lcyt;Lcjw;Lgp;Lbwp;)Z
      intermediary method_7885 Lnet/minecraft/class_1792;method_7885(Lnet/minecraft/class_2680;Lnet/minecraft/class_1937;Lnet/minecraft/class_2338;Lnet/minecraft/class_1657;)Z
      named canMine Lnet/minecraft/item/Item;canMine(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/player/PlayerEntity;)Z
    • getMiningSpeedMultiplier

      public float getMiningSpeedMultiplier(ItemStack stack, BlockState state)
      Returns the multiplier applied to the mining speed of stack when mining state.

      The default value is 1.0f. Returning larger integer will cause the block to be mined faster. Enchantments, status effects, and other effects that affect mining speed are instead handled in PlayerEntity.getBlockBreakingSpeed(net.minecraft.block.BlockState).

      Overrides:
      getMiningSpeedMultiplier in class Item
      Returns:
      the multiplier applied to the mining speed of stack when mining state
      See Also:
      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a(Lcdt;Lcyt;)F
      intermediary method_7865 Lnet/minecraft/class_1792;method_7865(Lnet/minecraft/class_1799;Lnet/minecraft/class_2680;)F
      named getMiningSpeedMultiplier Lnet/minecraft/item/Item;getMiningSpeedMultiplier(Lnet/minecraft/item/ItemStack;Lnet/minecraft/block/BlockState;)F
    • postHit

      public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attacker)
      Called on the server when the item is used to hit an entity.

      Tools and melee weapons should override this to damage the stack.

      Overrides:
      postHit in class Item
      Returns:
      whether the item's use stat should be incremented
      See Also:
      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a(Lcdt;Lbeg;Lbeg;)Z
      intermediary method_7873 Lnet/minecraft/class_1792;method_7873(Lnet/minecraft/class_1799;Lnet/minecraft/class_1309;Lnet/minecraft/class_1309;)Z
      named postHit Lnet/minecraft/item/Item;postHit(Lnet/minecraft/item/ItemStack;Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/entity/LivingEntity;)Z
    • postMine

      public boolean postMine(ItemStack stack, World world, BlockState state, BlockPos pos, LivingEntity miner)
      Called on the server when the item is used to break a block.

      Tools and melee weapons should override this to damage the stack, after checking if the block's hardness is larger than 0.0f.

      Overrides:
      postMine in class Item
      Returns:
      whether the item's use stat should be incremented
      See Also:
      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a(Lcdt;Lcjw;Lcyt;Lgp;Lbeg;)Z
      intermediary method_7879 Lnet/minecraft/class_1792;method_7879(Lnet/minecraft/class_1799;Lnet/minecraft/class_1937;Lnet/minecraft/class_2680;Lnet/minecraft/class_2338;Lnet/minecraft/class_1309;)Z
      named postMine Lnet/minecraft/item/Item;postMine(Lnet/minecraft/item/ItemStack;Lnet/minecraft/world/World;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/LivingEntity;)Z
    • isSuitableFor

      public boolean isSuitableFor(BlockState state)
      Determines whether this item can be used as a suitable tool for mining the specified block. Depending on block implementation, when combined together, the correct item and block may achieve a better mining speed and yield drops that would not be obtained when mining otherwise.

      Note that this is not the only way to achieve "effectiveness" when mining. Other items, such as shears on string, may use their own logic and calls to this method might not return a value consistent to this rule for those items.

      Overrides:
      isSuitableFor in class Item
      Mappings:
      Namespace Name Mixin selector
      official a_ Lcdp;a_(Lcyt;)Z
      intermediary method_7856 Lnet/minecraft/class_1792;method_7856(Lnet/minecraft/class_2680;)Z
      named isSuitableFor Lnet/minecraft/item/Item;isSuitableFor(Lnet/minecraft/block/BlockState;)Z
    • getAttributeModifiers

      public Multimap<EntityAttribute,EntityAttributeModifier> getAttributeModifiers(EquipmentSlot slot)
      Returns the attribute modifiers the item provides.

      Tools and armor should override this to specify the attack damage or armor points.

      Overrides:
      getAttributeModifiers in class Item
      Returns:
      the attribute modifiers the item provides
      Mappings:
      Namespace Name Mixin selector
      official a Lcdp;a(Lbdw;)Lcom/google/common/collect/Multimap;
      intermediary method_7844 Lnet/minecraft/class_1792;method_7844(Lnet/minecraft/class_1304;)Lcom/google/common/collect/Multimap;
      named getAttributeModifiers Lnet/minecraft/item/Item;getAttributeModifiers(Lnet/minecraft/entity/EquipmentSlot;)Lcom/google/common/collect/Multimap;