Guest User

Untitled

a guest
Aug 20th, 2021
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.08 KB | None | 0 0
  1. public class StaffStorage implements Capability.IStorage<IStaff> {
  2.  
  3.     @Deprecated
  4.     @Override
  5.     public INBT writeNBT(Capability<IStaff> capability, IStaff instance, Direction side) {
  6.         CompoundNBT nbt = new CompoundNBT();
  7.  
  8.         if(instance.getCastSound().toString() != null)
  9.             nbt.putString("cast_sound", Registry.SOUND_EVENT.getKey(instance.getCastSound()).toString());
  10.         if(instance.getEmptySound().toString() != null)
  11.             nbt.putString("empty_sound", Registry.SOUND_EVENT.getKey(instance.getEmptySound()).toString());
  12.         return nbt;
  13.     }
  14.     @Deprecated
  15.     @Override
  16.     public void readNBT(Capability<IStaff> capability, IStaff instance, Direction side, INBT nbt) {
  17.         CompoundNBT tag = (CompoundNBT)nbt;
  18.             instance.castSound(Registry.SOUND_EVENT.getOptional(new ResourceLocation(tag.getString("cast_sound"))).orElse(SoundInit.BASIC_MAGIC_SHOOT));
  19.             instance.emptySound(Registry.SOUND_EVENT.getOptional(new ResourceLocation(tag.getString("empty_sound"))).orElse(SoundInit.BASIC_EMPTY_SPELLCAST));
  20.  
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment