public final class CapabilityDispatcher extends java.lang.Object implements INBTSerializable<NBTTagCompound>, ICapabilityProvider
Modifier and Type | Field and Description |
---|---|
private ICapabilityProvider[] |
caps |
private java.lang.String[] |
names |
private INBTSerializable<NBTBase>[] |
writers |
Constructor and Description |
---|
CapabilityDispatcher(java.util.Map<ResourceLocation,ICapabilityProvider> list) |
CapabilityDispatcher(java.util.Map<ResourceLocation,ICapabilityProvider> list,
ICapabilityProvider parent) |
Modifier and Type | Method and Description |
---|---|
boolean |
areCompatible(CapabilityDispatcher other) |
void |
deserializeNBT(NBTTagCompound nbt) |
<T> T |
getCapability(Capability<T> capability,
EnumFacing facing)
Retrieves the handler for the capability requested on the specific side.
|
boolean |
hasCapability(Capability<?> capability,
EnumFacing facing)
Determines if this object has support for the capability in question on the specific side.
|
NBTTagCompound |
serializeNBT() |
private ICapabilityProvider[] caps
private INBTSerializable<NBTBase>[] writers
private java.lang.String[] names
public CapabilityDispatcher(java.util.Map<ResourceLocation,ICapabilityProvider> list)
public CapabilityDispatcher(java.util.Map<ResourceLocation,ICapabilityProvider> list, @Nullable ICapabilityProvider parent)
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing)
ICapabilityProvider
ICapabilityProvider.getCapability(Capability, EnumFacing)
.
Basically, this method functions analogously to Map.containsKey(Object)
.
Example: A Pipe getting a cover placed on one side causing it lose the Inventory attachment function for that side.
This is a light weight version of getCapability, intended for metadata uses.
hasCapability
in interface ICapabilityProvider
capability
- The capability to checkfacing
- The Side to check from:
CAN BE NULL. Null is defined to represent 'internal' or 'self'ICapabilityProvider.getCapability(Capability, EnumFacing)
must not return null.@Nullable public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing)
ICapabilityProvider
Basically, this method functions analogously to Map.get(Object)
.
getCapability
in interface ICapabilityProvider
capability
- The capability to checkfacing
- The Side to check from,
CAN BE NULL. Null is defined to represent 'internal' or 'self'ICapabilityProvider.hasCapability(Capability, EnumFacing)
would return true.public NBTTagCompound serializeNBT()
serializeNBT
in interface INBTSerializable<NBTTagCompound>
public void deserializeNBT(NBTTagCompound nbt)
deserializeNBT
in interface INBTSerializable<NBTTagCompound>
public boolean areCompatible(CapabilityDispatcher other)