Advertisement
Guest User

Untitled

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