Player Specific Variable

Started by Ultadoer on

Topic category: Help with MCreator software

Last seen on 03:19, 28. Jan 2023
Joined Feb 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Player Specific Variable

How would I make a player specific variable in 1.7.9 mcreator?

Last seen on 17:17, 10. Jan 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The way to save any data…
Wed, 05/09/2018 - 15:50

The way to save any data related to a specific player, entity or even ItemStack is definitely capabilities.
First you have to create an interface that will contain all methods that you need for the functioning of your mechanics, but usually, they are just getters/setters for your variables. Then you need another class that implements this interface. Here are the variables declared and modified. Another class you need implements ICapabilitySerializable and it converts the capability to NBT and vice versa, well so does actually also another class that implements IStorage<IExtendedPlayer>. Last class you need is an event handler, where you subscribe for AttachCapabilitiesEvent<Entity> event, check for EntityPlayer and using event.addCapability(ResourceLocation, ICapabilityProvider) you attach the capability to the player.