MFF

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

    Couper les musiques d'origine

    Planifier Épinglé Verrouillé Déplacé Résolu Anciennes versions
    1.6.x
    35 Messages 3 Publieurs 9.1k 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

      J’ai pas dit de supprimer tout l’ancien code o_O
      Juste le code qui jouait le son, donc world.playsound.

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

        Ok,
        j’ai des erreurs résolus, mais j’ai toujours options qui bug et

        (new PlayBackgroundMusicEvent(this, soundpoolentry));
        

        Et j’ai aussi une nouvelle erreur :
        sndSystem

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

          Je l’ai mis dans TickEnd

          Vous pensez que c’est à cause de ça?___
          Ou…. Je crois peut être savoir pourquoi y’a des erreurs, mais là je peux pas coder.
          Je vous dirai la réponse demain.

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

            Salut
            J’ai tester, non je ne vois pas où peut être l’erreur.

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

              J’ai recréer le code, réessayer, mais ça ne marche toujours pas
              Un de vous a t-il une idée svp ?

              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

                Je vois pas, tu pourrais me renvoyez le code que tu as dans ta classe principale + ton tickhandler pour que je puisse denouveau faire des tests en local ?

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

                  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.client.audio.SoundPoolEntry;
                  import net.minecraft.util.MathHelper;
                  import net.minecraft.world.biome.BiomeGenBase;
                  import net.minecraftforge.client.event.sound.PlayBackgroundMusicEvent;
                  import net.minecraftforge.client.event.sound.SoundEvent;
                  import cpw.mods.fml.client.FMLClientHandler;
                  import cpw.mods.fml.common.ITickHandler;
                  import cpw.mods.fml.common.TickType;
                  
                  public class ClientTickHandler implements ITickHandler
                  {
                  
                  @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);
                  
                  if(rand.nextInt(15) > 13)
                  {
                  System.out.println(biome.getFloatTemperature());
                  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))
                  {
                  SoundPoolEntry soundpoolentry = mc.sndManager.soundPoolMusic.getRandomSoundFromSoundPool("ta music");
                  soundpoolentry = SoundEvent.getResult(new PlayBackgroundMusicEvent(this, soundpoolentry));
                  
                  if (soundpoolentry != null)
                  {
                  mc.ticksBeforeMusic = this.rand.nextInt(3060) + 3060;
                  mc.sndSystem.backgroundMusic("BgMusic", soundpoolentry.func_110457_b(), soundpoolentry.func_110458_a(), false);
                  mc.sndSystem.setVolume("BgMusic", this.options.musicVolume);
                  mc.sndSystem.play("BgMusic");
                  }}
                  else
                  {
                  SoundPoolEntry soundpoolentry = mc.sndManager.soundPoolMusic.getRandomSoundFromSoundPool("ta music");
                  soundpoolentry = SoundEvent.getResult(new PlayBackgroundMusicEvent(this, soundpoolentry));
                  
                  if (soundpoolentry != null)
                  {
                  mc.ticksBeforeMusic = this.rand.nextInt(3060) + 3060;
                  mc.sndSystem.backgroundMusic("BgMusic", soundpoolentry.func_110457_b(), soundpoolentry.func_110458_a(), false);
                  mc.sndSystem.setVolume("BgMusic", this.options.musicVolume);
                  mc.sndSystem.play("BgMusic");
                  }}
                  }
                  }
                  }
                  
                  @Override
                  public EnumSet <ticktype>ticks()
                  {
                  return EnumSet.of(TickType.PLAYER);
                  }
                  
                  @Override
                  public String getLabel()
                  {
                  return "snow tick handler";
                  }
                  
                  }
                  

                  Classe principale(dans la méthode load) :

                  TickRegistry.registerTickHandler(new ClientTickHandler(), Side.CLIENT);
                  ```</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

                    Le tick handler :

                    package tutoriel.common;
                    
                    import java.util.EnumSet;
                    import java.util.Random;
                    
                    import net.minecraft.block.Block;
                    import net.minecraft.client.Minecraft;
                    import net.minecraft.client.audio.SoundPoolEntry;
                    import net.minecraft.client.settings.GameSettings;
                    import net.minecraft.util.MathHelper;
                    import net.minecraft.world.biome.BiomeGenBase;
                    import net.minecraftforge.client.event.sound.PlayBackgroundMusicEvent;
                    import net.minecraftforge.client.event.sound.SoundEvent;
                    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;
                    
                    @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);
                    
                    if(rand.nextInt(15) > 13)
                    {
                    System.out.println(biome.getFloatTemperature());
                    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)
                    {
                    System.out.println(timer);
                    if(timer == 3060)
                    {
                    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))
                    {
                    SoundPoolEntry soundpoolentry = mc.sndManager.soundPoolMusic.getRandomSoundFromSoundPool("modtutoriel:test");
                    soundpoolentry = SoundEvent.getResult(new PlayBackgroundMusicEvent(mc.sndManager, soundpoolentry));
                    
                    if(soundpoolentry != null)
                    {
                    mc.sndManager.sndSystem.backgroundMusic("BgMusic", soundpoolentry.func_110457_b(), soundpoolentry.func_110458_a(), false);
                    mc.sndManager.sndSystem.setVolume("BgMusic", 1.0F);
                    mc.sndManager.sndSystem.play("BgMusic");
                    }
                    }
                    else
                    {
                    SoundPoolEntry soundpoolentry = mc.sndManager.soundPoolMusic.getRandomSoundFromSoundPool("modtutoriel:test");
                    soundpoolentry = SoundEvent.getResult(new PlayBackgroundMusicEvent(mc.sndManager, soundpoolentry));
                    
                    if(soundpoolentry != null)
                    {
                    mc.sndManager.sndSystem.backgroundMusic("BgMusic", soundpoolentry.func_110457_b(), soundpoolentry.func_110458_a(), false);
                    mc.sndManager.sndSystem.setVolume("BgMusic", 1.0F);
                    mc.sndManager.sndSystem.play("BgMusic");
                    }
                    }
                    timer = 0;
                    }
                    else
                    {
                    timer++;
                    }
                    }
                    }
                    }
                    
                    @Override
                    public EnumSet <ticktype>ticks()
                    {
                    return EnumSet.of(TickType.PLAYER);
                    }
                    
                    @Override
                    public String getLabel()
                    {
                    return "snow tick handler";
                    }
                    
                    }
                    

                    À ajouter dans l’event sound :

                    event.manager.addMusic("modtutoriel:test.ogg");
                    

                    Et le son dans /assets/modtutoriel/music/test.ogg

                    Testé & approuvé :p</ticktype></ticktype></ticktype>

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

                      Merci
                      Mais est-ce que je dois laissez ça ? :

                      @ForgeSubscribe
                      public void onSoundPlayed(PlayBackgroundMusicEvent event)
                      {
                      event.setCanceled(true);
                      }
                      
                      

                      J’ai aussi mis Le MUSIC_INTERVAL à 1 juste pour tester.

                      Et si je laisse le code, Minecraft crash, et si je l’enlève, ça joue aussi les autres musiques.
                      Merci d’ava,ce

                      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

                        Enleve, on peut pas Cancel la music apparemment. J’ai vraiment pas d’idée pour la musique, il faudra modifier
                        private int ticksBeforeMusic; dans net.minecraft.client.audio.SoundManager, le problème c’est que la variable est private 😕
                        Au pire, il faudrait voir avec la réflexion si c’est possible.

                        Ha sinon, remplace ça :
                        mc.sndManager.sndSystem.setVolume(“BgMusic”, 1.0F);
                        par ça :
                        mc.sndManager.sndSystem.setVolume(“BgMusic”, mc.gameSettings.musicVolume);
                        Comme ça le son sera prit dans les options 🙂

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

                          Mais comment je fais pour enlever les musiques originaux, alors ?___
                          Peut être en utilisant les reflections avec le fichier des musiques, mais je ne sais pas où il se trouve. Et j’ai chercher partout.

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

                            Personne ?

                            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

                              Après

                              if(timer == 3060)
                              {
                              

                              Ajoute ce code :

                              mc.sndManager.sndSystem.stop("BgMusic");
                              ObfuscationReflectionHelper.setPrivateValue(SoundManager.class, mc.sndManager, 3060, "ticksBeforeMusic", "");
                              

                              Le premier devrait stoper la musique en cours, j’ai pas eu l’occasion de tester. Le deuxième change la valeur ticksBeforeMusic sur 3060, donc ça laisse le temps à ta musique de ce jouer sans qu’une autre vienne pas dessus. J’ai vérifie avec le System.out.prinln, ça marche, la valeur est bien modifié.

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

                                Salut
                                Merci, mais ça ne marche pas
                                Voilà mon code :

                                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.client.audio.SoundManager;
                                import net.minecraft.client.audio.SoundPoolEntry;
                                import net.minecraft.client.settings.GameSettings;
                                import net.minecraft.util.MathHelper;
                                import net.minecraft.world.biome.BiomeGenBase;
                                import net.minecraftforge.client.event.sound.PlayBackgroundMusicEvent;
                                import net.minecraftforge.client.event.sound.SoundEvent;
                                import cpw.mods.fml.client.FMLClientHandler;
                                import cpw.mods.fml.common.ITickHandler;
                                import cpw.mods.fml.common.ObfuscationReflectionHelper;
                                import cpw.mods.fml.common.TickType;
                                
                                public class ClientTickHandler implements ITickHandler
                                {
                                public int timer = 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);
                                
                                if(rand.nextInt(15) > 13)
                                {
                                System.out.println(biome.getFloatTemperature());
                                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)
                                {
                                System.out.println(timer);
                                if(timer == 3060)
                                {
                                mc.sndManager.sndSystem.stop("BgMusic");
                                ObfuscationReflectionHelper.setPrivateValue(SoundManager.class, mc.sndManager, 3060, "ticksBeforeMusic", "");
                                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))
                                {
                                SoundPoolEntry soundpoolentry = mc.sndManager.soundPoolMusic.getRandomSoundFromSoundPool("halloween:music");
                                soundpoolentry = SoundEvent.getResult(new PlayBackgroundMusicEvent(mc.sndManager, soundpoolentry));
                                
                                if(soundpoolentry != null)
                                {
                                mc.sndManager.sndSystem.backgroundMusic("BgMusic", soundpoolentry.func_110457_b(), soundpoolentry.func_110458_a(), false);
                                mc.sndManager.sndSystem.setVolume("BgMusic", 1.0F);
                                mc.sndManager.sndSystem.play("BgMusic");
                                System.out.println("ca marche :)");
                                }
                                
                                }
                                else
                                {
                                SoundPoolEntry soundpoolentry = mc.sndManager.soundPoolMusic.getRandomSoundFromSoundPool("halloween:music");
                                soundpoolentry = SoundEvent.getResult(new PlayBackgroundMusicEvent(mc.sndManager, soundpoolentry));
                                
                                if(soundpoolentry != null)
                                {
                                mc.sndManager.sndSystem.backgroundMusic("BgMusic", soundpoolentry.func_110457_b(), soundpoolentry.func_110458_a(), false);
                                mc.sndManager.sndSystem.setVolume("BgMusic", 1.0F);
                                mc.sndManager.sndSystem.play("BgMusic");
                                }
                                }
                                timer = 0;
                                }
                                else
                                {
                                timer++;
                                }
                                }
                                }
                                }
                                
                                @Override
                                public EnumSet <ticktype>ticks()
                                {
                                return EnumSet.of(TickType.PLAYER);
                                }
                                
                                @Override
                                public String getLabel()
                                {
                                return "snow tick handler";
                                }
                                
                                }
                                

                                J’ai donc mis le code pour que ça affiche des mots dans la console, mais ça ne marche pas
                                Ce qui veut dire que quelque chose dans le code bug.</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

                                  Le son ne se joue plus du tout ?

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

                                    Non
                                    (désolée du temps de réponse)___
                                    Enfin…., ça se joue peut être; mais si ça se joue, c’est comme les autres musiques. Et comme y’a + de 10 musiques et 10 min entre chaque, faudrait rester une après midi entière avec Minercaft allumer pour savoir si ça se joue.
                                    Mais en tout cas, avant ça se jouait tout le temps. Plus maintenant.

                                    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

                                      Essaye d’enlever le mc.sndManager.sndSystem.stop(“BgMusic”);, mais le problème c’est que si une musique est actuellement en train d’être joué, ça va superposer l’une sur l’autre, sauf si le fait de jouer une nouvelle musique coupe l’autre.

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

                                        Salut
                                        Désolée du temps de réponse
                                        Non, ça ne marche pas
                                        Sinon, j’ai un truc qui peut vachement simplifier la tache : Si je sais le fichier où sont écrit les emplacements des musics, je pourrais modifier les valeurs pour ne mettre que la mienne. Mais je ne trouve pas ce fameux fichier. Un de vous sait ?

                                        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 y a pas de fichier pour ça, c’est une array list dans l’audio manager.

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

                                            Donc ça veut dire que je ne peut pas modifier ce fichier ?

                                            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