Guest User

ModCapStorage Class

a guest
Oct 22nd, 2020
18
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class ModCapStorage implements Capability.IStorage<IModCap> {
  2.  
  3. @Override
  4. public FloatNBT writeNBT(Capability<IModCap> capability, IModCap instance, Direction side) {
  5. return FloatNBT.valueOf(instance.get());
  6. }
  7.  
  8. @Override
  9. public void readNBT(Capability<IModCap> capability, IModCap instance, Direction side, INBT nbt) {
  10. instance.set();
  11. }
  12.  
  13. public static final ResourceLocation MOD_CAP = new ResourceLocation(Main.MOD_ID, "mod_cap");
  14. @SubscribeEvent
  15. public void attachCapabilitiesEntity(final AttachCapabilitiesEvent<Entity> event) {
  16.  
  17. if ((event.getObject() instanceof LivingEntity) && !(event.getObject() instanceof PlayerEntity))
  18. event.addCapability(MOD_CAP, new ModCap());
  19. }
  20. }
RAW Paste Data