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
ConstructorDescriptionThis initializes a newHashedArmorpiece
with noSlimefunArmorPiece
and a zero hash. -
Method Summary
Modifier and TypeMethodDescriptiongetItem()
boolean
hasDiverged
(ItemStack stack) This method checks whether the givenItemStack
is no longer similar to the one represented by thisHashedArmorpiece
.toString()
void
update
(ItemStack stack, SlimefunItem item)
-
Constructor Details
-
HashedArmorpiece
public HashedArmorpiece()This initializes a newHashedArmorpiece
with noSlimefunArmorPiece
and a zero hash.
-
-
Method Details
-
update
- Parameters:
stack
- The new armorpiece to be stored in thisHashedArmorpiece
item
- TheSlimefunItem
corresponding to the providedItemStack
, may be null
-
hasDiverged
This method checks whether the givenItemStack
is no longer similar to the one represented by thisHashedArmorpiece
.- Parameters:
stack
- TheItemStack
to compare- Returns:
- Whether the
HashedArmorpiece
and the givenItemStack
mismatch
-
getItem
- Returns:
- An
Optional
describing the result
-
toString
-