Bonjour voila je viens de creer mon petit mode mais j’aimerait pouvoir réparer les armures et outils a partir du minerai mais je n’arrive a faire cela que celle a partir du quel j’ai créer le minerai. C’est a dire j’aimerait pouvoir réparer mon armure et mes outils en émeraude mais je ne trouve pas comment faire. Voici mon code
Pour ma classe principale :
package fr.volario.mod.common;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.EnumHelper;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import fr.volario.mod.proxy.CommonProxy;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.block.Block;
import cpw.mods.fml.common.registry.GameRegistry;
@Mod(modid = "modemerald", name = "ModEmerald", version = "1.0.0")
public class ModEmerald
{
@Instance("ModEmerald")
public static ModEmerald Instance;
public static final String MODID = "ModEmerald";
@SidedProxy(clientSide = "fr.volario.mod.proxy.ClientProxy", serverSide = "fr.volario.mod.proxy.CommonProxy")
public static CommonProxy proxy;
public static Item Sapphire, Ruby, helmetEmerald, chestPlateEmerald, leggingsEmerald, bootsEmerald, helmetRuby, chestPlateRuby, leggingsRuby, bootsRuby, helmetSapphire, chestPlateSapphire, bootsSapphire, leggingsSapphire;
public static Item HoeRuby, HoeSapphire, HoeEmerald;
public static Item ShovelRuby, ShovelSapphire, ShovelEmerald;
public static Item AxeRuby, AxeSapphire, AxeEmerald;
public static Item PickAxeRuby, PickAxeSapphire, PickAxeEmerald;
public static Item SwordRuby, SwordSapphire, SwordEmerald;
public static EnumToolMaterial toolEmerald = EnumHelper.addToolMaterial("toolEmerald", 3, 2000, 13.0F, 4.0F, 15);
public static EnumToolMaterial toolRuby = EnumHelper.addToolMaterial("toolRuby", 3, 2500, 18.0F, 6.0F, 15);
public static EnumToolMaterial toolSapphire = EnumHelper.addToolMaterial("toolSapphire", 3, 3000, 23.0F, 8.0F, 15);
public static EnumArmorMaterial ItemEmeraldArmor = EnumHelper.addArmorMaterial("armorEmerald", 35, new int[] {4, 9, 7, 4}, 10);
public static EnumArmorMaterial ItemRubyArmor = EnumHelper.addArmorMaterial("armorRuby", 35, new int[] {5, 10, 8, 5}, 10);
public static EnumArmorMaterial ItemSapphireArmor = EnumHelper.addArmorMaterial("armorSapphire", 35, new int[] {6, 11, 9, 6}, 10);
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
proxy.registerRender();
}
@EventHandler
public void init(FMLInitializationEvent event)
{
Sapphire = new Sapphire(10015)
.setUnlocalizedName("Sapphire")
.setTextureName(ModEmerald.MODID + ":Sapphire")
.setCreativeTab(CreativeTabs.tabMaterials);
Ruby = new Ruby(10014)
.setUnlocalizedName("Ruby")
.setTextureName(ModEmerald.MODID + ":Ruby")
.setCreativeTab(CreativeTabs.tabMaterials);
HoeRuby = new HoeRuby(10016, toolRuby)
.setUnlocalizedName("HoeRuby")
.setTextureName(ModEmerald.MODID + ":HoeRuby")
.setCreativeTab(CreativeTabs.tabTools);
HoeEmerald = new HoeEmerald(10017, toolEmerald)
.setUnlocalizedName("HoeEmerald")
.setTextureName(ModEmerald.MODID + ":HoeEmerald")
.setCreativeTab(CreativeTabs.tabTools);
HoeSapphire = new HoeSapphire(10018, toolSapphire)
.setUnlocalizedName("HoeSapphire")
.setTextureName(ModEmerald.MODID + ":HoeSapphire")
.setCreativeTab(CreativeTabs.tabTools);
AxeRuby = new AxeRuby(10019, toolRuby)
.setUnlocalizedName("AxeRuby")
.setTextureName(ModEmerald.MODID + ":AxeRuby")
.setCreativeTab(CreativeTabs.tabTools);
AxeEmerald = new AxeEmerald(10020, toolEmerald)
.setUnlocalizedName("AxeEmerald")
.setTextureName(ModEmerald.MODID + ":AxeEmerald")
.setCreativeTab(CreativeTabs.tabTools);
AxeSapphire = new AxeSapphire(10021, toolSapphire)
.setUnlocalizedName("AxeSapphire")
.setTextureName(ModEmerald.MODID + ":AxeSapphire")
.setCreativeTab(CreativeTabs.tabTools);
ShovelRuby = new ShovelRuby(10022, toolRuby)
.setUnlocalizedName("ShovelRuby")
.setTextureName(ModEmerald.MODID + ":ShovelRuby")
.setCreativeTab(CreativeTabs.tabTools);
ShovelEmerald = new ShovelEmerald(10023, toolEmerald)
.setUnlocalizedName("ShovelEmerald")
.setTextureName(ModEmerald.MODID + ":ShovelEmerald")
.setCreativeTab(CreativeTabs.tabTools);
ShovelSapphire = new ShovelSapphire(10024, toolSapphire)
.setUnlocalizedName("ShovelSapphire")
.setTextureName(ModEmerald.MODID + ":ShovelSapphire")
.setCreativeTab(CreativeTabs.tabTools);
PickAxeRuby = new PickAxeRuby(10025, toolRuby)
.setUnlocalizedName("PickAxeRuby")
.setTextureName(ModEmerald.MODID + ":PickAxeRuby")
.setCreativeTab(CreativeTabs.tabTools);
PickAxeEmerald = new PickAxeEmerald(10026, toolEmerald)
.setUnlocalizedName("PickAxeEmerald")
.setTextureName(ModEmerald.MODID + ":PickAxeEmerald")
.setCreativeTab(CreativeTabs.tabTools);
PickAxeSapphire = new PickAxeSapphire(10027, toolSapphire)
.setUnlocalizedName("PickAxeSapphire")
.setTextureName(ModEmerald.MODID + ":PickAxeSapphire")
.setCreativeTab(CreativeTabs.tabTools);
SwordRuby = new SwordRuby(10028, toolRuby)
.setUnlocalizedName("SwordRuby")
.setTextureName(ModEmerald.MODID + ":SwordRuby")
.setCreativeTab(CreativeTabs.tabCombat);
SwordEmerald = new SwordEmerald(10029, toolEmerald)
.setUnlocalizedName("SwordEmerald")
.setTextureName(ModEmerald.MODID + ":SwordEmerald")
.setCreativeTab(CreativeTabs.tabCombat);
SwordSapphire = new SwordSapphire(10030, toolSapphire)
.setUnlocalizedName("SwordSapphire")
.setTextureName(ModEmerald.MODID + ":SwordSapphire")
.setCreativeTab(CreativeTabs.tabCombat);
helmetEmerald = new EmeraldArmor(12002, ItemEmeraldArmor, 0,0)
.setUnlocalizedName("EmeraldHelmet")
.setTextureName("modemerald:EmeraldHelmet");
chestPlateEmerald = new EmeraldArmor(12003, ItemEmeraldArmor, 0, 1)
.setUnlocalizedName("EmeraldChestPlate")
.setTextureName("modemerald:EmeraldChestplate");
leggingsEmerald = new EmeraldArmor(12004, ItemEmeraldArmor, 0, 2)
.setUnlocalizedName("EmeraldLeggings")
.setTextureName("modemerald:EmeraldLeggings");
bootsEmerald = new EmeraldArmor(12005, ItemEmeraldArmor, 0, 3)
.setUnlocalizedName("EmeraldBoots")
.setTextureName("modemerald:EmeraldBoots");
helmetRuby = new RubyArmor(12006, ItemRubyArmor, 0,0)
.setUnlocalizedName("RubyHelmet")
.setTextureName("modemerald:RubyHelmet");
chestPlateRuby = new RubyArmor(12007, ItemRubyArmor, 0, 1)
.setUnlocalizedName("RubyChestPlate")
.setTextureName("modemerald:RubyChestplate");
leggingsRuby = new RubyArmor(12008, ItemRubyArmor, 0, 2)
.setUnlocalizedName("RubyLeggings")
.setTextureName("modemerald:RubyLeggings");
bootsRuby = new RubyArmor(12009, ItemRubyArmor, 0, 3)
.setUnlocalizedName("RubyBoots")
.setTextureName("modemerald:RubyBoots");
helmetSapphire = new SapphireArmor(12010, ItemSapphireArmor, 0,0)
.setUnlocalizedName("SapphireHelmet")
.setTextureName("modemerald:SapphireHelmet");
chestPlateSapphire = new SapphireArmor(12011, ItemSapphireArmor, 0, 1)
.setUnlocalizedName("SapphireChestPlate")
.setTextureName("modemerald:SapphireChestplate");
leggingsSapphire = new SapphireArmor(12012, ItemSapphireArmor, 0, 2)
.setUnlocalizedName("SapphireLeggings")
.setTextureName("modemerald:SapphireLeggings");
bootsSapphire = new SapphireArmor(12013, ItemSapphireArmor, 0, 3)
.setUnlocalizedName("SapphireBoots")
.setTextureName("modemerald:SapphireBoots");
GameRegistry.registerItem(AxeEmerald, "AxeEmerald");
GameRegistry.registerItem(AxeRuby, "AxeRuby");
GameRegistry.registerItem(AxeSapphire, "AxeSapphire");
GameRegistry.registerItem(ShovelEmerald, "ShovelEmerald");
GameRegistry.registerItem(ShovelRuby, "ShovelRuby");
GameRegistry.registerItem(ShovelSapphire, "ShovelSapphire");
GameRegistry.registerItem(PickAxeEmerald, "PickAxeEmerald");
GameRegistry.registerItem(PickAxeRuby, "PickAxeRuby");
GameRegistry.registerItem(PickAxeSapphire, "PickAxeSapphire");
GameRegistry.registerItem(HoeEmerald, "HoeEmerald");
GameRegistry.registerItem(HoeRuby, "HoeRuby");
GameRegistry.registerItem(HoeSapphire, "HoeSapphire");
GameRegistry.registerItem(Ruby, "Ruby");
GameRegistry.registerItem(Sapphire, "Sapphire");
GameRegistry.addRecipe(new ItemStack(helmetEmerald), new Object[]{"XXX", "X X", 'X', Item.emerald,
});
GameRegistry.addRecipe(new ItemStack(chestPlateEmerald), new Object[]{"X X", "XXX", "XXX", 'X', Item.emerald,
});
GameRegistry.addRecipe(new ItemStack(leggingsEmerald), new Object[]{"XXX", "X X", "X X", 'X', Item.emerald,
});
GameRegistry.addRecipe(new ItemStack(bootsEmerald), new Object[]{"X X", "X X", 'X', Item.emerald,
});
GameRegistry.addRecipe(new ItemStack(PickAxeEmerald), new Object[]{"XXX", " S ", " S ", 'X', Item.emerald, 'S', Item.stick
});
GameRegistry.addRecipe(new ItemStack(SwordEmerald), new Object[]{"X", "X", "S", 'X', Item.emerald, 'S', Item.stick
});
GameRegistry.addRecipe(new ItemStack(HoeEmerald), new Object[]{"XX", " #", " #", 'X', Item.emerald, '#', Item.stick
});
GameRegistry.addRecipe(new ItemStack(ShovelEmerald), new Object[]{"X", "#", "#", 'X', Item.emerald, '#', Item.stick
});
GameRegistry.addRecipe(new ItemStack(AxeEmerald), new Object[]{"XX", "X#", " #", 'X', Item.emerald, '#', Item.stick
});
GameRegistry.addRecipe(new ItemStack(helmetRuby), new Object[]{"XXX", "X X", 'X', Ruby,
});
GameRegistry.addRecipe(new ItemStack(chestPlateRuby), new Object[]{"X X", "XXX", "XXX", 'X', Ruby,
});
GameRegistry.addRecipe(new ItemStack(leggingsRuby), new Object[]{"XXX", "X X", "X X", 'X', Ruby,
});
GameRegistry.addRecipe(new ItemStack(bootsRuby), new Object[]{"X X", "X X", 'X', Ruby,
});
GameRegistry.addRecipe(new ItemStack(PickAxeRuby), new Object[]{"XXX", " S ", " S ", 'X', Ruby, 'S', Item.stick
});
GameRegistry.addRecipe(new ItemStack(SwordRuby), new Object[]{"X", "X", "S", 'X', Ruby, 'S', Item.stick
});
GameRegistry.addRecipe(new ItemStack(HoeRuby), new Object[]{"XX", " #", " #", 'X', Ruby, '#', Item.stick
});
GameRegistry.addRecipe(new ItemStack(ShovelRuby), new Object[]{"X", "#", "#", 'X', Ruby, '#', Item.stick
});
GameRegistry.addRecipe(new ItemStack(AxeRuby), new Object[]{"XX", "X#", " #", 'X', Ruby, '#', Item.stick
});
GameRegistry.addRecipe(new ItemStack(helmetSapphire), new Object[]{"XXX", "X X", 'X', Sapphire,
});
GameRegistry.addRecipe(new ItemStack(chestPlateSapphire), new Object[]{"X X", "XXX", "XXX", 'X', Sapphire,
});
GameRegistry.addRecipe(new ItemStack(leggingsSapphire), new Object[]{"XXX", "X X", "X X", 'X', Sapphire,
});
GameRegistry.addRecipe(new ItemStack(bootsSapphire), new Object[]{"X X", "X X", 'X', Sapphire,
});
GameRegistry.addRecipe(new ItemStack(PickAxeSapphire), new Object[]{"XXX", " S ", " S ", 'X', Sapphire, 'S', Item.stick
});
GameRegistry.addRecipe(new ItemStack(SwordSapphire), new Object[]{"X", "X", "S", 'X', Sapphire, 'S', Item.stick
});
GameRegistry.addRecipe(new ItemStack(HoeSapphire), new Object[]{"XX", " #", " #", 'X', Sapphire, '#', Item.stick
});
GameRegistry.addRecipe(new ItemStack(ShovelSapphire), new Object[]{"X", "#", "#", 'X', Sapphire, '#', Item.stick
});
GameRegistry.addRecipe(new ItemStack(AxeSapphire), new Object[]{"XX", "X#", " #", 'X', Sapphire, '#', Item.stick
});
}
private void setCreativeTab(CreativeTabs tabcombat) {
// TODO Auto-generated method stub
}
@EventHandler
public void postInit(FMLPostInitializationEvent event)
{
}
}
Et pour ma class Armure Emeraude
package fr.volario.mod.common;
import net.minecraft.item.ItemArmor;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class EmeraldArmor extends ItemArmor
{
public EmeraldArmor(int id, EnumArmorMaterial armorMaterial, int type, int layer)
{
super(id, armorMaterial, type, layer);
}
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
{
if(slot == 2)
{
return ModEmerald.MODID + ":textures/models/armor/armoremerald_layer_1.png";
}
return ModEmerald.MODID + ":textures/models/armor/armoremerald_layer_2.png";
}
public boolean getIsRepairable(ItemStack input, ItemStack repair)
{
if(repair.getItem() == ModEmerald.item.Emerald)
{
return true;
}
return false;
}
}
Et la class d’un de mes outils en émeraude :
package fr.volario.mod.common;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
public class AxeEmerald extends ItemAxe
{
public AxeEmerald(int id, EnumToolMaterial toolMaterial)
{
super(id, toolMaterial);
}
public boolean getIsRepairable(ItemStack input, ItemStack repair)
{
if(repair.getItem() == ModEmerald.item.emerald)
{
return true;
}
return false;
}
}