MFF

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

    Block de type plante

    Planifier Épinglé Verrouillé Déplacé Résolu 1.7.x
    1.7.x
    8 Messages 3 Publieurs 1.7k 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.
    • T Hors-ligne
      TheWolf
      dernière édition par robin4002

      Salut tout le monde, voila j’ai à nouveau un souci. J’ai créé un bloc mais j’aimerais qu’il soit de type plante (tel une fleur) mais j’aimerais en même temps qu’il ne soit généré que sur l’herbe dans le monde comme une fleur :). Si quelqu’un a la solution à mon problème merci de l’exprimer dans les plus brefs délais.
      Cordialement.

      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

        Salut
        Pour générer un bloc décoratif : http://www.minecraftforgefrance.fr/showthread.php?tid=157&pid=1565#pid1565
        Dans la fonction generate tu as juste a remplacer
        if((world.getBlockId(x, y - 1, z) == Block.grass.blockID && isAir)|| (world.getBlockId(x, y - 1, z) == Block.dirt.blockID && isAir))
        par :
        if(world.getBlock(x, y - 1, z) == Blocks.grass && isAir)
        Pour la 1.7
        Il faut aussi changer le world.setBlock(x, y, z, Block.web.blockID);, pas besoin du .blockID en 1.7, donc tu mets :
        world.setBlock(x, y, z, ClassePrincipale.tonBloc);

        Il y a aussi le world generator c’est :
        GameRegistry.registerWorldGenerator(new WorldGenTutorial() , 0); en 1.7.
        Il y peut être d’autre truc différent en 1.7, de tête de voit que ça.

        Pour le rendu du bloc, regarde BlockFlower.
        ÉDIT : cadeau -> http://www.minecraftforgefrance.fr/showthread.php?tid=279&pid=2920#pid2920

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

          Est-ce que tu peux m’expliquer sur skype parce que là je l’ai mis dans ma classe WorldGeneration mais il y a des erreurs partout et en plus je ne sais pas où va ton explication :

          Dans la fonction generate tu as juste a remplacer
          if((world.getBlockId(x, y - 1, z) == Block.grass.blockID && isAir)|| (world.getBlockId(x, y - 1, z) == Block.dirt.blockID && isAir))
          par :
          if(world.getBlock(x, y - 1, z) == Blocks.grass && isAir)
          Pour la 1.7
          Il faut aussi changer le world.setBlock(x, y, z, Block.web.blockID);, pas besoin du .blockID en 1.7, donc tu mets :
          world.setBlock(x, y, z, ClassePrincipale.tonBloc);

          Il y a aussi le world generator c’est :
          GameRegistry.registerWorldGenerator(new WorldGenTutorial() , 0); en 1.7.
          Il y peut être d’autre truc différent en 1.7, de tête de voit que ça.

          Pour le rendu du bloc, regarde BlockFlower.

          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 robin4002

            Dans la fonction init de la classe principale :

            GameRegistry.registerWorldGenerator(new WorldGenTutorial(), 0);
            

            La classe WorldGenTutorial :

            package tutoriel.common;
            
            import java.util.Random;
            
            import net.minecraft.world.World;
            import net.minecraft.world.chunk.IChunkProvider;
            import cpw.mods.fml.common.IWorldGenerator;
            
            public class WorldGenTutorial implements IWorldGenerator
            {
                @Override
                public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
                {
                    switch(world.provider.dimensionId)
                    {
                        case 0:
                            generateSurface(world, random, chunkX * 16, chunkZ * 16);
                    }
                }
            
                private void generateSurface(World world, Random rand, int x, int z)
                {
                    for(int i = 0; i < 75; i++)
                    {
                        int randPosX = x + rand.nextInt(16);
                        int randPosY = rand.nextInt(128);
                        int randPosZ = z + rand.nextInt(16);
                        (new WorldGenTaPlante()).generate(world, rand, randPosX, randPosY, randPosZ);
                    }
                }
            }
            

            WorldGenTaPlante :

            package tutoriel.common;
            
            import java.util.Random;
            
            import net.minecraft.block.Block;
            import net.minecraft.world.World;
            import net.minecraft.world.gen.feature.WorldGenerator;
            
            public class WorldGenTaPlante extends WorldGenerator
            {
                @Override
                public boolean generate(World world, Random random, int x, int y, int z)
                {
                    if(world.getBlockId(x, y - 1, z) == Blocks.grass && world.isAirBlock(x, y, z))
                    {
                        world.setBlock(x, y, z, TaClassePrincipale.tonBloc);
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            

            Pour changer la hauteur minimum :
            int randPosY = rand.nextInt(hauteur);
            Et pour la probabilité change le i < 75

            C’est mieux comme ça ?

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

              Bon c’est mieux mais il reste 2 erreurs :
              generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)

              et l’erreur est :
              Duplicate method generate(Random, int, int, World, IChunkProvider, IChunkProvider) in type WorldGeneration

              generateSurface(World world, Random rand, int x, int z)

              et l’erreur est :
              Duplicate method generateSurface(World, Random, int, int) in type WorldGeneration

              tout ça dans la classe worldgeneration

              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

                Duplicate method = la méthode est en double.
                Envoie ta classe.

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

                  package fr.craftandfight.serveur.common;
                  
                  import java.util.Random;
                  
                  import net.minecraft.block.Block;
                  import net.minecraft.world.World;
                  import net.minecraft.world.chunk.IChunkProvider;
                  import net.minecraft.world.gen.feature.WorldGenFlowers;
                  import net.minecraft.world.gen.feature.WorldGenMinable;
                  import cpw.mods.fml.common.IWorldGenerator;
                  
                  public class WorldGeneration implements IWorldGenerator
                  
                  {
                  public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
                  
                  switch (world.provider.dimensionId)
                  
                  {
                  
                  case -1:
                  
                  generateNether(world, random, chunkX * 16, chunkZ * 16);
                  
                  case 0:
                  
                  generateSurface(world, random, chunkX * 16, chunkZ * 16);
                  
                  case 1:
                  
                  generateEnd(world, random, chunkX * 16, chunkZ * 16);}
                  
                  }
                  
                  private void generateEnd(World world, Random random, int x, int z) {
                  
                  }
                  
                  private void generateSurface(World world, Random random, int x, int z) {
                  
                  this.addOreSpawn(ModCraftAndFight.rubyOre, world, random, x, z, 16, 16, 8, 1, 0, 16);
                  this.addOreSpawn(ModCraftAndFight.sapphireOre, world, random, x, z, 16, 16, 8, 1, 0, 16);
                  this.addOreSpawn(ModCraftAndFight.jadeOre, world, random, x, z, 16, 16, 4, 4, 0, 10);
                  this.addOreSpawn(ModCraftAndFight.rainbowOre, world, random, x, z, 16, 16, 3, 1, 0, 8);
                  this.addOreSpawn(ModCraftAndFight.nuclearOre, world, random, x, z, 16, 16, 2, 1, 0, 8);
                  this.addOreSpawn(ModCraftAndFight.agathOre, world, random, x, z, 16, 16, 5, 1, 0, 13);
                  
                  }
                  
                  public void addOreSpawn(Block block, World world, Random random, int blockXPos, int blockZPos, int maxX, int maxZ, int maxVeinSize, int chancesToSpawn, int minY, int maxY) {
                  
                  assert maxY > minY : "La position Y maximum doit être supérieure à la position Y minimum.";
                  
                  assert maxX > 0 && maxX <= 16 : "X doit se trouver entre 0 et 16.";
                  
                  assert minY > 0 : "La position Y minimum doit être supérieure à 0.";
                  
                  assert maxY < 256 && maxY > 0 : "La position Y maximum doit se trouver entre 0 et 256.";
                  
                  assert maxZ > 0 && maxZ <= 16 : "Z doit se trouver entre 0 et 16.";
                  
                  int diffBtwnMinMaxY = maxY - minY;
                  
                  for (int x = 0; x < chancesToSpawn; x++) {
                  
                  int posX = blockXPos + random.nextInt(maxX);
                  
                  int posY = minY + random.nextInt(diffBtwnMinMaxY);
                  
                  int posZ = blockZPos + random.nextInt(maxZ);
                  
                  (new WorldGenMinable(block, maxVeinSize)).generate(world, random, posX, posY, posZ);
                  
                  }
                  
                  }
                  
                  private void generateNether(World world, Random random, int x, int z) {
                  
                  }
                  
                  @Override
                  public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
                  {
                  switch(world.provider.dimensionId)
                  {
                  case 0:
                  generateSurface(world, random, chunkX * 16, chunkZ * 16);
                  }
                  }
                  
                  private void generateSurface(World world, Random rand, int x, int z)
                  {
                  for(int i = 0; i < 75; i ++)
                  {
                  int randPosX = x + rand.nextInt(16);
                  int randPosY = rand.nextInt(128);
                  int randPosZ = z + rand.nextInt(16);
                  (new WorldGenerationCoca()).generate(world, rand, randPosX, randPosY, randPosZ);
                  }
                  }
                  }
                  
                  1 réponse Dernière réponse Répondre Citer 0
                  • DiangleD Hors-ligne
                    Diangle
                    dernière édition par

                    @‘TheWolf’:

                    package fr.craftandfight.serveur.common;
                    
                    import java.util.Random;
                    
                    import net.minecraft.block.Block;
                    import net.minecraft.world.World;
                    import net.minecraft.world.chunk.IChunkProvider;
                    import net.minecraft.world.gen.feature.WorldGenFlowers;
                    import net.minecraft.world.gen.feature.WorldGenMinable;
                    import cpw.mods.fml.common.IWorldGenerator;
                    
                    public class WorldGeneration implements IWorldGenerator
                    
                    {
                    public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
                    
                    switch (world.provider.dimensionId)
                    
                    {
                    
                    case -1:
                    
                    generateNether(world, random, chunkX * 16, chunkZ * 16);
                    
                    case 0:
                    
                    generateSurface(world, random, chunkX * 16, chunkZ * 16);
                    
                    case 1:
                    
                    generateEnd(world, random, chunkX * 16, chunkZ * 16);}
                    
                    }
                    
                    private void generateEnd(World world, Random random, int x, int z) {
                    
                    }
                    
                    private void generateSurface(World world, Random random, int x, int z) {
                    
                    this.addOreSpawn(ModCraftAndFight.rubyOre, world, random, x, z, 16, 16, 8, 1, 0, 16);
                    this.addOreSpawn(ModCraftAndFight.sapphireOre, world, random, x, z, 16, 16, 8, 1, 0, 16);
                    this.addOreSpawn(ModCraftAndFight.jadeOre, world, random, x, z, 16, 16, 4, 4, 0, 10);
                    this.addOreSpawn(ModCraftAndFight.rainbowOre, world, random, x, z, 16, 16, 3, 1, 0, 8);
                    this.addOreSpawn(ModCraftAndFight.nuclearOre, world, random, x, z, 16, 16, 2, 1, 0, 8);
                    this.addOreSpawn(ModCraftAndFight.agathOre, world, random, x, z, 16, 16, 5, 1, 0, 13);
                    
                    }
                    
                    public void addOreSpawn(Block block, World world, Random random, int blockXPos, int blockZPos, int maxX, int maxZ, int maxVeinSize, int chancesToSpawn, int minY, int maxY) {
                    
                    assert maxY > minY : "La position Y maximum doit être supérieure à la position Y minimum.";
                    
                    assert maxX > 0 && maxX <= 16 : "X doit se trouver entre 0 et 16.";
                    
                    assert minY > 0 : "La position Y minimum doit être supérieure à 0.";
                    
                    assert maxY < 256 && maxY > 0 : "La position Y maximum doit se trouver entre 0 et 256.";
                    
                    assert maxZ > 0 && maxZ <= 16 : "Z doit se trouver entre 0 et 16.";
                    
                    int diffBtwnMinMaxY = maxY - minY;
                    
                    for (int x = 0; x < chancesToSpawn; x++) {
                    
                    int posX = blockXPos + random.nextInt(maxX);
                    
                    int posY = minY + random.nextInt(diffBtwnMinMaxY);
                    
                    int posZ = blockZPos + random.nextInt(maxZ);
                    
                    (new WorldGenMinable(block, maxVeinSize)).generate(world, random, posX, posY, posZ);
                    
                    }
                    
                    }
                    
                    private void generateNether(World world, Random random, int x, int z) {
                    
                    }
                    
                    @Override
                    public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
                    {
                    switch(world.provider.dimensionId)
                    {
                    case 0:
                    generateSurface(world, random, chunkX * 16, chunkZ * 16);
                    }
                    }
                    
                    private void generateSurface(World world, Random rand, int x, int z)
                    {
                    for(int i = 0; i < 75; i ++)
                    {
                    int randPosX = x + rand.nextInt(16);
                    int randPosY = rand.nextInt(128);
                    int randPosZ = z + rand.nextInt(16);
                    (new WorldGenerationCoca()).generate(world, rand, randPosX, randPosY, randPosZ);
                    }
                    }
                    }
                    
                    

                    Tu as deux ois la méthode generate t’a classe doit être comme sa :

                    package fr.craftandfight.serveur.common;
                    
                    import java.util.Random;
                    
                    import net.minecraft.block.Block;
                    import net.minecraft.world.World;
                    import net.minecraft.world.chunk.IChunkProvider;
                    import net.minecraft.world.gen.feature.WorldGenFlowers;
                    import net.minecraft.world.gen.feature.WorldGenMinable;
                    import cpw.mods.fml.common.IWorldGenerator;
                    
                    public class WorldGeneration implements IWorldGenerator
                    
                    {
                    public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
                    
                    switch (world.provider.dimensionId)
                    
                    {
                    
                    case -1:
                    
                    generateNether(world, random, chunkX * 16, chunkZ * 16);
                    
                    case 0:
                    
                    generateSurface(world, random, chunkX * 16, chunkZ * 16);
                    
                    case 1:
                    
                    generateEnd(world, random, chunkX * 16, chunkZ * 16);}
                    
                    }
                    
                    private void generateEnd(World world, Random random, int x, int z) {
                    
                    }
                    
                    private void generateSurface(World world, Random random, int x, int z) {
                    
                    for(int i = 0; i < 75; i ++)
                    {
                    int randPosX = x + rand.nextInt(16);
                    int randPosY = rand.nextInt(128);
                    int randPosZ = z + rand.nextInt(16);
                    (new WorldGenerationCoca()).generate(world, rand, randPosX, randPosY, randPosZ);
                    }
                    this.addOreSpawn(ModCraftAndFight.rubyOre, world, random, x, z, 16, 16, 8, 1, 0, 16);
                    this.addOreSpawn(ModCraftAndFight.sapphireOre, world, random, x, z, 16, 16, 8, 1, 0, 16);
                    this.addOreSpawn(ModCraftAndFight.jadeOre, world, random, x, z, 16, 16, 4, 4, 0, 10);
                    this.addOreSpawn(ModCraftAndFight.rainbowOre, world, random, x, z, 16, 16, 3, 1, 0, 8);
                    this.addOreSpawn(ModCraftAndFight.nuclearOre, world, random, x, z, 16, 16, 2, 1, 0, 8);
                    this.addOreSpawn(ModCraftAndFight.agathOre, world, random, x, z, 16, 16, 5, 1, 0, 13);
                    
                    }
                    
                    public void addOreSpawn(Block block, World world, Random random, int blockXPos, int blockZPos, int maxX, int maxZ, int maxVeinSize, int chancesToSpawn, int minY, int maxY) {
                    
                    assert maxY > minY : "La position Y maximum doit être supérieure à la position Y minimum.";
                    
                    assert maxX > 0 && maxX <= 16 : "X doit se trouver entre 0 et 16.";
                    
                    assert minY > 0 : "La position Y minimum doit être supérieure à 0.";
                    
                    assert maxY < 256 && maxY > 0 : "La position Y maximum doit se trouver entre 0 et 256.";
                    
                    assert maxZ > 0 && maxZ <= 16 : "Z doit se trouver entre 0 et 16.";
                    
                    int diffBtwnMinMaxY = maxY - minY;
                    
                    for (int x = 0; x < chancesToSpawn; x++) {
                    
                    int posX = blockXPos + random.nextInt(maxX);
                    
                    int posY = minY + random.nextInt(diffBtwnMinMaxY);
                    
                    int posZ = blockZPos + random.nextInt(maxZ);
                    
                    (new WorldGenMinable(block, maxVeinSize)).generate(world, random, posX, posY, posZ);
                    
                    }
                    
                    }
                    
                    private void generateNether(World world, Random random, int x, int z) {
                    
                    }
                    
                    }
                    
                    
                    1 réponse Dernière réponse Répondre Citer 0
                    • 1 / 1
                    • Premier message
                      Dernier message
                    Design by Woryk
                    ContactMentions Légales

                    MINECRAFT FORGE FRANCE © 2024

                    Powered by NodeBB