SOLVED Récupérer les blocs génériques d'un mod


  • Bonjour,
    Je voudrais savoir si il est possible de récupérer tout les blocs d’un mod bien précis.
    Je m’explique:

    J’ai un mod qui va créer des blocs de cette façon :

    :::

    ​@EventHandler
    public void Init(FMLInitializationEvent event)
    {
    proxy.registerRender();
    
    AddPillar(AddMaterial.nether, "nether", "Nether", Blocks.netherrack);
    }
    […]
    
    private void AddPillar(Material material, String Name, String DisplayName, Block Depart){
    Block block = new AddBlockMT(material, MODID, Name+"_block", "", Tab);
    Block blocklines = new AddBlockMTC(material, MODID, Name+"_block", "_lines", Name+"_block_lines_top", Name+"_block_lines", Name+"_block_lines_top", Tab);
    Block blockchiseled = new AddBlockMTC(material, MODID, Name+"_block", "_chiseled", Name+"_block_chiseled_top", Name+"_block_chiseled", Name+"_block_chiseled_top", Tab);
    Block single_blocklinesslab = new AddSlab(false, material, Name+"_block", "_lines", blocklines, Tab).setHardness(0.8F);
    Block double_blocklinesslab = new AddSlab(true, material, "nether_block", "_lines", blocklines, Tab).setHardness(0.8F);
    Block single_blockchiseledslab = new AddSlab(false, material, Name+"_block", "_chiseled", blockchiseled, Tab).setHardness(0.8F);
    Block double_blockchiseledslab = new AddSlab(true, material, Name+"_block", "_chiseled", blockchiseled, Tab).setHardness(0.8F);
    Block single_blockslab = new AddSlab(false, material, Name+"_block", "", block, Tab).setHardness(0.8F);
    Block double_blockslab = new AddSlab(true, material, Name+"_block", "", block, Tab).setHardness(0.8F);
    Block blockstair = new AddStair(block, 0, Name+"_block", "", Tab);
    Block blocklinesstair = new AddStair(blockchiseled, 0, Name+"_block", "_lines", Tab);
    Block blockchiseledstair = new AddStair(blocklines, 0, Name+"_block", "_chiseled", Tab);
    
    GameRegistry.registerBlock(block, DisplayName+"Block");
    GameRegistry.registerBlock(blocklines, DisplayName+"Lines");
    GameRegistry.registerBlock(blockchiseled, DisplayName+"Chiseled");
    GameRegistry.registerBlock(single_blockchiseledslab, DisplayName+"ChiseledSlabS");
    GameRegistry.registerBlock(double_blockchiseledslab, DisplayName+"ChiseledSlabD");
    GameRegistry.registerBlock(single_blocklinesslab, DisplayName+"LinesSlabS");
    GameRegistry.registerBlock(double_blocklinesslab, DisplayName+"LinesSlabD");
    GameRegistry.registerBlock(single_blockslab, DisplayName+"SlabS");
    GameRegistry.registerBlock(double_blockslab, DisplayName+"SlabD");
    GameRegistry.registerBlock(blockstair, DisplayName+"Stair");
    GameRegistry.registerBlock(blocklinesstair, DisplayName+"LinesStair");
    GameRegistry.registerBlock(blockchiseledstair, DisplayName+"ChiseledStair");
    
    GameRegistry.addRecipe(new ItemStack(block, 9), new Object[]{ "AAA","AAA","AAA",'A', new ItemStack(Depart, 1), });[/font]
    GameRegistry.addRecipe(new ItemStack(blocklines, 1), new Object[]{ "AA ","AA ","   ",'A', new ItemStack(block, 1), });[/font]
    GameRegistry.addRecipe(new ItemStack(blockchiseled, 1), new Object[]{ "AA ","AA ","   ",'A', new ItemStack(single_blockslab, 1), });[/font]
    GameRegistry.addRecipe(new ItemStack(single_blockslab, 6), new Object[]{ "AAA","   ","   ",'A', new ItemStack(block, 1), });[/font]
    GameRegistry.addRecipe(new ItemStack(single_blocklinesslab, 6), new Object[]{ "AAA","   ","   ",'A', new ItemStack(blocklines, 1), });[/font]
    GameRegistry.addRecipe(new ItemStack(single_blockchiseledslab, 6), new Object[]{ "AAA","   ","   ",'A', new ItemStack(blockchiseled, 1), });[/font]
    GameRegistry.addRecipe(new ItemStack(blockstair, 4), new Object[]{ "A  ","AA ","AAA",'A', new ItemStack(block, 1), });[/font]
    GameRegistry.addRecipe(new ItemStack(blocklinesstair, 4), new Object[]{ "A  ","AA ","AAA",'A', new ItemStack(blocklines, 1), });[/font]
    GameRegistry.addRecipe(new ItemStack(blockchiseledstair, 4), new Object[]{ "A  ","AA ","AAA",'A', new ItemStack(blockchiseled, 1), });[/font]
    
    }
    

    :::

    AddBlock() / AddBlockMT() permet de créer des blocs basiques de façon automatique.

    Je voudrais que mon deuxième mod réutilise les blocs produit par mon premier mod.
    Est-ce Possible?

    Merci d’avance pour vos réponses.

  • Administrateurs Rédacteurs Moddeurs confirmés

    Block block = GameRegistry.getBlock("modid", "nom");
    if(block != null)
    {
            // le bloc existe, il a donc été trouvé
    }
    else
    {
        // bloc pas trouvé, le mod qui doit l'ajouter n'est pas installé
    }
    

    Après tu fais ce que tu veux avec l’instance du bloc (ajouter des recettes, etc …)


  • Merci beaucoups ! 🙂