Jump to content

caliban

Members
  • Posts

    13
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • Location
    France

caliban's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I change it and now it works Thank you very much !
  2. I suppose he was right so i did like he said, i extended my class ModArmors from Item
  3. My class modArmors where i declare all my armours: package com.mod.CaliArmor.init; import java.util.ArrayList; import static java.util.Arrays.asList; import com.mod.CaliArmor.items.armor.*; import com.mod.CaliArmor.utils.ArmorMaterials; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.EntityEquipmentSlot; 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.world.World; public class ModArmors extends Item { //Armor public static ItemArmor stone_helmet, stone_chestplate, stone_leggings, stone_boots; public static ItemArmor kevlar_helmet, kevlar_chestplate, kevlar_leggings, kevlar_boots; public static ItemArmor volcanite_helmet, volcanite_chestplate, volcanite_leggings, volcanite_boots; private static Item[] armors; public ModArmors() { initArmor(); } public static void initArmor() { stone_helmet = new Helmet("stone_helmet", ArmorMaterials.stoneMat, 2, EntityEquipmentSlot.HEAD); stone_chestplate = new Chestplate("stone_chestplate", ArmorMaterials.stoneMat, 2, EntityEquipmentSlot.CHEST); stone_leggings = new Leggings("stone_leggings", ArmorMaterials.stoneMat, 2, EntityEquipmentSlot.LEGS); stone_boots = new Boots("stone_boots", ArmorMaterials.stoneMat, 2, EntityEquipmentSlot.FEET); kevlar_helmet = new Helmet("kevlar_helmet", ArmorMaterials.kevlarMat, 2, EntityEquipmentSlot.HEAD); kevlar_chestplate = new Chestplate("kevlar_chestplate", ArmorMaterials.kevlarMat, 2, EntityEquipmentSlot.CHEST); kevlar_leggings = new Leggings("kevlar_leggings", ArmorMaterials.kevlarMat, 2, EntityEquipmentSlot.LEGS); kevlar_boots = new Boots("kevlar_boots", ArmorMaterials.kevlarMat, 2, EntityEquipmentSlot.FEET); volcanite_helmet = new Helmet("volcanite_helmet", ArmorMaterials.volcaniteMat, 2, EntityEquipmentSlot.HEAD); volcanite_chestplate = new Chestplate("volcanite_chestplate", ArmorMaterials.volcaniteMat, 2, EntityEquipmentSlot.CHEST); volcanite_leggings = new Leggings("volcanite_leggings", ArmorMaterials.volcaniteMat, 2, EntityEquipmentSlot.LEGS); volcanite_boots = new Boots("volcanite_boots", ArmorMaterials.volcaniteMat, 2, EntityEquipmentSlot.FEET); armors = new Item[]{stone_helmet, stone_chestplate, stone_leggings, stone_boots, kevlar_helmet, kevlar_chestplate, kevlar_leggings, kevlar_boots, volcanite_helmet, volcanite_chestplate, volcanite_leggings, volcanite_boots}; } //List to initialize ItemArmor and not have to copy/paste @Override public void onArmorTick(World world, EntityPlayer player, ItemStack item) { //Testing if player is wearing an armor if(player.inventory.armorItemInSlot(0) != null) { //Testing if player is wearing the right armor System.out.println("Test_1234828"); player.addPotionEffect(new PotionEffect(Potion.getPotionById(12), 40)); if(player.inventory.armorItemInSlot(0).getItem() == volcanite_helmet) { //Application of effect player.addPotionEffect(new PotionEffect(Potion.getPotionById(12), 40)); } } } public static Item[] getArmors() { return armors; } } My class ModItems, initilizing item, textures anbd other items package com.mod.CaliArmor.init; import java.util.ArrayList; import com.mod.CaliArmor.CaliArmor; import com.mod.CaliArmor.items.armor.*; import com.mod.CaliArmor.items.tools.*; import com.mod.CaliArmor.utils.*; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemArmor.ArmorMaterial; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class ModItems { /* public static Item stone_helmet, stone_chestplate, stone_leggings, stone_boots; public static Item kevlar_helmet, kevlar_chestplate, kevlar_leggings, kevlar_boots; public static Item volcanite_helmet, volcanite_chestplate, volcanite_leggings, volcanite_boots; */ public static Item volcanite_ingot; public static Item kevlar_plate; public static Item volcanite_pickaxe, volcanite_axe, volcanite_shovel, volcanite_hoe, volcanite_sword; private static ArrayList<Item> items; public static void initItems() { new ModArmors(); //Initializing material volcanite_ingot = new Item().setRegistryName("volcanite_ingot").setUnlocalizedName("volcanite_ingot").setCreativeTab(CaliArmor.armorTab); kevlar_plate = new Item().setRegistryName("kevlar_plate").setUnlocalizedName("kevlar_plate").setCreativeTab(CaliArmor.armorTab); //Initializing tool volcanite_pickaxe = new Pickaxe("volcanite_pickaxe", ToolMaterials.volcaniteMat); volcanite_axe = new Axe("volcanite_axe", ToolMaterials.volcaniteMat); volcanite_shovel = new Shovel("volcanite_shovel", ToolMaterials.volcaniteMat); volcanite_sword = new Sword("volcanite_sword", ToolMaterials.volcaniteMat); volcanite_hoe = new Hoe("volcanite_hoe", ToolMaterials.volcaniteMat); //Add all item in array list to register easier items = new ArrayList<Item>(); items.add(volcanite_ingot); items.add(kevlar_plate); items.add(volcanite_axe); items.add(volcanite_pickaxe); items.add(volcanite_shovel); items.add(volcanite_sword); items.add(volcanite_hoe); for (Item armor : ModArmors.getArmors()) { items.add(armor); } } public static void registerItems() { for(Item item : items) { registerItem(item); } } @SideOnly(Side.CLIENT) public static void registerRenders() { for(Item item : items) { registerRender(item, 0); } } private static void registerItem(Item item) { GameRegistry.register(item); } private static void registerRender(Item item, int meta) { ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(new ResourceLocation(References.MODID, item.getUnlocalizedName().substring(5)), "inventory")); } } Thee rest of my code is here : https://github.com/TheCaliban/CaliArmor/tree/master/src/main/java/com/mod/CaliArmor Thank
  4. That's what i done, I'm a little bit confused because when i'm testing my mod, this method is never called ..... so i supposed the @Override is not sufficient and i have to put my method in a specific place.
  5. I already created a class for my Chestplate. For each part of the armour, there is a class named by the specific part. So i have 4 class (Boots, Chestplate, Helmet and Leggings) that i have created
  6. I did like you said, i extended my class ModArmors from Item, i have no error now but in game nothing happend when i'm wearing the armour. Maybe i did some mistakes in my method to give the effect, can you check it and tell me if something seems strange to you (i changed the id of slot by the new references and this the same) Thank you
  7. The tag @Override cannot be applicate to my method, eclipse tell me to remove it. I don't want to abuse your help but if you can check my code, you could be able to help me better My class ModArmors extend of ModItems package com.mod.CaliArmor.init; import java.util.ArrayList; import static java.util.Arrays.asList; import com.mod.CaliArmor.items.armor.*; import com.mod.CaliArmor.utils.ArmorMaterials; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.EntityEquipmentSlot; 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.world.World; public class ModArmors extends ModItems { //Armor public static ItemArmor stone_helmet, stone_chestplate, stone_leggings, stone_boots; public static ItemArmor kevlar_helmet, kevlar_chestplate, kevlar_leggings, kevlar_boots; public static ItemArmor volcanite_helmet, volcanite_chestplate, volcanite_leggings, volcanite_boots; private static Item[] armors; public ModArmors() { initArmor(); } public static void initArmor() { stone_helmet = new Helmet("stone_helmet", ArmorMaterials.stoneMat, 2, EntityEquipmentSlot.HEAD); stone_chestplate = new Chestplate("stone_chestplate", ArmorMaterials.stoneMat, 2, EntityEquipmentSlot.CHEST); stone_leggings = new Leggings("stone_leggings", ArmorMaterials.stoneMat, 2, EntityEquipmentSlot.LEGS); stone_boots = new Boots("stone_boots", ArmorMaterials.stoneMat, 2, EntityEquipmentSlot.FEET); kevlar_helmet = new Helmet("kevlar_helmet", ArmorMaterials.kevlarMat, 2, EntityEquipmentSlot.HEAD); kevlar_chestplate = new Chestplate("kevlar_chestplate", ArmorMaterials.kevlarMat, 2, EntityEquipmentSlot.CHEST); kevlar_leggings = new Leggings("kevlar_leggings", ArmorMaterials.kevlarMat, 2, EntityEquipmentSlot.LEGS); kevlar_boots = new Boots("kevlar_boots", ArmorMaterials.kevlarMat, 2, EntityEquipmentSlot.FEET); volcanite_helmet = new Helmet("volcanite_helmet", ArmorMaterials.volcaniteMat, 2, EntityEquipmentSlot.HEAD); volcanite_chestplate = new Chestplate("volcanite_chestplate", ArmorMaterials.volcaniteMat, 2, EntityEquipmentSlot.CHEST); volcanite_leggings = new Leggings("volcanite_leggings", ArmorMaterials.volcaniteMat, 2, EntityEquipmentSlot.LEGS); volcanite_boots = new Boots("volcanite_boots", ArmorMaterials.volcaniteMat, 2, EntityEquipmentSlot.FEET); armors = new Item[]{stone_helmet, stone_chestplate, stone_leggings, stone_boots, kevlar_helmet, kevlar_chestplate, kevlar_leggings, kevlar_boots, volcanite_helmet, volcanite_chestplate, volcanite_leggings, volcanite_boots}; } //List to initialize ItemArmor and not have to copy/paste @Override //Tag give me an error cause there is no onArmorTick() method up public void onArmorTick(World world, EntityPlayer player, ItemStack item) { //Testing if player is wearing an armor if(player.inventory.armorItemInSlot(0) != null && player.inventory.armorItemInSlot(1) != null && player.inventory.armorItemInSlot(2) != null && player.inventory.armorItemInSlot(3) != null) { //Testing if player is wearing the right armor if(player.inventory.armorItemInSlot(0).getItem() == ModArmors.volcanite_chestplate && player.inventory.armorItemInSlot(1).getItem() == ModArmors.volcanite_leggings && player.inventory.armorItemInSlot(2).getItem() == ModArmors.volcanite_boots && player.inventory.armorItemInSlot(3).getItem() == ModArmors.volcanite_helmet) { //Application of effect player.addPotionEffect(new PotionEffect(Potion.getPotionById(12), 40)); } } } public static Item[] getArmors() { return armors; } } And my class ModItems: package com.mod.CaliArmor.init; import java.util.ArrayList; import com.mod.CaliArmor.CaliArmor; import com.mod.CaliArmor.items.armor.*; import com.mod.CaliArmor.items.tools.*; import com.mod.CaliArmor.utils.*; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemArmor.ArmorMaterial; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class ModItems { /* public static Item stone_helmet, stone_chestplate, stone_leggings, stone_boots; public static Item kevlar_helmet, kevlar_chestplate, kevlar_leggings, kevlar_boots; public static Item volcanite_helmet, volcanite_chestplate, volcanite_leggings, volcanite_boots; */ public static Item volcanite_ingot; public static Item kevlar_plate; public static Item volcanite_pickaxe, volcanite_axe, volcanite_shovel, volcanite_hoe, volcanite_sword; private static ArrayList<Item> items; public static void initItems() { new ModArmors(); //Initializing material volcanite_ingot = new Item().setRegistryName("volcanite_ingot").setUnlocalizedName("volcanite_ingot").setCreativeTab(CaliArmor.armorTab); kevlar_plate = new Item().setRegistryName("kevlar_plate").setUnlocalizedName("kevlar_plate").setCreativeTab(CaliArmor.armorTab); //Initializing tool volcanite_pickaxe = new Pickaxe("volcanite_pickaxe", ToolMaterials.volcaniteMat); volcanite_axe = new Axe("volcanite_axe", ToolMaterials.volcaniteMat); volcanite_shovel = new Shovel("volcanite_shovel", ToolMaterials.volcaniteMat); volcanite_sword = new Sword("volcanite_sword", ToolMaterials.volcaniteMat); volcanite_hoe = new Hoe("volcanite_hoe", ToolMaterials.volcaniteMat); //Add all item in array list to register easier items = new ArrayList<Item>(); items.add(volcanite_ingot); items.add(kevlar_plate); items.add(volcanite_axe); items.add(volcanite_pickaxe); items.add(volcanite_shovel); items.add(volcanite_sword); items.add(volcanite_hoe); for (Item armor : ModArmors.getArmors()) { items.add(armor); } } public static void registerItems() { for(Item item : items) { registerItem(item); } } @SideOnly(Side.CLIENT) public static void registerRenders() { for(Item item : items) { registerRender(item, 0); } } private static void registerItem(Item item) { GameRegistry.register(item); } private static void registerRender(Item item, int meta) { ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(new ResourceLocation(References.MODID, item.getUnlocalizedName().substring(5)), "inventory")); } } Thanks
  8. I saw this example on the guide page but i did not understand how it works. That's why i said be more specific Thanks you for your help
  9. I'm a little new in the world of modder, can you be a little more specific or give me an example according to my case. (i tried different solution before asking you again and none worked)
  10. Hello guys, After watching differents tutorials, i decide to put an effect on an armor set but i don't understood where put the method onArmorTick(). I read several old post on the forum but i didn't learn more .... So i hope you will be able what is missing in my code. Thanks Here is my method: public void onArmorTick(World world, EntityPlayer player, ItemStack item) { //Testing if player is wearing an armor if(player.inventory.armorItemInSlot(0) != null && player.inventory.armorItemInSlot(1) != null && player.inventory.armorItemInSlot(2) != null && player.inventory.armorItemInSlot(3) != null) { //Testing if player is wearing the right armor if(player.inventory.armorItemInSlot(0).getItem() == volcanite_chestplate && player.inventory.armorItemInSlot(1).getItem() == volcanite_leggings && player.inventory.armorItemInSlot(2).getItem() == volcanite_boots && player.inventory.armorItemInSlot(3).getItem() == volcanite_helmet) { //Application of effect player.addPotionEffect(new PotionEffect(Potion.getPotionById(12), 40)); } } } The rest if that interest you is here: https://github.com/TheCaliban/CaliArmor/tree/master/src/main/java/com/mod/CaliArmor
  11. Thank you it works very well !
  12. Thank you for your answar, i uploaded my project here: https://github.com/TheCaliban/CaliArmor I've already used the system of proxy and preInit, init and postInit method. Maybe you can check my code and tell what is wrong. Thank you
  13. Hello guy, I started programming mod very recently and i'm facing a problem with the port of my mod on server. Many peoples told that the mod is nowaday universal and works both on client and on server. However, the server refuse tu start because of java.lang.NoSuchMethodError on my registerRender() method. I specify i put the " @SideOnly(Side.CLIENT)" before but nothing change. I hope you can help me and thank you error_eclipse.txt
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.