• Récent
  • Mots-clés
  • Populaire
  • Utilisateurs
  • Groupes
  • S'inscrire
  • Se connecter
  • S'inscrire
  • Se connecter
  • Recherche
  • Récent
  • Mots-clés
  • Populaire
  • Utilisateurs
  • Groupes

Résolu Crash timer sur serveur.

1.7.x
1.7.2
3
8
1.5k
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.
  • A
    AceGamer45 dernière édition par 19 mars 2014, 20:43

    Bonjours à tous !

    Aujourd’hui j’ai eu des problèmes en voulant codder un objet qui utilise une commande je rencontre 2 problèmes.

    Le 1er c’est un objet qui exécute instantanée la commande, l’objet doit être garder et on peux l’utiliser autant de fois que l’on souhaite, le problème avec cette objet c’est que en solo sa fonctionne mais la command s’exécute 2fois de suite et en multijoueur sur un serveur il fait crash voici le rapport d’erreur :

    // Shall we play a game?
    Time: 19/03/14 21:16
    Description: Ticking entity
    java.lang.NullPointerException
    at pixelbadge.Stats.func_77663_a(Stats.java:60)
    at net.minecraft.item.ItemStack.func_77945_a(ItemStack.java:498)
    at net.minecraft.entity.player.InventoryPlayer.func_70429_k(InventoryPlayer.java:359)
    at net.minecraft.entity.player.EntityPlayer.func_70636_d(EntityPlayer.java:606)
    at net.minecraft.client.entity.EntityPlayerSP.func_70636_d(EntityPlayerSP.java:307)
    at net.minecraft.entity.EntityLivingBase.func_70071_h_(EntityLivingBase.java:1826)
    at net.minecraft.entity.player.EntityPlayer.func_70071_h_(EntityPlayer.java:342)
    at net.minecraft.client.entity.EntityClientPlayerMP.func_70071_h_(SourceFile:46)
    at net.minecraft.world.World.func_72866_a(World.java:2350)
    at net.minecraft.world.World.func_72870_g(World.java:2311)
    at net.minecraft.world.World.func_72939_s(World.java:2157)
    at net.minecraft.client.Minecraft.func_71407_l(Minecraft.java:1921)
    at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:910)
    at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:838)
    at net.minecraft.client.main.Main.main(SourceFile:101)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:131)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:27)

    le code est :

    package pixelbadge;
    import pixelmonfr.pixelmain;
    import net.minecraft.command.ICommandManager;
    import net.minecraft.entity.Entity;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemStack;
    import net.minecraft.server.MinecraftServer;
    import net.minecraft.world.World;
    public class Stats extends Item
    {
    private int timer;
    public Stats(int par1)
    {
    super(par1);
    this.setCreativeTab(pixelmain.pixelitems);
    this.setMaxStackSize(1);
    }
    public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
    {
    timer = 1;
    return stack;
    }
    public void onUpdate(ItemStack stack, World world, Entity entity, int id, boolean isCurrent)
    {
    if(timer > -1 && entity instanceof EntityPlayer)
    {
    timer–;
    }
    if(timer == 0 && entity instanceof EntityPlayer)
    {
    ICommandManager icommandmanager = MinecraftServer.getServer().getCommandManager();
    icommandmanager.executeCommand((EntityPlayer)entity, "/pokestats");
    }
    }
    }

    Et le second est un objet qui doit exécuter la command après un certains temps puis disparaître mais pareille il fait crash en multi, voici le code :

    package pixelbadge;
    import net.minecraft.command.ICommandManager;
    import net.minecraft.entity.Entity;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemStack;
    import net.minecraft.server.MinecraftServer;
    import net.minecraft.world.World;
    import pixelmonfr.pixelmain;
    public class oeufpichu extends Item
    {
       private int timer;
       public oeufpichu(int par1)
       {
           super(par1);
           this.setCreativeTab(pixelmain.pixelitems);
           this.setMaxStackSize(1);
       }
       /**
        * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
        */
       public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
       {
           this.timer = 168000;
           --stack.stackSize;
           return stack;
       }
       /**
        * Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and
        * update it's contents.
        */
       public void onUpdate(ItemStack stack, World world, Entity entity, int id, boolean isCurrent)
       {
           if (this.timer > -1 && entity instanceof EntityPlayer)
           {
               --this.timer;
           }
           if (this.timer == 0 && entity instanceof EntityPlayer)
           {
               ICommandManager icommandmanager = MinecraftServer.getServer().getCommandManager();
               icommandmanager.executeCommand((EntityPlayer)entity, "/pokegive @p pichu lvl1");
           }
       }
    }

    Sa ne fait pas crash le serveur mais seulement la personne ^^

    Je suis pas un expert en java mais je sais lire les tutos et des que j’ai un problème j’arrive à le résoudre seul mais la je sèche et je suis en 1.6.4.

    Merci aux personnes qui m’aiderons, sur ce bonne soirée !

    1 réponse Dernière réponse Répondre Citer 0
    • robin4002
      robin4002 Moddeurs confirmés Rédacteurs Administrateurs dernière édition par 19 mars 2014, 20:55

      public void onUpdate(ItemStack stack, World world, Entity entity, int id, boolean isCurrent)
      {
      if(!world.isRemote)
      {
      if (this.timer > -1 && entity instanceof EntityPlayer)
      {
      –this.timer;
      }
      if (this.timer == 0 && entity instanceof EntityPlayer)
      {
      ICommandManager icommandmanager = MinecraftServer.getServer().getCommandManager();
      icommandmanager.executeCommand((EntityPlayer)entity, "/pokegive @p pichu lvl1");
      }
      }
      }

      Les commandes c’est côté serveur uniquement, donc toujours !world.isRemote

      1 réponse Dernière réponse Répondre Citer 0
      • A
        AceGamer45 dernière édition par 19 mars 2014, 22:28

        Merci de la réponse rapide, je test et je vous tiens au courant !

        1 réponse Dernière réponse Répondre Citer 0
        • environ 7 jours
        • A
          AceGamer45 dernière édition par 27 mars 2014, 09:45

          Je viens au nouvelle donc pour le 1er sa fonctionne mais pour le deuxième je veux faire que après 14minute par exemple celui ci fait le commande et j’ai beau attendre, l’objet disparaît quand je clique et rien ne se passe après 14minute

          voici le code :

          package pixelbadge;
          import net.minecraft.command.ICommandManager;
          import net.minecraft.entity.Entity;
          import net.minecraft.entity.player.EntityPlayer;
          import net.minecraft.item.Item;
          import net.minecraft.item.ItemStack;
          import net.minecraft.server.MinecraftServer;
          import net.minecraft.world.World;
          import pixelmonfr.pixelmain;
          public class oeufpichu extends Item
          {
          private int timer;
          public oeufpichu(int par1)
          {
          super(par1);
          this.setCreativeTab(pixelmain.pixelitems);
          this.setMaxStackSize(1);
          }
          /**
          * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
          */
          public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
          {
          this.timer = 168000;
          –stack.stackSize;
          return stack;
          }
          /**
          * Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and
          * update it's contents.
          */
          public void onUpdate(ItemStack stack, World world, Entity entity, int id, boolean isCurrent)
          {
          if(!world.isRemote)
          {
          if (this.timer > -1 && entity instanceof EntityPlayer)
          {
          --this.timer;
          }
          if (this.timer == 0 && entity instanceof EntityPlayer)
          {
          ICommandManager icommandmanager = MinecraftServer.getServer().getCommandManager();
          icommandmanager.executeCommand((EntityPlayer)entity, "/pokegive @p pichu lvl1");
          }
          }
          }
          }

          Merci de votre aide

          1 réponse Dernière réponse Répondre Citer 0
          • robin4002
            robin4002 Moddeurs confirmés Rédacteurs Administrateurs dernière édition par 27 mars 2014, 12:34

            Oui, ça ne risque pas de fonctionner, comme tu fais disparaître l’objet, le code n’est plus exécuté.
            Il faudrait plutôt faire disparaître l’item lors de l’effet de la commande.

            1 réponse Dernière réponse Répondre Citer 0
            • A
              AceGamer45 dernière édition par 27 mars 2014, 12:46

              C’est bien ce que je pensais, et donc je dois modifier quoi dans le code ? Je suis pas très très bon en java encore ^^’

              Edit : je pense avoir trouver je fais un test

              1 réponse Dernière réponse Répondre Citer 0
              • T
                totos51 dernière édition par 27 mars 2014, 12:49

                plus simplement ce que veux dire robin c’est que au lieud e supprimer l’item de la main dès que tu clic droit, le faire plutot au bout de 14 minutes enfin je pense avoir compris ainsi par contre il faut trouver un moyen d’empecher l’utilisation plusieurs fois, dans l’idée utiliser une variable lors de la première utilisation qui fait qu’on ne peut pas l’utiliser plusieurs fois.

                1 réponse Dernière réponse Répondre Citer 0
                • A
                  AceGamer45 dernière édition par 27 mars 2014, 13:15

                  Finalement je n’est pas réussi je ne comprend pas trop comment faire, si tu pouvais m’aider un peu plus en modifiant le code ci dessus car j’ai du mal là ^^

                  Edit : Voilà j’ai trouver une alternative en gros le –stack.stacksize; je les mis après la commande donc quand on veux le réutiliser il disparaît :

                  package pixelbadge;
                  import net.minecraft.command.ICommandManager;
                  import net.minecraft.entity.Entity;
                  import net.minecraft.entity.player.EntityPlayer;
                  import net.minecraft.item.Item;
                  import net.minecraft.item.ItemStack;
                  import net.minecraft.server.MinecraftServer;
                  import net.minecraft.world.World;
                  import pixelmonfr.pixelmain;
                  public class oeufpichu extends Item
                  {
                  private int timer;
                  public oeufpichu(int par1)
                  {
                  super(par1);
                  this.setCreativeTab(pixelmain.pixelitems);
                  this.setMaxStackSize(1);
                  }
                  /**
                  * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
                  */
                  public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
                  {
                  this.timer = 2400;
                  return stack;
                  }
                  /**
                  * Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and
                  * update it's contents.
                  */
                  public void onUpdate(ItemStack stack, World world, Entity entity, int id, boolean isCurrent)
                  {
                  if(!world.isRemote)
                  {
                  if (this.timer > -1 && entity instanceof EntityPlayer)
                  {
                  --this.timer;
                  }
                  if (this.timer == 0 && entity instanceof EntityPlayer)
                  {
                  ICommandManager icommandmanager = MinecraftServer.getServer().getCommandManager();
                  icommandmanager.executeCommand((EntityPlayer)entity, "/pokegive @p pichu lvl1");
                  --stack.stackSize;
                  }
                  }
                  }
                  1 réponse Dernière réponse Répondre Citer 0
                  • 1 / 1
                  3 sur 8
                  • Premier message
                    3/8
                    Dernier message
                  Design by Woryk
                  Contact / Mentions Légales

                  MINECRAFT FORGE FRANCE © 2018

                  Powered by NodeBB