Récupérer le temps
-
World world = null;
Pourquoi faire ça ?
Cette variable est complètement inutile, tu peux directement utiliser this.worldObjEt tu obtiens quelle exception ?
-
L’exception ne s’affiche pas sur la console mais sur le computer:

et j’ai changer World world = null par this.getWorldObj()
-
Renvoie ton code actuelle.
-
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; } } -
Vérifie que la méthode isRaining() n’est pas ClientSideOnly
-
J’ai regardé la fonction dans les sources mais rien est précisé à ce niveau là.
Apparemment non elle ne l’est pas.
-
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. -
Essayez de gardez le launcher ouvert….?
-
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 -
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?
-
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

-
Merci beaucoup,
Sa marche parfaitement avec le constructeur dans le TileEntity.