Résolu Comment faire un ItemBlock
-
Bonjour à toute la communauté Minecraft Forge France,
Je suis en train actuellement d’update mon mod vers la 1.11, mais les nouvelles versions de forge ayant retirer le registerBlock, j’ai du refaire le fonctionne de mes Items et de mes blocks. Je n’ai pas eu trop de soucis pour ce qui est des Items une petite recherche avec mon ami google m’a suffit mais j’ai plus de difficulté avec les blocks. Après avoir fait quelque recherche sur les blocks et étant tombé sur des choses telles que “ItemBlock” et ayant essayer de les utiliser mais sans succès, j’ai décidé de faire appel à votre aide.
Comment faire l’item relatif à un block ?Pour préciser j’ai 2 class, l’une avec les Item et l’autre avec les blocks avec tout deux les renders et les register.
Ma class BlocksMod:
package fr.jules552.mod.init; import net.minecraft.block.Block; import net.minecraft.block.material.MapColor; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.common.registry.GameRegistry; import Blocks.AdamantiumMinerai; import Blocks.AluminiumMinerai; import Blocks.BlockSilver; import Blocks.BlockXray; import Blocks.LumineuxBlock; import Blocks.PadBounceBlue; import Blocks.PadBounceGreen; import Blocks.PadBounceRed; import Blocks.SilverMinerai; import fr.jules552.mod.Reference; public class BlocksMod { public static Block adamantium_block, adamantium_ore; public static Block silver_ore, silver_block; public static Block aluminium_ore, aluminium_block; public static Block light_block; public static Block xray_block; public static Block bounce_pad_red, bounce_pad_blue, bounce_pad_green; public static void init() { //Adamantium adamantium_block = new AdamantiumMinerai(Material.IRON).setUnlocalizedName("adamantium_block").setCreativeTab(ItemsMod.tabCustomTab).setHardness(5.0F); adamantium_ore = new AdamantiumMinerai(Material.ROCK).setUnlocalizedName("adamantium_ore").setCreativeTab(ItemsMod.tabCustomTab).setHardness(5.0F); //Silver silver_ore = new SilverMinerai(Material.ROCK).setUnlocalizedName("silver_ore").setCreativeTab(ItemsMod.tabCustomTab).setHardness(5.0F); silver_block = new SilverMinerai(Material.IRON).setUnlocalizedName("silver_block").setCreativeTab(ItemsMod.tabCustomTab).setHardness(5.0F); //Aluminium aluminium_ore = new AluminiumMinerai(Material.ROCK).setUnlocalizedName("aluminium_ore").setCreativeTab(ItemsMod.tabCustomTab).setHardness(5.0F); aluminium_block = new AluminiumMinerai(Material.IRON).setUnlocalizedName("aluminium_block").setCreativeTab(ItemsMod.tabCustomTab).setHardness(5.0F); //Special xray_block = new BlockXray(Material.GLASS).setUnlocalizedName("xray_block").setCreativeTab(ItemsMod.tabCustomTab).setHardness(5.0F); light_block = new LumineuxBlock(Material.BARRIER).setUnlocalizedName("light_block").setCreativeTab(ItemsMod.tabCustomTab).setBlockUnbreakable().setLightLevel(1.0F); bounce_pad_red = new PadBounceRed().setUnlocalizedName("bounce_pad_red").setCreativeTab(ItemsMod.tabCustomTab).setHardness(0.0F); bounce_pad_blue = new PadBounceBlue().setUnlocalizedName("bounce_pad_blue").setCreativeTab(ItemsMod.tabCustomTab).setHardness(0.0F); bounce_pad_green = new PadBounceGreen().setUnlocalizedName("bounce_pad_green").setCreativeTab(ItemsMod.tabCustomTab).setHardness(0.0F); } public static void register() { //GameRegistry Adamantium GameRegistry.register(adamantium_block.setRegistryName(adamantium_block.getUnlocalizedName().substring(5))); GameRegistry.register(adamantium_ore.setRegistryName(adamantium_ore.getUnlocalizedName().substring(5))); //GameRegistry Silver GameRegistry.register(silver_ore.setRegistryName(silver_ore.getUnlocalizedName().substring(5))); GameRegistry.register(silver_block.setRegistryName(silver_block.getUnlocalizedName().substring(5))); //GameRegistry Aluminium GameRegistry.register(aluminium_ore.setRegistryName(aluminium_ore.getUnlocalizedName().substring(5))); GameRegistry.register(aluminium_block.setRegistryName(aluminium_block.getUnlocalizedName().substring(5))); //GameRegistry Special GameRegistry.register(xray_block.setRegistryName(xray_block.getUnlocalizedName().substring(5))); GameRegistry.register(light_block.setRegistryName(light_block.getUnlocalizedName().substring(5))); GameRegistry.register(bounce_pad_red.setRegistryName(bounce_pad_red.getUnlocalizedName().substring(5))); GameRegistry.register(bounce_pad_blue.setRegistryName(bounce_pad_blue.getUnlocalizedName().substring(5))); GameRegistry.register(bounce_pad_green.setRegistryName(bounce_pad_green.getUnlocalizedName().substring(5))); //Les Crafts //Crafts pour Adamantium GameRegistry.addSmelting(BlocksMod.adamantium_ore, new ItemStack(ItemsMod.adamantium_ingot), 1.8F); GameRegistry.addRecipe(new ItemStack(BlocksMod.adamantium_block, 1), new Object[] {"###", "###","###", '#', ItemsMod.adamantium_ingot}); GameRegistry.addShapelessRecipe(new ItemStack(ItemsMod.adamantium_ingot,9), new ItemStack(BlocksMod.adamantium_block)); //Crafts pour Silver GameRegistry.addSmelting(BlocksMod.silver_ore, new ItemStack(ItemsMod.silver_ingot), 0.8F); GameRegistry.addRecipe(new ItemStack(BlocksMod.silver_block, 1), new Object[] {"###", "###","###", '#', ItemsMod.silver_ingot}); GameRegistry.addShapelessRecipe(new ItemStack(ItemsMod.silver_ingot,9), new ItemStack(BlocksMod.silver_block)); //Crafts pour Aluminium GameRegistry.addSmelting(BlocksMod.aluminium_ore, new ItemStack(ItemsMod.aluminium_ingot), 0.7F); GameRegistry.addRecipe(new ItemStack(BlocksMod.aluminium_block, 1), new Object[] {"###", "###","###", '#', ItemsMod.aluminium_ingot}); GameRegistry.addShapelessRecipe(new ItemStack(ItemsMod.aluminium_ingot,9), new ItemStack(BlocksMod.aluminium_block)); //Crafts pour SpecialBlocks GameRegistry.addRecipe(new ItemStack(BlocksMod.xray_block, 1), new Object[] {"###", "#/#","###", '/', BlocksMod.adamantium_block, '#', Blocks.GLASS}); } public static void registerRenders() { //registerRender Adamantium registerRender(adamantium_block); registerRender(adamantium_ore); //registerRender Silver registerRender(silver_ore); registerRender(silver_block); //registerRender Aluminium registerRender(aluminium_ore); registerRender(aluminium_block); //registerRender Special registerRender(light_block); registerRender(xray_block); registerRender(bounce_pad_red); registerRender(bounce_pad_blue); registerRender(bounce_pad_green); } public static void registerRender(Block block) { Item item = Item.getItemFromBlock(block); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new net.minecraft.client.renderer.block.model.ModelResourceLocation(Reference.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory")); } }
Et ma class ItemsMod:
package fr.jules552.mod.init; import com.jcraft.jorbis.Block; import fr.jules552.mod.Reference; import fr.jules552.mod.init.Adamantium.ArmorAdamantium; import fr.jules552.mod.init.Adamantium.AxeAdamantium; import fr.jules552.mod.init.Adamantium.PickaxeAdamantium; import fr.jules552.mod.init.Adamantium.ShovelAdamantium; import fr.jules552.mod.init.Adamantium.ItemSword2; import fr.jules552.mod.init.Adamantium.SwordAdamantium; import fr.jules552.mod.init.Aluminium.ArmorAluminium; import fr.jules552.mod.init.Aluminium.AxeAluminium; import fr.jules552.mod.init.Aluminium.PickaxeAluminium; import fr.jules552.mod.init.Aluminium.ShovelAluminium; import fr.jules552.mod.init.Aluminium.SwordAluminium; import fr.jules552.mod.init.CreativesTabs.AdamantiumCreativeTabs; import fr.jules552.mod.init.Silver.ArmorSilver; import fr.jules552.mod.init.Silver.AxeSilver; import fr.jules552.mod.init.Silver.PickaxeSilver; import fr.jules552.mod.init.Silver.ShovelSilver; import fr.jules552.mod.init.Silver.SwordSilver; import net.minecraft.client.Minecraft; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.init.SoundEvents; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemArmor.ArmorMaterial; import net.minecraft.item.ItemRecord; import net.minecraft.item.ItemStack; import net.minecraft.item.Item.ToolMaterial; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.fml.common.registry.GameRegistry; public class ItemsMod { //Nouveaux Matériaux public static ToolMaterial AdamantiumPick = EnumHelper.addToolMaterial("AdamantiumPick", 3, 2002, 15.0F, 3.0F, 11); public static ToolMaterial AdamantiumSwo = EnumHelper.addToolMaterial("AdamantiumSwo", 3, 2002, 15.0F, 5.0F, 11); public static ToolMaterial AdamantiumSho = EnumHelper.addToolMaterial("AdamantiumSho", 3, 2002, 15.0F, 2.0F, 11); public static ToolMaterial AdamantiumAx = EnumHelper.addToolMaterial("AdamantiumAx", 3, 2002, 15.0F, 7.0F, 11); public static ArmorMaterial AdamantiumArmor = EnumHelper.addArmorMaterial("AdamantiumArmor", "AdamantiumArmor", 50, new int[]{4, 7, 10, 5}, 10, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 0); public static ArmorMaterial SilverArmor = EnumHelper.addArmorMaterial("SilverArmor", "SilverArmor", 15, new int[]{2, 4, 5, 3}, 18, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 0); public static ToolMaterial SilverPick = EnumHelper.addToolMaterial("SilverPick", 3, 196, 7.0F, 1.0F, 18); public static ToolMaterial SilverSwo = EnumHelper.addToolMaterial("SilverSwo", 3, 196, 15.0F, 1.5F, 18); public static ToolMaterial SilverSho = EnumHelper.addToolMaterial("SilverSho", 3, 196, 7.0F, 1.0F, 18); public static ToolMaterial SilverAx = EnumHelper.addToolMaterial("SilverAx", 3, 196, 5.0F, 1.0F, 18); public static ToolMaterial AluminiumPick = EnumHelper.addToolMaterial("AluminiumPick", 3, 225, 8.0F, 0.5F, 16); public static ToolMaterial AluminiumSwo = EnumHelper.addToolMaterial("AluminiumSwo", 3, 225, 15.0F, 1.0F, 16); public static ToolMaterial AluminiumSho = EnumHelper.addToolMaterial("AluminiumSho", 3, 225, 8.0F, 0.5F, 16); public static ToolMaterial AluminiumAx = EnumHelper.addToolMaterial("AluminiumAx", 3, 225, 6.0F, 0.5F, 16); public static ArmorMaterial AluminiumArmor = EnumHelper.addArmorMaterial("AluminiumArmor", "AluminiumArmor", 15, new int[]{2, 4, 4, 3}, 18, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 0); //CreativeTabs public static CreativeTabs tabCustomTab = new AdamantiumCreativeTabs(); //Les Items public static Item adamantium_ingot, adamantium_pickaxe, adamantium_sword, adamantium_shovel, adamantium_axe, adamantium_helmet, adamantium_chestplate, adamantium_leggings, adamantium_boots; public static Item silver_ingot, silver_helmet,silver_chestplate,silver_leggings,silver_boots, silver_pickaxe, silver_sword, silver_shovel, silver_axe; public static Item aluminium_ingot, aluminium_pickaxe, aluminium_sword, aluminium_shovel, aluminium_axe, aluminium_helmet, aluminium_chestplate, aluminium_leggings, aluminium_boots; public static void init() { //Adamantium adamantium_ingot = new Item().setUnlocalizedName("adamantium_ingot").setCreativeTab(ItemsMod.tabCustomTab); adamantium_pickaxe = new PickaxeAdamantium(AdamantiumPick).setUnlocalizedName("adamantium_pickaxe").setCreativeTab(ItemsMod.tabCustomTab); adamantium_sword = new SwordAdamantium(AdamantiumSwo, 0).setUnlocalizedName("adamantium_sword").setCreativeTab(ItemsMod.tabCustomTab); adamantium_shovel = new ShovelAdamantium(AdamantiumSho).setUnlocalizedName("adamantium_shovel").setCreativeTab(ItemsMod.tabCustomTab); adamantium_axe = new AxeAdamantium(AdamantiumAx).setUnlocalizedName("adamantium_axe").setCreativeTab(ItemsMod.tabCustomTab); adamantium_helmet = new ArmorAdamantium(AdamantiumArmor, EntityEquipmentSlot.HEAD, "adamantium_helmet").setUnlocalizedName("adamantium_helmet").setCreativeTab(ItemsMod.tabCustomTab); adamantium_chestplate = new ArmorAdamantium(AdamantiumArmor, EntityEquipmentSlot.CHEST, "adamantium_chestplate").setUnlocalizedName("adamantium_chestplate").setCreativeTab(ItemsMod.tabCustomTab); adamantium_leggings = new ArmorAdamantium(AdamantiumArmor, EntityEquipmentSlot.LEGS, "adamantium_leggings").setUnlocalizedName("adamantium_leggings").setCreativeTab(ItemsMod.tabCustomTab); adamantium_boots = new ArmorAdamantium(AdamantiumArmor, EntityEquipmentSlot.FEET, "adamantium_boots").setUnlocalizedName("adamantium_boots").setCreativeTab(ItemsMod.tabCustomTab); //Silver silver_ingot = new Item().setUnlocalizedName("silver_ingot").setCreativeTab(ItemsMod.tabCustomTab); silver_helmet = new ArmorSilver(SilverArmor, EntityEquipmentSlot.HEAD).setUnlocalizedName("silver_helmet").setCreativeTab(ItemsMod.tabCustomTab); silver_chestplate = new ArmorSilver(SilverArmor, EntityEquipmentSlot.CHEST).setUnlocalizedName("silver_chestplate").setCreativeTab(ItemsMod.tabCustomTab); silver_leggings = new ArmorSilver(SilverArmor, EntityEquipmentSlot.LEGS).setUnlocalizedName("silver_leggings").setCreativeTab(ItemsMod.tabCustomTab); silver_boots = new ArmorSilver(SilverArmor, EntityEquipmentSlot.FEET).setUnlocalizedName("silver_boots").setCreativeTab(ItemsMod.tabCustomTab); silver_pickaxe = new PickaxeSilver(SilverPick).setUnlocalizedName("silver_pickaxe").setCreativeTab(ItemsMod.tabCustomTab); silver_sword = new SwordSilver(SilverSwo, 0).setUnlocalizedName("silver_sword").setCreativeTab(ItemsMod.tabCustomTab); silver_shovel = new ShovelSilver(SilverSho).setUnlocalizedName("silver_shovel").setCreativeTab(ItemsMod.tabCustomTab); silver_axe = new AxeSilver(SilverAx).setUnlocalizedName("silver_axe").setCreativeTab(ItemsMod.tabCustomTab); //Aluminium aluminium_ingot = new Item().setUnlocalizedName("aluminium_ingot").setCreativeTab(ItemsMod.tabCustomTab); aluminium_pickaxe = new PickaxeAluminium(AluminiumPick).setUnlocalizedName("aluminium_pickaxe").setCreativeTab(ItemsMod.tabCustomTab); aluminium_sword = new SwordAluminium(AluminiumSwo, 0).setUnlocalizedName("aluminium_sword").setCreativeTab(ItemsMod.tabCustomTab); aluminium_shovel = new ShovelAluminium(AluminiumSho).setUnlocalizedName("aluminium_shovel").setCreativeTab(ItemsMod.tabCustomTab); aluminium_axe = new AxeAluminium(AluminiumAx).setUnlocalizedName("aluminium_axe").setCreativeTab(ItemsMod.tabCustomTab); aluminium_helmet = new ArmorAluminium(AluminiumArmor, EntityEquipmentSlot.HEAD).setUnlocalizedName("aluminium_helmet").setCreativeTab(ItemsMod.tabCustomTab); aluminium_chestplate = new ArmorAluminium(AluminiumArmor, EntityEquipmentSlot.CHEST).setUnlocalizedName("aluminium_chestplate").setCreativeTab(ItemsMod.tabCustomTab); aluminium_leggings = new ArmorAluminium(AluminiumArmor, EntityEquipmentSlot.LEGS).setUnlocalizedName("aluminium_leggings").setCreativeTab(ItemsMod.tabCustomTab); aluminium_boots = new ArmorAluminium(AluminiumArmor, EntityEquipmentSlot.FEET).setUnlocalizedName("aluminium_boots").setCreativeTab(ItemsMod.tabCustomTab); } public static void register() { //Items //GameRegistry pour Adamantium GameRegistry.register(adamantium_ingot.setRegistryName("adamantium_ingot")); GameRegistry.register(adamantium_pickaxe.setRegistryName("adamantium_pickaxe")); GameRegistry.register(adamantium_sword.setRegistryName("adamantium_sword")); GameRegistry.register(adamantium_shovel.setRegistryName("adamantium_shovel")); GameRegistry.register(adamantium_axe.setRegistryName("adamantium_axe")); GameRegistry.register(adamantium_helmet.setRegistryName("adamantium_helmet")); GameRegistry.register(adamantium_chestplate.setRegistryName("adamantium_chestplate")); GameRegistry.register(adamantium_leggings.setRegistryName("adamantium_leggings")); GameRegistry.register(adamantium_boots.setRegistryName("adamantium_boots")); //GameRegistry pour Silver GameRegistry.register(silver_ingot.setRegistryName("silver_ingot")); GameRegistry.register(silver_helmet.setRegistryName("silver_helmet")); GameRegistry.register(silver_chestplate.setRegistryName("silver_chestplate")); GameRegistry.register(silver_leggings.setRegistryName("silver_leggings")); GameRegistry.register(silver_boots.setRegistryName("silver_boots")); GameRegistry.register(silver_pickaxe.setRegistryName("silver_pickaxe")); GameRegistry.register(silver_sword.setRegistryName("silver_sword")); GameRegistry.register(silver_shovel.setRegistryName("silver_shovel")); GameRegistry.register(silver_axe.setRegistryName("silver_axe")); //Gameregistry Aluminium GameRegistry.register(aluminium_ingot.setRegistryName("aluminium_ingot")); GameRegistry.register(aluminium_pickaxe.setRegistryName("aluminium_pickaxe")); GameRegistry.register(aluminium_sword.setRegistryName("aluminium_sword")); GameRegistry.register(aluminium_shovel.setRegistryName("aluminium_shovel")); GameRegistry.register(aluminium_axe.setRegistryName("aluminium_axe")); GameRegistry.register(aluminium_helmet.setRegistryName("aluminium_helmet")); GameRegistry.register(aluminium_chestplate.setRegistryName("aluminium_chestplate")); GameRegistry.register(aluminium_leggings.setRegistryName("aluminium_leggings")); GameRegistry.register(aluminium_boots.setRegistryName("aluminium_boots")); //Crafts //Crafts pour Adamantium GameRegistry.addRecipe(new ItemStack(ItemsMod.adamantium_pickaxe, 1), new Object[] {"###", " / "," / ", '#', ItemsMod.adamantium_ingot, '/', Items.STICK}); GameRegistry.addRecipe(new ItemStack(ItemsMod.adamantium_sword, 1), new Object[] {" # ", " # "," / ", '#', ItemsMod.adamantium_ingot, '/', Items.STICK}); GameRegistry.addRecipe(new ItemStack(ItemsMod.adamantium_sword, 1), new Object[] {" #", " #"," /", '#', ItemsMod.adamantium_ingot, '/', Items.STICK}); GameRegistry.addRecipe(new ItemStack(ItemsMod.adamantium_sword, 1), new Object[] {"# ", "# ","/ ", '#', ItemsMod.adamantium_ingot, '/', Items.STICK}); GameRegistry.addRecipe(new ItemStack(ItemsMod.adamantium_axe, 1), new Object[] {"## ", "#/ "," / ", '#', ItemsMod.adamantium_ingot, '/', Items.STICK}); GameRegistry.addRecipe(new ItemStack(ItemsMod.adamantium_axe, 1), new Object[] {" ##", " /#"," / ", '#', ItemsMod.adamantium_ingot, '/', Items.STICK}); GameRegistry.addRecipe(new ItemStack(ItemsMod.adamantium_shovel, 1), new Object[] {" # ", " / "," / ", '#', ItemsMod.adamantium_ingot, '/', Items.STICK}); GameRegistry.addRecipe(new ItemStack(ItemsMod.adamantium_shovel, 1), new Object[] {" #", " /"," /", '#', ItemsMod.adamantium_ingot, '/', Items.STICK}); GameRegistry.addRecipe(new ItemStack(ItemsMod.adamantium_shovel, 1), new Object[] {"# ", "/ ","/ ", '#', ItemsMod.adamantium_ingot, '/', Items.STICK}); GameRegistry.addRecipe(new ItemStack(ItemsMod.adamantium_helmet, 1), new Object[] {"###", "# #"," ", '#', ItemsMod.adamantium_ingot}); GameRegistry.addRecipe(new ItemStack(ItemsMod.adamantium_helmet, 1), new Object[] {" ", "###","# #", '#', ItemsMod.adamantium_ingot}); GameRegistry.addRecipe(new ItemStack(ItemsMod.adamantium_chestplate, 1), new Object[] {"# #", "###","###", '#', ItemsMod.adamantium_ingot}); GameRegistry.addRecipe(new ItemStack(ItemsMod.adamantium_leggings, 1), new Object[] {"###", "# #","# #", '#', ItemsMod.adamantium_ingot}); GameRegistry.addRecipe(new ItemStack(ItemsMod.adamantium_boots, 1), new Object[] {"# #", "# #"," ", '#', ItemsMod.adamantium_ingot}); GameRegistry.addRecipe(new ItemStack(ItemsMod.adamantium_boots, 1), new Object[] {" ", "# #","# #", '#', ItemsMod.adamantium_ingot}); //Crafts pour Silver GameRegistry.addRecipe(new ItemStack(ItemsMod.silver_pickaxe, 1), new Object[] {"###", " / "," / ", '#', ItemsMod.silver_ingot, '/', Items.STICK}); GameRegistry.addRecipe(new ItemStack(ItemsMod.silver_sword, 1), new Object[] {" # ", " # "," / ", '#', ItemsMod.silver_ingot, '/', Items.STICK}); GameRegistry.addRecipe(new ItemStack(ItemsMod.silver_sword, 1), new Object[] {" #", " #"," /", '#', ItemsMod.silver_ingot, '/', Items.STICK}); GameRegistry.addRecipe(new ItemStack(ItemsMod.silver_sword, 1), new Object[] {"# ", "# ","/ ", '#', ItemsMod.silver_ingot, '/', Items.STICK}); GameRegistry.addRecipe(new ItemStack(ItemsMod.silver_axe, 1), new Object[] {"## ", "#/ "," / ", '#', ItemsMod.silver_ingot, '/', Items.STICK}); GameRegistry.addRecipe(new ItemStack(ItemsMod.silver_axe, 1), new Object[] {" ##", " /#"," / ", '#', ItemsMod.silver_ingot, '/', Items.STICK}); GameRegistry.addRecipe(new ItemStack(ItemsMod.silver_shovel, 1), new Object[] {" # ", " / "," / ", '#', ItemsMod.silver_ingot, '/', Items.STICK}); GameRegistry.addRecipe(new ItemStack(ItemsMod.silver_shovel, 1), new Object[] {" #", " /"," /", '#', ItemsMod.silver_ingot, '/', Items.STICK}); GameRegistry.addRecipe(new ItemStack(ItemsMod.silver_shovel, 1), new Object[] {"# ", "/ ","/ ", '#', ItemsMod.silver_ingot, '/', Items.STICK}); GameRegistry.addRecipe(new ItemStack(ItemsMod.silver_helmet, 1), new Object[] {"###", "# #"," ", '#', ItemsMod.silver_ingot}); GameRegistry.addRecipe(new ItemStack(ItemsMod.silver_helmet, 1), new Object[] {" ", "###","# #", '#', ItemsMod.silver_ingot}); GameRegistry.addRecipe(new ItemStack(ItemsMod.silver_chestplate, 1), new Object[] {"# #", "###","###", '#', ItemsMod.silver_ingot}); GameRegistry.addRecipe(new ItemStack(ItemsMod.silver_leggings, 1), new Object[] {"###", "# #","# #", '#', ItemsMod.silver_ingot}); GameRegistry.addRecipe(new ItemStack(ItemsMod.silver_boots, 1), new Object[] {"# #", "# #"," ", '#', ItemsMod.silver_ingot}); GameRegistry.addRecipe(new ItemStack(ItemsMod.silver_boots, 1), new Object[] {" ", "# #","# #", '#', ItemsMod.silver_ingot}); //Crafts pour Aluminium GameRegistry.addRecipe(new ItemStack(ItemsMod.aluminium_pickaxe, 1), new Object[] {"###", " / "," / ", '#', ItemsMod.aluminium_ingot, '/', Items.STICK}); GameRegistry.addRecipe(new ItemStack(ItemsMod.aluminium_sword, 1), new Object[] {" # ", " # "," / ", '#', ItemsMod.aluminium_ingot, '/', Items.STICK}); GameRegistry.addRecipe(new ItemStack(ItemsMod.aluminium_sword, 1), new Object[] {" #", " #"," /", '#', ItemsMod.aluminium_ingot, '/', Items.STICK}); GameRegistry.addRecipe(new ItemStack(ItemsMod.aluminium_sword, 1), new Object[] {"# ", "# ","/ ", '#', ItemsMod.aluminium_ingot, '/', Items.STICK}); GameRegistry.addRecipe(new ItemStack(ItemsMod.aluminium_axe, 1), new Object[] {"## ", "#/ "," / ", '#', ItemsMod.aluminium_ingot, '/', Items.STICK}); GameRegistry.addRecipe(new ItemStack(ItemsMod.aluminium_axe, 1), new Object[] {" ##", " /#"," / ", '#', ItemsMod.aluminium_ingot, '/', Items.STICK}); GameRegistry.addRecipe(new ItemStack(ItemsMod.aluminium_shovel, 1), new Object[] {" # ", " / "," / ", '#', ItemsMod.aluminium_ingot, '/', Items.STICK}); GameRegistry.addRecipe(new ItemStack(ItemsMod.aluminium_shovel, 1), new Object[] {" #", " /"," /", '#', ItemsMod.aluminium_ingot, '/', Items.STICK}); GameRegistry.addRecipe(new ItemStack(ItemsMod.aluminium_shovel, 1), new Object[] {"# ", "/ ","/ ", '#', ItemsMod.aluminium_ingot, '/', Items.STICK}); GameRegistry.addRecipe(new ItemStack(ItemsMod.aluminium_helmet, 1), new Object[] {"###", "# #"," ", '#', ItemsMod.aluminium_ingot}); GameRegistry.addRecipe(new ItemStack(ItemsMod.aluminium_helmet, 1), new Object[] {" ", "###","# #", '#', ItemsMod.aluminium_ingot}); GameRegistry.addRecipe(new ItemStack(ItemsMod.aluminium_chestplate, 1), new Object[] {"# #", "###","###", '#', ItemsMod.aluminium_ingot}); GameRegistry.addRecipe(new ItemStack(ItemsMod.aluminium_leggings, 1), new Object[] {"###", "# #","# #", '#', ItemsMod.aluminium_ingot}); GameRegistry.addRecipe(new ItemStack(ItemsMod.aluminium_boots, 1), new Object[] {"# #", "# #"," ", '#', ItemsMod.aluminium_ingot}); GameRegistry.addRecipe(new ItemStack(ItemsMod.aluminium_boots, 1), new Object[] {" ", "# #","# #", '#', ItemsMod.aluminium_ingot}); } public static void registerRenders() { //Renders Adamantium registerRender(adamantium_ingot); registerRender(adamantium_pickaxe); registerRender(adamantium_sword); registerRender(adamantium_shovel); registerRender(adamantium_axe); registerRender(adamantium_helmet); registerRender(adamantium_chestplate); registerRender(adamantium_leggings); registerRender(adamantium_boots); //Renders Silver registerRender(silver_ingot); registerRender(silver_helmet); registerRender(silver_chestplate); registerRender(silver_leggings); registerRender(silver_boots); registerRender(silver_pickaxe); registerRender(silver_sword); registerRender(silver_shovel); registerRender(silver_axe); //Renders Aluminium registerRender(aluminium_ingot); registerRender(aluminium_pickaxe); registerRender(aluminium_sword); registerRender(aluminium_shovel); registerRender(aluminium_axe); registerRender(aluminium_helmet); registerRender(aluminium_chestplate); registerRender(aluminium_leggings); registerRender(aluminium_boots); } public static void registerRender(Item item) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new net.minecraft.client.renderer.block.model.ModelResourceLocation(Reference.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory")); } }
Un petit coup de pouce avec juste un petit exemple serait le bienvenu, et n’hésiter pas à apporter quelques explications avec que je ne recopie pas bêtement ^^
Merci d’avance,
jules552 -
Salut !
Pile quand je reviens sur le forum je tombe sur ça . Je suis donc très heureux de te proposer mon tutoriel qui doit aussi fonctionner pour la 1.11 : https://www.minecraftforgefrance.fr/showthread.php?tid=3718 .
J’espère qu’il te sera utile ! -
@‘TheRedColossus’:
Salut !
Pile quand je reviens sur le forum je tombe sur ça . Je suis donc très heureux de te proposer mon tutoriel qui doit aussi fonctionner pour la 1.11 : https://www.minecraftforgefrance.fr/showthread.php?tid=3718 .
J’espère qu’il te sera utile !Merci, mais il me reste quelques petits problèmes
déjà pourrais-tu me valider si j’ai bien refait ma classe BlocksMod s’il te plait ?package fr.jules552.mod.init; import net.minecraft.block.Block; import net.minecraft.block.material.MapColor; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemStack; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import Blocks.AdamantiumMinerai; import Blocks.AluminiumMinerai; import Blocks.BlockSilver; import Blocks.BlockXray; import Blocks.LumineuxBlock; import Blocks.PadBounceBlue; import Blocks.PadBounceGreen; import Blocks.PadBounceRed; import Blocks.SilverMinerai; import fr.jules552.mod.Reference; public class BlocksMod { public static final Block ADAMANTIUM_BLOCK = new AdamantiumMinerai(Material.IRON).setRegistryName("adamantium_block").setCreativeTab(ItemsMod.tabCustomTab).setHardness(5.0F); public static final Block ADAMANTIUM_ORE = new AdamantiumMinerai(Material.ROCK).setRegistryName("adamantium_ore").setCreativeTab(ItemsMod.tabCustomTab).setHardness(5.0F); public static final Block SILVER_BLOCK = new SilverMinerai(Material.IRON).setRegistryName("silver_block").setCreativeTab(ItemsMod.tabCustomTab).setHardness(5.0F); public static final Block SILVER_ORE = new SilverMinerai(Material.ROCK).setRegistryName("silver_ore").setCreativeTab(ItemsMod.tabCustomTab).setHardness(5.0F); public static final Block ALUMINIUM_BLOCK = new AluminiumMinerai(Material.ROCK).setRegistryName("aluminium_block").setCreativeTab(ItemsMod.tabCustomTab).setHardness(5.0F); public static final Block ALUMINIUM_ORE = new AluminiumMinerai(Material.ROCK).setRegistryName("aluminium_ore").setCreativeTab(ItemsMod.tabCustomTab).setHardness(5.0F); public static final Block LIGHT_BLOCK = new LumineuxBlock(Material.BARRIER).setRegistryName("light_block").setCreativeTab(ItemsMod.tabCustomTab).setBlockUnbreakable().setLightLevel(1.0F); public static final Block XRAY_BLOCK = new LumineuxBlock(Material.GLASS).setRegistryName("xray_block").setCreativeTab(ItemsMod.tabCustomTab).setHardness(5.0F); public static final Block BOUNCE_PAD_RED = new LumineuxBlock(Material.ROCK).setRegistryName("bounce_pad_red").setCreativeTab(ItemsMod.tabCustomTab).setHardness(0.0F); public static final Block BOUNCE_PAD_BLUE = new LumineuxBlock(Material.ROCK).setRegistryName("bounce_pad_blue").setCreativeTab(ItemsMod.tabCustomTab).setHardness(0.0F); public static final Block BOUNCE_PAD_GREEN = new LumineuxBlock(Material.ROCK).setRegistryName("bounce_pad_green").setCreativeTab(ItemsMod.tabCustomTab).setHardness(0.0F); public static void registerBlocks (){ GameRegistry.register (ADAMANTIUM_BLOCK); GameRegistry.register (ADAMANTIUM_ORE); GameRegistry.register (SILVER_BLOCK); GameRegistry.register (SILVER_ORE); GameRegistry.register (ALUMINIUM_BLOCK); GameRegistry.register (ALUMINIUM_ORE); GameRegistry.register (LIGHT_BLOCK); GameRegistry.register (XRAY_BLOCK); GameRegistry.register (BOUNCE_PAD_RED); GameRegistry.register (BOUNCE_PAD_BLUE); GameRegistry.register (BOUNCE_PAD_GREEN); } public static void register() { //Les Crafts //Crafts pour Adamantium GameRegistry.addSmelting(BlocksMod.ADAMANTIUM_ORE, new ItemStack(ItemsMod.adamantium_ingot), 1.8F); GameRegistry.addRecipe(new ItemStack(BlocksMod.ADAMANTIUM_BLOCK, 1), new Object[] {"###", "###","###", '#', ItemsMod.adamantium_ingot}); GameRegistry.addShapelessRecipe(new ItemStack(ItemsMod.adamantium_ingot,9), new ItemStack(BlocksMod.ADAMANTIUM_BLOCK)); //Crafts pour Silver GameRegistry.addSmelting(BlocksMod.SILVER_ORE, new ItemStack(ItemsMod.silver_ingot), 0.8F); GameRegistry.addRecipe(new ItemStack(BlocksMod.SILVER_BLOCK, 1), new Object[] {"###", "###","###", '#', ItemsMod.silver_ingot}); GameRegistry.addShapelessRecipe(new ItemStack(ItemsMod.silver_ingot,9), new ItemStack(BlocksMod.SILVER_BLOCK)); //Crafts pour Aluminium GameRegistry.addSmelting(BlocksMod.ALUMINIUM_ORE, new ItemStack(ItemsMod.aluminium_ingot), 0.7F); GameRegistry.addRecipe(new ItemStack(BlocksMod.ALUMINIUM_BLOCK, 1), new Object[] {"###", "###","###", '#', ItemsMod.aluminium_ingot}); GameRegistry.addShapelessRecipe(new ItemStack(ItemsMod.aluminium_ingot,9), new ItemStack(BlocksMod.ALUMINIUM_BLOCK)); //Crafts pour SpecialBlocks GameRegistry.addRecipe(new ItemStack(BlocksMod.XRAY_BLOCK, 1), new Object[] {"###", "#/#","###", '/', BlocksMod.ADAMANTIUM_BLOCK, '#', Blocks.GLASS}); } @SideOnly (Side.CLIENT) public static void registerItemBlockModels (){ ModelLoader.setCustomModelResourceLocation (Item.getItemFromBlock (ADAMANTIUM_BLOCK), 0, new ModelResourceLocation (Reference.MOD_ID+":adamantium_block", "inventory")); ModelLoader.setCustomModelResourceLocation (Item.getItemFromBlock (ADAMANTIUM_ORE), 0, new ModelResourceLocation (Reference.MOD_ID+":adamantium_ore", "inventory")); ModelLoader.setCustomModelResourceLocation (Item.getItemFromBlock (SILVER_BLOCK), 0, new ModelResourceLocation (Reference.MOD_ID+":silver_block", "inventory")); ModelLoader.setCustomModelResourceLocation (Item.getItemFromBlock (SILVER_ORE), 0, new ModelResourceLocation (Reference.MOD_ID+":silver_ore", "inventory")); ModelLoader.setCustomModelResourceLocation (Item.getItemFromBlock (ALUMINIUM_BLOCK), 0, new ModelResourceLocation (Reference.MOD_ID+":aluminium_block", "inventory")); ModelLoader.setCustomModelResourceLocation (Item.getItemFromBlock (ALUMINIUM_ORE), 0, new ModelResourceLocation (Reference.MOD_ID+":aluminium_ore", "inventory")); ModelLoader.setCustomModelResourceLocation (Item.getItemFromBlock (LIGHT_BLOCK), 0, new ModelResourceLocation (Reference.MOD_ID+":light_block", "inventory")); ModelLoader.setCustomModelResourceLocation (Item.getItemFromBlock (XRAY_BLOCK), 0, new ModelResourceLocation (Reference.MOD_ID+":xray_block", "inventory")); ModelLoader.setCustomModelResourceLocation (Item.getItemFromBlock (BOUNCE_PAD_RED), 0, new ModelResourceLocation (Reference.MOD_ID+":bounce_pad_red", "inventory")); ModelLoader.setCustomModelResourceLocation (Item.getItemFromBlock (BOUNCE_PAD_BLUE), 0, new ModelResourceLocation (Reference.MOD_ID+":bounce_pad_blue", "inventory")); ModelLoader.setCustomModelResourceLocation (Item.getItemFromBlock (BOUNCE_PAD_GREEN), 0, new ModelResourceLocation (Reference.MOD_ID+":bounce_pad_green", "inventory")); } private static void registerItemBlock (Block block){ ItemBlock adamantium_ItemBlock = new ItemBlock (ADAMANTIUM_BLOCK); adamantium_ItemBlock.setRegistryName (ADAMANTIUM_BLOCK.getRegistryName()); GameRegistry.register (adamantium_ItemBlock); ItemBlock adamantium_ItemOre = new ItemBlock (ADAMANTIUM_ORE); adamantium_ItemOre.setRegistryName (ADAMANTIUM_ORE.getRegistryName()); GameRegistry.register (adamantium_ItemOre); ItemBlock silver_ItemBlock = new ItemBlock (SILVER_BLOCK); silver_ItemBlock.setRegistryName (SILVER_BLOCK.getRegistryName()); GameRegistry.register (silver_ItemBlock); ItemBlock silver_ItemOre = new ItemBlock (SILVER_ORE); silver_ItemOre.setRegistryName (SILVER_ORE.getRegistryName()); GameRegistry.register (silver_ItemOre); ItemBlock aluminium_ItemBlock = new ItemBlock (ALUMINIUM_BLOCK); aluminium_ItemBlock.setRegistryName (ALUMINIUM_BLOCK.getRegistryName()); GameRegistry.register (aluminium_ItemBlock); ItemBlock aluminium_ItemOre = new ItemBlock (ALUMINIUM_ORE); aluminium_ItemOre.setRegistryName (ALUMINIUM_ORE.getRegistryName()); GameRegistry.register (aluminium_ItemOre); ItemBlock light_ItemBlock = new ItemBlock (LIGHT_BLOCK); light_ItemBlock.setRegistryName (LIGHT_BLOCK.getRegistryName()); GameRegistry.register (light_ItemBlock); ItemBlock xray_ItemBlock = new ItemBlock (XRAY_BLOCK); xray_ItemBlock.setRegistryName (XRAY_BLOCK.getRegistryName()); GameRegistry.register (xray_ItemBlock); ItemBlock bounce_pad_ItemBlockRed = new ItemBlock (BOUNCE_PAD_RED); bounce_pad_ItemBlockRed.setRegistryName (BOUNCE_PAD_RED.getRegistryName()); GameRegistry.register (bounce_pad_ItemBlockRed); ItemBlock bounce_pad_ItemBlockBlue = new ItemBlock (BOUNCE_PAD_BLUE); bounce_pad_ItemBlockBlue.setRegistryName (BOUNCE_PAD_BLUE.getRegistryName()); GameRegistry.register (bounce_pad_ItemBlockBlue); ItemBlock bounce_pad_ItemBlockGreen = new ItemBlock (BOUNCE_PAD_GREEN); bounce_pad_ItemBlockGreen.setRegistryName (BOUNCE_PAD_GREEN.getRegistryName()); GameRegistry.register (bounce_pad_ItemBlockGreen); } }
Seconde question, je met quoi du coup dans ma classe ClientProxy?
package fr.jules552.mod.proxy; import fr.jules552.mod.init.ItemsMod; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; import fr.jules552.mod.init.BlocksMod; public class ClientProxy extends CommonProxy { @Override public void registerRenders() { ItemsMod.registerRenders(); BlocksMod.register(); } }
De même pour ma class Adamantium ? :
package fr.jules552.mod; import fr.jules552.mod.WorldGeneration.GenerationHelper; import fr.jules552.mod.init.BlocksMod; import fr.jules552.mod.init.ItemsMod; import fr.jules552.mod.proxy.CommonProxy; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.oredict.OreDictionary; @Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.MOD_VERSION) public class Adamantium { @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS) public static CommonProxy proxy; @EventHandler public void preInit(FMLPreInitializationEvent event) { ItemsMod.init(); ItemsMod.register(); BlocksMod.register(); // Système de Générération OreDictionary.registerOre("AdamantiumOre", new ItemStack(BlocksMod.ADAMANTIUM_ORE)); OreDictionary.registerOre("SilverOre", new ItemStack(BlocksMod.SILVER_ORE)); OreDictionary.registerOre("AluminiumOre", new ItemStack(BlocksMod.ALUMINIUM_ORE)); GameRegistry.registerWorldGenerator(new GenerationHelper(), 2); } @EventHandler public void init(FMLInitializationEvent event) { proxy.registerRenders(); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } }
Merci encore pour ton tutoriel très complet ^^
-
GameRegistry.register(new ItemBlock(tonBlock), tonBlock.getRegistryName());
-
@‘robin4002’:
GameRegistry.register(new ItemBlock(tonBlock), tonBlock.getRegistryName());
Merci, cette fois-ci les items sont bien générés mais reste 2 problèmes, les items s’appellent tous “till.null.name” (même si l’ID est bon avec adamantium:…) et aucune texture en conséquent n’est appliqué, de où pourrai venir le problème ?
-
Tes proxis sont mal gérés j’ai l’impression. Toutes les preinit, init et postinit doivent être gérés dans les proxis. La classe du mod redirige juste vers le bon proxi. Essaye de revoir les tutos de mff.
-
@‘TheRedColossus’:
Tes proxis sont mal gérés j’ai l’impression. Toutes les preinit, init et postinit doivent être gérés dans les proxis. La classe du mod redirige juste vers le bon proxi. Essaye de revoir les tutos de mff.
Surement, Ils fonctionnaient très bien avant mais bon avec cette update… le problème c’est que j’utilise absolument pas les même méthode de rangement etc dans le code et du coup je suis un peu perdu avec les tutoriels… et j’ai franchement pas envie de tout réécrir, je pense qu’il y a un problème à fixé dans tous ce qui est preInit, init et postinit effectivement mais le problème c’est de savoir où…
tu n’aurais pas un exemple à me montrer de la classe ou tu gères tout ça? pour m’en inspirer
-
Le proxi commun enregistre un peu tous sauf les textures et les modèles.
Le proxi server hérite du commun donc il fait la même chose.
Pareil que le proxi client : il hérite du commun donc il fait la même chose que le commun mais en plus il va gérer les textures et les modèles. Ce qui est logique parceque le client s’occupe de l’affichage.
-
@‘TheRedColossus’:
Le proxi commun enregistre un peu tous sauf les textures et les modèles.
Le proxi server hérite du commun donc il fait la même chose.
Pareil que le proxi client : il hérite du commun donc il fait la même chose que le commun mais en plus il va gérer les textures et les modèles. Ce qui est logique parceque le client s’occupe de l’affichage.
Sans être méchant ça m’aide pas beaucoup, quand je regarde le tutoriel que tu m’as envoyé quasiment tout est différent et mis à des places différents ou ne ressemblant pas vraiment à ce que j’ai. Je suis un peu bloqué là…
-
Bien sûr que j’ai un exemple à te montrer je t’envoie ça demain 18h ou 7h si j’ai le temps parceque là je suis sur mon téléphone. C’est super galère :@ .
-
Si tu veux tu m’envoie ton skype par mail ou MP et demain soir je me ferai un plaisir de tous t’expliquer.
-
@‘TheRedColossus’:
Bien sûr que j’ai un exemple à te montrer je t’envoie ça demain 18h ou 7h si j’ai le temps parceque là je suis sur mon téléphone. C’est super galère :@ .
Je comprend, c’est quand même sympa de ta part de m’avoir aider, ne t’inquiète pas après ça presse pas ^^ , tant que ça m’évite de devoir réecrir le mod en entier
J’ai juste une question, pourquoi LexManos a modifié le fonctionnement en faites ? Il y a un vrai intérêt technique derrière ou ? Si quelqu’un pouvait me répondre la dessus ça serait sympa aussi
Et bien alors à demain TheRedColossus et Merci encore de ton aide
-
Le registre a été réécrit avec un code plus efficace.
Lorsqu’il y a changement dans forge c’est toujours pour améliorer, pas juste pour casser les pieds des moddeurs.