MFF

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

    Scoreboard

    Planifier Épinglé Verrouillé Déplacé Résolu 1.7.x
    1.7.10
    12 Messages 3 Publieurs 2.7k 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.
    • DiabolicaTrixD Hors-ligne
      DiabolicaTrix Correcteurs Moddeurs confirmés
      dernière édition par

      Bonjour, je me demandais comment faire pour récupérer des informations d’un scoreboard, par example le score d’un joueur. J’ai vu dans la classe Scoreboard le getObjective mais il ne fonctionne pas: Cannot make a static reference to the non-static method getObjective(String) from the type Scoreboard

      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

        C’est une méthode non static donc il faut l’instance. C’est du Java ça.

        1 réponse Dernière réponse Répondre Citer 0
        • DiabolicaTrixD Hors-ligne
          DiabolicaTrix Correcteurs Moddeurs confirmés
          dernière édition par

          scoreobjective est null…:

          package diabolicatrix.project;
          
          import java.util.UUID;
          
          import cpw.mods.fml.common.eventhandler.SubscribeEvent;
          import cpw.mods.fml.common.gameevent.InputEvent.KeyInputEvent;
          import cpw.mods.fml.relauncher.Side;
          import cpw.mods.fml.relauncher.SideOnly;
          import diabolicatrix.project.proxy.ClientProxy;
          import net.minecraft.client.Minecraft;
          import net.minecraft.entity.Entity;
          import net.minecraft.entity.player.EntityPlayer;
          import net.minecraft.scoreboard.ScoreObjective;
          import net.minecraft.scoreboard.Scoreboard;
          import net.minecraft.server.MinecraftServer;
          
          public class T4EventHandler {
          
          private MinecraftServer mcs;
          private Minecraft mc;
          private UUID uuid;
          public String popo = "Policier";
          private String boardTitle;
          private String scoreString;
          private Scoreboard scoreboard = new Scoreboard();
          
          @SubscribeEvent
          @SideOnly(Side.CLIENT)
          public void onKeyInput(KeyInputEvent event) {
          if (ClientProxy.overMouse.isPressed()) {
          if (Minecraft.getMinecraft().objectMouseOver.entityHit instanceof EntityPlayer) {
          System.out.println("lel");
          Base.instance.network.sendToServer(new PacketOp());
          }
          }
          if (ClientProxy.restrain.isPressed()) {
          if (Minecraft.getMinecraft().objectMouseOver.entityHit instanceof Entity) {
          System.out.println("Trying to restrain..,");
          if (Minecraft.getMinecraft().objectMouseOver.entityHit != null) {
          uuid = Minecraft.getMinecraft().objectMouseOver.entityHit.getUniqueID();
          Base.instance.network.sendToServer(new PacketRestrainServer(uuid));
          ScoreObjective scoreobjective = this.scoreboard.getObjective("1");
          if(scoreobjective != null)
          {
          System.out.println(scoreobjective);
          }
          }
          }
          }
          }
          
          }
          

          J’ai bien mon scoreboard de créé.

          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

            Il faut faire comme ça pour avoir l’instance du scoreboard : Scoreboard scoreboard = this.mc.theWorld.getScoreboard();

            1 réponse Dernière réponse Répondre Citer 0
            • RedRelayR Hors-ligne
              RedRelay Moddeurs confirmés
              dernière édition par

              C’est du Java. Tu fais n’importe quoi avec le code et tu ne comprend pas ce que tu fais.
              “new” “static” etc ont un sens donc tu ignores alors que c’est la base de la POO.
              Sans bagage en Java, tu vas devoir effacé 40 lignes de code toutes les 10 lignes.
              On ne récupère pas un objet en faisant une nouvelle instance de sa classe.

              –------------------------------------------------------------------------------------
              Si tu trouves mon intervention pertinente, n'hésite pas a m…

              1 réponse Dernière réponse Répondre Citer 0
              • DiabolicaTrixD Hors-ligne
                DiabolicaTrix Correcteurs Moddeurs confirmés
                dernière édition par

                Non, ça fonctionne pas:

                Scoreboard scoreboard = Minecraft.getMinecraft().theWorld.getScoreboard();

                [19:28:26] [Client thread/ERROR] [FML]: The following problems were captured during this phase
                [19:28:26] [Client thread/ERROR] [FML]: Caught exception from t4pro
                java.lang.NullPointerException
                at diabolicatrix.project.T4EventHandler.<init>(T4EventHandler.java:26) ~[bin/:?]
                at diabolicatrix.project.Base.init(Base.java:56) ~[bin/:?]
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51]
                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_51]
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_51]
                at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_51]
                at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532) ~[forgeSrc-1.7.10-10.13.4.1492-1.7.10.jar:?]
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51]
                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_51]
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_51]
                at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_51]
                at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?]
                at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?]
                at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?]
                at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?]
                at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?]
                at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) ~[forgeSrc-1.7.10-10.13.4.1492-1.7.10.jar:?]
                at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190) ~[forgeSrc-1.7.10-10.13.4.1492-1.7.10.jar:?]
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51]
                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_51]
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_51]
                at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_51]
                at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?]
                at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?]
                at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?]
                at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?]
                at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?]
                at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119) [LoadController.class:?]
                at cpw.mods.fml.common.Loader.initializeMods(Loader.java:737) [Loader.class:?]
                at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:311) [FMLClientHandler.class:?]
                at net.minecraft.client.Minecraft.startGame(Minecraft.java:597) [Minecraft.class:?]
                at net.minecraft.client.Minecraft.run(Minecraft.java:942) [Minecraft.class:?]
                at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?]
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51]
                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_51]
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_51]
                at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_51]
                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 net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]
                at GradleStart.main(Unknown Source) [start/:?]
                [19:28:26] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: –-- Minecraft Crash Report ----
                // This doesn't make any sense!
                
                Time: 7/31/15 7:28 PM
                Description: Initializing game
                
                java.lang.NullPointerException: Initializing game
                at diabolicatrix.project.T4EventHandler.<init>(T4EventHandler.java:26)
                at diabolicatrix.project.Base.init(Base.java:56)
                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 cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532)
                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 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(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                at java.lang.reflect.Method.invoke(Unknown Source)
                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(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 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 diabolicatrix.project.T4EventHandler.<init>(T4EventHandler.java:26)
                at diabolicatrix.project.Base.init(Base.java:56)
                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 cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532)
                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 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(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                at java.lang.reflect.Method.invoke(Unknown Source)
                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(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 net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
                at GradleStart.main(Unknown Source)
                
                -- System Details --
                Details:
                Minecraft Version: 1.7.10
                Operating System: Windows 8.1 (x86) version 6.3
                Java Version: 1.8.0_51, Oracle Corporation
                Java VM Version: Java HotSpot(TM) Client VM (mixed mode), Oracle Corporation
                Memory: 913367872 bytes (871 MB) / 1046937600 bytes (998 MB) up to 1046937600 bytes (998 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.1492 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.1492-1.7.10.jar)
                UCHI Forge{10.13.4.1492} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1492-1.7.10.jar)
                UCHE t4pro{1.0.1} [Project] (bin)
                GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.5.13399 Compatibility Profile Context 15.200.1046.2' Renderer: 'AMD Radeon HD 7560D'
                Launched Version: 1.7.10
                LWJGL: 2.9.1
                OpenGL: AMD Radeon HD 7560D GL version 4.5.13399 Compatibility Profile Context 15.200.1046.2, ATI Technologies Inc.
                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)
                [19:28:26] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:398]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\alexy\Desktop\ForgeAltis\eclipse\.\crash-reports\crash-2015-07-31_19.28.26-client.txt
                AL lib: (EE) alc_cleanup: 1 device not closed
                Java HotSpot(TM) Client VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
                
                ```</init></init></init>
                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

                  T4EventHandler.java:26)
                  Ligne 26 de T4EventHandler ?

                  1 réponse Dernière réponse Répondre Citer 0
                  • DiabolicaTrixD Hors-ligne
                    DiabolicaTrix Correcteurs Moddeurs confirmés
                    dernière édition par

                    [size=x-smallScoreboard scoreboard = Minecraft.getMinecraft().theWorld.getScoreboard();]

                    Je l’avais donné

                    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

                      theWorld est surement null. Tu as mit cette ligne directement dans dans la classe ? Si oui c’est normal que theWorld est null puisque ta classe est chargé avant que le joueur soit dans un monde.

                      1 réponse Dernière réponse Répondre Citer 0
                      • DiabolicaTrixD Hors-ligne
                        DiabolicaTrix Correcteurs Moddeurs confirmés
                        dernière édition par

                        ça me donne ça: net.minecraft.scoreboard.ScoreObjective@8602f5
                        C’est un peu ilisible.

                        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

                          Normale puisque c’est un objet … Regardes dans le code de mc comment ils fond pour recup les valeurs.

                          1 réponse Dernière réponse Répondre Citer 0
                          • DiabolicaTrixD Hors-ligne
                            DiabolicaTrix Correcteurs Moddeurs confirmés
                            dernière édition par

                            Ouais, j’suis con, pour ceux qui veulent avoir la solution:

                            Scoreboard scoreboard = Minecraft.getMinecraft().theWorld.getScoreboard();
                            String name = Minecraft.getMinecraft().thePlayer.getDisplayName();
                            
                            ScoreObjective scoreobjective = scoreboard.getObjective("1");
                            if (scoreobjective != null) {
                            Score test = scoreboard.func_96529_a(name, scoreobjective);
                            if (test.getScorePoints() > 0) {
                            System.out.println("Score > 0");
                            }
                            }
                            
                            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