Créer une armure
-
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; } } -
public boolean getIsRepairable(ItemStack input, ItemStack repair) { if(repair.getItem() == Item.emerald) { return true; } return false; }Par contre comme tu codes en 1.6.4, ça serait mieux de poster dans le tutoriel 1.6.4 et non dans le tutoriel 1.7.x
-
Merci bien de votre réponse
-
Bonsoir j’ai éssayé d’appliquer un effet de potion sur mes armures mais il ne fonctionne pas et je ne comprends pas pourquoi pouvez vous m’aider s’il vous plait ?
Voici la classe de mon armure :package com.phoenixarena.phoenix.common; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; public class ItemAdamantiumArmor extends ItemArmor { public ItemAdamantiumArmor(ArmorMaterial material, int type) { super(material ,0 ,type); } public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { if(stack.getItem()== Phoenix.adamantiumLeggings) { return Phoenix.MODID + ":textures/models/armor/adamantium_layer_2.png"; } return Phoenix.MODID + ":textures/models/armor/adamantium_layer_1.png"; } //Reparation public boolean getIsRepairable(ItemStack input, ItemStack repair) { if(repair.getItem() == Phoenix.adamantiumPowder) { return true; } return false; } //EFFET SPECIAL : Vitesse public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 20, 0)); } }Merci d’avance

-
Tu es en quel version ? 1.7 ou 1.8 ?
-
Ajoute @Override au dessus de la fonction onArmorTick. Il t’indique quoi ?
-
salut je voudrai savoir quel est la condition a mettre pour dire a mon armure que les effet doit être actif quand mon set d’armure est complète. Merci d’avance ^^
package CrystalCombats; import CrystalTools.CrystalTool; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; public class ItemGreenCrystalArmor extends ItemArmor { public ItemGreenCrystalArmor(ArmorMaterial enumArmorMaterial, int slot, int layer) { super(enumArmorMaterial, slot, layer); } @SideOnly(Side.CLIENT) @Override public EnumRarity getRarity(ItemStack stack) { return EnumRarity.rare; } @Override public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { if(stack.getItem() == CrystalCombat.greenCrystalHelmet || stack.getItem() == CrystalCombat.greenCrystalChestPlate || stack.getItem() == CrystalCombat.greenCrystalBoots) return "minecraft:textures/models/armor/greencrystal_layer_1.png"; else if(stack.getItem() == CrystalCombat.greenCrystalLeggings) return "minecraft:textures/models/armor/greencrystal_layer_2.png"; else return null; } public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { player.addPotionEffect(new PotionEffect(Potion.waterBreathing.id, 20, 0)); player.addPotionEffect(new PotionEffect(Potion.invisibility.id, 20, 0)); player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 20, 0)); } } -
Bonjour, tous d’abord excellent tutoriel
mais j’aurais une question comment peut t’on faire pour quand on prend des dégât de chute l’armure perdent en durabilité car contre des mobs j’en perd mais pas quand je tombe de hautMerci d’avance, TheAzylium
-
@‘TheAzylium’:
Bonjour, tous d’abord excellent tutoriel
mais j’aurais une question comment peut t’on faire pour quand on prend des dégât de chute l’armure perdent en durabilité car contre des mobs j’en perd mais pas quand je tombe de hautMerci d’avance, TheAzylium
Ce calcul est fait lors du calcul d’armure, dans la logique de minecraft, c’est les bottes qui prennent les dégâts. Pour contrer ça tu peux utiliser le livingFallEvent ou le LivingHurtEvent dans lequel tu baisse la durabilité manuellement (je me rappelle plus de la fonction à utiliser)
-
@‘SCAREX’:
@‘TheAzylium’:
Bonjour, tous d’abord excellent tutoriel
mais j’aurais une question comment peut t’on faire pour quand on prend des dégât de chute l’armure perdent en durabilité car contre des mobs j’en perd mais pas quand je tombe de hautMerci d’avance, TheAzylium
Ce calcul est fait lors du calcul d’armure, dans la logique de minecraft, c’est les bottes qui prennent les dégâts. Pour contrer ça tu peux utiliser le livingFallEvent ou le LivingHurtEvent dans lequel tu baisse la durabilité manuellement (je me rappelle plus de la fonction à utiliser)
Merci j’ai enfin réussi j’avais oublier la classe LivingEventHandler ^^
-
bonjours, j’ai fait le tuto mais mes armures ne sont pas craftable, ous pouvez me dire comment les rendres craftable x) ?
-
En ajoutant le craft ?
Envoyé de mon SM-G920F en utilisant Tapatalk
-
oui mais quand je fais
GameRegistry.addRecipe(new ItemStack(acier, 1), new Object[]{
" A ", “AAA”, " A ", ‘A’, new ItemStack(Items.iron_ingot, 1, 1),
});
sa marche pas -
la c’est pour le craft de l’acier ( composant de l’armure)
-
Ton armure s’appelle acier ?!
Tu ajoutes un lingot avec un metadata aussiEnvoyé de mon SM-G920F en utilisant Tapatalk
-
mais meme pour creer un craft a un item sa ne marche pas, je ne peux pas le crafter en jeu
-
Où est la ligne de code ?
Envoyé de mon SM-G920F en utilisant Tapatalk
-
[//code]
package fairytail.common;import net.minecraft.entity.Entity;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;public class ItemArmorAcier extends ItemArmor
{
public ItemArmorAcier(ArmorMaterial material, int type)
{
super(material, 0, type);
}
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
{
if(slot == 2)
{
return ModFairytail.MODID + “:textures/models/armor/acier_layer_2.png”;
}
return ModFairytail.MODID + “:textures/models/armor/acier_layer_1.png”;
}
public boolean getIsRepairable(ItemStack input, ItemStack repair)
{
if(repair.getItem() == ModFairytail.acier)
{
return true;
}
return false;
}
}les crafts ne sont pas definie la et je ne sais pas comment leur mettre leurs craft
-
Il faut mettre la ligne de code dans le init ou le postinit
Envoyé de mon SM-G920F en utilisant Tapatalk
-
acier = new Acier().setUnlocalizedName(“acier”).setTextureName(ModFairytail.MODID + “:acier”).setCreativeTab(CreativeTabs.tabMaterials);
GameRegistry.registerItem(acier, “acier”);
GameRegistry.addRecipe(new ItemStack(acier, 1), new Object[]{
" A ", “AAA”, " A ", ‘A’, new ItemStack(Items.iron_ingot, 1, 1),
});
sa marche pas non plus