Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class StaffCapability
- {
- @CapabilityInject(IStaff.class)
- public static Capability<IStaff> STAFF = null;
- public static void register()
- {
- CapabilityManager.INSTANCE.register(IStaff.class, new StaffStorage(), DefaultStaffCapability::new);
- }
- public static class Storage implements Capability.IStorage<IStaff>
- {
- @Deprecated
- @Nullable
- @Override
- public INBT writeNBT(Capability<IStaff> capability, IStaff instance, Direction side) {
- CompoundNBT nbt = new CompoundNBT();
- //nbt.putString("Entity", Registry.ENTITY_TYPE.getKey(instance.getEntity().getType()).toString());
- if(instance.getCastSound() != null)
- nbt.putString("cast_sound", Registry.SOUND_EVENT.getKey(instance.getCastSound()).toString());
- if(instance.getEmptySound() != null)
- nbt.putString("empty_sound", Registry.SOUND_EVENT.getKey(instance.getEmptySound()).toString());
- return nbt;
- }
- @Deprecated
- @Override
- public void readNBT(Capability<IStaff> capability, IStaff instance, Direction side, INBT nbt) {
- CompoundNBT cnbt = (CompoundNBT) nbt;
- instance.castSound(Registry.SOUND_EVENT.getOptional(new ResourceLocation(cnbt.getString("cast_sound"))).orElse(SoundInit.BASIC_MAGIC_SHOOT));
- instance.emptySound(Registry.SOUND_EVENT.getOptional(new ResourceLocation(cnbt.getString("empty_sound"))).orElse(SoundInit.BASIC_EMPTY_SPELLCAST));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement