Class CapabilityDispatcher
java.lang.Object
net.minecraftforge.common.capabilities.CapabilityDispatcher
- All Implemented Interfaces:
ICapabilityProvider,INBTSerializable<CompoundNBT>
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public final class CapabilityDispatcher
extends Object
implements INBTSerializable<CompoundNBT>, 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
FieldsModifier and TypeFieldDescriptionprivate ICapabilityProvider[]private String[]private INBTSerializable<INBT>[] -
Constructor Summary
ConstructorsConstructorDescriptionCapabilityDispatcher(Map<ResourceLocation, ICapabilityProvider> list, List<Runnable> listeners) CapabilityDispatcher(Map<ResourceLocation, ICapabilityProvider> list, List<Runnable> listeners, ICapabilityProvider parent) -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoid<T> LazyOptional<T>getCapability(Capability<T> cap, Direction side) Retrieves the Optional handler for the capability requested on the specific side.voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:ICapabilityProviderRetrieves 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:
getCapabilityin interfaceICapabilityProvider- Returns:
- The requested an optional holding the requested capability.
-
serializeNBT
- Specified by:
serializeNBTin interfaceINBTSerializable<CompoundNBT>
-
deserializeNBT
- Specified by:
deserializeNBTin interfaceINBTSerializable<CompoundNBT>
-
areCompatible
-
invalidate
public void invalidate()
-