MFF

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

    Ajout d'un son quand il neige

    Planifier Épinglé Verrouillé Déplacé Résolu Anciennes versions
    1.6.2
    23 Messages 4 Publieurs 6.6k Vues 1 Watching
    Charger plus de messages
    • Du plus ancien au plus récent
    • Du plus récent au plus ancien
    • Les plus votés
    Répondre
    • Répondre à l'aide d'un nouveau sujet
    Se connecter pour répondre
    Ce sujet a été supprimé. Seuls les utilisateurs avec les droits d'administration peuvent le voir.
    • robin4002R Hors-ligne
      robin4002 Moddeurs confirmés Rédacteurs Administrateurs
      dernière édition par

      par exemple
      (rand.nextInt(15) > 3) rendra le son plus fréquent.

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

        Donc si j’ai bien compris, plus le 1er nombre est proche du deuxième, moins le son se jouera souvent.
        C’est ça ?___
        J’ai tester, et ben non
        Je sais pas pourquoi mais j’ai l’impression que c’est complètement au hasard.

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

          @‘Axaurus’:

          J’ai tester, et ben non
          Je sais pas pourquoi mais j’ai l’impression que c’est complètement au hasard.

          rand est une instance de random… c’est parfaitement normal que ça soit au hasard

          Twitter :

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

            Salut
            Bah, comment je peux faire, alors, pour que la musique se lance qu’une fois que la même musique est fini ?
            Je sais pas si j’ai bien expliquer. Donc si vous ne comprenez pas, n’hésitez pas à me demander 😉
            Merci

            PS : je précise que la musique dure 2 min 33. Je sais pas si ça sera utile.

            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

              Dans ce cas il faudrait faire un timer.

              1 réponse Dernière réponse Répondre Citer 0
              • jglrxavpokJ Hors-ligne
                jglrxavpok Modérateurs
                dernière édition par

                Je n’ai pas le code de Minecraft sous les yeux mais je peux te mettre sur la piste avec ce que je connais de leur système audio:
                Normalement, grâce à Forge, tu devrais pouvoir récupérer une instance de Minecraft.
                Une fois cette instance récupérée, fais cet appel:

                Minecraft instance = Minecraft.getMinecraft(); // Vieille méthode, je sais pas si elle marche encore
                boolean isPlaying = instance.sndManager.sndSystem.playing("NOM DE LA SOURCE DE MUSIQUE");
                

                pour savoir si la source est toujours en train de jouer.

                (Je fais ça de tête, pas sûr que ça marche à 100%)

                Modérateur sur MFF. 
                Mon Github: http://github.com/jglrxavpok
                Mon compte Steam si vous voulez jouer à CS:GO ou TF2 avec moi: https://steamcommunity.com/id/jglrxavpok/

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

                  Salut
                  Merci
                  Donc, j’ai créer un timer :

                  if(timer == 3060)
                  {
                  System.out.println("lol");
                  int i = MathHelper.floor_double(mc.thePlayer.posX);
                  int k = MathHelper.floor_double(mc.thePlayer.posZ);
                  int k1 = i + rand.nextInt(10) - rand.nextInt(10);
                  int l1 = k + rand.nextInt(10) - rand.nextInt(10);
                  int i2 = mc.theWorld.getPrecipitationHeight(k1, l1);
                  int j2 = mc.theWorld.getBlockId(k1, i2 - 1, l1);
                  float f1 = rand.nextFloat();
                  float f2 = rand.nextFloat();
                  double d0 = (double)((float)k1 + f1);
                  double d1 = (double)((float)i2 + 0.1F) - Block.blocksList[j2].getBlockBoundsMinY();
                  double d2 = (double)((float)l1 + f2);
                  boolean biomeneige = biome.getFloatTemperature() == 0.05F || biome.getFloatTemperature() == 0.0F;
                  if(mc.theWorld.isRaining() && biomeneige)
                  
                  {
                  if(d1 > mc.thePlayer.posY + 1.0D && mc.theWorld.getPrecipitationHeight(MathHelper.floor_double(mc.thePlayer.posX), MathHelper.floor_double(mc.thePlayer.posZ)) > MathHelper.floor_double(mc.thePlayer.posY))
                  {
                  System.out.println("XD");
                  mc.theWorld.playSound(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ, "halloween:music", 0.1F, 0.5F, false);
                  }
                  else
                  {
                  mc.theWorld.playSound(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ, "halloween:music", 0.2F, 1.0F, false);
                  }
                  timer = 0;
                  }
                  else {
                  if ( timer <= nombre_de_tick ) {
                  timer++;
                  }
                  
                  else { } }
                  }
                  

                  Juste après la condition, j’ai mis le code pour qu’un message s’affiche dans la console
                  Il s’affiche, donc le code marche bien.
                  Mais le problème, c’est que la musique ne marche pas.
                  Après ça, j’ai insérer le code de l’affichage d’un message juste avant le code de la musique, mais ça n’apparaît pas. Donc, y’a un code qui bug.
                  Si vous pouvez m’aider, …
                  Merci d’avance

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

                    Salut
                    Je suis idiot <_>

                    En fait, je pense qu’il faut mettre ça :

                    if(timer == 3060)
                    {
                    System.out.println("lol");
                    {
                    if(d1 > mc.thePlayer.posY + 1.0D && mc.theWorld.getPrecipitationHeight(MathHelper.floor_double(mc.thePlayer.posX), MathHelper.floor_double(mc.thePlayer.posZ)) > MathHelper.floor_double(mc.thePlayer.posY))
                    {
                    System.out.println("XD");
                    mc.theWorld.playSound(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ, "halloween:music", 0.1F, 0.5F, false);
                    }
                    else
                    {
                    mc.theWorld.playSound(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ, "halloween:music", 0.2F, 1.0F, false);
                    }
                    timer = 0;
                    }
                    else {
                    if ( timer <= nombre_de_tick ) {
                    timer++;
                    }
                    
                    else { } }
                    }
                    

                    Je pense qu’il faut plutôt mettre ça.
                    Mais je ne peux pas tester, je ne suis pas encore chez moi.
                    Je vous tient au courant du message.
                    Mais si vous avez une meilleure réponse, n’hésitez pas à poster 😉

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

                      Non, ça ne marche pas
                      J’ai mis ça : ```java
                      if(timer == 3060)
                      {
                      System.out.println(“lol”);
                      int i = MathHelper.floor_double(mc.thePlayer.posX);
                      int k = MathHelper.floor_double(mc.thePlayer.posZ);
                      int k1 = i + rand.nextInt(10) - rand.nextInt(10);
                      int l1 = k + rand.nextInt(10) - rand.nextInt(10);
                      int i2 = mc.theWorld.getPrecipitationHeight(k1, l1);
                      int j2 = mc.theWorld.getBlockId(k1, i2 - 1, l1);
                      float f1 = rand.nextFloat();
                      float f2 = rand.nextFloat();
                      double d0 = (double)((float)k1 + f1);
                      double d1 = (double)((float)i2 + 0.1F) - Block.blocksList[j2].getBlockBoundsMinY();
                      double d2 = (double)((float)l1 + f2);
                      boolean biomeneige = biome.getFloatTemperature() == 0.05F || biome.getFloatTemperature() == 0.0F;
                      if(d1 > mc.thePlayer.posY + 1.0D && mc.theWorld.getPrecipitationHeight(MathHelper.floor_double(mc.thePlayer.posX), MathHelper.floor_double(mc.thePlayer.posZ)) > MathHelper.floor_double(mc.thePlayer.posY))
                      {
                      System.out.println(“XD”);

                      mc.theWorld.playSound(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ, “halloween:music”, 0.1F, 0.5F, false);
                      }
                      else
                      {
                      mc.theWorld.playSound(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ, “halloween:music”, 0.2F, 1.0F, false);
                      }
                      timer = 0;
                      }
                      else {
                      if ( timer <= nombre_de_tick ) {
                      timer++;
                      }

                      else { } }
                      }

                      
                      Si un de vous à proposez, n'hésitez pas ;)
                      Merci d'avance___
                      Si en fait, ça marche
                      J'ai juste oublier d'activer le son de mon casque lol
                      je suis nul
                      
                      En tout cas, voici les lignes de codes si ça peut en aider certain :
                      Dans l'initialisation du mod :```java
                      TickRegistry.registerTickHandler(new ClientTickHandler(), Side.CLIENT);
                      

                      Dans le ClientTickHandler :

                      package This_is_Halloween;
                      
                      import java.util.EnumSet;
                      import java.util.Random;
                      
                      import net.minecraft.block.Block;
                      import net.minecraft.client.Minecraft;
                      import net.minecraft.util.MathHelper;
                      import net.minecraft.world.biome.BiomeGenBase;
                      import cpw.mods.fml.client.FMLClientHandler;
                      import cpw.mods.fml.common.ITickHandler;
                      import cpw.mods.fml.common.TickType;
                      
                      public class ClientTickHandler implements ITickHandler
                      {
                      public int timer = 3060;
                      public int nombre_de_tick = 3060;
                      @Override
                      public void tickStart(EnumSet <ticktype>type, Object… tickData)
                      {
                      
                      }
                      
                      @Override
                      public void tickEnd(EnumSet <ticktype>type, Object... tickData)
                      {
                      Minecraft mc = FMLClientHandler.instance().getClient();
                      Random rand = mc.theWorld.rand;
                      BiomeGenBase biome = mc.theWorld.getBiomeGenForCoords((int)mc.thePlayer.posX, (int)mc.thePlayer.posZ);
                      final Minecraft minecraft = FMLClientHandler.instance().getClient();
                      if (type.equals(EnumSet.of(TickType.PLAYER)))
                      {
                      
                      }
                      
                      if(timer == 3060) //3060 ticks = 2 minutes 33
                      {
                      System.out.println("lol");
                      int i = MathHelper.floor_double(mc.thePlayer.posX);
                      int k = MathHelper.floor_double(mc.thePlayer.posZ);
                      int k1 = i + rand.nextInt(10) - rand.nextInt(10);
                      int l1 = k + rand.nextInt(10) - rand.nextInt(10);
                      int i2 = mc.theWorld.getPrecipitationHeight(k1, l1);
                      int j2 = mc.theWorld.getBlockId(k1, i2 - 1, l1);
                      float f1 = rand.nextFloat();
                      float f2 = rand.nextFloat();
                      double d0 = (double)((float)k1 + f1);
                      double d1 = (double)((float)i2 + 0.1F) - Block.blocksList[j2].getBlockBoundsMinY();
                      double d2 = (double)((float)l1 + f2);
                      boolean biomeneige = biome.getFloatTemperature() == 0.05F || biome.getFloatTemperature() == 0.0F;
                      if(d1 > mc.thePlayer.posY + 1.0D && mc.theWorld.getPrecipitationHeight(MathHelper.floor_double(mc.thePlayer.posX), MathHelper.floor_double(mc.thePlayer.posZ)) > MathHelper.floor_double(mc.thePlayer.posY))
                      {
                      System.out.println("XD");
                      
                      mc.theWorld.playSound(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ, "halloween:music", 0.1F, 0.5F, false);
                      }
                      else
                      {
                      mc.theWorld.playSound(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ, "halloween:music", 0.2F, 1.0F, false);
                      }
                      timer = 0;
                      }
                      else {
                      if ( timer <= nombre_de_tick ) {
                      timer++;
                      }
                      
                      else { } }
                      }
                      
                      @Override
                      public EnumSet <ticktype>ticks()
                      {
                      return EnumSet.of(TickType.PLAYER);
                      }
                      
                      @Override
                      public String getLabel()
                      {
                      return "test";
                      }
                      }
                      ```</ticktype></ticktype></ticktype>
                      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

                        Ok, du coup c’est définitivement résolu, bravo à toi pour ton travail de recherche jusqu’à résoudre le problème tout seul, tous les codeurs devrait faire ça, de toute façon c’est comme ça qu’on réussi, en continuant à chercher jusqu’à que ça fonctionne comme on veut 😉

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

                        MINECRAFT FORGE FRANCE © 2024

                        Powered by NodeBB