Skip to content

Instantly share code, notes, and snippets.

@izzyaxel
Created March 2, 2016 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save izzyaxel/22b03d17600a97b55e2f to your computer and use it in GitHub Desktop.
Save izzyaxel/22b03d17600a97b55e2f to your computer and use it in GitHub Desktop.
public class ManaPersistence
{
public static ManaPersistence INSTANCE = new ManaPersistence();
@SubscribeEvent
public void persistMana(PlayerEvent.Clone event)
{
AAExtPlayerHelper.getIEEP(event.entityPlayer).copyIEEP(AAExtPlayerHelper.getIEEP(event.original));
}
@SubscribeEvent
public void syncPersistenceToClient(EntityJoinWorldEvent event)
{
if(!event.world.isRemote && event.entity instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer)event.entity;
AAExtendedPlayer props = (AAExtendedPlayer)player.getExtendedProperties(AAExtendedPlayer.EEPName);
ArcaneArtificing.snw.sendToAll(new MessageSyncMana(player.getEntityId(), props.getWhiteMana(), props.getBlueMana(), props.getBlackMana(), props.getGreenMana(), props.getRedMana(), props.hasLearnedAboutmana()));
}
}
@SubscribeEvent
public void syncOnDisconnect(cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent event)
{
if(!event.player.worldObj.isRemote)
{
AAExtendedPlayer props = (AAExtendedPlayer)event.player.getExtendedProperties(AAExtendedPlayer.EEPName);
ArcaneArtificing.snw.sendToAll(new MessageSyncMana(event.player.getEntityId(), props.getWhiteMana(), props.getBlueMana(), props.getBlackMana(), props.getGreenMana(), props.getRedMana(), props.hasLearnedAboutmana()));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment