Class CapabilityDispatcher
java.lang.Object
net.minecraftforge.common.capabilities.CapabilityDispatcher
- All Implemented Interfaces:
ICapabilityProvider
,INBTSerializable<CompoundTag>
@ParametersAreNonnullByDefault
public final class CapabilityDispatcher
extends Object
implements INBTSerializable<CompoundTag>, ICapabilityProvider
A high-speed implementation of a capability delegator.
This is used to wrap the results of the AttachCapabilitiesEvent.
It is HIGHLY recommended that you DO NOT use this approach unless
you MUST delegate to multiple providers instead just implement y
our handlers using normal if statements.
Internally the handlers are baked into arrays for fast iteration.
The ResourceLocations will be used for the NBT Key when serializing.
-
Field Summary
Modifier and TypeFieldDescriptionprivate ICapabilityProvider[]
private String[]
private INBTSerializable<Tag>[]
-
Constructor Summary
ConstructorDescriptionCapabilityDispatcher(Map<ResourceLocation,ICapabilityProvider> list, List<Runnable> listeners)
CapabilityDispatcher(Map<ResourceLocation,ICapabilityProvider> list, List<Runnable> listeners, ICapabilityProvider parent)
-
Method Summary
Modifier and TypeMethodDescriptionboolean
areCompatible(CapabilityDispatcher other)
void
deserializeNBT(CompoundTag nbt)
<T> LazyOptional<T>
getCapability(Capability<T> cap, Direction side)
Retrieves the Optional handler for the capability requested on the specific side.void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minecraftforge.common.capabilities.ICapabilityProvider
getCapability
-
Field Details
-
caps
-
writers
-
names
-
listeners
-
-
Constructor Details
-
CapabilityDispatcher
public CapabilityDispatcher(Map<ResourceLocation,ICapabilityProvider> list, List<Runnable> listeners) -
CapabilityDispatcher
public CapabilityDispatcher(Map<ResourceLocation,ICapabilityProvider> list, List<Runnable> listeners, @Nullable ICapabilityProvider parent)
-
-
Method Details
-
getCapability
Description copied from interface:ICapabilityProvider
Retrieves the Optional handler for the capability requested on the specific side. The return value CAN be the same for multiple faces. Modders are encouraged to cache this value, using the listener capabilities of the Optional to be notified if the requested capability get lost.- Specified by:
getCapability
in interfaceICapabilityProvider
- Parameters:
cap
- The capability to checkside
- The Side to check from, CAN BE NULL. Null is defined to represent 'internal' or 'self'- Returns:
- The requested an optional holding the requested capability.
-
serializeNBT
- Specified by:
serializeNBT
in interfaceINBTSerializable<CompoundTag>
-
deserializeNBT
- Specified by:
deserializeNBT
in interfaceINBTSerializable<CompoundTag>
-
areCompatible
-
invalidate
public void invalidate()
-