MFF

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

    Convertir Double en Int

    Planifier Épinglé Verrouillé Déplacé Résolu 1.7.x
    1.7.10
    16 Messages 3 Publieurs 847 Vues 3 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.
    • D Hors-ligne
      Drastic
      dernière édition par

      Bonjour, je voulais convertir un double en Int mais ca crash quand je lance
      Merci 🙂

          int PosX= (int)mc.thePlayer.posX;
          int PosY= (int)mc.thePlayer.posY;
          int PosZ= (int)mc.thePlayer.posZ;
      
      1 réponse Dernière réponse Répondre Citer 0
      • D Hors-ligne
        Drastic
        dernière édition par

        ah oui, ca vien de l’instance

        package com.extremium.mod;
        
        import cpw.mods.fml.client.FMLClientHandler;
        import cpw.mods.fml.common.Mod.Instance;
        import cpw.mods.fml.common.eventhandler.SubscribeEvent;
        import cpw.mods.fml.relauncher.Side;
        import cpw.mods.fml.relauncher.SideOnly;
        import net.minecraft.client.Minecraft;
        import net.minecraft.client.gui.FontRenderer;
        import net.minecraft.util.Direction;
        import net.minecraft.util.MathHelper;
        import net.minecraftforge.client.event.RenderGameOverlayEvent;
        
        public class EventHandlerMod
        { 
        
            @SideOnly(Side.CLIENT) 
            @SubscribeEvent
            public void onRenderPre(RenderGameOverlayEvent.Pre event)
            {
                if(event.type == RenderGameOverlayEvent.ElementType.DEBUG)
                {
                    Minecraft mc = Minecraft.getMinecraft();
                    int PosX= (int)mc.thePlayer.posX;
                    int PosY= (int)mc.thePlayer.posX;
                    int PosZ= (int)mc.thePlayer.posZ;
                    event.setCanceled(true);
                    this.drawString(Minecraft.getMinecraft().fontRenderer, "Fps : " + mc.debug.split(",", 2)[0], 5, 5, 26666);
                    this.drawString(Minecraft.getMinecraft().fontRenderer, "Biome : " + mc.theWorld.getBiomeGenForCoords(5, 15).biomeName, 5, 15, 77777);
                    this.drawString(Minecraft.getMinecraft().fontRenderer, "x : " + PosX + " y : " + PosY + " z : " + PosZ, 5, 25, 547444);
                    this.drawString(Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().getEntityDebug(), 5, 35, 877778814);
                    
                    
                }
                
            }
             
            public void drawString(FontRenderer par1FontRenderer, String par2Str, int par3, int par4, int par5)
            {
                par1FontRenderer.drawStringWithShadow(par2Str, par3, par4, par5);
            }
        
            
        }
        
        
        
        1 réponse Dernière réponse Répondre Citer 0
        • isadorI Hors-ligne
          isador Moddeurs confirmés Modérateurs
          dernière édition par

          Bonjour, merci de nous donner plus d’info, comme le rapport de crash.

          Merci de respecter les règles de la section. Cela fait plusieurs fois que je remarque que tes demandes ne les respectes pas, ton prochain sujet qui ne respecte pas les règles sera sanctionné.

          Cordialement
          Isador34

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

            voici le crash report :

            ---- Minecraft Crash Report ----
            // Why did you do that?
            
            Time: 21/09/19 17:03
            Description: Initializing game
            
            java.lang.NullPointerException: Initializing game
            	at com.extremium.mod.EventHandlerMod.<init>(EventHandlerMod.java:17)
            	at com.extremium.mod.Extremium.init(Extremium.java:119)
            	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            	at java.lang.reflect.Method.invoke(Method.java:498)
            	at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532)
            	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            	at java.lang.reflect.Method.invoke(Method.java:498)
            	at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
            	at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
            	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
            	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
            	at com.google.common.eventbus.EventBus.post(EventBus.java:275)
            	at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)
            	at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190)
            	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            	at java.lang.reflect.Method.invoke(Method.java:498)
            	at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
            	at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
            	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
            	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
            	at com.google.common.eventbus.EventBus.post(EventBus.java:275)
            	at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119)
            	at cpw.mods.fml.common.Loader.initializeMods(Loader.java:737)
            	at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:311)
            	at net.minecraft.client.Minecraft.startGame(Minecraft.java:597)
            	at net.minecraft.client.Minecraft.run(Minecraft.java:942)
            	at net.minecraft.client.main.Main.main(Main.java:164)
            	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            	at java.lang.reflect.Method.invoke(Method.java:498)
            	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
            	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
            	at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
            	at GradleStart.main(Unknown Source)
            
            
            A detailed walkthrough of the error, its code path and all known details is as follows:
            ---------------------------------------------------------------------------------------
            
            -- Head --
            Stacktrace:
            	at com.extremium.mod.EventHandlerMod.<init>(EventHandlerMod.java:17)
            	at com.extremium.mod.Extremium.init(Extremium.java:119)
            	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            	at java.lang.reflect.Method.invoke(Method.java:498)
            	at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532)
            	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            	at java.lang.reflect.Method.invoke(Method.java:498)
            	at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
            	at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
            	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
            	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
            	at com.google.common.eventbus.EventBus.post(EventBus.java:275)
            	at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)
            	at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190)
            	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            	at java.lang.reflect.Method.invoke(Method.java:498)
            	at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
            	at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
            	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
            	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
            	at com.google.common.eventbus.EventBus.post(EventBus.java:275)
            	at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119)
            	at cpw.mods.fml.common.Loader.initializeMods(Loader.java:737)
            	at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:311)
            	at net.minecraft.client.Minecraft.startGame(Minecraft.java:597)
            
            -- Initialization --
            Details:
            Stacktrace:
            	at net.minecraft.client.Minecraft.run(Minecraft.java:942)
            	at net.minecraft.client.main.Main.main(Main.java:164)
            	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            	at java.lang.reflect.Method.invoke(Method.java:498)
            	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
            	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
            	at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
            	at GradleStart.main(Unknown Source)
            
            -- System Details --
            Details:
            	Minecraft Version: 1.7.10
            	Operating System: Windows 10 (amd64) version 10.0
            	Java Version: 1.8.0_181, Oracle Corporation
            	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
            	Memory: 624676280 bytes (595 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
            	JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
            	AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
            	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
            	FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1614 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
            	UCHI	mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) 
            	UCHI	FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar) 
            	UCHI	Forge{10.13.4.1614} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar) 
            	UCHE	extremium{2.4} [Extremium Mod] (bin) 
            	GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.6.0 NVIDIA 430.86' Renderer: 'GeForce GTX 1050/PCIe/SSE2'
            	Launched Version: 1.7.10
            	LWJGL: 2.9.1
            	OpenGL: GeForce GTX 1050/PCIe/SSE2 GL version 4.6.0 NVIDIA 430.86, NVIDIA Corporation
            	GL Caps: Using GL 1.3 multitexturing.
            Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
            Anisotropic filtering is supported and maximum anisotropy is 16.
            Shaders are available because OpenGL 2.1 is supported.
            
            	Is Modded: Definitely; Client brand changed to 'fml,forge'
            	Type: Client (map_client.txt)
            	Resource Packs: []
            	Current Language: English (US)
            	Profiler Position: N/A (disabled)
            	Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
            	Anisotropic Filtering: Off (1)
            
            1 réponse Dernière réponse Répondre Citer 0
            • isadorI Hors-ligne
              isador Moddeurs confirmés Modérateurs
              dernière édition par

              je suppose au vu du crash, que ton player n’est pas encore créé au moment où tu le get, d’où la NPE

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

                ?? Pas compris. Et sinon, une soluce ?
                Merci encore 🙂

                1 réponse Dernière réponse Répondre Citer 0
                • isadorI Hors-ligne
                  isador Moddeurs confirmés Modérateurs
                  dernière édition par

                  sais-tu ce qu’est une NPE (NullPointerException)?

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

                    euuuh non…
                    Je suis pas très calé xD
                    Merci

                    1 réponse Dernière réponse Répondre Citer 0
                    • isadorI Hors-ligne
                      isador Moddeurs confirmés Modérateurs
                      dernière édition par

                      Alors il faudrait penser à apprendre le Java avant de vouloir modder. Tu n’arriveras à rien sinon

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

                        Merci mais en fait je crois comprendre avc du recul que veut dire Npe xD
                        Mais le probleme est que je ne comprends pas où est le bug

                        1 réponse Dernière réponse Répondre Citer 0
                        • isadorI Hors-ligne
                          isador Moddeurs confirmés Modérateurs
                          dernière édition par

                          Justement, si tu avais les bases en Java tu saurais où se trouve le problème, et pro-tips, c’est pas ton cast le problème

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

                            En fait je crois que si car quand j’enleve les 3 lignes ca crash plus

                            1 réponse Dernière réponse Répondre Citer 0
                            • isadorI Hors-ligne
                              isador Moddeurs confirmés Modérateurs
                              dernière édition par

                              je t’assure que ça viens pas du cast, laisse ces trois ligne mais sans le cast et tu verras

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

                                ah oui, ca vien de l’instance

                                package com.extremium.mod;
                                
                                import cpw.mods.fml.client.FMLClientHandler;
                                import cpw.mods.fml.common.Mod.Instance;
                                import cpw.mods.fml.common.eventhandler.SubscribeEvent;
                                import cpw.mods.fml.relauncher.Side;
                                import cpw.mods.fml.relauncher.SideOnly;
                                import net.minecraft.client.Minecraft;
                                import net.minecraft.client.gui.FontRenderer;
                                import net.minecraft.util.Direction;
                                import net.minecraft.util.MathHelper;
                                import net.minecraftforge.client.event.RenderGameOverlayEvent;
                                
                                public class EventHandlerMod
                                { 
                                
                                    @SideOnly(Side.CLIENT) 
                                    @SubscribeEvent
                                    public void onRenderPre(RenderGameOverlayEvent.Pre event)
                                    {
                                        if(event.type == RenderGameOverlayEvent.ElementType.DEBUG)
                                        {
                                            Minecraft mc = Minecraft.getMinecraft();
                                            int PosX= (int)mc.thePlayer.posX;
                                            int PosY= (int)mc.thePlayer.posX;
                                            int PosZ= (int)mc.thePlayer.posZ;
                                            event.setCanceled(true);
                                            this.drawString(Minecraft.getMinecraft().fontRenderer, "Fps : " + mc.debug.split(",", 2)[0], 5, 5, 26666);
                                            this.drawString(Minecraft.getMinecraft().fontRenderer, "Biome : " + mc.theWorld.getBiomeGenForCoords(5, 15).biomeName, 5, 15, 77777);
                                            this.drawString(Minecraft.getMinecraft().fontRenderer, "x : " + PosX + " y : " + PosY + " z : " + PosZ, 5, 25, 547444);
                                            this.drawString(Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().getEntityDebug(), 5, 35, 877778814);
                                            
                                            
                                        }
                                        
                                    }
                                     
                                    public void drawString(FontRenderer par1FontRenderer, String par2Str, int par3, int par4, int par5)
                                    {
                                        par1FontRenderer.drawStringWithShadow(par2Str, par3, par4, par5);
                                    }
                                
                                    
                                }
                                
                                
                                
                                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

                                  Bonsoir,

                                  Si le problème n’est pas résolu (je vois que code ne correspond plus au rapport de crash, tu as changé des choses) il faut ajouter un null check sur la variable qui est null.

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

                                    oui, j’ai réglé le bug, ca vient du fait que je ne l’ai pas mis dans la fonction RenderGameOverlayEvent

                                    1 réponse Dernière réponse Répondre Citer 0
                                    • D Hors-ligne
                                      Drastic @robin4002
                                      dernière édition par

                                      @robin4002 et au fait, aurais tu une soluce pour le post du mob invisible que j’ai fait ?

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

                                      MINECRAFT FORGE FRANCE © 2024

                                      Powered by NodeBB