MFF

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

    [1.7.10] Génération de minerais avec metadatas

    Planifier Épinglé Verrouillé Déplacé Non résolu Sans suite
    1.7.10
    5 Messages 2 Publieurs 236 Vues 2 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.
    • HangelH Hors-ligne
      Hangel
      dernière édition par

      Bonjour j’ai créé un bloc avec métadata et j’aimerai qu’il se génère dans le monde, voici les codes :

      Classe du blocs avec meta :

      public class MarblesBlocks extends Block {
      
      	public static String[] subBlock = new String[]{"marble1","marble2","marble3","marble4"};
      	public IIcon[] iconArray = new IIcon[subBlock.length];
      	public MarblesBlocks() {
      		super(Material.rock);
      		this.setCreativeTab(ModTest.tab_mod);
      		this.setBlockName("marble");
      		this.setHardness(1.5F);
      		this.setResistance(10.0F);
      		this.setHarvestLevel("pickaxe", 1);
      	}
      	
      	public int damageDropped(int metadata) {
      		return metadata;
      	}
      	
          public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
          	for(int i = 0; i < subBlock.length; i++) {
          		list.add(new ItemStack(item, 1, i));
          	}
          }
          
          public void registerBlockIcons(IIconRegister iconRegister) {
          	for(int i = 0; i < subBlock.length; i++) {
              this.iconArray[i] = iconRegister.registerIcon(Reference.MOD_ID + ":" + subBlock[i]);
          	}
          }
          
          public IIcon getIcon(int side, int metadata) {
          	if(metadata >= 0 && metadata < subBlock.length) {
          		return this.iconArray[metadata];
          	}
              return this.iconArray[0];
          	}
      }
      

      De l’itemBlock du metadata :

      public class ItemMarblesBlocks extends ItemBlock {
      
      	public ItemMarblesBlocks(Block block) {
      		super(block);
      		this.setMaxDamage(0);
      		this.setHasSubtypes(true);
      	}
      	
          @SideOnly(Side.CLIENT)
          public IIcon getIconFromDamage(int metadata)
          {
              return this.field_150939_a.getIcon(2, metadata);
          }
          
          public int getMetadata(int metadata)
          {
              return metadata;
          }
          
          public String getUnlocalizedName(ItemStack p_77667_1_)
          {
              int metadata = p_77667_1_.getItemDamage();
      
              if (metadata < 0 || metadata >= MarblesBlocks.subBlock.length)
              {
                  metadata = 0;
              }
      
              return super.getUnlocalizedName() + "." + MarblesBlocks.subBlock[metadata];
          }
      }
      

      De ma classe de génération :

      public class TestWorldGen implements IWorldGenerator {
      
      	@Override
      	public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {	
      		
      		switch(world.provider.dimensionId) {
      		case -1:
      			GenerateNether(world, chunkX * 16, chunkZ *16, random);
      		case 0:
      			GenerateOverWorld(world, chunkX * 16, chunkZ *16, random);
      		case 1:
      			GenerateEnd(world, chunkX * 16, chunkZ *16, random);
      		}
      	}
      	
      	private void addOre(Block block, Block blockSpawn, Random random, World world, int posX, int posZ, int minY, int maxY, int minV, int maxV, int spawnChance) {
      		for(int i = 0; i < spawnChance; i++) {
      			int chunkSize = 16;
      			int Xpos = posX + random.nextInt(chunkSize);
      			int Ypos = minY + random.nextInt(maxY - minY);
      			int Zpos = posZ + random.nextInt(chunkSize);
      			
      			new WorldGenMinable(block, maxV).generate(world, random, Xpos, Ypos, Zpos);
      			}
      		}
      	
      
      	private void GenerateNether(World world, int i, int j, Random random) {	
      	}
      
      	private void GenerateOverWorld(World world, int i, int j, Random random) {
                      //c lui ki faut changer
      		addOre(BlockMod.marbles, Blocks.stone, random, world, i, j, 1, 255, 4, 9, 100);
      
      	}
      
      	private void GenerateEnd(World world, int i, int j, Random random) {
      	}
      }
      

      Merci d’avance pour l’aide 🙂

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

        Tu as bien GameRegistry. tes items/blocks ?
        Tu as bien mis dans preInit le WorldRegister?
        (WorldRegister.mainRegistry)
        (Ou quelque chose du genre, c’est peut-être ça)

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

          Oui, car mes blocs metadata marchent normalement, dans la génération les autres minerais se génère, mais quand je met mon bloc meta dans la génération, il se génère bien MAIS c’est seulement le premier metadata qui apparait, c’est ça qui ne va pas, faire générer les autres métadata du bloc

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

            Alors là… je peux pas t’aider plus désolé ^^’

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

              ok merci quand même

              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