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.
    • E Hors-ligne
      elx9000
      dernière édition par

      Je suis désolé mais je ne comprends pas ce que c’est que les packets et comment on les utilises. Merci d’avance.

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

        Il suffit de chercher, surtout qu’il y a un tuto sur le forum.

        Si je vous ai aidé, n'oubliez pas d’être heureux, j'aiderai encore +

        AymericRed, moddeur expérimenté qui aide sur ce forum et qui peut accepter de faire un mod Forge rémunéré de temps en temps.

        Mes tutos : Table de craft, plugin NEI, plugin JEI, modifier l'overlay
        Je suis un membre apprécié et joueur, j'ai déjà obtenu 6 points de réputation.

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

          Désolé, je n’avais pas regardé 😉 . J’ai compris l’idée des packets, par contre je voudrais savoir pour mon problème n°1 où faut-il que je mette event.side.server.

          Merci d’avance.

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

            Alors si tu mets ça ça permettra que le code à l’intérieur d’un if event.side.isServer() ne soit appelé que si tes sur le serveur, sinon tu peux utiliser un évent tel que ServerTickEvent.

            Si je vous ai aidé, n'oubliez pas d’être heureux, j'aiderai encore +

            AymericRed, moddeur expérimenté qui aide sur ce forum et qui peut accepter de faire un mod Forge rémunéré de temps en temps.

            Mes tutos : Table de craft, plugin NEI, plugin JEI, modifier l'overlay
            Je suis un membre apprécié et joueur, j'ai déjà obtenu 6 points de réputation.

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

              Je viens d’essayer avec les packets mais ça crash. Je m’y suis peut-être mal pris 😕 . J’ai fait ça :

              La classe principale (ModSurvivant):

              
              package com.survivant.mod;
              
              import java.awt.Color;
              
              import com.jcraft.jogg.Packet;
              import com.survivant.mod.Capabilities.CapabilityHandler;
              import com.survivant.mod.Packet.Message;
              import com.survivant.mod.blocks.BlockMod;
              import com.survivant.mod.blocks.BlockPotableWater;
              import com.survivant.mod.blocks.PotableWater;
              import com.survivant.mod.entity.EntityFish;
              import com.survivant.mod.entity.EntityRay;
              import com.survivant.mod.entity.EntitySalmon;
              import com.survivant.mod.handlers.EntityHandler;
              import com.survivant.mod.items.ItemMod;
              import com.survivant.mod.proxy.CommonProxy;
              
              import net.minecraft.block.Block;
              import net.minecraft.block.state.IBlockState;
              import net.minecraft.client.renderer.ItemMeshDefinition;
              import net.minecraft.client.renderer.block.statemap.StateMapperBase;
              import net.minecraft.client.resources.model.ModelBakery;
              import net.minecraft.client.resources.model.ModelResourceLocation;
              import net.minecraft.creativetab.CreativeTabs;
              import net.minecraft.init.Items;
              import net.minecraft.item.Item;
              import net.minecraft.item.ItemStack;
              import net.minecraft.util.DamageSource;
              import net.minecraft.util.ResourceLocation;
              import net.minecraftforge.client.model.ModelLoader;
              import net.minecraftforge.common.MinecraftForge;
              import net.minecraftforge.common.capabilities.Capability;
              import net.minecraftforge.common.capabilities.CapabilityInject;
              import net.minecraftforge.event.entity.living.LivingEvent;
              import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;
              import net.minecraftforge.fluids.BlockFluidClassic;
              import net.minecraftforge.fluids.Fluid;
              import net.minecraftforge.fluids.FluidContainerRegistry;
              import net.minecraftforge.fluids.FluidRegistry;
              import net.minecraftforge.fluids.FluidStack;
              import net.minecraftforge.fml.common.FMLCommonHandler;
              import net.minecraftforge.fml.common.Mod;
              import net.minecraftforge.fml.common.Mod.EventHandler;
              import net.minecraftforge.fml.common.Mod.Instance;
              import net.minecraftforge.fml.common.SidedProxy;
              import net.minecraftforge.fml.common.event.FMLInitializationEvent;
              import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
              import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
              import net.minecraftforge.fml.common.network.NetworkRegistry;
              import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
              import net.minecraftforge.fml.common.registry.GameRegistry;
              import net.minecraftforge.fml.relauncher.Side;
              import net.minecraftforge.fml.relauncher.SideOnly;
              
              @Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION)
              
              public class ModSurvivant
              {
              
                 public static SimpleNetworkWrapper network;
              
                 @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
                 public static CommonProxy proxy;
              
                 @Instance(Reference.MOD_ID)
                 public static ModSurvivant instance;
              
                 public static CreativeTabs tabSurvivant = new CreativeTabs("tabSurvivant")
                 {
                     @SideOnly(Side.CLIENT)
                     public Item getTabIconItem()
                     {
                         return Item.getItemFromBlock(BlockMod.blockTotem);
                     }
                 };
              
                 public static PotableWater potable_water = new PotableWater();
                 public static BlockPotableWater blockPotableWater;
              
                 public static DamageSource damageSourceDehydration;
              
                 @EventHandler
                 public void preInit (FMLPreInitializationEvent event)
                 {    
                     RemoveRecipes.init();
                     damageSourceDehydration = new DamageSource("damageSourceDehydration").setDamageBypassesArmor();
                     ItemMod.init();
                     ItemMod.register();
                     BlockMod.init();
                     BlockMod.register();  
              
                     /*Eau potable*/
                     FluidRegistry.registerFluid(potable_water);
                     blockPotableWater = new BlockPotableWater(potable_water);
                     GameRegistry.registerBlock(blockPotableWater, "blockPotableWater");
              
                     Item item = Item.getItemFromBlock(blockPotableWater);
                     ModelBakery.registerItemVariants(item);
                     final ModelResourceLocation loc = new ModelResourceLocation("survivant:potable");
                     ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition()
                     {
                         @Override
                         public ModelResourceLocation getModelLocation(ItemStack stack)
                         {
                             return loc;
                         }
                     });
                     ModelLoader.setCustomStateMapper(blockPotableWater, new StateMapperBase()
                     {
                         @Override
                         protected ModelResourceLocation getModelResourceLocation(IBlockState state)
                         {
                             return loc;
                         }
                     });
              
                     network = NetworkRegistry.INSTANCE.newSimpleChannel("MyChannel");
                     network.registerMessage(Message.Handler.class, Message.class, 0, Side.CLIENT);
                 }
              
                 @EventHandler
                 public void init (FMLInitializationEvent event)
                 {        
                     proxy.registerRenders();
                     proxy.init(event);
                     MinecraftForge.EVENT_BUS.register(new SurvivantBlockEvent());      
                     MinecraftForge.EVENT_BUS.register(new SurvivantThirstBar());
                     EntityHandler.RegisterFish(EntityFish.class, "Fish");
                     EntityHandler.RegisterSalmon(EntitySalmon.class, "Salmon");
                     EntityHandler.RegisterRay(EntityRay.class, "Ray");
                 }
              
                 @EventHandler
                 public void postInit (FMLPostInitializationEvent event)
                 {
              
                 }
              }
              
              ``` 
              
              La classe Message (pour le packet):
              ```java
              
              package com.survivant.mod.Packet;
              
              import io.netty.buffer.ByteBuf;
              import net.minecraftforge.fml.common.network.ByteBufUtils;
              import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
              import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
              import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
              
              public class Message implements IMessage
              {
                 private float thirstVal;
              
                 public Message()
                 {
              
                 }
              
                 public Message(float val)
                 {
                     this.thirstVal = val;
                 }
              
                 @Override
                 public void fromBytes(ByteBuf buf)
                 {
                     thirstVal = ByteBufUtils.readVarShort(buf);
                 }
              
                 @Override
                 public void toBytes(ByteBuf buf)
                 {
                     ByteBufUtils.writeVarShort(buf, (int)thirstVal);
                 }
              
                 public static class Handler implements IMessageHandler <message, imessage="">{
              
                     @Override
                     public IMessage onMessage(Message message, MessageContext ctx)
                     {
                         return null;
                     }
              
                 }
              }
              
              

              La classe SurvivantThirstBar :

              
              package com.survivant.mod;
              
              import com.survivant.mod.Capabilities.IThirst;
              import com.survivant.mod.Capabilities.ThirstProvider;
              import com.survivant.mod.Packet.Message;
              
              import net.minecraft.client.Minecraft;
              import net.minecraft.entity.player.EntityPlayer;
              import net.minecraft.entity.player.EntityPlayerMP;
              import net.minecraft.potion.Potion;
              import net.minecraft.potion.PotionEffect;
              import net.minecraft.util.ChatComponentText;
              import net.minecraft.util.DamageSource;
              import net.minecraft.util.ResourceLocation;
              import net.minecraftforge.client.event.GuiScreenEvent;
              import net.minecraftforge.client.event.RenderGameOverlayEvent;
              import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
              import net.minecraftforge.event.AttachCapabilitiesEvent;
              import net.minecraftforge.event.entity.player.PlayerEvent;
              import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent;
              import net.minecraftforge.fml.common.eventhandler.Event;
              import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
              import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent;
              import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerRespawnEvent;
              import net.minecraftforge.fml.common.gameevent.TickEvent;
              import net.minecraftforge.fml.relauncher.Side;
              import net.minecraftforge.fml.relauncher.SideOnly;
              
              public class SurvivantThirstBar
              {
                 public static int i = 0;
              
                 @SubscribeEvent
                 public void onPlayerLogsIn(PlayerLoggedInEvent event)
                 {
                     EntityPlayer player = event.player;
                     IThirst thirst = player.getCapability(ThirstProvider.THIRST_CAP, null);
                     thirst = (IThirst)ModSurvivant.network.getPacketFrom(new Message(thirst.getThirst()));
                 }
              
                 @SubscribeEvent
                 public void onPlayerSleep(PlayerSleepInBedEvent event)
                 {
                     EntityPlayer player = event.entityPlayer;
                     if (player.worldObj.isRemote)
                     {
                         return;
                     }
                     IThirst thirst = player.getCapability(ThirstProvider.THIRST_CAP, null);
                 }
              
                 @SubscribeEvent
                 public void onPlayerClone(PlayerEvent.Clone event)
                 {
                     EntityPlayer player = event.entityPlayer;
                     IThirst thirst = player.getCapability(ThirstProvider.THIRST_CAP, null);
                     thirst.set(86);
                 }
              
                 @SubscribeEvent
                 public void playerTick(TickEvent.ServerTickEvent event)
                 {            
                     EntityPlayer player = Minecraft.getMinecraft().thePlayer;
                     IThirst thirst = player.getCapability(ThirstProvider.THIRST_CAP, null);
                     if (!player.capabilities.isCreativeMode)
                     {
                         i++;
                         if (i == 800)
                         {
                             thirst.consume(1);
                             ModSurvivant.network.sendTo(new Message(thirst.getThirst()), (EntityPlayerMP)player);
                             System.out.println("thirst = " + thirst.getThirst());
                             i = 0;
                         }
                         if (thirst.getThirst() == 0)
                         {
                             player.attackEntityFrom(ModSurvivant.damageSourceDehydration, 1.0F);
                         }
                     }
                 }
              
                 @SubscribeEvent
                 public void onRenderGameOverlay(RenderGameOverlayEvent event)
                 {
                     if (!event.isCancelable() && event.type == ElementType.EXPERIENCE)
                     {
                         Minecraft mc = Minecraft.getMinecraft();
              
                         if (!mc.thePlayer.capabilities.isCreativeMode)
                         {
                             EntityPlayer player = mc.thePlayer;
                             IThirst thirst = player.getCapability(ThirstProvider.THIRST_CAP, null);
              
                             int posX = event.resolution.getScaledWidth() / 2 + 7;
                             int posY = event.resolution.getScaledHeight() - 50;
              
                             mc.renderEngine.bindTexture(new ResourceLocation("survivant:textures/gui/thirstBar.png"));
                             mc.ingameGUI.drawTexturedModalRect(posX, posY, 0, 0, 88, 9);
                             mc.ingameGUI.drawTexturedModalRect(posX + 1, posY + 1, 0, 9, (int)thirst.getThirst(), 7);
                         }
                     }
                 }
              
              }
              
              

              Merci d’avance pour votre aide.</message,>

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

                Alors déjà, da

                Si je vous ai aidé, n'oubliez pas d’être heureux, j'aiderai encore +

                AymericRed, moddeur expérimenté qui aide sur ce forum et qui peut accepter de faire un mod Forge rémunéré de temps en temps.

                Mes tutos : Table de craft, plugin NEI, plugin JEI, modifier l'overlay
                Je suis un membre apprécié et joueur, j'ai déjà obtenu 6 points de réputation.

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

                  Alors déjà dans le “onMessage” de ton packet, tu ne fais rien, donc le packet devient inutile, il faut que tu affectes la valeur de soif du packet à ta capability.
                  Ensuite, pourrait-on avoir le plus important, le rapport de crash ?

                  Si je vous ai aidé, n'oubliez pas d’être heureux, j'aiderai encore +

                  AymericRed, moddeur expérimenté qui aide sur ce forum et qui peut accepter de faire un mod Forge rémunéré de temps en temps.

                  Mes tutos : Table de craft, plugin NEI, plugin JEI, modifier l'overlay
                  Je suis un membre apprécié et joueur, j'ai déjà obtenu 6 points de réputation.

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

                    J’ai mis ceci :

                    
                    @Override
                     public IMessage onMessage(Message message, MessageContext ctx)
                     {
                          EntityPlayer player = Minecraft.getMinecraft().thePlayer;
                          IThirst thirst = player.getCapability(ThirstProvider.THIRST_CAP, null);
                          thirst.set(thirstVal);
                          return null;
                     }
                    
                    

                    Et voici pour le crash report :

                    2017-06-04 14:30:18,876 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
                    2017-06-04 14:30:18,882 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
                    [14:30:19] [main/INFO] [GradleStart]: Extra: []
                    [14:30:19] [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:30:19] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
                    [14:30:19] [main/INFO] [LaunchWrapper]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
                    [14:30:19] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.CoremodTweaker
                    [14:30:19] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLTweaker
                    [14:30:19] [main/INFO] [FML]: Forge Mod Loader version 11.15.1.1747 for Minecraft 1.8.9 loading
                    [14:30:19] [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:30:19] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation
                    [14:30:19] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.CoremodTweaker
                    [14:30:19] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.fml.relauncher.FMLCorePlugin
                    [14:30:19] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.classloading.FMLForgePlugin
                    [14:30:19] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
                    [14:30:19] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
                    [14:30:19] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.AccessTransformerTweaker
                    [14:30:19] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
                    [14:30:19] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
                    [14:30:19] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
                    [14:30:19] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work!
                    [14:30:21] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing
                    [14:30:21] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
                    [14:30:21] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
                    [14:30:23] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.AccessTransformerTweaker
                    [14:30:23] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.TerminalTweaker
                    [14:30:23] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.TerminalTweaker
                    [14:30:23] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main}
                    2017-06-04 14:30:24,317 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
                    2017-06-04 14:30:24,391 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
                    2017-06-04 14:30:24,394 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
                    [14:30:24] [Client thread/INFO]: Setting user: Player943
                    [14:30:31] [Client thread/INFO]: LWJGL Version: 2.9.4
                    [14:30:33] [Client thread/WARN] [FML]: =============================================================
                    [14:30:33] [Client thread/WARN] [FML]: MOD HAS DIRECT REFERENCE System.exit() THIS IS NOT ALLOWED REROUTING TO FML!
                    [14:30:33] [Client thread/WARN] [FML]: Offendor: com/sun/jna/Native.main([Ljava/lang/String;)V
                    [14:30:33] [Client thread/WARN] [FML]: Use FMLCommonHandler.exitJava instead
                    [14:30:33] [Client thread/WARN] [FML]: =============================================================
                    [14:30:34] [Client thread/INFO] [STDOUT]: [net.minecraftforge.fml.client.SplashProgress:start:246]: –-- Minecraft Crash Report ----
                    // Quite honestly, I wouldn't worry myself about that.
                    
                    Time: 04/06/17 14:30
                    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: 787543920 bytes (751 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:30:34] [Client thread/INFO] [FML]: MinecraftForge v11.15.1.1747 Initialized
                    [14:30:34] [Client thread/INFO] [FML]: Replaced 204 ore recipies
                    [14:30:35] [Client thread/INFO] [FML]: Found 0 mods from the command line. Injecting into mod discoverer
                    [14:30:35] [Client thread/INFO] [FML]: Searching C:\Users\user\Desktop\forge-1.8.9-11.15.1.1747-mdk\run\mods for mods
                    [14:30:38] [Client thread/INFO] [FML]: Forge Mod Loader has identified 4 mods to load
                    [14:30:38] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, survivant] at CLIENT
                    [14:30:38] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, survivant] at SERVER
                    [14:30:40] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Mod Survivant
                    [14:30:40] [Client thread/INFO] [FML]: Processing ObjectHolder annotations
                    [14:30:40] [Client thread/INFO] [FML]: Found 384 ObjectHolder annotations
                    [14:30:40] [Client thread/INFO] [FML]: Identifying ItemStackHolder annotations
                    [14:30:40] [Client thread/INFO] [FML]: Found 0 ItemStackHolder annotations
                    [14:30:40] [Client thread/INFO] [FML]: Configured a dormant chunk cache size of 0
                    [14:30:40] [Forge Version Check/INFO] [ForgeVersionCheck]: [Forge] Starting version check at http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json
                    [14:30:40] [Client thread/INFO] [FML]: Applying holder lookups
                    [14:30:40] [Client thread/INFO] [FML]: Holder lookups applied
                    [14:30:40] [Client thread/INFO] [FML]: Injecting itemstacks
                    [14:30:40] [Client thread/INFO] [FML]: Itemstack injection complete
                    [14:30:41] [Forge Version Check/INFO] [ForgeVersionCheck]: [Forge] Found status: OUTDATED Target: 11.15.1.1902
                    [14:30:41] [Sound Library Loader/INFO]: Starting up SoundSystem…
                    [14:30:41] [Thread-9/INFO]: Initializing LWJGL OpenAL
                    [14:30:41] [Thread-9/INFO]: (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
                    [14:30:42] [Thread-9/INFO]: OpenAL initialized.
                    [14:30:42] [Sound Library Loader/INFO]: Sound engine started
                    [14:30:56] [Client thread/INFO] [FML]: Max texture size: 8192
                    [14:30:56] [Client thread/INFO]: Created: 16x16 textures-atlas
                    [14:30:57] [Client thread/ERROR] [FML]: Model definition for location survivant:blockBanana#inventory not found
                    [14:30:57] [Client thread/ERROR] [FML]: Model definition for location survivant:blockCoconut#inventory not found
                    [14:30:58] [Client thread/INFO] [FML]: Injecting itemstacks
                    [14:30:58] [Client thread/INFO] [FML]: Itemstack injection complete
                    [14:30:59] [Client thread/INFO] [FML]: Forge Mod Loader has successfully loaded 4 mods
                    [14:30:59] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Mod Survivant
                    [14:30:59] [Client thread/INFO]: SoundSystem shutting down…
                    [14:30:59] [Client thread/WARN]: Author: Paul Lamb, www.paulscode.com
                    [14:30:59] [Sound Library Loader/INFO]: Starting up SoundSystem…
                    [14:30:59] [Thread-11/INFO]: Initializing LWJGL OpenAL
                    [14:30:59] [Thread-11/INFO]: (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
                    [14:30:59] [Thread-11/INFO]: OpenAL initialized.
                    [14:30:59] [Sound Library Loader/INFO]: Sound engine started
                    [14:31:09] [Client thread/INFO] [FML]: Max texture size: 8192
                    [14:31:11] [Client thread/INFO]: Created: 512x512 textures-atlas
                    [14:31:11] [Client thread/ERROR] [FML]: Model definition for location survivant:blockBanana#inventory not found
                    [14:31:11] [Client thread/ERROR] [FML]: Model definition for location survivant:blockCoconut#inventory not found
                    [14:31:19] [Server thread/INFO]: Starting integrated minecraft server version 1.8.9
                    [14:31:19] [Server thread/INFO]: Generating keypair
                    [14:31:19] [Server thread/INFO] [FML]: Injecting existing block and item data into this server instance
                    [14:31:19] [Server thread/INFO] [FML]: Found a missing id from the world survivant:blockCampfire
                    [14:31:19] [Server thread/INFO] [FML]: Found a missing id from the world survivant:block_potable_water
                    [14:31:19] [Server thread/INFO] [FML]: Found a missing id from the world survivant:blockManioc
                    [14:31:19] [Server thread/INFO] [FML]: Found a missing id from the world survivant:block2
                    [14:31:19] [Server thread/INFO] [FML]: Found a missing id from the world survivant:blockSurvivalBed
                    [14:31:19] [Server thread/INFO] [FML]: Found a missing id from the world survivant:blockSaltWater
                    [14:31:19] [Server thread/INFO] [FML]: Applying holder lookups
                    [14:31:19] [Server thread/INFO] [FML]: Holder lookups applied
                    [14:31:19] [Server thread/INFO] [FML]: Loading dimension 0 (Mod survivant) (net.minecraft.server.integrated.IntegratedServer@41db268d)
                    [14:31:19] [Server thread/INFO] [FML]: Loading dimension 1 (Mod survivant) (net.minecraft.server.integrated.IntegratedServer@41db268d)
                    [14:31:19] [Server thread/INFO] [FML]: Loading dimension -1 (Mod survivant) (net.minecraft.server.integrated.IntegratedServer@41db268d)
                    [14:31:19] [Server thread/INFO]: Preparing start region for level 0
                    [14:31:21] [Server thread/INFO]: Preparing spawn area: 42%
                    [14:31:21] [Server thread/ERROR] [FML]: Exception caught during firing event net.minecraftforge.fml.common.gameevent.TickEvent$ServerTickEvent@29adea34:
                    java.lang.NullPointerException
                    at com.survivant.mod.SurvivantThirstBar.playerTick(SurvivantThirstBar.java:64) ~[SurvivantThirstBar.class:?]
                    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_12_SurvivantThirstBar_playerTick_ServerTickEvent.invoke(.dynamic) ~[?:?]
                    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:49) ~[ASMEventHandler.class:?]
                    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140) [EventBus.class:?]
                    at net.minecraftforge.fml.common.FMLCommonHandler.onPreServerTick(FMLCommonHandler.java:266) [FMLCommonHandler.class:?]
                    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:670) [MinecraftServer.class:?]
                    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:159) [IntegratedServer.class:?]
                    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:548) [MinecraftServer.class:?]
                    at java.lang.Thread.run(Unknown Source) [?:1.8.0_121]
                    [14:31:21] [Server thread/ERROR] [FML]: Index: 1 Listeners:
                    [14:31:21] [Server thread/ERROR] [FML]: 0: NORMAL
                    [14:31:21] [Server thread/ERROR] [FML]: 1: ASM: com.survivant.mod.SurvivantThirstBar@2149532d playerTick(Lnet/minecraftforge/fml/common/gameevent/TickEvent$ServerTickEvent;)V
                    [14:31:21] [Server thread/ERROR]: Encountered an unexpected exception
                    java.lang.NullPointerException
                    at com.survivant.mod.SurvivantThirstBar.playerTick(SurvivantThirstBar.java:64) ~[SurvivantThirstBar.class:?]
                    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_12_SurvivantThirstBar_playerTick_ServerTickEvent.invoke(.dynamic) ~[?:?]
                    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:49) ~[ASMEventHandler.class:?]
                    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140) ~[EventBus.class:?]
                    at net.minecraftforge.fml.common.FMLCommonHandler.onPreServerTick(FMLCommonHandler.java:266) ~[FMLCommonHandler.class:?]
                    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:670) ~[MinecraftServer.class:?]
                    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:159) ~[IntegratedServer.class:?]
                    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:548) [MinecraftServer.class:?]
                    at java.lang.Thread.run(Unknown Source) [?:1.8.0_121]
                    [14:31:21] [Server thread/ERROR]: This crash report has been saved to: C:\Users\user\Desktop\forge-1.8.9-11.15.1.1747-mdk\run\.\crash-reports\crash-2017-06-04_14.31.21-server.txt
                    [14:31:21] [Server thread/INFO]: Stopping server
                    [14:31:21] [Server thread/INFO]: Saving players
                    [14:31:21] [Server thread/INFO]: Saving worlds
                    [14:31:21] [Server thread/INFO]: Saving chunks for level 'Mod survivant'/Overworld
                    [14:31:21] [Server thread/INFO]: Saving chunks for level 'Mod survivant'/Nether
                    [14:31:21] [Server thread/INFO]: Saving chunks for level 'Mod survivant'/The End
                    [14:31:21] [Server thread/INFO] [FML]: Unloading dimension 0
                    [14:31:21] [Server thread/INFO] [FML]: Unloading dimension -1
                    [14:31:21] [Server thread/INFO] [FML]: Unloading dimension 1
                    [14:31:21] [Server thread/INFO] [FML]: Applying holder lookups
                    [14:31:21] [Server thread/INFO] [FML]: Holder lookups applied
                    [14:31:21] [Server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STOPPING and forced into state SERVER_STOPPED. Errors may have been discarded.
                    [14:31:22] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:612]: –-- Minecraft Crash Report ----
                    // You're mean.
                    
                    Time: 04/06/17 14:31
                    Description: Exception in server tick loop
                    
                    java.lang.NullPointerException: Exception in server tick loop
                    at com.survivant.mod.SurvivantThirstBar.playerTick(SurvivantThirstBar.java:64)
                    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_12_SurvivantThirstBar_playerTick_ServerTickEvent.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.fml.common.FMLCommonHandler.onPreServerTick(FMLCommonHandler.java:266)
                    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:670)
                    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:159)
                    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:548)
                    at java.lang.Thread.run(Unknown Source)
                    
                    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: 821776008 bytes (783 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: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.
                    Profiler Position: N/A (disabled)
                    Player Count: 0 / 8; []
                    Type: Integrated Server (map_client.txt)
                    Is Modded: Definitely; Client brand changed to 'fml,forge'
                    [14:31:22] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:612]: #@!@# Game crashed! Crash report saved to: #@!@# .\crash-reports\crash-2017-06-04_14.31.21-server.txt
                    AL lib: (EE) alc_cleanup: 1 device not closed
                    Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
                    
                    

                    Merci par avance.

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

                      
                      @SubscribeEvent
                        public void playerTick(TickEvent.ServerTickEvent event)
                        {           
                             EntityPlayer player = Minecraft.getMinecraft().thePlayer;
                             …
                        }
                      
                      

                      Tu ne peut pas récupérer le joueur de cette façon car cela est faisable seulement côté client or ServerTickEvent se fait côté serveur.
                      Remplace ServerTickEvent par PlayerTickEvent et check si event.side est égal à side.server :

                      
                      @SubscribeEvent
                          public void playerTick(TickEvent.PlayerTickEvent event)
                          {   
                             if(event.side == Side.SERVER){
                                IThirst thirst = event.player.getCapability(ThirstProvider.THIRST_CAP, null);
                                //fais tout ce que tu doit faire ici
                             }
                          }
                      
                      
                      1 réponse Dernière réponse Répondre Citer 0
                      • E Hors-ligne
                        elx9000
                        dernière édition par

                        C’est presque bon, mes deux problèmes sont réglés, le seul petit souci est que lorsque je me reconnecte et que ma bar de soif était à 66 par exemple, pendant un instant on dirait qu’elle est pleine (or ce n’est pas le cas), mais lorsque la valeur de la bar de soif diminue de 1, visuellement elle prend la valeur 65.
                        Peut-être que cela ce règle dans la fonction onPlayerLogIn mais je n’ai aucune idée de comment faire ceci.
                        Merci d’avance.

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

                          Oui cela peut se fixer avec l’utilisation de l’event PlayerLoggedInEvent, il suffira alors d’envoyer le packet comme tu le fais quand tu diminues la soif via l’event PlayerTickEvent.

                          Si je vous ai aidé, n'oubliez pas d’être heureux, j'aiderai encore +

                          AymericRed, moddeur expérimenté qui aide sur ce forum et qui peut accepter de faire un mod Forge rémunéré de temps en temps.

                          Mes tutos : Table de craft, plugin NEI, plugin JEI, modifier l'overlay
                          Je suis un membre apprécié et joueur, j'ai déjà obtenu 6 points de réputation.

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

                            Lorsque je me suis connecté, la bar de soif était bien visuellement à 65, mais lorsque j’ai quitté le monde puis que je suis revenu, le monde ne c’est pas chargé (je suis revenu au menu principale). Dans la fonction playerLogsIn j’ai mis ceci :

                            
                            @SubscribeEvent
                               public void onPlayerLogsIn(PlayerLoggedInEvent event)
                               {
                                   EntityPlayer player = event.player;
                                   IThirst thirst = player.getCapability(ThirstProvider.THIRST_CAP, null);
                                   ModSurvivant.network.sendTo(new Message(thirst.getThirst()), (EntityPlayerMP)player);
                               }
                            
                            

                            Voici ce qu’il y a dans la console :

                            [14:54:55] [Client thread/FATAL]: Error executing task
                            java.util.concurrent.ExecutionException: java.lang.NullPointerException
                            at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_121]
                            at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_121]
                            at net.minecraft.util.Util.runTask(Util.java:23) [Util.class:?]
                            at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1070) [Minecraft.class:?]
                            at net.minecraft.client.Minecraft.run(Minecraft.java:380) [Minecraft.class:?]
                            at net.minecraft.client.main.Main.main(Main.java:116) [Main.class:?]
                            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_121]
                            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_121]
                            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_121]
                            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_121]
                            at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
                            at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
                            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_121]
                            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_121]
                            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_121]
                            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_121]
                            at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
                            at GradleStart.main(GradleStart.java:26) [start/:?]
                            Caused by: java.lang.NullPointerException
                            at net.minecraft.client.network.NetHandlerPlayClient.handleSetSlot(NetHandlerPlayClient.java:1154) ~[NetHandlerPlayClient.class:?]
                            at net.minecraft.network.play.server.S2FPacketSetSlot.processPacket(S2FPacketSetSlot.java:33) ~[S2FPacketSetSlot.class:?]
                            at net.minecraft.network.play.server.S2FPacketSetSlot.processPacket(S2FPacketSetSlot.java:11) ~[S2FPacketSetSlot.class:?]
                            at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) ~[PacketThreadUtil$1.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 net.minecraft.util.Util.runTask(Util.java:22) ~[Util.class:?]
                            … 15 more
                            

                            Merci par avance.

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

                              Change

                              
                              @Override
                              public IMessage onMessage(Message message, MessageContext ctx)
                              {
                                   EntityPlayer player = Minecraft.getMinecraft().thePlayer;
                                   IThirst thirst = player.getCapability(ThirstProvider.THIRST_CAP, null);
                                   thirst.set(thirstVal);
                                   return null;
                              }
                              
                              

                              Par

                              
                              @Override
                              public IMessage onMessage(Message message, MessageContext ctx) {
                                 Minecraft.getMinecraft().addScheduledTask(new Runnable() {
                                    @Override
                                    public void run() {
                                       EntityPlayer player = Minecraft.getMinecraft().thePlayer;
                                       IThirst thirst = player.getCapability(ThirstProvider.THIRST_CAP, null);
                                       thirst.set(message.thirstVal);
                                     }
                                 });
                                 return null;
                              }
                              
                              
                              1 réponse Dernière réponse Répondre Citer 0
                              • E Hors-ligne
                                elx9000
                                dernière édition par robin4002

                                Ca marche !!! Merci à tous pour votre aide.
                                Aussi, pour éclairer ceux qui chercherait à faire une chose semblable, je met en pièce jointe les classes relative à ce système de soif.

                                Encore merci. 😉

                                Système de soif.zip

                                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