Guest User

Untitled

a guest
Apr 10th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. public class ReArmerProvider implements ICapabilitySerializable<INBT> {
  2.  
  3. @CapabilityInject(IReArmer.class)
  4. public static final Capability<IReArmer> REARMER_CAPABILITY = null;
  5.  
  6. private LazyOptional<IReArmer> instance = LazyOptional.of(REARMER_CAPABILITY::getDefaultInstance);
  7.  
  8. @Nonnull
  9. @Override
  10. public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
  11. return cap == REARMER_CAPABILITY ? instance.cast() : LazyOptional.empty(); }
  12.  
  13. @Override
  14. public INBT serializeNBT() {
  15. return REARMER_CAPABILITY.getStorage().writeNBT(REARMER_CAPABILITY, this.instance.orElseThrow(() -> new IllegalArgumentException("LazyOptional must not be empty!")), null);
  16. }
  17.  
  18. @Override
  19. public void deserializeNBT(INBT nbt) {
  20. REARMER_CAPABILITY.getStorage().readNBT(REARMER_CAPABILITY, this.instance.orElseThrow(() -> new IllegalArgumentException("LazyOptional must not be empty!")), null, nbt);
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment