Class HashedArmorpiece
java.lang.Object
io.github.thebusybiscuit.slimefun4.api.items.HashedArmorpiece
This class serves as a way of checking whether a
Player has changed their armor
between ticks. We do that by storing the hash of their armor and a reference to the
corresponding SlimefunArmorPiece if such a correlation exists.
This gives us a significant performance improvement as we only need to check for a
SlimefunArmorPiece if the item diverged in the first place.- Author:
- TheBusyBiscuit
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionThis initializes a newHashedArmorpiecewith noSlimefunArmorPieceand a zero hash. -
Method Summary
Modifier and TypeMethodDescriptiongetItem()booleanhasDiverged(ItemStack stack) This method checks whether the givenItemStackis no longer similar to the one represented by thisHashedArmorpiece.toString()voidupdate(ItemStack stack, SlimefunItem item)
-
Constructor Details
-
HashedArmorpiece
public HashedArmorpiece()This initializes a newHashedArmorpiecewith noSlimefunArmorPieceand a zero hash.
-
-
Method Details
-
update
- Parameters:
stack- The new armorpiece to be stored in thisHashedArmorpieceitem- TheSlimefunItemcorresponding to the providedItemStack, may be null
-
hasDiverged
This method checks whether the givenItemStackis no longer similar to the one represented by thisHashedArmorpiece.- Parameters:
stack- TheItemStackto compare- Returns:
- Whether the
HashedArmorpieceand the givenItemStackmismatch
-
getItem
- Returns:
- An
Optionaldescribing the result
-
toString
-