Creepinson

Untitled

Jun 25th, 2017
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. package me.creepinson.capability;
  2.  
  3. import net.minecraft.nbt.NBTBase;
  4. import net.minecraft.util.EnumFacing;
  5. import net.minecraftforge.common.capabilities.Capability;
  6. import net.minecraftforge.common.capabilities.CapabilityInject;
  7. import net.minecraftforge.common.capabilities.ICapabilitySerializable;
  8.  
  9. public class DisguiseProvider implements ICapabilitySerializable<NBTBase>
  10.  
  11. {
  12.  
  13. @CapabilityInject(IDisguise.class)
  14.  
  15. public static final Capability<IDisguise> DISGUISE = null;
  16.  
  17.  
  18.  
  19. private IDisguise instance = DISGUISE.getDefaultInstance();
  20.  
  21.  
  22.  
  23. @Override
  24.  
  25. public boolean hasCapability(Capability<?> capability, EnumFacing facing)
  26.  
  27. {
  28.  
  29. return capability == DISGUISE;
  30.  
  31. }
  32.  
  33.  
  34.  
  35. @Override
  36.  
  37. public <T> T getCapability(Capability<T> capability, EnumFacing facing)
  38.  
  39. {
  40.  
  41. return capability == DISGUISE ? DISGUISE.<T> cast(this.instance) : null;
  42.  
  43. }
  44.  
  45.  
  46.  
  47. @Override
  48.  
  49. public NBTBase serializeNBT()
  50.  
  51. {
  52.  
  53. return DISGUISE.getStorage().writeNBT(DISGUISE, this.instance, null);
  54.  
  55. }
  56.  
  57.  
  58.  
  59. @Override
  60.  
  61. public void deserializeNBT(NBTBase nbt)
  62.  
  63. {
  64.  
  65. DISGUISE.getStorage().readNBT(DISGUISE, this.instance, null, nbt);
  66.  
  67. }
  68.  
  69. }
Add Comment
Please, Sign In to add comment