Advertisement
Guest User

Untitled

a guest
Aug 20th, 2021
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.54 KB | None | 0 0
  1. public class StaffCapability
  2. {
  3.  
  4.     @CapabilityInject(IStaff.class)
  5.     public static Capability<IStaff> STAFF = null;
  6.  
  7.     public static void register()
  8.     {
  9.         CapabilityManager.INSTANCE.register(IStaff.class, new StaffStorage(), DefaultStaffCapability::new);
  10.     }
  11.  
  12.     public static class Storage implements Capability.IStorage<IStaff>
  13.     {
  14.         @Deprecated
  15.         @Nullable
  16.         @Override
  17.         public INBT writeNBT(Capability<IStaff> capability, IStaff instance, Direction side) {
  18.             CompoundNBT nbt = new CompoundNBT();
  19.             //nbt.putString("Entity", Registry.ENTITY_TYPE.getKey(instance.getEntity().getType()).toString());
  20.             if(instance.getCastSound() != null)
  21.                 nbt.putString("cast_sound", Registry.SOUND_EVENT.getKey(instance.getCastSound()).toString());
  22.             if(instance.getEmptySound() != null)
  23.                 nbt.putString("empty_sound", Registry.SOUND_EVENT.getKey(instance.getEmptySound()).toString());
  24.             return nbt;
  25.         }
  26.         @Deprecated
  27.         @Override
  28.         public void readNBT(Capability<IStaff> capability, IStaff instance, Direction side, INBT nbt) {
  29.             CompoundNBT cnbt = (CompoundNBT) nbt;
  30.             instance.castSound(Registry.SOUND_EVENT.getOptional(new ResourceLocation(cnbt.getString("cast_sound"))).orElse(SoundInit.BASIC_MAGIC_SHOOT));
  31.             instance.emptySound(Registry.SOUND_EVENT.getOptional(new ResourceLocation(cnbt.getString("empty_sound"))).orElse(SoundInit.BASIC_EMPTY_SPELLCAST));
  32.  
  33.         }
  34.     }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement