MFF

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

    Récupérer le temps

    Planifier Épinglé Verrouillé Déplacé Résolu 1.7.x
    1.7.10
    13 Messages 4 Publieurs 3.9k 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.
    • tybauT Hors-ligne
      tybau
      dernière édition par

      L’exception ne s’affiche pas sur la console mais sur le computer:

      et j’ai changer World world = null par this.getWorldObj()

      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

        Renvoie ton code actuelle.

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

          package fr.kebabfondation.aecomputer.TileEntity;
          
          import net.minecraft.tileentity.TileEntity;
          import net.minecraft.world.World;
          import dan200.computercraft.api.lua.ILuaContext;
          import dan200.computercraft.api.lua.LuaException;
          import dan200.computercraft.api.peripheral.IComputerAccess;
          import dan200.computercraft.api.peripheral.IPeripheral;
          
          public class TileEntityRainDetector extends TileEntity implements IPeripheral{
          
          @Override
          public String getType() {
          return "ChannelDetector";
          }
          
          @Override
          public String[] getMethodNames() {
          return new String[] {"getWeather", "start", "stop", "change"};
          }
          
          @Override
          public Object[] callMethod(IComputerAccess computer, ILuaContext context,
          int method, Object[] arguments) throws LuaException,
          InterruptedException {
          switch(method){
          case(0):
          if (this.getWorldObj().getWorldInfo().isRaining()){
          return new Object[] {"Il pleut"};
          }
          return new Object[] {"Il Pleut pas"};
          case(1):
          return new Object[] {true};
          case(2):
          return new Object[] {true};
          }
          
          return null;
          }
          
          @Override
          public void attach(IComputerAccess computer) {
          
          }
          
          @Override
          public void detach(IComputerAccess computer) {
          
          }
          
          @Override
          public boolean equals(IPeripheral other) {
          return false;
          }
          }
          
          
          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

            Vérifie que la méthode isRaining() n’est pas ClientSideOnly

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

              J’ai regardé la fonction dans les sources mais rien est précisé à ce niveau là.

              Apparemment non elle ne l’est pas.

              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

                En effet, pas de @SideOnly, donc je ne vois pas pourquoi ça ne fonctionne pas 😕
                Et sans logs ça va être difficile de savoir qu’est ce qui cause problème.

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

                  Essayez de gardez le launcher ouvert….?

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

                    J’ai ajouté une ligne de debug pour vérifier que la méthode est bien appelé et c’est le cas:

                    ​package fr.kebabfondation.aecomputer.TileEntity;
                    
                    import net.minecraft.tileentity.TileEntity;
                    import cpw.mods.fml.relauncher.Side;
                    import cpw.mods.fml.relauncher.SideOnly;
                    import dan200.computercraft.api.lua.ILuaContext;
                    import dan200.computercraft.api.lua.LuaException;
                    import dan200.computercraft.api.peripheral.IComputerAccess;
                    import dan200.computercraft.api.peripheral.IPeripheral;
                    
                    public class TileEntityRainDetector extends TileEntity implements IPeripheral{
                    
                    @Override
                    public String getType() {
                    return "ChannelDetector";
                    }
                    
                    @Override
                    public String[] getMethodNames() {
                    return new String[] {"getWeather", "start", "stop", "change"};
                    }
                    
                    @Override
                    public Object[] callMethod(IComputerAccess computer, ILuaContext context,
                    int method, Object[] arguments) throws LuaException,
                    InterruptedException {
                    switch(method){
                    case(0):
                    System.out.println("Il pleut"); //Debug
                    if (this.getWorldObj().getWorldInfo().isRaining()){
                    return new Object[] {"Il pleut"};
                    }
                    return new Object[] {"Il Pleut pas"};
                    case(1):
                    return new Object[] {true};
                    case(2):
                    return new Object[] {true};
                    }
                    
                    return null;
                    }
                    
                    @Override
                    public void attach(IComputerAccess computer) {
                    
                    }
                    
                    @Override
                    public void detach(IComputerAccess computer) {
                    
                    }
                    
                    @Override
                    public boolean equals(IPeripheral other) {
                    return false;
                    }
                    }
                    

                    Voici les logs:

                    [15:34:20] [Server thread/INFO]: Preparing start region for level 0

                    [15:34:21] [Server thread/INFO]: Changing view distance to 12, from 10
                    [15:34:21] [Thread-20/WARN] [FML]: =============================================================
                    [15:34:21] [Thread-20/WARN] [FML]: MOD HAS DIRECT REFERENCE System.exit() THIS IS NOT ALLOWED REROUTING TO FML!
                    [15:34:21] [Thread-20/WARN] [FML]: Offendor: org/luaj/vm2/lib/OsLib.exit(I)V
                    [15:34:21] [Thread-20/WARN] [FML]: Use FMLCommonHandler.exitJava instead
                    [15:34:21] [Thread-20/WARN] [FML]: =============================================================
                    [15:34:21] [Netty Client IO #0/INFO] [FML]: Server protocol version 1
                    [15:34:21] [Netty IO #1/INFO] [FML]: Client protocol version 1
                    [15:34:21] [Netty IO #1/INFO] [FML]: Client attempting to join with 6 mods : ComputerCraft@1.65,mcp@9.05,FML@7.10.85.1230,fta@1.0,Forge@10.13.2.1230,CodeChickenCore@1.0.4.29
                    [15:34:21] [Netty IO #1/INFO] [FML]: Attempting connection with missing mods [] at CLIENT
                    [15:34:21] [Netty Client IO #0/INFO] [FML]: Attempting connection with missing mods [] at SERVER
                    [15:34:21] [Server thread/INFO] [FML]: [Server thread] Server side modded connection established
                    [15:34:21] [Client thread/INFO] [FML]: [Client thread] Client side modded connection established
                    [15:34:21] [Server thread/INFO]: Player906[local:E:55445dc0] logged in with entity id 375 at (-235.62404160644985, 72.0, 237.19164903788885)
                    [15:34:21] [Server thread/INFO]: Player906 joined the game
                    [15:34:22] [Server thread/INFO]: Saving and pausing game…
                    [15:34:22] [Server thread/INFO]: Saving chunks for level ‘Test World Modding’/Overworld
                    [15:34:23] [Server thread/INFO]: Saving chunks for level ‘Test World Modding’/Nether
                    [15:34:23] [Server thread/INFO]: Saving chunks for level ‘Test World Modding’/The End
                    [15:34:44] [Coroutine-3/INFO] [STDOUT]: [fr.kebabfondation.aecomputer.TileEntity.TileEntityRainDetector:callMethod:29]: Il pleut
                    [15:34:46] [Server thread/INFO]: Saving and pausing game…
                    [15:34:46] [Server thread/INFO]: Saving chunks for level ‘Test World Modding’/Overworld
                    [15:34:47] [Server thread/INFO]: Saving chunks for level ‘Test World Modding’/Nether
                    [15:34:47] [Server thread/INFO]: Saving chunks for level ‘Test World Modding’/The End

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

                      Apparemment, après plusieurs essaies, c’est le World qu’il n’arrive pas à récupérer.

                      Comment puis-je faire pour récupérer le monde dans lequel ce situe mon block?

                      1 réponse Dernière réponse Répondre Citer 0
                      • jglrxavpokJ Hors-ligne
                        jglrxavpok Modérateurs
                        dernière édition par

                        Il me semble qu’il te faut un constructeur avec en argument une instance de World. Ensuite garde cette instance dans une variable dans la TileEntity 😉

                        Modérateur sur MFF. 
                        Mon Github: http://github.com/jglrxavpok
                        Mon compte Steam si vous voulez jouer à CS:GO ou TF2 avec moi: https://steamcommunity.com/id/jglrxavpok/

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

                          Merci beaucoup,

                          Sa marche parfaitement avec le constructeur dans le TileEntity.

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

                          MINECRAFT FORGE FRANCE © 2024

                          Powered by NodeBB