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

      Forge à un event pour les sons jouer, regarde dans le package net.minecraftforge.client.event.sound, il y a pas mal de PlaySound event, cherche le quel correspond aux musiques de minecraft (tu enregistre l’event et tu fais logger dans la console quand le son se lance) une fois que tu l’as trouvé, tu as juste à faire event.setCanceled(true); pour supprimer le son.

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

        Désolée, je ne trouve pas quel event correspond aux musiques de Minecraft
        Si tu peux m’aider
        PS : les fichiers sons de Minecraft ont changé en 1.6, donc les events sound aussi. Peut être pour ça
        Où alors, c’est que je ne sais pas chercher -_-

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

          Ou peut être que si je trouve quel fichiers sont enregistrer les musiques, je pourrai faire un implements

          Mais je ne trouve pas le fichier.

          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 ta classe eventsound :

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

            Le problème, c’est que la music n’est pas cancelable, donc ça fait crash
            Le mieux sera de jouer ton son comme une musique, enfin que le jeu ne joue pas une autre musique en même temps, et qu’il soit fort par tout, donc dans l’event sound :
            event.manager.addMusic(“modid:music”) (le son sera dans assets/modid/music/)
            Et pour jouer le son :

            SoundPoolEntry soundpoolentry = mc.sndManager.soundPoolMusic.getRandomSoundFromSoundPool("ta music");
            soundpoolentry = SoundEvent.getResult(new PlayBackgroundMusicEvent(this, soundpoolentry));
            
            if (soundpoolentry != null)
            {
            mc.sndSystem.backgroundMusic("BgMusic", soundpoolentry.func_110457_b(), soundpoolentry.func_110458_a(), false);
            mc.sndSystem.setVolume("BgMusic", this.options.musicVolume);
            mc.sndSystem.play("BgMusic");
            }
            

            J’ai pas eu le temps de tester, mais ça devrait être ça.

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

              Salut
              Merci et désolée de ne pas avoir répondu plus tôt

              Mes erreurs :

              mc
              

              Que je fasse n’importe quoi, c’est le mot d’après qui bug.

              rand
              

              Que je fasse n’importe quoi, c’est nextInt qui bug.

              (new PlayBackgroundMusicEvent(this, soundpoolentry));
              

              Le problème, c’est que les 2 options pour régler cette erreur modifient les sources de Forges.

              Merci d’avance

              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

                Oups, j’ai édité, j’ai supprimé la ligne inutile.
                Tu as bien mit ce code dans ton tickhandler à la place du son actuelle ?

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

                  J’ai les même erreurs que tout a l’heure, juste le rand en moins.
                  Merci d’avance

                  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 peux avoir ton code entier du tick handler ?

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

                      package This_is_Halloween;
                      
                      import java.util.EnumSet;
                      
                      import net.minecraftforge.client.event.sound.PlayBackgroundMusicEvent;
                      import net.minecraftforge.event.ForgeSubscribe;
                      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)
                      {
                      
                      }
                      @ForgeSubscribe
                      public void onSoundPlayed(PlayBackgroundMusicEvent event)
                      {
                      event.setCanceled(true);
                      }
                      @Override
                      public void tickEnd(EnumSet <ticktype>type, Object... tickData)
                      {
                      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";
                      }
                      }
                      ```</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

                        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
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • Premier message
                                              Dernier message
                                            Design by Woryk
                                            ContactMentions Légales

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB