Advertisement
Guest User

Untitled

a guest
Aug 20th, 2021
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. public class StaffProvider implements ICapabilitySerializable<CompoundNBT>
  2. {
  3.  
  4.     private final DefaultStaffCapability staff = new DefaultStaffCapability();
  5.     private final LazyOptional<IStaff> staffLazyOptional = LazyOptional.of(() -> staff);
  6.  
  7.  
  8.  
  9.     public void invalidate() { staffLazyOptional.invalidate(); }
  10.  
  11.     @Nullable
  12.     @Override
  13.     public <T> LazyOptional<T> getCapability( Capability<T> cap, Direction side) {
  14.         return staffLazyOptional.cast();
  15.     }
  16.  
  17.     @Override
  18.     public CompoundNBT serializeNBT() {
  19.         if(StaffCapability.STAFF == null)
  20.             return new CompoundNBT();
  21.         else
  22.             return (CompoundNBT) StaffCapability.STAFF.writeNBT(staff, null);
  23.     }
  24.  
  25.     @Override
  26.     public void deserializeNBT(CompoundNBT nbt) {
  27.         if(StaffCapability.STAFF != null)
  28.             StaffCapability.STAFF.readNBT(staff, null, nbt);
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement