MFF

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

    Génération de minerais

    Planifier Épinglé Verrouillé Déplacé Résolu 1.12.x
    1.12.2
    4 Messages 3 Publieurs 468 Vues 3 Watching
    Charger plus de messages
    • Du plus ancien au plus récent
    • Du plus récent au plus ancien
    • Les plus votés
    Répondre
    • Répondre à l'aide d'un nouveau sujet
    Se connecter pour répondre
    Ce sujet a été supprimé. Seuls les utilisateurs avec les droits d'administration peuvent le voir.
    • DailyCraftD Hors-ligne
      DailyCraft
      dernière édition par DailyCraft

      Bonjour,

      J’ai un problème et une question :

      problème :
      Je n’arrives pas à générer mon block même dans l’overworld

      question :
      Comment on fait comment pour choisir dans quel block notre minerai spawn pour que ça marche dans les différantes dimensions ?

      public class OreGeneration implements IWorldGenerator
      {
          @Override
          public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator generator, IChunkProvider provider)
          {
              switch (world.provider.getDimension())
              {
                  case 1:
                      generateEnd(random, chunkX, chunkZ, world, generator, provider);
      
                  case 0:
                      generateOverworld(random, chunkX, chunkZ, world, generator, provider);
      
                  case -1:
                      generateNether(random, chunkX, chunkZ, world, generator, provider);
              }
          }
      
          private void generateEnd(Random random, int chunkX, int chunkZ, World world, IChunkGenerator generator, IChunkProvider provider)
          {
              generateOre(ModBlocks.RUBY_ORE.getDefaultState(), world, random, chunkX * 16, chunkZ * 16, 1, 256, 1, 1, 200);
          }
      
          private void generateOverworld(Random random, int chunkX, int chunkZ, World world, IChunkGenerator generator, IChunkProvider provider)
          {
          }
      
          private void generateNether(Random random, int chunkX, int chunkZ, World world, IChunkGenerator generator, IChunkProvider provider)
          {
          }
      
          private void generateOre(IBlockState ore, World world, Random random, int x, int z, int minY, int maxY, int minSize, int maxSize, int chances)
          {
              int deltaY = maxY - minY;
      
              for (int i = 0; i < chances; i++)
              {
                  BlockPos pos = new BlockPos(x + random.nextInt(16), minY + random.nextInt(deltaY), z + random.nextInt(16));
      
                  WorldGenMinable generator = new WorldGenMinable(ore, random.nextInt(maxSize) + minSize);
                  generator.generate(world, random, pos);
              }
          }
      }
      

      Classe principal :

          @Mod.EventHandler
          public void preInit(FMLPreInitializationEvent event)
          {
              proxy.preInit();
      
              GameRegistry.registerWorldGenerator(new OreGeneration(), 3);
          }
      

      Mes créations :

      Mod en cours de développement : Personal Robot (1.15.2)

      Datapacks : DailyCraft's Craft (beta)

      Je suis un membre apprécié et joueur, j'ai déjà obtenu 2 point(s) de réputation.

      1 réponse Dernière réponse Répondre Citer 1
      • DailyCraftD Hors-ligne
        DailyCraft
        dernière édition par

        C’est bon, j’ai régler mon problème :

        public class OreGeneration implements IWorldGenerator
        {
            @Override
            public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator generator, IChunkProvider provider)
            {
                switch (world.provider.getDimension())
                {
                    case 1:
                        runGenerator(ModBlocks.RUBY_ORE, Blocks.END_STONE, 8, 200, 0, 256, random, chunkX, chunkZ, world);
                        break;
                }
            }
        
            private void runGenerator(Block block, Block blockIn, int maxSize, int chance, int minHeight, int maxHeight, Random random, int chunkX, int chunkZ, World world)
            {
                if (minHeight > maxHeight || minHeight < 0 || minHeight > 256)
                    throw new IllegalArgumentException("Ore Generated out of bounds");
        
                int heightDiff = maxHeight - minHeight + 1;
        
                for (int i = 0; i < chance; i++)
                {
                    int x = chunkX * 16 + random.nextInt(16);
                    int y = minHeight + random.nextInt(heightDiff);
                    int z = chunkZ * 16 + random.nextInt(16);
        
                    WorldGenerator generator = new WorldGenMinable(block.getDefaultState(), maxSize, BlockMatcher.forBlock(blockIn));
                    generator.generate(world, random, new BlockPos(x, y, z));
                }
            }
        }
        

        Mes créations :

        Mod en cours de développement : Personal Robot (1.15.2)

        Datapacks : DailyCraft's Craft (beta)

        Je suis un membre apprécié et joueur, j'ai déjà obtenu 2 point(s) de réputation.

        1 réponse Dernière réponse Répondre Citer 1
        • Flow ArgF Hors-ligne
          Flow Arg Moddeurs confirmés
          dernière édition par Flow Arg

          Salut,
          Si ton minerai ne spawn pas dans l’overworld, c’est parce que tu l’a mis dans generateEnd au lieu de ta méthode generateOverworld.
          Et je ne comprend pas ta question : dans quel block ton minerai spawn ?
          Ton minerai spawn aléatoirement dans n’importe quel block. Je ne comprends donc pas ta question.

          PS : Zom’ le meilleur x)

          Mon GitHub
          Mon repo Maven
          Mon Updater
          Je suis un membre apprécié et joueur, j'ai déjà obtenu 10 points de réputation.

          GregoirelpvG 1 réponse Dernière réponse Répondre Citer 0
          • GregoirelpvG Hors-ligne
            Gregoirelpv @Flow Arg
            dernière édition par

            @Flow-Arg

            Mdrrrrrr bv

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

              C’est bon, j’ai régler mon problème :

              public class OreGeneration implements IWorldGenerator
              {
                  @Override
                  public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator generator, IChunkProvider provider)
                  {
                      switch (world.provider.getDimension())
                      {
                          case 1:
                              runGenerator(ModBlocks.RUBY_ORE, Blocks.END_STONE, 8, 200, 0, 256, random, chunkX, chunkZ, world);
                              break;
                      }
                  }
              
                  private void runGenerator(Block block, Block blockIn, int maxSize, int chance, int minHeight, int maxHeight, Random random, int chunkX, int chunkZ, World world)
                  {
                      if (minHeight > maxHeight || minHeight < 0 || minHeight > 256)
                          throw new IllegalArgumentException("Ore Generated out of bounds");
              
                      int heightDiff = maxHeight - minHeight + 1;
              
                      for (int i = 0; i < chance; i++)
                      {
                          int x = chunkX * 16 + random.nextInt(16);
                          int y = minHeight + random.nextInt(heightDiff);
                          int z = chunkZ * 16 + random.nextInt(16);
              
                          WorldGenerator generator = new WorldGenMinable(block.getDefaultState(), maxSize, BlockMatcher.forBlock(blockIn));
                          generator.generate(world, random, new BlockPos(x, y, z));
                      }
                  }
              }
              

              Mes créations :

              Mod en cours de développement : Personal Robot (1.15.2)

              Datapacks : DailyCraft's Craft (beta)

              Je suis un membre apprécié et joueur, j'ai déjà obtenu 2 point(s) de réputation.

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

              MINECRAFT FORGE FRANCE © 2024

              Powered by NodeBB