Changes

15 bytes added ,  01:25, 2 January 2021
m
Fixing capability invalidation on tile entities: PR #7536
Line 26: Line 26:  
Both the <code>getCapability</code> methods have a second parameter, of type <code>Direction</code>, which can be used in the to request the specific instance for that one face. If passed <code>null</code>, it can be assumed that the request comes either from within the block, or from some place where the side has no meaning, such as a different dimension. In this case a general capability instance that does not care about sides will be requested instead. The return type of <code>getCapability</code> will correspond to the type declared in the capability passed to the method. For the item handler capability, this is indeed <code>IItemHandler</code>.
 
Both the <code>getCapability</code> methods have a second parameter, of type <code>Direction</code>, which can be used in the to request the specific instance for that one face. If passed <code>null</code>, it can be assumed that the request comes either from within the block, or from some place where the side has no meaning, such as a different dimension. In this case a general capability instance that does not care about sides will be requested instead. The return type of <code>getCapability</code> will correspond to the type declared in the capability passed to the method. For the item handler capability, this is indeed <code>IItemHandler</code>.
   −
== Exposing a Capability ==
+
==Exposing a Capability==
 
  −
 
   
In order to expose a capability, you will first need an instance of the underlying capability type. Note that you should assign a separate instance to each object that keeps the capability, since the capability will most probably be tied to the containing object.
 
In order to expose a capability, you will first need an instance of the underlying capability type. Note that you should assign a separate instance to each object that keeps the capability, since the capability will most probably be tied to the containing object.
   Line 52: Line 50:     
@Override
 
@Override
public void remove() {
+
protected void invalidateCaps() {
   super.remove();
+
   super.invalidateCaps();
 
   inventoryHandlerLazyOptional.invalidate();
 
   inventoryHandlerLazyOptional.invalidate();
 
}
 
}