Package net.xun.armory.impl.item.tools
Class GenericAttributeHelper
java.lang.Object
net.xun.armory.impl.item.tools.GenericAttributeHelper
- All Implemented Interfaces:
AttributeHelper
Default implementation of
AttributeHelper applying standard
Minecraft attack attributes using vanilla's attribute modifier system.
This implementation follows vanilla Minecraft conventions for applying combat attributes to tools, ensuring compatibility with the game's attribute system and consistent behavior across different tool types.
Attack Speed Convention:
Minecraft internally represents attack speed as an offset from a base value of 4.0. This implementation automatically converts the provided attack speed value to the appropriate modifier offset. For example:- An attack speed of 1.6 becomes: 1.6 - 4.0 = -2.4 modifier
- An attack speed of 3.0 becomes: 3.0 - 4.0 = -1.0 modifier
- An attack speed of 4.0 becomes: 4.0 - 4.0 = 0.0 modifier
- Since:
- 1.0.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.world.item.Item.PropertiesapplyAttributes(net.minecraft.world.item.Item.Properties properties, float damage, float speed) Applies standard combat attributes to item properties using Minecraft's attribute modifier system.
-
Constructor Details
-
GenericAttributeHelper
public GenericAttributeHelper()
-
-
Method Details
-
applyAttributes
public net.minecraft.world.item.Item.Properties applyAttributes(net.minecraft.world.item.Item.Properties properties, float damage, float speed) Applies standard combat attributes to item properties using Minecraft's attribute modifier system.This method enhances the provided item properties by adding attribute modifiers for attack damage and attack speed. Both modifiers are applied exclusively to the
EquipmentSlotGroup.MAINHANDequipment slot.- Specified by:
applyAttributesin interfaceAttributeHelper- Parameters:
properties- initial item properties to modify, nevernulldamage- total attack damage value (tier base damage + tool bonus), typically between 0.0F and 15.0F for balanced toolsspeed- attack speed value in attacks per second (not the modifier offset), typically between 0.5F and 4.0F for balanced tools- Returns:
- modified properties with attack damage and speed attribute modifiers,
never
null - Throws:
NullPointerException- ifpropertiesisnullIllegalArgumentException- if attribute values would result in nonsensical modifiers (e.g., negative attack damage for weapons)- See Also:
-