La faim



  • Bonjours,

    Je voudrai savoir si il y a une possibilité de faire que notre bar de faim ne descant jamais.

    J'ai essayer de faire sa:

    if(event.type == ElementType.FOOD)
    {
    event.setCanceled(true);
    }

    Mais sa enlève juste la bar de faim



  • Faut passer par des events



  • C'est a dire


  • Moddeurs confirmés Rédacteurs Administrateurs

    PlayerTickEvent
    Si ça barre de faim n'est pas égale à 20, tu fais un player.getFoodStat().addStat(niveau de nourriture à ajouter, saturation);



  • J'ai essayer sa mais sa marche pas :

    public void PlayerTickEvent(TickEvent.Phase phase, EntityPlayer player){
    player.getFoodStats().addStats(20, 20);
    }



  • c'est plutôt

    @SubscribeEvent
    public void nomDeFonctionQueTuVeux(PlayerEvent event)
    {
    if(FMLClientHandler.instance().getClient().thePlayer.getFoodStats().getFoodLevel() < 20)
    {
    event.entityPlayer.getFoodStats().addStats(20, 20);
    }
    }
    

    ?



  • Il me dit invalid caractere a sa

    .getFoodLevel​() < 20)



  • tu vois pas un petit point violet genre en bas des lettres ?

    exemple ça –->[size=xx-small.]


    Tu le supprime et c'est bon normalement



  • J'ai un crash

    –-- Minecraft Crash Report ----
    // Everything's going to plan. No, really, that was supposed to happen.
    
    Time: 03/09/14 02:21
    Description: Ticking memory connection
    
    java.lang.NullPointerException: Ticking memory connection
    at cpw.mods.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:110)
    at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:232)
    at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182)
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:720)
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:608)
    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482)
    at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:746)
    
    A detailed walkthrough of the error, its code path and all known details is as follows:
    ---------------------------------------------------------------------------------------
    
    -- Head --
    Stacktrace:
    at cpw.mods.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:110)
    at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:232)
    
    -- Ticking connection --
    Details:
    Connection: net.minecraft.network.NetworkManager@52f16b73
    Stacktrace:
    at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182)
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:720)
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:608)
    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482)
    at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:746)
    
    -- System Details --
    Details:
    Minecraft Version: 1.7.2
    Operating System: Windows 7 (amd64) version 6.1
    Java Version: 1.7.0_45, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 865424456 bytes (825 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
    JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
    AABB Pool Size: 2108 (118048 bytes; 0 MB) allocated, 2108 (118048 bytes; 0 MB) used
    IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95
    FML: MCP v9.03 FML v7.2.211.1121 Minecraft Forge 10.12.2.1121 4 mods loaded, 4 mods active
    mcp{9.03} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    FML{7.2.211.1121} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.2.1121.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    Forge{10.12.2.1121} [Minecraft Forge] (forgeSrc-1.7.2-10.12.2.1121.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    heal{1.0.0} [heal] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    Profiler Position: N/A (disabled)
    Vec3 Pool Size: 296 (16576 bytes; 0 MB) allocated, 295 (16520 bytes; 0 MB) used
    Player Count: 0 / 8; []
    Type: Integrated Server (map_client.txt)
    Is Modded: Definitely; Client brand changed to 'fml,forge'
    


  • C'est que mon code n'est pas bon



  • Merci quand même, Il doit bien avoir un code mais quoi



  • A toi de tester, trifouiller les différentes classes de Minecraft, events…



  • C'est se que j'essaye

    Edit: sa veut un peu plus de 1heure que je cherche, je ne trouve vraiment pas


  • Moddeurs confirmés Rédacteurs Administrateurs

    event.player par FMLClientHandler.instance().getClient().thePlayer. u_U
    Tick = serveur & client, si tu utilise un truc client forcement ça fou la merde.



  • J'ai pas compris ta phrase

    Edit c'est bon j'ai mis sa:

    @SubscribeEvent
    public void PlayerTickEvent(PlayerEvent event)
    {
    if(event.entityPlayer.getFoodStats().getFoodLevel() < 20)
    {
    event.entityPlayer.getFoodStats().addStats(20, 20);
    }
    }


Log in to reply