MFF

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

    Faire un compteur de tick (Bar de soif)

    Planifier Épinglé Verrouillé Déplacé Résolu 1.8.x
    1.8.9
    88 Messages 8 Publieurs 16.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.
    • robin4002R Hors-ligne
      robin4002 Moddeurs confirmés Rédacteurs Administrateurs
      dernière édition par

      Désolé du temps de réponse, j’avais complètement oublié.
      Il avait des npe dans la console en rapport avec le chargement du nbt du joueur, causé par ta capabilité. Dans ThirstCapabilities.java :

      @Override
      public NBTTagCompound serializeNBT()
      {
      NBTTagCompound compound = new NBTTagCompound();
      compound.setInteger("ThirstVal", this.getThirstVal());
      return null;
      }
      

      devrait être :

      @Override
      public NBTTagCompound serializeNBT()
      {
      NBTTagCompound compound = new NBTTagCompound();
      compound.setInteger("ThirstVal", this.getThirstVal());
      return compound;
      }
      

      Et c’est tout ce que j’ai eu besoin de changer. Le joueur prend bien des dégâts ensuite.

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

        Je ne comprends pas, ça ne veut pas fonctionner. Voilà ce que met la console maintenant :

        2017-04-21 14:37:33,411 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
        2017-04-21 14:37:33,416 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
        [14:37:33] [main/INFO] [GradleStart]: Extra: []
        [14:37:33] [main/INFO] [GradleStart]: Running with arguments: [–userProperties, {}, --assetsDir, C:/Users/user/.gradle/caches/minecraft/assets, --assetIndex, 1.8, --accessToken{REDACTED}, --version, 1.8.9, --tweakClass, net.minecraftforge.fml.common.launcher.FMLTweaker, --tweakClass, net.minecraftforge.gradle.tweakers.CoremodTweaker]
        [14:37:33] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
        [14:37:33] [main/INFO] [LaunchWrapper]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
        [14:37:33] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.CoremodTweaker
        [14:37:33] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLTweaker
        [14:37:33] [main/INFO] [FML]: Forge Mod Loader version 11.15.1.1747 for Minecraft 1.8.9 loading
        [14:37:33] [main/INFO] [FML]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.8.0_121, running on Windows 8.1:amd64:6.3, installed at C:\Program Files\Java\jre1.8.0_121
        [14:37:33] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation
        [14:37:33] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.CoremodTweaker
        [14:37:33] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.fml.relauncher.FMLCorePlugin
        [14:37:33] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.classloading.FMLForgePlugin
        [14:37:33] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
        [14:37:33] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
        [14:37:33] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.AccessTransformerTweaker
        [14:37:33] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
        [14:37:33] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
        [14:37:33] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
        [14:37:33] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work!
        [14:37:35] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing
        [14:37:35] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
        [14:37:35] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
        [14:37:36] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.AccessTransformerTweaker
        [14:37:36] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.TerminalTweaker
        [14:37:36] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.TerminalTweaker
        [14:37:36] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main}
        2017-04-21 14:37:37,641 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
        2017-04-21 14:37:37,725 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
        2017-04-21 14:37:37,731 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
        [14:37:38] [Client thread/INFO]: Setting user: Player193
        [14:37:44] [Client thread/INFO]: LWJGL Version: 2.9.4
        [14:37:45] [Client thread/WARN] [FML]: =============================================================
        [14:37:45] [Client thread/WARN] [FML]: MOD HAS DIRECT REFERENCE System.exit() THIS IS NOT ALLOWED REROUTING TO FML!
        [14:37:45] [Client thread/WARN] [FML]: Offendor: com/sun/jna/Native.main([Ljava/lang/String;)V
        [14:37:45] [Client thread/WARN] [FML]: Use FMLCommonHandler.exitJava instead
        [14:37:45] [Client thread/WARN] [FML]: =============================================================
        [14:37:46] [Client thread/INFO] [STDOUT]: [net.minecraftforge.fml.client.SplashProgress:start:246]: –-- Minecraft Crash Report ----
        // Hi. I'm Minecraft, and I'm a crashaholic.
        
        Time: 21/04/17 14:37
        Description: Loading screen debug info
        
        This is just a prompt for computer specs to be printed. THIS IS NOT A ERROR
        
        A detailed walkthrough of the error, its code path and all known details is as follows:
        ---------------------------------------------------------------------------------------
        
        -- System Details --
        Details:
        Minecraft Version: 1.8.9
        Operating System: Windows 8.1 (amd64) version 6.3
        Java Version: 1.8.0_121, Oracle Corporation
        Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
        Memory: 764710904 bytes (729 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
        JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
        IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
        FML:
        Loaded coremods (and transformers):
        GL info: ' Vendor: 'Intel' Version: '4.0.0 - Build 10.18.10.3621' Renderer: 'Intel(R) HD Graphics 4000'
        [14:37:46] [Client thread/INFO] [FML]: MinecraftForge v11.15.1.1747 Initialized
        [14:37:46] [Client thread/INFO] [FML]: Replaced 204 ore recipies
        [14:37:47] [Client thread/INFO] [FML]: Found 0 mods from the command line. Injecting into mod discoverer
        [14:37:47] [Client thread/INFO] [FML]: Searching C:\Users\user\Desktop\forge-1.8.9-11.15.1.1747-mdk\run\mods for mods
        [14:37:51] [Client thread/INFO] [FML]: Forge Mod Loader has identified 4 mods to load
        [14:37:51] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, survivant] at CLIENT
        [14:37:51] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, survivant] at SERVER
        [14:37:52] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Mod Survivant
        [14:37:52] [Client thread/INFO] [FML]: Processing ObjectHolder annotations
        [14:37:52] [Client thread/INFO] [FML]: Found 384 ObjectHolder annotations
        [14:37:52] [Client thread/INFO] [FML]: Identifying ItemStackHolder annotations
        [14:37:52] [Client thread/INFO] [FML]: Found 0 ItemStackHolder annotations
        [14:37:53] [Client thread/INFO] [FML]: Configured a dormant chunk cache size of 0
        [14:37:53] [Forge Version Check/INFO] [ForgeVersionCheck]: [Forge] Starting version check at http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json
        [14:37:53] [Forge Version Check/INFO] [ForgeVersionCheck]: [Forge] Found status: OUTDATED Target: 11.15.1.1902
        [14:37:53] [Client thread/INFO] [FML]: Applying holder lookups
        [14:37:53] [Client thread/INFO] [FML]: Holder lookups applied
        [14:37:53] [Client thread/INFO] [FML]: Injecting itemstacks
        [14:37:53] [Client thread/INFO] [FML]: Itemstack injection complete
        [14:37:54] [Sound Library Loader/INFO]: Starting up SoundSystem…
        [14:37:54] [Thread-9/INFO]: Initializing LWJGL OpenAL
        [14:37:54] [Thread-9/INFO]: (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
        [14:37:54] [Thread-9/INFO]: OpenAL initialized.
        [14:37:54] [Sound Library Loader/INFO]: Sound engine started
        [14:38:02] [Client thread/INFO] [FML]: Max texture size: 8192
        [14:38:02] [Client thread/INFO]: Created: 16x16 textures-atlas
        [14:38:03] [Client thread/ERROR] [FML]: Model definition for location survivant:blockBanana#inventory not found
        [14:38:03] [Client thread/ERROR] [FML]: Model definition for location survivant:blockCoconut#inventory not found
        [14:38:05] [Client thread/INFO] [FML]: Injecting itemstacks
        [14:38:05] [Client thread/INFO] [FML]: Itemstack injection complete
        [14:38:05] [Client thread/INFO] [FML]: Forge Mod Loader has successfully loaded 4 mods
        [14:38:05] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Mod Survivant
        [14:38:05] [Client thread/INFO]: SoundSystem shutting down…
        [14:38:05] [Client thread/WARN]: Author: Paul Lamb, www.paulscode.com
        [14:38:05] [Sound Library Loader/INFO]: Starting up SoundSystem…
        [14:38:05] [Thread-11/INFO]: Initializing LWJGL OpenAL
        [14:38:05] [Thread-11/INFO]: (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
        [14:38:05] [Thread-11/INFO]: OpenAL initialized.
        [14:38:06] [Sound Library Loader/INFO]: Sound engine started
        [14:38:11] [Client thread/INFO] [FML]: Max texture size: 8192
        [14:38:12] [Client thread/INFO]: Created: 512x512 textures-atlas
        [14:38:12] [Client thread/ERROR] [FML]: Model definition for location survivant:blockBanana#inventory not found
        [14:38:12] [Client thread/ERROR] [FML]: Model definition for location survivant:blockCoconut#inventory not found
        [14:38:14] [Realms Notification Availability checker #1/INFO]: Could not authorize you against Realms server: Invalid session id
        [14:38:37] [Realms Notification Availability checker #1/INFO]: Could not authorize you against Realms server: Invalid session id
        [14:38:37] [Server thread/INFO]: Starting integrated minecraft server version 1.8.9
        [14:38:37] [Server thread/INFO]: Generating keypair
        [14:38:37] [Server thread/INFO] [FML]: Injecting existing block and item data into this server instance
        [14:38:37] [Server thread/INFO] [FML]: Applying holder lookups
        [14:38:37] [Server thread/INFO] [FML]: Holder lookups applied
        [14:38:38] [Server thread/INFO] [FML]: Loading dimension 0 (Nouveau monde) (net.minecraft.server.integrated.IntegratedServer@2edd88d1)
        [14:38:38] [Server thread/INFO] [FML]: Loading dimension 1 (Nouveau monde) (net.minecraft.server.integrated.IntegratedServer@2edd88d1)
        [14:38:38] [Server thread/INFO] [FML]: Loading dimension -1 (Nouveau monde) (net.minecraft.server.integrated.IntegratedServer@2edd88d1)
        [14:38:38] [Server thread/INFO]: Preparing start region for level 0
        [14:38:39] [Server thread/INFO]: Preparing spawn area: 31%
        [14:38:39] [Realms Notification Availability checker #1/INFO]: Could not authorize you against Realms server: Invalid session id
        [14:38:39] [Server thread/INFO]: Changing view distance to 12, from 10
        [14:38:40] [Netty Local Client IO #0/INFO] [FML]: Server protocol version 2
        [14:38:40] [Netty Server IO #1/INFO] [FML]: Client protocol version 2
        [14:38:40] [Netty Server IO #1/INFO] [FML]: Client attempting to join with 4 mods : FML@8.0.99.99,Forge@11.15.1.1747,mcp@9.19,survivant@1.0.0
        [14:38:40] [Netty Local Client IO #0/INFO] [FML]: [Netty Local Client IO #0] Client side modded connection established
        [14:38:40] [Server thread/INFO] [FML]: [Server thread] Server side modded connection established
        [14:38:41] [Server thread/INFO]: Player193[local:E:365416ba] logged in with entity id 118 at (-274.6609106403902, 70.0, 572.49508106187)
        [14:38:41] [Server thread/INFO]: Player193 a rejoint la partie
        [14:38:42] [pool-2-thread-1/WARN]: Couldn't look up profile properties for com.mojang.authlib.GameProfile@640e53f1[id=e6106110-0611-3c88-99d4-92770daab422,name=Player193,properties={},legacy=false]
        com.mojang.authlib.exceptions.AuthenticationException: The client has sent too many requests within a certain amount of time
        at com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService.makeRequest(YggdrasilAuthenticationService.java:65) ~[YggdrasilAuthenticationService.class:?]
        at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillGameProfile(YggdrasilMinecraftSessionService.java:175) [YggdrasilMinecraftSessionService.class:?]
        at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:59) [YggdrasilMinecraftSessionService$1.class:?]
        at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:56) [YggdrasilMinecraftSessionService$1.class:?]
        at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524) [guava-17.0.jar:?]
        at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317) [guava-17.0.jar:?]
        at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280) [guava-17.0.jar:?]
        at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195) [guava-17.0.jar:?]
        at com.google.common.cache.LocalCache.get(LocalCache.java:3934) [guava-17.0.jar:?]
        at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938) [guava-17.0.jar:?]
        at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821) [guava-17.0.jar:?]
        at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4827) [guava-17.0.jar:?]
        at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillProfileProperties(YggdrasilMinecraftSessionService.java:165) [YggdrasilMinecraftSessionService.class:?]
        at net.minecraft.client.Minecraft.func_181037_M(Minecraft.java:2915) [Minecraft.class:?]
        at net.minecraft.client.resources.SkinManager$3.run(SkinManager.java:130) [SkinManager$3.class:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_121]
        at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_121]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_121]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_121]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_121]
        [14:39:06] [Server thread/INFO]: Saving and pausing game…
        [14:39:06] [Server thread/INFO]: Saving chunks for level 'Nouveau monde'/Overworld
        [14:39:06] [Server thread/INFO]: Saving chunks for level 'Nouveau monde'/Nether
        [14:39:06] [Server thread/INFO]: Saving chunks for level 'Nouveau monde'/The End
        [14:39:32] [Server thread/INFO]: Saving and pausing game…
        [14:39:32] [Server thread/INFO]: Saving chunks for level 'Nouveau monde'/Overworld
        [14:39:32] [Server thread/INFO]: Saving chunks for level 'Nouveau monde'/Nether
        [14:39:32] [Server thread/INFO]: Saving chunks for level 'Nouveau monde'/The End
        [14:39:33] [Server thread/INFO]: Stopping server
        [14:39:33] [Server thread/INFO]: Saving players
        [14:39:33] [Server thread/INFO]: Saving worlds
        [14:39:33] [Server thread/INFO]: Saving chunks for level 'Nouveau monde'/Overworld
        [14:39:33] [Server thread/INFO]: Saving chunks for level 'Nouveau monde'/Nether
        [14:39:33] [Server thread/INFO]: Saving chunks for level 'Nouveau monde'/The End
        [14:39:33] [Server thread/INFO] [FML]: Unloading dimension 0
        [14:39:33] [Server thread/INFO] [FML]: Unloading dimension -1
        [14:39:33] [Server thread/INFO] [FML]: Unloading dimension 1
        [14:39:34] [Server thread/INFO] [FML]: Applying holder lookups
        [14:39:34] [Server thread/INFO] [FML]: Holder lookups applied
        [14:39:34] [Client thread/INFO]: Stopping!
        [14:39:34] [Client thread/INFO]: SoundSystem shutting down…
        [14:39:34] [Realms Notification Availability checker #1/INFO]: Could not authorize you against Realms server: Invalid session id
        [14:39:34] [Client thread/WARN]: Author: Paul Lamb, www.paulscode.com
        Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
        
        

        Merci d’avance.

        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

          Tu n’arrives pas à entrer dans le monde où il n’y avait juste aucun log pendant ta session de jeu ?

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

            J’arrive à aller sur le monde, le seul souci c’est que lorsque je met la barre à 0, je ne prend pas de dégât alors que je devrais en prendre.

            Merci par avance.

            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

              Étonnant comme chez moi ça fonctionne avec le même code …
              Cliques sur workspace -> clean pour forcer eclipse à tout recompiler

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

                Je dois avoir un souci avec la capabilities ou même la fonction qui gère les ticks du joueurs. Maintenant, à chaque fois que je lance le jeu, visuellement, la barre de soif est au max mais quand je met un System.out.println(cap.getThirstVal()); la valeur est à 0.
                Si je met des dégâts, même si la barre de soif est visuellement au max, je prend des dégâts.
                Bizarre.

                Merci d’avance.

                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

                  Envoies la classe de ta capability.

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

                    Voici :

                    La classe PacketThirstCapabilities :

                    
                    package com.survivant.mod;
                    
                    import io.netty.buffer.ByteBuf;
                    import net.minecraft.client.Minecraft;
                    import net.minecraft.server.MinecraftServer;
                    import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
                    import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
                    import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
                    import net.minecraftforge.fml.relauncher.Side;
                    import net.minecraftforge.fml.relauncher.SideOnly;
                    
                    public class PacketThirstCapabilities implements IMessage
                    {
                       public static int thirstValue;
                    
                       public PacketThirstCapabilities(int thirstValue)
                       {
                           this.thirstValue = thirstValue;
                       }
                    
                       public PacketThirstCapabilities() {}
                    
                       @Override
                       public void fromBytes(ByteBuf buf)
                       {
                           this.thirstValue = buf.readInt();
                       }
                    
                       @Override
                       public void toBytes(ByteBuf buf)
                       {
                           buf.writeInt(this.thirstValue);
                       }
                    
                       public static class ServerHandler implements IMessageHandler <packetthirstcapabilities, imessage="">{
                    
                           @Override
                           public IMessage onMessage(PacketThirstCapabilities message, MessageContext ctx)
                           {
                               MinecraftServer.getServer().addScheduledTask(new ScheduledPacketTask(ctx.getServerHandler().playerEntity, message));
                               return null;
                           }
                    
                       }
                    
                       @SideOnly(Side.CLIENT)
                       public static class ClientHandler implements IMessageHandler <packetthirstcapabilities, imessage="">{
                    
                           @Override
                           public IMessage onMessage(PacketThirstCapabilities message, MessageContext ctx)
                           {
                               Minecraft.getMinecraft().addScheduledTask(new ScheduledPacketTask(null, message));
                               return null;
                           }
                    
                       }
                    }
                    
                    

                    La classe ScheduledPacketTask :

                    
                    package com.survivant.mod;
                    
                    import net.minecraft.client.Minecraft;
                    import net.minecraft.entity.player.EntityPlayer;
                    import net.minecraftforge.fml.relauncher.Side;
                    import net.minecraftforge.fml.relauncher.SideOnly;
                    
                    public class ScheduledPacketTask implements Runnable
                    {
                       private EntityPlayer player;
                       private PacketThirstCapabilities message;
                    
                       public ScheduledPacketTask(EntityPlayer player, PacketThirstCapabilities message)
                       {
                           this.player = player;
                           this.message = message;
                       }
                    
                       @Override
                       public void run()
                       {
                           EntityPlayer player = this.player == null ? getPlayer() : this.player;
                           player.getCapability(ModSurvivant.T_CAP, null).setThirstVal(message.thirstValue);
                       }
                    
                       @SideOnly(Side.CLIENT)
                       private EntityPlayer getPlayer()
                       {
                           return Minecraft.getMinecraft().thePlayer;
                       }  
                    }
                    
                    

                    La classe ThirstCapabilities :

                    
                    package com.survivant.mod;
                    
                    import java.util.concurrent.Callable;
                    
                    import net.minecraft.entity.player.EntityPlayer;
                    import net.minecraft.entity.player.EntityPlayerMP;
                    import net.minecraft.nbt.NBTBase;
                    import net.minecraft.nbt.NBTTagCompound;
                    import net.minecraft.util.EnumFacing;
                    import net.minecraftforge.common.capabilities.Capability;
                    import net.minecraftforge.common.capabilities.CapabilityManager;
                    import net.minecraftforge.common.capabilities.ICapabilityProvider;
                    import net.minecraftforge.common.util.INBTSerializable;
                    
                    public class ThirstCapabilities implements ICapabilityProvider,INBTSerializable <nbttagcompound>{
                       public int thirstValue;
                       private EntityPlayer player;
                    
                       @Override
                       public boolean hasCapability(Capability capability, EnumFacing facing)
                       {
                           return ModSurvivant.T_CAP != null && capability == ModSurvivant.T_CAP;
                       }
                    
                       @Override
                       public <t>T getCapability(Capability <t>capability, EnumFacing facing)
                       {
                           return ModSurvivant.T_CAP != null && capability == ModSurvivant.T_CAP ? (T)this : null;
                       }
                    
                       @Override
                       public NBTTagCompound serializeNBT()
                       {
                           NBTTagCompound compound = new NBTTagCompound();
                           compound.setInteger("ThirstVal", this.getThirstVal());
                           return compound;              
                       }
                    
                       @Override
                       public void deserializeNBT(NBTTagCompound compound)
                       {
                           this.setThirstVal(compound.getInteger("ThirstVal"));
                       }  
                    
                       public void setThirstVal(int thirstValue)
                       {
                           this.thirstValue = thirstValue;
                       }
                    
                       public int getThirstVal()
                       {
                           return this.thirstValue;
                       }
                    
                       public static class Storage implements Capability.IStorage <thirstcapabilities>{
                    
                           @Override
                           public NBTBase writeNBT(Capability <thirstcapabilities>capability, ThirstCapabilities instance, EnumFacing side)
                           {
                               return null;
                           }
                    
                           @Override
                           public void readNBT(Capability <thirstcapabilities>capability, ThirstCapabilities instance, EnumFacing side, NBTBase nbt)
                           {
                    
                           }
                    
                       }
                    
                       public static class Factory implements Callable <thirstcapabilities>{
                           @Override
                           public ThirstCapabilities call() throws Exception
                           {
                               return null;
                           }
                       }
                    
                       public static void register()
                       {
                           CapabilityManager.INSTANCE.register(ThirstCapabilities.class, new ThirstCapabilities.Storage(), new ThirstCapabilities.Factory());
                       }
                    
                       public ThirstCapabilities(EntityPlayer player)
                       {
                           this.thirstValue = 86;
                           this.player = player;
                       }
                    
                       public void sync()
                       {
                           PacketThirstCapabilities packet = new PacketThirstCapabilities(this.getThirstVal());
                           if(!this.player.worldObj.isRemote)
                           {
                               EntityPlayerMP playerMP = (EntityPlayerMP)player;
                               ModSurvivant.network.sendTo(packet, playerMP);
                           }
                           else
                           {
                               ModSurvivant.network.sendToServer(packet);
                           }
                       }
                    }
                    
                    

                    Merci par avance.</thirstcapabilities></thirstcapabilities></thirstcapabilities></thirstcapabilities></t></t></nbttagcompound></packetthirstcapabilities,></packetthirstcapabilities,>

                    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

                      thirstValue ne devrait pas être static dans la classe PacketThirstCapabilities.
                      Je ne vois pas d’autres problèmes sinon.

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

                        Changes

                        
                        @Override
                          public NBTTagCompound serializeNBT()
                          {
                              NBTTagCompound compound = new NBTTagCompound();
                              compound.setInteger("ThirstVal", this.getThirstVal());
                              return compound;               
                          }
                        
                          @Override
                          public void deserializeNBT(NBTTagCompound compound)
                          {
                              this.setThirstVal(compound.getInteger("ThirstVal"));
                          }  
                        
                        

                        Par

                        
                         @Override
                          public NBTTagCompound serializeNBT()
                          {
                              return Storage.writeNBT(ModSurvivant.T_CAP, this, null);//Le this est peut-être faux           
                          }
                        
                          @Override
                          public void deserializeNBT(NBTTagCompound compound)
                          {
                              Storage.readNBT(ModSurvivant.T_CAP, this, null, compound);//Pareil
                          } 
                        
                        

                        Et

                        
                         @Override
                              public NBTBase writeNBT(Capability <thirstcapabilities>capability, ThirstCapabilities instance, EnumFacing side)
                              {
                                  return null;
                              }
                        
                              @Override
                              public void readNBT(Capability <thirstcapabilities>capability, ThirstCapabilities instance, EnumFacing side, NBTBase nbt)
                              { 
                        
                              } 
                        
                        

                        Par

                        
                        @Override
                              public NBTBase writeNBT(Capability <thirstcapabilities>capability, ThirstCapabilities instance, EnumFacing side)
                              {
                                  return new NBTTagInt(instance.getThirstVal());
                              }
                        
                              @Override
                              public void readNBT(Capability <thirstcapabilities>capability, ThirstCapabilities instance, EnumFacing side, NBTBase nbt)
                              {
                                  if(nbt instanceof NBTTagInt)
                                     instance.setThirstVal(((NBTTagInt) nbt).getInt());
                              }
                        
                        

                        Aussi, le fait que tu mettes tout dans une class n’aide pas.
                        Je te conseil de tout mettre en 5 classes : 
                        -IThirst → Interface qui comprend les méthodes getThirstVal et setThirstVal,
                        -**ThirstCap **→ Class qui implémente **IThirst **et qui contient la variable thirstValue en field,
                        -**ThirstProvider **→ Class qui implémente ICapabilitySerializable<nbtbase>, et qui contient notamment l’instance de Capability<ithirst>,
                        -**ThirstStorage **→ Class qui implémente IStorage<ithirst>. C’est ici où tu dois écrire et lire les NBT,
                        -**CapabilityHandler **→ Class qui contient l’event AttachCapabilitiesEvent. <type>(ici Entity) afin d’attacher le capability au joueur.
                        Ça permettrait d’avoir un code plus lisible.

                        Aussi, si le joueur change de dimension, il va perdre toutes les valeurs de son capability. Pour cela, avec l’event PlayerEvent.Clone, vérifie que isWasDeath() est *false *et ainsi mettre les valeurs du capability de l’ancien joueur sur le nouveau.

                        Voici un tutorial en anglais qui explique très bien comment faire tout cela : http://www.planetminecraft.com/blog/forge-tutorial-capability-system/.</type></ithirst></ithirst></nbtbase></thirstcapabilities></thirstcapabilities></thirstcapabilities></thirstcapabilities>

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

                          J’ai suivi le tuto sans sucés puisque le jeu crash à la génération du monde. Aussi, voici si join le dossier avec les classes concernées.

                          Les capability et moi décidément ça fait 2, il n’y a pas un moyen plus simple d’enregistrer une valeur pour un joueur ?

                          Merci par avance.

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

                            Changes

                            
                                @Override
                                public <t>T getCapability(Capability <t>capability, EnumFacing facing)
                                {
                                    return capability == THIRST_CAP ? (T)this.instance : null;
                                }
                            
                            

                            Par

                            
                                @Override
                                public <t>T getCapability(Capability <t>capability, EnumFacing facing)
                                {
                                    return capability == THIRST_CAP ? THIRST_CAP.<t>cast(this.instance) : null;
                                }
                            
                            

                            Si tu crash encore, envoies le crash report.</t></t></t></t></t>

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

                              J’ai une erreur sur cast.

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

                                Laquelle ? Envoies le message d’erreur ainsi que la méthode.

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

                                  
                                  <t>T getCapability(Capability <t>capability, EnumFacing facing)    {        return capability == THIRST_CAP ? THIRST_CAP.<t>cast(this.instance) : null;       }</t></t></t>
                                  
                                  

                                  Le cast de cast(this.instance) est souligné en rouge il veut que je cast THIRST_CAP.

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

                                    Je viens d’essayer en 1.8.9 (étant donner que je faisait tout en 1.11.2) et la méthode cast n’existe pas. Donc laisse comme c’était avant, et envoies le crash report s’il y en a.

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

                                      Voici le crash report :

                                      –-- Minecraft Crash Report ----
                                      // Hi. I'm Minecraft, and I'm a crashaholic.
                                      
                                      Time: 08/05/17 14:31
                                      Description: Unexpected error
                                      
                                      java.lang.NullPointerException: Unexpected error
                                      at com.survivant.mod.SurvivantThirstBar.onRenderGameOverlay(SurvivantThirstBar.java:83)
                                      at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_13_SurvivantThirstBar_onRenderGameOverlay_RenderGameOverlayEvent.invoke(.dynamic)
                                      at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:49)
                                      at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140)
                                      at net.minecraftforge.client.GuiIngameForge.post(GuiIngameForge.java:854)
                                      at net.minecraftforge.client.GuiIngameForge.renderExperience(GuiIngameForge.java:561)
                                      at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:145)
                                      at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1135)
                                      at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1107)
                                      at net.minecraft.client.Minecraft.run(Minecraft.java:380)
                                      at net.minecraft.client.main.Main.main(Main.java:116)
                                      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:135)
                                      at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
                                      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.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
                                      at GradleStart.main(GradleStart.java:26)
                                      
                                      A detailed walkthrough of the error, its code path and all known details is as follows:
                                      ---------------------------------------------------------------------------------------
                                      
                                      -- Head --
                                      Stacktrace:
                                      at com.survivant.mod.SurvivantThirstBar.onRenderGameOverlay(SurvivantThirstBar.java:83)
                                      at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_13_SurvivantThirstBar_onRenderGameOverlay_RenderGameOverlayEvent.invoke(.dynamic)
                                      at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:49)
                                      at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140)
                                      at net.minecraftforge.client.GuiIngameForge.post(GuiIngameForge.java:854)
                                      at net.minecraftforge.client.GuiIngameForge.renderExperience(GuiIngameForge.java:561)
                                      at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:145)
                                      
                                      -- Affected level --
                                      Details:
                                      Level name: MpServer
                                      All players: 1 total; [EntityPlayerSP['Player338'/168, l='MpServer', x=8,50, y=65,00, z=8,50]]
                                      Chunk stats: MultiplayerChunkCache: 0, 0
                                      Level seed: 0
                                      Level generator: ID 01 - flat, ver 0\. Features enabled: false
                                      Level generator options:
                                      Level spawn location: -52,00,4,00,414,00 - World: (-52,4,414), Chunk: (at 12,0,14 in -4,25; contains blocks -64,0,400 to -49,255,415), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
                                      Level time: 0 game time, 0 day time
                                      Level dimension: 0
                                      Level storage version: 0x00000 - Unknown?
                                      Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
                                      Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false
                                      Forced entities: 1 total; [EntityPlayerSP['Player338'/168, l='MpServer', x=8,50, y=65,00, z=8,50]]
                                      Retry entities: 0 total; []
                                      Server brand: fml,forge
                                      Server type: Integrated singleplayer server
                                      Stacktrace:
                                      at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:383)
                                      at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2645)
                                      at net.minecraft.client.Minecraft.run(Minecraft.java:409)
                                      at net.minecraft.client.main.Main.main(Main.java:116)
                                      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:135)
                                      at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
                                      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.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
                                      at GradleStart.main(GradleStart.java:26)
                                      
                                      – System Details --
                                      Details:
                                      Minecraft Version: 1.8.9
                                      Operating System: Windows 8.1 (amd64) version 6.3
                                      Java Version: 1.8.0_121, Oracle Corporation
                                      Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
                                      Memory: 658588368 bytes (628 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
                                      JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
                                      IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
                                      FML: MCP 9.19 Powered by Forge 11.15.1.1747 4 mods loaded, 4 mods active
                                      States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
                                      UCHIJAAAA mcp{9.19} [Minecraft Coder Pack] (minecraft.jar)
                                      UCHIJAAAA FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8.9-11.15.1.1747.jar)
                                      UCHIJAAAA Forge{11.15.1.1747} [Minecraft Forge] (forgeSrc-1.8.9-11.15.1.1747.jar)
                                      UCHIJAAAA survivant{1.0.0} [Mod Survivant] (bin)
                                      Loaded coremods (and transformers):
                                      GL info: ' Vendor: 'Intel' Version: '4.0.0 - Build 10.18.10.3621' Renderer: 'Intel(R) HD Graphics 4000'
                                      Launched Version: 1.8.9
                                      LWJGL: 2.9.4
                                      OpenGL: Intel(R) HD Graphics 4000 GL version 4.0.0 - Build 10.18.10.3621, Intel
                                      GL Caps: Using GL 1.3 multitexturing.
                                      Using GL 1.3 texture combiners.
                                      Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
                                      Shaders are available because OpenGL 2.1 is supported.
                                      VBOs are available because OpenGL 1.5 is supported.
                                      
                                      Using VBOs: No
                                      Is Modded: Definitely; Client brand changed to 'fml,forge'
                                      Type: Client (map_client.txt)
                                      Resource Packs:
                                      Current Language: Français (France)
                                      Profiler Position: N/A (disabled)
                                      CPU: 4x Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
                                      
                                      1 réponse Dernière réponse Répondre Citer 0
                                      • Alexandre1156A Hors-ligne
                                        Alexandre1156
                                        dernière édition par

                                        Si tu n’as fait aucun changement par rapport à la dernière fois, la ligne 83 correspond à ça :

                                        
                                        mc.ingameGUI.drawTexturedModalRect(posX + 1, posY + 1, 0, 9, (int)thirst.getThirst(), 7);
                                        
                                        

                                        Je pense que la variable *thirst *doit être null, ce qui cause le crash.
                                        Pour voir si j’ai raison, rajoute cette ligne avant :

                                        
                                        System.out.println("isThirstNull : "+(thirst == null));
                                        
                                        

                                        Si elle est sur true, il faudrait regarder du côté de le class **CapabilityHandler **et voir si le capability est bien assigné au joueur.
                                        Conseil : regarde cette vidéo pour apprendre à lire un crash report : https://www.youtube.com/watch?v=Uipvf_DmyQc

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

                                          Effectivement c’est sur true, par contre dans capabilityHandler j’ai l’impression qu’elle est bien assignée au joueur. Merci par avance.

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

                                            Pas d’idée pour corriger la class CapabilityHandler ?Car moi je sais pas quoi faire. Merci par avance.

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

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB