Advertisement
Guest User

Untitled

a guest
Apr 27th, 2021
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. public class CoolDownCapability
  2. {
  3. @CapabilityInject(ICoolDown.class)
  4. public static Capability<ICoolDown> COOLDOWN_CAPABILITY = null;
  5.  
  6. public static void register()
  7. {
  8. CapabilityManager.INSTANCE.register(ICoolDown.class, new Storage(), DefaultCoolDownCapability::new);
  9. }
  10.  
  11. public static class Storage implements Capability.IStorage<ICoolDown>
  12. {
  13. @Nullable
  14. @Override
  15. public INBT writeNBT(Capability<ICoolDown> capability, ICoolDown instance, Direction side) {
  16. CompoundNBT tag = new CompoundNBT();
  17. tag.putInt("ticksIn", instance.getCoolDown());
  18. return tag;
  19. }
  20.  
  21. @Override
  22. public void readNBT(Capability<ICoolDown> capability, ICoolDown instance, Direction side, INBT nbt) {
  23. int ticksIn = ((CompoundNBT)nbt).getInt("ticksIn");
  24. instance.setCoolDown(ticksIn);
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement