im making a mod and im trying to make dynamic tooltips with special args. i want to do this in a seperate class from the class shown in this post and use it almost like a prefab that applies to all the items and even blocks in this class and the class i use for blocks.
this is how i would normally add tooltips but it only works if i make a class for each item or block and im trying to avoid that
@Override
public void addInformation(ItemStack itemstack, World world, List<String> list, ITooltipFlag flag) {
list.add("target practice?");
list.add("MD=2147483647 ");
list.add("insta kill arrows");
}
this is one of my pickaxes
ToolMaterial, Material name, add material to game, materials referenced name, type of tool, mining level, max hit damage, stack size
public static final ItemPickaxe BASE_PICKAXE = new BasicToolPrefabPickaxe("base_pickaxe",MATERIAL_BASE,"pickaxe",0,64,1);
this is the material for said pickaxe
ToolMaterial, Material name, add material to game, materials referenced name, harvest level, max uses, efficiency, hit damage, enchantability
public static final Item.ToolMaterial MATERIAL_BASE = EnumHelper.addToolMaterial("material_base", 2147483647, -1, 2147483647.0f, 2147483647.0f, 2147483647);
//(yes i know i use different info on certain things, thats just me testing stuff)
im trying to make a class that looks at info in these 2 lines of code and add them to a tooltip to each item or block that uses these types of lines of code. it would be nice if i could set a tooltip color based on what information is being shown aswell.
this code is all in the same class.
i have not messed with blockstates (metadata)
i do not know java either. but ive been learning along the way.
public class BasicItemRegistry
{
public static final List<Item> ITEMS = new ArrayList<Item>();
//tool materials
public static final Item.ToolMaterial MATERIAL_BASE = EnumHelper.addToolMaterial("material_base", 2147483647, -1, 2147483647.0f, 2147483647.0f, 2147483647);
public static final Item.ToolMaterial MATERIAL_CHARKITE = EnumHelper.addToolMaterial("material_charkite", 4, -1, 2147483647.0f, 13.0f, 2147483647);
//armor materials
public static final ItemArmor.ArmorMaterial ARMOR_BASE = EnumHelper.addArmorMaterial("base_armour", Reference.MOD_ID + ":base", -1, new int [] {2147483647,2147483647,2147483647,2147483647}, 2147483647, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 2147483647.0f);
public static final ItemArmor.ArmorMaterial ARMOR_CHARKITE = EnumHelper.addArmorMaterial("base_charkite", Reference.MOD_ID + ":charkite", -1, new int [] {8192,8192,8192,8192}, 2147483647, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 10);
//special items
public static final Item CRAFTING_ITEM = new BasicItemPrefab("crafting_item",-1,"base_multi_tool",0,1);
public static final Item ITEM_FLOUR = new BasicItemPrefab("item_flour",-1,"base_multi_tool",0,1);
public static final Item ITEM_BOTTLE_EMPTY = new BasicItemPrefab("item_bottle_empty",-1,"base_multi_tool",0,1);
public static final Item ITEM_BOTTLE_GLUE_WHITE = new BasicItemPrefab("item_bottle_glue_white",-1,"base_multi_tool",0,1);
//items
public static final Item BASE_INGOT = new BasicItemPrefab("base_ingot",-1,"base_multi_tool",0,64);
public static final Item BASE_REBAR = new BasicItemPrefab("base_rebar",-1,"base_multi_tool",0,64);
public static final Item BASE_STICK = new BasicItemPrefab("base_stick",-1,"base_multi_tool",0,64);
public static final Item BASE_DUST = new BasicItemPrefab("base_dust",100,"base_multi_tool",0,64);
public static final Item BASE_NUGGET = new BasicItemPrefab("base_nugget",-1,"base_multi_tool",0,64);
public static final Item BASE_HAMMER = new BasicItemPrefab("base_hammer",-1,"base_multi_tool",0,1);
//foods
//public static final ItemSword BASE_APPLE = new BasicWeaponPrefabSword("base_apple", MATERIAL_BASE,"pickaxe",0);
//tools and weapons-------------------------------------------- pickaxe - axe - shovel - base_multi_tool
public static final ItemSword BASE_SWORD = new BasicWeaponPrefabSword("base_sword", MATERIAL_BASE,"pickaxe",0);
public static final ItemSpade BASE_SHOVEL = new BasicToolPrefabSpade("base_shovel",MATERIAL_BASE,"pickaxe",0);
public static final ItemPickaxe BASE_PICKAXE = new BasicToolPrefabPickaxe("base_pickaxe",MATERIAL_BASE,"pickaxe",0,64,1);
public static final ItemShears BASE_SHEAR = new BasicToolPrefabShear("base_shear",MATERIAL_BASE,"shear",0);
public static final ItemBow BASE_BOW = new BasicWeaponPrefabBow("base_bow",150,"bow",0,64);
public static final ItemMultiToolPrefab BASE_MULTI_TOOL = new BasicToolPrefabMulti("base_multi_tool",MATERIAL_BASE,"item_multi_tool",0,100,64);
public static final ItemAxe BASE_AXE = new BasicToolPrefabAxe("base_axe",MATERIAL_BASE,"axe",0,100f,0.0f,1);
public static final ItemHoe BASE_HOE = new BasicToolPrefabHoe("base_hoe",MATERIAL_BASE,"hoe",0,100,64);
//armor items -------------------------------------------------renderindexin 1,1,2,1 ---EntityEquipmentSlot.HEAD,CHEST,LEGS,FEET
public static final Item BASE_HELMET = new BasicItemPrefabArmor("base_helmet",ARMOR_BASE, 1, EntityEquipmentSlot.HEAD,150,"pickaxe",0,1);
public static final Item BASE_CHESTPLATE = new BasicItemPrefabArmor("base_chestplate",ARMOR_BASE, 1, EntityEquipmentSlot.CHEST,150,"pickaxe",0,1);
public static final Item BASE_LEGGINGS = new BasicItemPrefabArmor("base_leggings",ARMOR_BASE, 2, EntityEquipmentSlot.LEGS,150,"pickaxe",0,1);
public static final Item BASE_BOOTS = new BasicItemPrefabArmor("base_boots",ARMOR_BASE, 1, EntityEquipmentSlot.FEET,150,"pickaxe",0,1);
public static final BasicItemPrefabElytra BASE_ELYTRA = new BasicItemPrefabElytra("base_elytra",ARMOR_BASE,1,EntityEquipmentSlot.CHEST);
//netherstar stuff++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
public static final Item DUST_NETHERSTAR = new BasicItemPrefab("dust_netherstar",-1,"base_multi_tool",0,64);
public static final Item INGOT_NETHERSTAR = new BasicItemPrefab("ingot_netherstar",-1,"base_multi_tool",0,64);
//charkite stuff++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//charkite tools and weapons
public static final ItemSword ITEM_CHARKITE_SWORD = new BasicWeaponPrefabSword("item_sword_charkite", MATERIAL_CHARKITE,"pickaxe",0);
public static final ItemSpade ITEM_CHARKITE_SHOVEL = new BasicToolPrefabSpade("item_shovel_charkite",MATERIAL_CHARKITE,"pickaxe",0);
public static final ItemPickaxe ITEM_CHARKITE_PICKAXE = new BasicToolPrefabPickaxe("item_pickaxe_charkite",MATERIAL_CHARKITE,"pickaxe",0,64,1);
public static final ItemShears ITEM_CHARKITE_SHEAR = new BasicToolPrefabShear("item_shear_charkite",MATERIAL_CHARKITE,"shear",0);
public static final ItemBow ITEM_CHARKITE_BOW = new BasicWeaponPrefabBow("item_bow_charkite",150,"bow",0,64);
public static final ItemMultiToolPrefab ITEM_CHARKITE_MULTI_TOOL = new BasicToolPrefabMulti("item_multi_tool_charkite",MATERIAL_CHARKITE,"item_multi_tool",0,100,64);
public static final ItemAxe ITEM_CHARKITE_AXE = new BasicToolPrefabAxe("item_axe_charkite",MATERIAL_CHARKITE,"axe",0,100f,0.0f,1);
public static final ItemHoe ITEM_CHARKITE_HOE = new BasicToolPrefabHoe("item_hoe_charkite",MATERIAL_CHARKITE,"hoe",0,100,64);
//charkite armor stuff
public static final Item ITEM_HELMET_CHARKITE = new BasicItemPrefabArmor("item_helmet_charkite",ARMOR_CHARKITE, 1, EntityEquipmentSlot.HEAD,150,"pickaxe",0,1);
public static final Item ITEM_CHESTPLATE_CHARKITE = new BasicItemPrefabArmor("item_chestplate_charkite",ARMOR_CHARKITE, 1, EntityEquipmentSlot.CHEST,150,"pickaxe",0,1);
public static final Item ITEM_LEGGINGS_CHARKITE = new BasicItemPrefabArmor("item_leggings_charkite",ARMOR_CHARKITE, 2, EntityEquipmentSlot.LEGS,150,"pickaxe",0,1);
public static final Item ITEM_BOOTS_CHARKITE = new BasicItemPrefabArmor("item_boots_charkite",ARMOR_CHARKITE, 1, EntityEquipmentSlot.FEET,150,"pickaxe",0,1);
public static final BasicItemPrefabElytra ITEM_ELYTRA_CHARKITE = new BasicItemPrefabElytra("item_elytra_charkite",ARMOR_CHARKITE,1,EntityEquipmentSlot.CHEST);
//charkite items
public static final Item ITEM_INGOT_CHARKITE = new BasicItemPrefab("item_ingot_charkite",-1,"base_multi_tool",0,64);
public static final Item ITEM_REBAR_CHARKITE = new BasicItemPrefab("item_rebar_charkite",-1,"base_multi_tool",0,64);
public static final Item ITEM_STICK_CHARKITE = new BasicItemPrefab("item_stick_charkite",-1,"base_multi_tool",0,64);
public static final Item ITEM_DUST_CHARKITE = new BasicItemPrefab("item_dust_charkite",100,"base_multi_tool",0,64);
public static final Item ITEM_NUGGET_CHARKITE = new BasicItemPrefab("item_nugget_charkite",-1,"base_multi_tool",0,64);
public static final Item ITEM_HAMMER_CHARKITE = new BasicItemPrefab("item_hammer_charkite",-1,"base_multi_tool",0,1);
}
i understand that, im trying to learn while making the mod. i just work so much that i barely have time. also i cant keep interested in coding videos and such.
ill look around and try to learn, i just feel it would be easier to learn if im doing something i do not consider boring (like making a minecraft mod)
i wish more documentation on 1.12.2 modding were out there. ive found lots of stuff but only the very basic things that are involved with modding.
no, i can not find any info on the subject,i tried to to change this
public class BasicItemPrefab extends Item implements IHasModel
{
public BasicItemPrefab
(
String name,
int maxdamage,
String tool,
int toollevel,
int stacksize
)
{
setCreativeTab(UTOTabs.UTOItems);//sets creative tab, change later
setUnlocalizedName(name);
setRegistryName(name);
//setDamage(64,);
setMaxDamage(maxdamage);
setHarvestLevel(tool,toollevel);
setMaxStackSize(stacksize);
BasicItemRegistry.ITEMS.add(this);
}
@Override
public void addInformation(ItemStack itemstack, World world, List<String> list, ITooltipFlag flag) {
list.add("name");
list.add("maxdamage");
list.add("tool");
list.add("toollevel");
}
@Override public void registerModels(){UTOMod.proxy.registerItemRenderer(this, 0, "inventory");}
}
i created a function for each thing that i wish to be in the tooltips, but it does not work, i can not figure this out, there is no information on the internet that is up to date for 1.12.2
but i want it to show the stats that are set through the super. the super holds the functions that are needed in my registration class when adding items. i do not see why i can not get it to work.
Thank you so much, ill try when i get off work. I see what i was doing wrong, when i set the variable for each of the things i wanted to add, i wasnt putting the information in the right place.
Also, i plan to turn many of my items into a breed of throwable items, and sling shot items, so you saw a prefab class that is not finished. I have to make entity's for nuggets-ingots-sticks-rods-rebar and a few others. Then add my own sounds for shooting and equiping. I will soon add a sling shot that uses the bow and arrow code.
The tool and tool level info is because im giving all my items the ability to mine everything at mining level 0 also they use my multitool prefab class so they can mine wood, sand, dirt and even stone faster than you can with a normal item.
Im basically testing things out. Thanks for the help, your awesome
thank you for all the help, i had to change a bit of the code because i use a custom material that is made within the registration class but other than that, its awesome. picture 1 shows what ive been playing with.
public class BasicToolPrefabPickaxe extends ItemPickaxe implements IHasModel
{
int HarvestLevel;
int MaxUses;
int Enchantability;
float Efficiency;
public BasicToolPrefabPickaxe
(
String name,
ToolMaterial material,
String tool,
int level,
int MaxUses,
int SetMaxStackSize,
int Efficiency
)
{
super(material);
setUnlocalizedName(name);
setRegistryName(name);
setCreativeTab(UTOTabs.UTOTools);
setHarvestLevel(tool,level);
setMaxDamage(MaxUses);
setMaxStackSize(SetMaxStackSize);
efficiency = Efficiency;
//Assigning value to these variables
this.HarvestLevel = BasicItemRegistry.MATERIAL_BASE.getHarvestLevel();
this.MaxUses = BasicItemRegistry.MATERIAL_BASE.getMaxUses();
//this.AttackDamage = BasicItemRegistry.MATERIAL_BASE.getAttackDamage();
this.Efficiency = BasicItemRegistry.MATERIAL_BASE.getEfficiency();
this.Enchantability = BasicItemRegistry.MATERIAL_BASE.getEnchantability();
//this.RepairItem = BasicItemRegistry.MATERIAL_BASE.getRepairItemStack();
BasicItemRegistry.ITEMS.add(this);
}
@Override
public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
//Making the tooltips
//For colors use for example: tooltip.add("Max Uses: " + TextFormatting.BLUE + maxUses);
tooltip.add(TextFormatting.BOLD +"Max Uses: " + TextFormatting.DARK_BLUE +MaxUses);
tooltip.add(TextFormatting.ITALIC+"Harvest Level: " + HarvestLevel);
tooltip.add(TextFormatting.GREEN+"Efficiency: " + Efficiency);
tooltip.add(TextFormatting.DARK_PURPLE+"Enchantability: "+TextFormatting.LIGHT_PURPLE+Enchantability);
}
@Override public void registerModels(){UTOMod.proxy.registerItemRenderer(this, 0, "inventory");}
}
modding helps me learn java much faster than those boring tutorials, ive still been working on "sololearn"
im currently on conditionals and loops,lesson 3, else if statements.
thanks for showing me this, im going to add you to the credits in my mod if you like, i just need to know what your minecraft name is if its different than the name you use on here.
im making a mod and im trying to make dynamic tooltips with special args. i want to do this in a seperate class from the class shown in this post and use it almost like a prefab that applies to all the items and even blocks in this class and the class i use for blocks.
this is how i would normally add tooltips but it only works if i make a class for each item or block and im trying to avoid that
this is one of my pickaxes
ToolMaterial, Material name, add material to game, materials referenced name, type of tool, mining level, max hit damage, stack size
this is the material for said pickaxe
ToolMaterial, Material name, add material to game, materials referenced name, harvest level, max uses, efficiency, hit damage, enchantability
im trying to make a class that looks at info in these 2 lines of code and add them to a tooltip to each item or block that uses these types of lines of code. it would be nice if i could set a tooltip color based on what information is being shown aswell.
this code is all in the same class.
i have not messed with blockstates (metadata)
i do not know java either. but ive been learning along the way.
this is the class itself
i understand that, im trying to learn while making the mod. i just work so much that i barely have time. also i cant keep interested in coding videos and such.
ill look around and try to learn, i just feel it would be easier to learn if im doing something i do not consider boring (like making a minecraft mod)
i wish more documentation on 1.12.2 modding were out there. ive found lots of stuff but only the very basic things that are involved with modding.
no, i can not find any info on the subject,i tried to to change this
but i want it to show the stats that are set through the super. the super holds the functions that are needed in my registration class when adding items. i do not see why i can not get it to work.
Thank you so much, ill try when i get off work. I see what i was doing wrong, when i set the variable for each of the things i wanted to add, i wasnt putting the information in the right place.
Also, i plan to turn many of my items into a breed of throwable items, and sling shot items, so you saw a prefab class that is not finished. I have to make entity's for nuggets-ingots-sticks-rods-rebar and a few others. Then add my own sounds for shooting and equiping. I will soon add a sling shot that uses the bow and arrow code.
The tool and tool level info is because im giving all my items the ability to mine everything at mining level 0 also they use my multitool prefab class so they can mine wood, sand, dirt and even stone faster than you can with a normal item.
Im basically testing things out. Thanks for the help, your awesome
thank you for all the help, i had to change a bit of the code because i use a custom material that is made within the registration class but other than that, its awesome. picture 1 shows what ive been playing with.
this is a prefab class for my pickaxe.
modding helps me learn java much faster than those boring tutorials, ive still been working on "sololearn"
im currently on conditionals and loops,lesson 3, else if statements.
thanks for showing me this, im going to add you to the credits in my mod if you like, i just need to know what your minecraft name is if its different than the name you use on here.