Class LivingEntityEquipmentWrapper
java.lang.Object
net.neoforged.neoforge.transfer.item.LivingEntityEquipmentWrapper
Exposes the armor or hands inventory of an
LivingEntity as a ResourceHandler<ItemResource>
using LivingEntity.getItemBySlot(EquipmentSlot) and LivingEntity.setItemSlot(EquipmentSlot, ItemStack).- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classprivate classThe wrapper for a singleEquipmentSlot, used as a building block. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final LivingEntityprivate static final Map<LivingEntity, LivingEntityEquipmentWrapper> SeeVanillaContainerWrapper.wrapperswhich is similar. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static LivingEntityEquipmentWrapper.EquipmentTypeWrapperinternalOf(LivingEntity entity, EquipmentSlot.Type equipmentType) static ResourceHandler<ItemResource> of(LivingEntity entity, EquipmentSlot equipmentSlot) Gets a wrapper for a single equipment slot.static ResourceHandler<ItemResource> of(LivingEntity entity, EquipmentSlot.Type equipmentType) Gets a wrapper for all equipment slots of a given type.
-
Field Details
-
wrappers
SeeVanillaContainerWrapper.wrapperswhich is similar.We use weak keys and values to avoid keeping a strong reference to the
LivingEntityuntil the next time the map is cleaned. As long as a slot wrapper is used, there is a strong reference to the outerLivingEntityEquipmentWrapperclass, which also references the living entity. This ensures that the entries remain in the map at least as long as the wrappers are in use. -
entity
-
byType
-
-
Constructor Details
-
LivingEntityEquipmentWrapper
-
-
Method Details
-
of
public static ResourceHandler<ItemResource> of(LivingEntity entity, EquipmentSlot.Type equipmentType) Gets a wrapper for all equipment slots of a given type.- Parameters:
entity- the entity whose equipment slots should be wrappedequipmentType- the type of equipment slots to wrap- Throws:
IllegalArgumentException- if the entity is a player and the equipment type is neitherEquipmentSlot.Type.HANDnorEquipmentSlot.Type.HUMANOID_ARMOR
-
of
Gets a wrapper for a single equipment slot.- Parameters:
entity- the entity whose equipment slots should be wrappedequipmentSlot- the equipment slot to wrap- Throws:
IllegalArgumentException- if the entity is a player and the equipment slot's type is neitherEquipmentSlot.Type.HANDnorEquipmentSlot.Type.HUMANOID_ARMOR
-
internalOf
private static LivingEntityEquipmentWrapper.EquipmentTypeWrapper internalOf(LivingEntity entity, EquipmentSlot.Type equipmentType)
-