MFF

    Minecraft Forge France
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes
    • Forge Events
      • Automatique
      • Foncé
      • Clair
    • S'inscrire
    • Se connecter

    Extended Entity Props. qui ne se savent pas

    Planifier Épinglé Verrouillé Déplacé Résolu 1.7.x
    1.7.10
    45 Messages 3 Publieurs 9.2k Vues 1 Watching
    Charger plus de messages
    • Du plus ancien au plus récent
    • Du plus récent au plus ancien
    • Les plus votés
    Répondre
    • Répondre à l'aide d'un nouveau sujet
    Se connecter pour répondre
    Ce sujet a été supprimé. Seuls les utilisateurs avec les droits d'administration peuvent le voir.
    • sosohS Hors-ligne
      sosoh
      dernière édition par

      Salut, j’ai un probleme avec mes entity props, elles ne savent pas a ma mort ni quand je deco/reco.

      ​package fr.sosoh.hogsmod.common.entity.props;
      
      import java.util.ArrayList;
      import java.util.Arrays;
      import java.util.List;
      
      import net.minecraft.entity.Entity;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.entity.player.EntityPlayerMP;
      import net.minecraft.nbt.NBTTagCompound;
      import net.minecraft.world.World;
      import net.minecraftforge.common.IExtendedEntityProperties;
      import fr.sosoh.hogsmod.common.Hogsmod;
      import fr.sosoh.hogsmod.common.packet.PacketMana;
      import fr.sosoh.hogsmod.common.packet.PacketSpellLeft;
      import fr.sosoh.hogsmod.common.packet.PacketSpellRight;
      import fr.sosoh.hogsmod.common.packet.PacketSpellsList;
      import fr.sosoh.hogsmod.proxy.CommonProxy;
      
      public class ExtendedEntityProps implements IExtendedEntityProperties
      {
      
      public final static String EXT_PROP_NAME = "ExtHogs";
      
      private final EntityPlayer player;
      
      public double mana;
          public double maxMana;
          public List <string>spellsList = new ArrayList<string>();
          public String spellRight, spellLeft;
      
          public ExtendedEntityProps(EntityPlayer player) 
          {
      this.player = player;
      this.mana = 1000;
      this.maxMana = 1000;
      
      this.spellRight = "";
      this.spellLeft = "";
      }
      
      @Override
      public void init(Entity entity, World world) 
      {
      
      }
      
      public static final void register(EntityPlayer player) 
      {
      player.registerExtendedProperties(ExtendedEntityProps.EXT_PROP_NAME,
      new ExtendedEntityProps(player));
      }
      
      public static final ExtendedEntityProps get(EntityPlayer player) 
      {
      return (ExtendedEntityProps) player.getExtendedProperties(EXT_PROP_NAME);
      }
      
      @Override
      public void saveNBTData(NBTTagCompound compound) 
      {
      
      NBTTagCompound properties = new NBTTagCompound();
      compound.setTag(EXT_PROP_NAME, properties);
      properties.setDouble("Mana", this.mana);
      properties.setDouble("MaxMana", this.maxMana);
      properties.setString("spellRight", this.spellRight);
      properties.setString("spellLeft", this.spellLeft);
      properties.setInteger("spellsListSize", this.spellsList.size());
      if(this.spellsList != null){
      for(String spell : this.spellsList)
      {
      properties.setString("spellsList", spell);
      }
      }
      }
      
      @Override
      public void loadNBTData(NBTTagCompound compound) 
      {
      NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PROP_NAME);
      this.mana = properties.getDouble("Mana");
      this.maxMana = properties.getDouble("MaxMana");
      this.spellRight = properties.getString("spellRight");
      this.spellLeft = properties.getString("spellLeft");
      int size = properties.getInteger("spellsListSize");
      if(size < 0){
      for(int i = 0; i < size; i++){
      String stringI = this.spellsList.get(i);
      this.spellsList.add(i, stringI);
      }
      }
      }
      
      public final void sync() 
      {
      PacketMana packetMana = new PacketMana(this.mana, this.maxMana);
      PacketSpellRight packetSpellRight = new PacketSpellRight(this.spellRight);
      PacketSpellLeft packetSpellLeft = new PacketSpellLeft(this.spellLeft);
      PacketSpellsList packetSpellsList = new PacketSpellsList(this.spellsList);
      
      if (!player.worldObj.isRemote) 
      {
      EntityPlayerMP player1 = (EntityPlayerMP) player;
      Hogsmod.network.sendTo(packetMana, player1);
      Hogsmod.network.sendTo(packetSpellRight, player1);
      Hogsmod.network.sendTo(packetSpellLeft, player1);
      Hogsmod.network.sendTo(packetSpellsList, player1);
      }
      }
      
      private static String getSaveKey(EntityPlayer player) 
      {
      return player.getDisplayName() + ":" + EXT_PROP_NAME;
      }
      
      public static void saveProxyData(EntityPlayer player) {
      ExtendedEntityProps playerData = ExtendedEntityProps.get(player);
      NBTTagCompound savedData = new NBTTagCompound();
      playerData.saveNBTData(savedData);
      CommonProxy.storeEntityData(getSaveKey(player), savedData);
      }
      
      public static void loadProxyData(EntityPlayer player) 
      {
      ExtendedEntityProps playerData = ExtendedEntityProps.get(player);
      NBTTagCompound savedData = CommonProxy.getEntityData(getSaveKey(player));
      
      if (savedData != null) 
      {
      playerData.loadNBTData(savedData);
      }
      playerData.sync();
      }
      
      public boolean removeMana(double amount) 
      {
      boolean sufficient = amount <= this.mana;
      
      if (sufficient) 
      {
      this.mana -= amount;
      this.sync();
      } else 
      {
      return false;
      }
      
      return sufficient;
      }
      
      public void addMana(double amount) 
      {
      this.mana += amount;
      this.sync();
      }
      
      public double getMana() 
      {
      return this.mana;
      }
      
      public void setMana(double newMana) 
      {
      this.mana = newMana;
      this.sync();
      }
      
      public double getMaxMana() {
      return this.maxMana;
      }
      
      public boolean setSpellRight(String spell){
      
      if(this.spellsList.contains(spell)){
      this.spellRight = spell;
      this.sync();
      return true;
      }
      
      return false;
      }
      
      public boolean setSpellLeft(String spell){
      
      if(this.spellsList.contains(spell)){
      this.spellLeft = spell;
      this.sync();
      return true;
      }
      
      return false;
      }
      
      public String getSpellRight(){
      return this.spellRight;
      }
      
      public String getSpellLeft(){
      return this.spellLeft;
      }
      
      public boolean addSpellsList(String spell){
      if(this.getSpellsList().contains(spell) == false){
      this.spellsList.add(spell);
      this.sync();
      return true;
      }
      return false;
      }
      
      public boolean removeSpellsList(String spell){
      if(this.getSpellsList().contains(spell) == true){
      this.spellsList.remove(spell);
      this.sync();
      return true;
      }
      return false;
      }
      
      public List <string>getSpellsList(){
      return this.spellsList;
      }
      }
      
      package fr.sosoh.hogsmod.common.event;
      
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.nbt.NBTTagCompound;
      import net.minecraft.util.ChatComponentText;
      import net.minecraftforge.event.entity.EntityEvent.EntityConstructing;
      import net.minecraftforge.event.entity.EntityJoinWorldEvent;
      import net.minecraftforge.event.entity.living.LivingDeathEvent;
      import net.minecraftforge.event.entity.living.LivingEvent;
      import cpw.mods.fml.common.eventhandler.SubscribeEvent;
      import fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps;
      import fr.sosoh.hogsmod.proxy.CommonProxy;
      
      public class EventHandlerExtendedProps {
      
      private CommonProxy proxy;
      public int ticks;
      
      @SubscribeEvent
      public void onEntityConstructing(EntityConstructing event) 
      {
      if (event.entity instanceof EntityPlayer && ExtendedEntityProps.get((EntityPlayer) event.entity) == null)
      ExtendedEntityProps.register((EntityPlayer) event.entity);
      }
      
      @SubscribeEvent
      public void onLivingDeathEvent(LivingDeathEvent event) {
      if (!event.entity.worldObj.isRemote
      && event.entity instanceof EntityPlayer) {
      NBTTagCompound playerData = new NBTTagCompound();
      ((ExtendedEntityProps) (event.entity
      .getExtendedProperties(ExtendedEntityProps.EXT_PROP_NAME)))
      .saveNBTData(playerData);
      proxy.storeEntityData(
      ((EntityPlayer) event.entity).getDisplayName(), playerData);
      ExtendedEntityProps.saveProxyData((EntityPlayer) event.entity);
      } else {
      
      }
      }
      
      @SubscribeEvent
      public void onEntityJoinWorld(EntityJoinWorldEvent event) {
      if (!(event.entity.worldObj.isRemote) && event.entity instanceof EntityPlayer) {
      
      EntityPlayer player = (EntityPlayer)event.entity;
      NBTTagCompound playerData = proxy.getEntityData(((EntityPlayer) event.entity).getDisplayName());
      
      if (playerData != null) {
      ((ExtendedEntityProps) (event.entity.getExtendedProperties(ExtendedEntityProps.EXT_PROP_NAME))).loadNBTData(playerData);
      }
      
      ((ExtendedEntityProps) (event.entity.getExtendedProperties(ExtendedEntityProps.EXT_PROP_NAME))).sync();
      }
      }
      
      @SubscribeEvent
      public void LivingUpdateEvent(LivingEvent.LivingUpdateEvent event){
      
      if(event.entity instanceof EntityPlayer){
      ExtendedEntityProps props = ExtendedEntityProps.get(((EntityPlayer) event.entity));
      
      if(props.getMana() != props.getMaxMana()){
      ticks = ticks+1;
      if(ticks == 9){
      props.setMana(props.getMana()+1);
      ticks = 0;
      }
      }
      
      }
      
      }
      
      }
      
      ```</string></string></string>

      Developpeur d'Hogsmod, un mod implémentant le Monde d'Harry Potter dans Minecraft!

      1 réponse Dernière réponse Répondre Citer 0
      • SCAREXS Hors-ligne
        SCAREX
        dernière édition par

        C’est sur que si ils ne savent pas, ils ne vont pas marcher 😛 .

        tu n’as pas de fonction qui est appelé lorsque le joueur se déconnecte.

        Site web contenant mes scripts : http://SCAREXgaming.github.io

        Pas de demandes de support par MP ni par skype SVP.
        Je n'accepte sur skype que l…

        1 réponse Dernière réponse Répondre Citer 0
        • sosohS Hors-ligne
          sosoh
          dernière édition par

          Mais quand je meurs et donc comment je fais pour quand je deco ?

          Developpeur d'Hogsmod, un mod implémentant le Monde d'Harry Potter dans Minecraft!

          1 réponse Dernière réponse Répondre Citer 0
          • SCAREXS Hors-ligne
            SCAREX
            dernière édition par

            @‘sosoh’:

            Mais quand je meurs et donc comment je fais pour quand je deco ?

            PlayerEvent.PlayerLoggedOutEvent

            Site web contenant mes scripts : http://SCAREXgaming.github.io

            Pas de demandes de support par MP ni par skype SVP.
            Je n'accepte sur skype que l…

            1 réponse Dernière réponse Répondre Citer 0
            • sosohS Hors-ligne
              sosoh
              dernière édition par

              Et pour quand je meurs ?

              Developpeur d'Hogsmod, un mod implémentant le Monde d'Harry Potter dans Minecraft!

              1 réponse Dernière réponse Répondre Citer 0
              • SCAREXS Hors-ligne
                SCAREX
                dernière édition par

                @‘sosoh’:

                Et pour quand je meurs ?

                LivingDeathEvent, mais tu l’as déjà.

                Site web contenant mes scripts : http://SCAREXgaming.github.io

                Pas de demandes de support par MP ni par skype SVP.
                Je n'accepte sur skype que l…

                1 réponse Dernière réponse Répondre Citer 0
                • sosohS Hors-ligne
                  sosoh
                  dernière édition par

                  J’ai mis ca, mais ca ne marche pas:

                  ​@SubscribeEvent
                  
                  public void onLivingDeathEvent(LivingDeathEvent event) {
                  if (!event.entity.worldObj.isRemote
                  && event.entity instanceof EntityPlayer) {
                  NBTTagCompound playerData = new NBTTagCompound();
                  ((ExtendedEntityProps) (event.entity
                  .getExtendedProperties(ExtendedEntityProps.EXT_PROP_NAME)))
                  .saveNBTData(playerData);
                  proxy.storeEntityData(
                  ((EntityPlayer) event.entity).getDisplayName(), playerData);
                  ExtendedEntityProps.saveProxyData((EntityPlayer) event.entity);
                  } else {
                  
                  }
                  }
                  

                  Developpeur d'Hogsmod, un mod implémentant le Monde d'Harry Potter dans Minecraft!

                  1 réponse Dernière réponse Répondre Citer 0
                  • robin4002R Hors-ligne
                    robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                    dernière édition par

                    Non, ce n’est pas ça le problème. La sauvegarde est sensé se faire automatiquement. Le problème se trouve dans la fonction saveNBTData

                    ​    @Override
                    
                        public void saveNBTData(NBTTagCompound compound)
                        {
                    
                            NBTTagCompound properties = new NBTTagCompound();
                            compound.setTag(EXT_PROP_NAME, properties);
                            properties.setDouble("Mana", this.mana);
                            properties.setDouble("MaxMana", this.maxMana);
                            properties.setString("spellRight", this.spellRight);
                            properties.setString("spellLeft", this.spellLeft);
                            properties.setInteger("spellsListSize", this.spellsList.size());
                            if(this.spellsList != null){
                                for(String spell : this.spellsList)
                                {
                                    properties.setString("spellsList", spell);
                                }
                            }
                        }
                    

                    Regarde bien ce que tu fais. Dans un premier temps tu créé une variable local de type NBTTagCompound, puis tu écris dans le nbt tag d’entity ta variable, et seulement après tu ajoutes des choses dans ta variable local. Donc au final rien est écrit, sauf un tab nbt vide.
                    Cela devrait être comme ça :

                    ​    @Override
                    
                        public void saveNBTData(NBTTagCompound compound)
                        {
                    
                            NBTTagCompound properties = new NBTTagCompound();
                            properties.setDouble("Mana", this.mana);
                            properties.setDouble("MaxMana", this.maxMana);
                            properties.setString("spellRight", this.spellRight);
                            properties.setString("spellLeft", this.spellLeft);
                            properties.setInteger("spellsListSize", this.spellsList.size());
                            if(this.spellsList != null){
                                for(String spell : this.spellsList)
                                {
                                    properties.setString("spellsList", spell);
                                }
                            }
                    compound.setTag(EXT_PROP_NAME, properties);
                    }
                    
                    1 réponse Dernière réponse Répondre Citer 0
                    • sosohS Hors-ligne
                      sosoh
                      dernière édition par

                      J’ai corrigé mais ca ne marche pas 😞

                      ​package fr.sosoh.hogsmod.common.event;
                      
                      import net.minecraft.entity.player.EntityPlayer;
                      import net.minecraft.nbt.NBTTagCompound;
                      import net.minecraft.util.ChatComponentText;
                      import net.minecraftforge.event.entity.EntityEvent.EntityConstructing;
                      import net.minecraftforge.event.entity.EntityJoinWorldEvent;
                      import net.minecraftforge.event.entity.living.LivingDeathEvent;
                      import net.minecraftforge.event.entity.living.LivingEvent;
                      import cpw.mods.fml.common.eventhandler.SubscribeEvent;
                      import cpw.mods.fml.common.gameevent.PlayerEvent;
                      import fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps;
                      import fr.sosoh.hogsmod.proxy.CommonProxy;
                      
                      public class EventHandlerExtendedProps {
                      
                      private CommonProxy proxy;
                      public int ticks;
                      
                      @SubscribeEvent
                      public void onEntityConstructing(EntityConstructing event) 
                      {
                      if (event.entity instanceof EntityPlayer && ExtendedEntityProps.get((EntityPlayer) event.entity) == null)
                      ExtendedEntityProps.register((EntityPlayer) event.entity);
                      }
                      
                      @SubscribeEvent
                      public void onLivingDeathEvent(LivingDeathEvent event)
                      {
                      if (!event.entity.worldObj.isRemote && event.entity instanceof EntityPlayer)
                      {
                      NBTTagCompound playerData = new NBTTagCompound();
                      ((ExtendedEntityProps)(event.entity.getExtendedProperties(ExtendedEntityProps.EXT_PROP_NAME))).saveNBTData(playerData);
                      proxy.storeEntityData(((EntityPlayer) event.entity).getDisplayName(), playerData);
                      ExtendedEntityProps.saveProxyData((EntityPlayer) event.entity);
                      }
                      }
                      
                      @SubscribeEvent
                      public void onEntityJoinWorld(EntityJoinWorldEvent event) {
                      if (!(event.entity.worldObj.isRemote) && event.entity instanceof EntityPlayer) {
                      
                      EntityPlayer player = (EntityPlayer)event.entity;
                      NBTTagCompound playerData = proxy.getEntityData(((EntityPlayer) event.entity).getDisplayName());
                      
                      if (playerData != null) {
                      ((ExtendedEntityProps) (event.entity.getExtendedProperties(ExtendedEntityProps.EXT_PROP_NAME))).loadNBTData(playerData);
                      }
                      
                      ((ExtendedEntityProps) (event.entity.getExtendedProperties(ExtendedEntityProps.EXT_PROP_NAME))).sync();
                      }
                      }
                      
                      @SubscribeEvent
                      public void onPlayerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event){
                      if (!(event.player.worldObj.isRemote)) {
                      
                      NBTTagCompound playerData = proxy.getEntityData((event.player).getDisplayName());
                      
                      if (playerData != null) {
                      ((ExtendedEntityProps) (event.player.getExtendedProperties(ExtendedEntityProps.EXT_PROP_NAME))).saveNBTData(playerData);
                      }
                      
                      ((ExtendedEntityProps) (event.player.getExtendedProperties(ExtendedEntityProps.EXT_PROP_NAME))).sync();
                      }
                      }
                      }
                      

                      Developpeur d'Hogsmod, un mod implémentant le Monde d'Harry Potter dans Minecraft!

                      1 réponse Dernière réponse Répondre Citer 0
                      • SCAREXS Hors-ligne
                        SCAREX
                        dernière édition par

                        @‘sosoh’:

                        J’ai corrigé mais ca ne marche pas 😞

                        ​package fr.sosoh.hogsmod.common.event;
                        
                        import net.minecraft.entity.player.EntityPlayer;
                        import net.minecraft.nbt.NBTTagCompound;
                        import net.minecraft.util.ChatComponentText;
                        import net.minecraftforge.event.entity.EntityEvent.EntityConstructing;
                        import net.minecraftforge.event.entity.EntityJoinWorldEvent;
                        import net.minecraftforge.event.entity.living.LivingDeathEvent;
                        import net.minecraftforge.event.entity.living.LivingEvent;
                        import cpw.mods.fml.common.eventhandler.SubscribeEvent;
                        import cpw.mods.fml.common.gameevent.PlayerEvent;
                        import fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps;
                        import fr.sosoh.hogsmod.proxy.CommonProxy;
                        
                        public class EventHandlerExtendedProps {
                        
                        private CommonProxy proxy;
                        public int ticks;
                        
                        @SubscribeEvent
                        public void onEntityConstructing(EntityConstructing event) 
                        {
                        if (event.entity instanceof EntityPlayer && ExtendedEntityProps.get((EntityPlayer) event.entity) == null)
                        ExtendedEntityProps.register((EntityPlayer) event.entity);
                        }
                        
                        @SubscribeEvent
                        public void onLivingDeathEvent(LivingDeathEvent event)
                        {
                        if (!event.entity.worldObj.isRemote && event.entity instanceof EntityPlayer)
                        {
                        NBTTagCompound playerData = new NBTTagCompound();
                        ((ExtendedEntityProps)(event.entity.getExtendedProperties(ExtendedEntityProps.EXT_PROP_NAME))).saveNBTData(playerData);
                        proxy.storeEntityData(((EntityPlayer) event.entity).getDisplayName(), playerData);
                        ExtendedEntityProps.saveProxyData((EntityPlayer) event.entity);
                        }
                        }
                         
                        @SubscribeEvent
                        public void onEntityJoinWorld(EntityJoinWorldEvent event) {
                        if (!(event.entity.worldObj.isRemote) && event.entity instanceof EntityPlayer) {
                        
                        EntityPlayer player = (EntityPlayer)event.entity;
                        NBTTagCompound playerData = proxy.getEntityData(((EntityPlayer) event.entity).getDisplayName());
                        
                        if (playerData != null) {
                        ((ExtendedEntityProps) (event.entity.getExtendedProperties(ExtendedEntityProps.EXT_PROP_NAME))).loadNBTData(playerData);
                        }
                        
                        ((ExtendedEntityProps) (event.entity.getExtendedProperties(ExtendedEntityProps.EXT_PROP_NAME))).sync();
                        }
                        }
                        
                        @SubscribeEvent
                        public void onPlayerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event){
                        if (!(event.player.worldObj.isRemote)) {
                        
                        NBTTagCompound playerData = proxy.getEntityData((event.player).getDisplayName());
                        
                        if (playerData != null) {
                        ((ExtendedEntityProps) (event.player.getExtendedProperties(ExtendedEntityProps.EXT_PROP_NAME))).saveNBTData(playerData);
                        }
                        
                        ((ExtendedEntityProps) (event.player.getExtendedProperties(ExtendedEntityProps.EXT_PROP_NAME))).sync();
                        }
                        }
                        }
                        

                        Mets un System.out.print (ou un log.info si tu en as un à disposition) dans ta fonction de sauvegarde et regarde s’il s’affiche quand tu te deco/reco etc.

                        Site web contenant mes scripts : http://SCAREXgaming.github.io

                        Pas de demandes de support par MP ni par skype SVP.
                        Je n'accepte sur skype que l…

                        1 réponse Dernière réponse Répondre Citer 0
                        • sosohS Hors-ligne
                          sosoh
                          dernière édition par

                          J’ai mis ca dans mes events, il affiche que c’est null (je peux t’envoyer mon src ?):

                          ​@SubscribeEvent
                          
                          public void onLivingDeathEvent(LivingDeathEvent event)
                          {
                          if (!event.entity.worldObj.isRemote && event.entity instanceof EntityPlayer){
                          System.out.println("Death");
                          NBTTagCompound playerData = new NBTTagCompound();
                          ((ExtendedEntityProps)(event.entity.getExtendedProperties(ExtendedEntityProps.EXT_PROP_NAME))).saveNBTData(playerData);
                          proxy.storeEntityData(((EntityPlayer) event.entity).getDisplayName(), playerData);
                          ExtendedEntityProps.saveProxyData((EntityPlayer) event.entity);
                          }
                          }
                          
                          @SubscribeEvent
                          public void onEntityJoinWorld(EntityJoinWorldEvent event) {
                          if (!(event.entity.worldObj.isRemote) && event.entity instanceof EntityPlayer) {
                          System.out.println("LoggedIn");
                          EntityPlayer player = (EntityPlayer)event.entity;
                          NBTTagCompound playerData = proxy.getEntityData(((EntityPlayer) event.entity).getDisplayName());
                          
                          if (playerData != null) {
                          System.out.println("LoggedIn-null");
                          ((ExtendedEntityProps) (event.entity.getExtendedProperties(ExtendedEntityProps.EXT_PROP_NAME))).loadNBTData(playerData);
                          }
                          
                          ((ExtendedEntityProps) (event.entity.getExtendedProperties(ExtendedEntityProps.EXT_PROP_NAME))).sync();
                          }
                          }
                          
                          @SubscribeEvent
                          public void onPlayerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event){
                          if (!(event.player.worldObj.isRemote)) {
                          
                          NBTTagCompound playerData = proxy.getEntityData((event.player).getDisplayName());
                          
                          if (playerData != null) {
                          ((ExtendedEntityProps) (event.player.getExtendedProperties(ExtendedEntityProps.EXT_PROP_NAME))).saveNBTData(playerData);
                          System.out.println("LoggedOut-Null");
                          }
                          System.out.println("LoggedOut");
                          ((ExtendedEntityProps) (event.player.getExtendedProperties(ExtendedEntityProps.EXT_PROP_NAME))).sync();
                          }
                          }
                          
                          [22:15:48] [Server thread/INFO] [STDOUT]: [fr.sosoh.hogsmod.common.event.EventHandlerExtendedProps:onLivingDeathEvent:32]: Death
                          [22:15:48] [Server thread/INFO]: sosoh fell out of the world
                          [22:15:48] [Client thread/INFO]: [CHAT] sosoh fell out of the world
                          [22:15:48] [Client thread/INFO]: [CHAT] Ouch! That looked like it hurt
                          [22:15:50] [Server thread/INFO] [STDOUT]: [fr.sosoh.hogsmod.common.event.EventHandlerExtendedProps:onEntityJoinWorld:43]: LoggedIn
                          [22:15:50] [Server thread/INFO] [STDOUT]: [fr.sosoh.hogsmod.common.event.EventHandlerExtendedProps:onEntityJoinWorld:48]: LoggedIn-null
                          

                          Developpeur d'Hogsmod, un mod implémentant le Monde d'Harry Potter dans Minecraft!

                          1 réponse Dernière réponse Répondre Citer 0
                          • SCAREXS Hors-ligne
                            SCAREX
                            dernière édition par

                            @‘sosoh’:

                            J’ai mis ca dans mes events, il affiche que c’est null (je peux t’envoyer mon src ?):

                            ​@SubscribeEvent
                            
                            public void onLivingDeathEvent(LivingDeathEvent event)
                            {
                            if (!event.entity.worldObj.isRemote && event.entity instanceof EntityPlayer){
                            System.out.println("Death");
                            NBTTagCompound playerData = new NBTTagCompound();
                            ((ExtendedEntityProps)(event.entity.getExtendedProperties(ExtendedEntityProps.EXT_PROP_NAME))).saveNBTData(playerData);
                            proxy.storeEntityData(((EntityPlayer) event.entity).getDisplayName(), playerData);
                            ExtendedEntityProps.saveProxyData((EntityPlayer) event.entity);
                            }
                            }
                             
                            @SubscribeEvent
                            public void onEntityJoinWorld(EntityJoinWorldEvent event) {
                            if (!(event.entity.worldObj.isRemote) && event.entity instanceof EntityPlayer) {
                            System.out.println("LoggedIn");
                            EntityPlayer player = (EntityPlayer)event.entity;
                            NBTTagCompound playerData = proxy.getEntityData(((EntityPlayer) event.entity).getDisplayName());
                            
                            if (playerData != null) {
                            System.out.println("LoggedIn-null");
                            ((ExtendedEntityProps) (event.entity.getExtendedProperties(ExtendedEntityProps.EXT_PROP_NAME))).loadNBTData(playerData);
                            }
                            
                            ((ExtendedEntityProps) (event.entity.getExtendedProperties(ExtendedEntityProps.EXT_PROP_NAME))).sync();
                            }
                            }
                            
                            @SubscribeEvent
                            public void onPlayerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event){
                            if (!(event.player.worldObj.isRemote)) {
                            
                            NBTTagCompound playerData = proxy.getEntityData((event.player).getDisplayName());
                            
                            if (playerData != null) {
                            ((ExtendedEntityProps) (event.player.getExtendedProperties(ExtendedEntityProps.EXT_PROP_NAME))).saveNBTData(playerData);
                            System.out.println("LoggedOut-Null");
                            }
                            System.out.println("LoggedOut");
                            ((ExtendedEntityProps) (event.player.getExtendedProperties(ExtendedEntityProps.EXT_PROP_NAME))).sync();
                            }
                            }
                            
                            [22:15:48] [Server thread/INFO] [STDOUT]: [fr.sosoh.hogsmod.common.event.EventHandlerExtendedProps:onLivingDeathEvent:32]: Death
                            [22:15:48] [Server thread/INFO]: sosoh fell out of the world
                            [22:15:48] [Client thread/INFO]: [CHAT] sosoh fell out of the world
                            [22:15:48] [Client thread/INFO]: [CHAT] Ouch! That looked like it hurt
                            [22:15:50] [Server thread/INFO] [STDOUT]: [fr.sosoh.hogsmod.common.event.EventHandlerExtendedProps:onEntityJoinWorld:43]: LoggedIn
                            [22:15:50] [Server thread/INFO] [STDOUT]: [fr.sosoh.hogsmod.common.event.EventHandlerExtendedProps:onEntityJoinWorld:48]: LoggedIn-null
                            

                            Mets les system.out.println dans ta fonction de sauvegarde, pas dans tes fonctions d’event. ça servirai pas à grand chose de m’envoyer tes sources car je m’y connait pas trop en EntityExtendedProperties.

                            Site web contenant mes scripts : http://SCAREXgaming.github.io

                            Pas de demandes de support par MP ni par skype SVP.
                            Je n'accepte sur skype que l…

                            1 réponse Dernière réponse Répondre Citer 0
                            • sosohS Hors-ligne
                              sosoh
                              dernière édition par

                              J’ai mis dans la fonction store de mon common proxy, ça marche. Quelqu’un a une idée ?

                              Developpeur d'Hogsmod, un mod implémentant le Monde d'Harry Potter dans Minecraft!

                              1 réponse Dernière réponse Répondre Citer 0
                              • SCAREXS Hors-ligne
                                SCAREX
                                dernière édition par

                                @‘sosoh’:

                                J’ai mis dans la fonction store de mon common proxy, ça marche. Quelqu’un a une idée ?

                                Le problème vient de là:

                                ​
                                @Override
                                
                                public void saveNBTData(NBTTagCompound compound)
                                {
                                
                                NBTTagCompound properties = new NBTTagCompound();
                                properties.setDouble("Mana", this.mana);
                                properties.setDouble("MaxMana", this.maxMana);
                                properties.setString("spellRight", this.spellRight);
                                properties.setString("spellLeft", this.spellLeft);
                                properties.setInteger("spellsListSize", this.spellsList.size());
                                if(this.spellsList != null){
                                for(String spell : this.spellsList)
                                {
                                properties.setString("spellsList", spell);
                                }
                                }
                                compound.setTag(EXT_PROP_NAME, properties);
                                }
                                

                                Ta boucle for supprime l’ancienne valeur : il faut utiliser un NBTTagList.

                                Site web contenant mes scripts : http://SCAREXgaming.github.io

                                Pas de demandes de support par MP ni par skype SVP.
                                Je n'accepte sur skype que l…

                                1 réponse Dernière réponse Répondre Citer 0
                                • sosohS Hors-ligne
                                  sosoh
                                  dernière édition par

                                  Tu peux m’expliquer comment car je ne maîtrise pas tout à fait?

                                  Developpeur d'Hogsmod, un mod implémentant le Monde d'Harry Potter dans Minecraft!

                                  1 réponse Dernière réponse Répondre Citer 0
                                  • SCAREXS Hors-ligne
                                    SCAREX
                                    dernière édition par

                                    @‘sosoh’:

                                    Tu peux m’expliquer comment car je ne maîtrise pas tout à fait?

                                    Regarde dans le code tu TileEntity coffre car j’ai jamais utilisé ce NBTTag mais je sais qu’il existe.

                                    Site web contenant mes scripts : http://SCAREXgaming.github.io

                                    Pas de demandes de support par MP ni par skype SVP.
                                    Je n'accepte sur skype que l…

                                    1 réponse Dernière réponse Répondre Citer 0
                                    • sosohS Hors-ligne
                                      sosoh
                                      dernière édition par

                                      Mais je mets un NBTTagList pour juste l’array ou pour toutes mes props ?

                                      Developpeur d'Hogsmod, un mod implémentant le Monde d'Harry Potter dans Minecraft!

                                      1 réponse Dernière réponse Répondre Citer 0
                                      • SCAREXS Hors-ligne
                                        SCAREX
                                        dernière édition par

                                        @‘sosoh’:

                                        Mais je mets un NBTTagList pour juste l’array ou pour toutes mes props ?

                                        juste pour ton array spellList.

                                        Site web contenant mes scripts : http://SCAREXgaming.github.io

                                        Pas de demandes de support par MP ni par skype SVP.
                                        Je n'accepte sur skype que l…

                                        1 réponse Dernière réponse Répondre Citer 0
                                        • sosohS Hors-ligne
                                          sosoh
                                          dernière édition par

                                          J’ai fait ca, mais ca ne marche pas:

                                          ​@Override
                                          
                                          public void saveNBTData(NBTTagCompound compound) 
                                              {
                                          
                                                  NBTTagCompound properties = new NBTTagCompound();
                                                  NBTTagList nbtlist = new NBTTagList();
                                                  properties.setDouble("Mana", this.mana);
                                                  properties.setDouble("MaxMana", this.maxMana);
                                                  properties.setString("spellRight", this.spellRight);
                                                  properties.setString("spellLeft", this.spellLeft);
                                                  properties.setInteger("spellsListSize", this.spellsList.size());
                                                  nbtlist.appendTag(properties);
                                                  if(this.spellsList != null){
                                                      for(String spell : this.spellsList)
                                                      {
                                                      NBTTagCompound nbttag = new NBTTagCompound();
                                                      nbttag.setString("spellsList", spell);
                                                          nbtlist.appendTag(nbttag);
                                                      }
                                                  }
                                                  compound.setTag(EXT_PROP_NAME, nbtlist);
                                              }
                                          
                                          @Override
                                          public void loadNBTData(NBTTagCompound compound) 
                                          {
                                          NBTTagList nbtlist = (NBTTagList) compound.getTag(EXT_PROP_NAME);
                                          NBTTagCompound properties = nbtlist.getCompoundTagAt(1);
                                          this.mana = properties.getDouble("Mana");
                                          this.maxMana = properties.getDouble("MaxMana");
                                          this.spellRight = properties.getString("spellRight");
                                          this.spellLeft = properties.getString("spellLeft");
                                          int size = properties.getInteger("spellsListSize");
                                          if(size > 0){
                                          for(int i = 0; i < size; i++){
                                          NBTTagCompound nbttag = nbtlist.getCompoundTagAt(i);
                                          this.spellsList.add(i, nbttag.getString("spellsList"));
                                          }
                                          }
                                          }
                                          

                                          Developpeur d'Hogsmod, un mod implémentant le Monde d'Harry Potter dans Minecraft!

                                          1 réponse Dernière réponse Répondre Citer 0
                                          • SCAREXS Hors-ligne
                                            SCAREX
                                            dernière édition par

                                            @‘sosoh’:

                                            J’ai fait ca, mais ca ne marche pas:

                                            ​@Override
                                            
                                            public void saveNBTData(NBTTagCompound compound) 
                                                {
                                            
                                                    NBTTagCompound properties = new NBTTagCompound();
                                                    NBTTagList nbtlist = new NBTTagList();
                                                    properties.setDouble("Mana", this.mana);
                                                    properties.setDouble("MaxMana", this.maxMana);
                                                    properties.setString("spellRight", this.spellRight);
                                                    properties.setString("spellLeft", this.spellLeft);
                                                    properties.setInteger("spellsListSize", this.spellsList.size());
                                                    nbtlist.appendTag(properties);
                                                    if(this.spellsList != null){
                                                        for(String spell : this.spellsList)
                                                        {
                                                        NBTTagCompound nbttag = new NBTTagCompound();
                                                        nbttag.setString("spellsList", spell);
                                                            nbtlist.appendTag(nbttag);
                                                        }
                                                    }
                                                    compound.setTag(EXT_PROP_NAME, nbtlist);
                                                }
                                            
                                            @Override
                                            public void loadNBTData(NBTTagCompound compound) 
                                            {
                                            NBTTagList nbtlist = (NBTTagList) compound.getTag(EXT_PROP_NAME);
                                            NBTTagCompound properties = nbtlist.getCompoundTagAt(1);
                                            this.mana = properties.getDouble("Mana");
                                            this.maxMana = properties.getDouble("MaxMana");
                                            this.spellRight = properties.getString("spellRight");
                                            this.spellLeft = properties.getString("spellLeft");
                                            int size = properties.getInteger("spellsListSize");
                                            if(size > 0){
                                            for(int i = 0; i < size; i++){
                                            NBTTagCompound nbttag = nbtlist.getCompoundTagAt(i);
                                            this.spellsList.add(i, nbttag.getString("spellsList"));
                                            }
                                            }
                                            }
                                            

                                            regarde comment les NBTTagList fonctionne dans le TileEntityChest

                                            Site web contenant mes scripts : http://SCAREXgaming.github.io

                                            Pas de demandes de support par MP ni par skype SVP.
                                            Je n'accepte sur skype que l…

                                            1 réponse Dernière réponse Répondre Citer 0
                                            • 1
                                            • 2
                                            • 3
                                            • 1 / 3
                                            • Premier message
                                              Dernier message
                                            Design by Woryk
                                            ContactMentions Légales

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB