Navigation

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    SOLVED Génération de minerais

    1.12.x
    1.12.2
    3
    4
    118
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DailyCraft
      DailyCraft last edited by 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);
          }
      
      1 Reply Last reply Reply Quote 1
      • DailyCraft
        DailyCraft last edited by

        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));
                }
            }
        }
        
        1 Reply Last reply Reply Quote 1
        • Flow Arg
          Flow Arg Moddeurs confirmés last edited by 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)

          Gregoirelpv 1 Reply Last reply Reply Quote 0
          • Gregoirelpv
            Gregoirelpv @Flow Arg last edited by

            @Flow-Arg

            Mdrrrrrr bv

            1 Reply Last reply Reply Quote 0
            • DailyCraft
              DailyCraft last edited by

              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));
                      }
                  }
              }
              
              1 Reply Last reply Reply Quote 1
              • 1 / 1
              • First post
                Last post
              Design by Woryk
              Contact / Mentions Légales / Faire un don

              MINECRAFT FORGE FRANCE © 2018

              Powered by NodeBB