Add descriptions to some wizardry items in JEI

Covers most of the items players might stumble across
This commit is contained in:
Electroblob77
2020-04-17 21:49:01 +01:00
parent cdc326e36c
commit 618df1c668
5 changed files with 138 additions and 18 deletions
@@ -3,17 +3,27 @@ package electroblob.wizardry.integration.jei;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.enchantment.Imbuement;
import electroblob.wizardry.item.IConjuredItem;
import electroblob.wizardry.item.ItemArcaneTome;
import electroblob.wizardry.item.ItemArtefact;
import electroblob.wizardry.item.ItemWandUpgrade;
import electroblob.wizardry.registry.WizardryBlocks;
import electroblob.wizardry.registry.WizardryEnchantments;
import electroblob.wizardry.registry.WizardryItems;
import mezz.jei.api.IModPlugin;
import mezz.jei.api.IModRegistry;
import mezz.jei.api.ISubtypeRegistry;
import mezz.jei.api.JEIPlugin;
import mezz.jei.api.ingredients.IIngredientBlacklist;
import mezz.jei.api.ingredients.VanillaTypes;
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentData;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import java.util.Arrays;
import java.util.Locale;
@JEIPlugin
public class WizardryJEIPlugin implements IModPlugin {
@@ -53,6 +63,41 @@ public class WizardryJEIPlugin implements IModPlugin {
}
}
addItemInfo(registry, WizardryItems.magic_crystal);
addItemInfo(registry, WizardryItems.wizard_handbook);
addItemInfo(registry, WizardryItems.crystal_shard);
addItemInfo(registry, WizardryItems.grand_crystal);
addItemInfo(registry, WizardryItems.identification_scroll);
addItemInfo(registry, WizardryItems.spell_book);
addItemInfo(registry, WizardryItems.scroll);
addItemInfo(registry, WizardryItems.armour_upgrade, ".desc_extended");
addItemInfo(registry, WizardryItems.purifying_elixir, ".desc_extended");
addItemInfo(registry, WizardryItems.astral_diamond);
for(Item item : Item.REGISTRY){
if(item instanceof ItemArtefact){
ItemStack stack = new ItemStack(item);
registry.addIngredientInfo(stack, VanillaTypes.ITEM, "item." + Wizardry.MODID + ":"
+ ((ItemArtefact)item).getType().toString().toLowerCase(Locale.ROOT) + ".generic.desc");
}else if(item instanceof ItemWandUpgrade || item instanceof ItemArcaneTome){
NonNullList<ItemStack> subItems = NonNullList.create();
item.getSubItems(item.getCreativeTab(), subItems);
for(ItemStack stack : subItems){
registry.addIngredientInfo(stack, VanillaTypes.ITEM, "item." + Wizardry.MODID +
":wand_upgrade.generic.desc");
}
}
}
addEnchantmentInfo(registry, WizardryEnchantments.magic_protection);
addEnchantmentInfo(registry, WizardryEnchantments.frost_protection);
addEnchantmentInfo(registry, WizardryEnchantments.shock_protection);
}
@Override
@@ -65,4 +110,36 @@ public class WizardryJEIPlugin implements IModPlugin {
}
private static void addItemInfo(IModRegistry registry, Item item){
addItemInfo(registry, item, ".desc");
}
private static void addItemInfo(IModRegistry registry, Item item, String... suffixes){
NonNullList<ItemStack> subItems = NonNullList.create();
item.getSubItems(item.getCreativeTab(), subItems);
for(ItemStack stack : subItems) addItemInfo(registry, stack, suffixes);
}
private static void addItemInfo(IModRegistry registry, ItemStack stack, String... suffixes){
String prefix = stack.getItem().getTranslationKey(stack);
String[] keys = Arrays.stream(suffixes).map(s -> prefix + s).toArray(String[]::new);
registry.addIngredientInfo(stack, VanillaTypes.ITEM, keys);
}
private static void addEnchantmentInfo(IModRegistry registry, Enchantment enchantment){
addEnchantmentInfo(registry, enchantment, ".desc");
}
private static void addEnchantmentInfo(IModRegistry registry, Enchantment enchantment, String... suffixes){
for(int level = enchantment.getMinLevel(); level <= enchantment.getMaxLevel(); level++){
addEnchantmentInfo(registry, new EnchantmentData(enchantment, level), suffixes);
}
}
private static void addEnchantmentInfo(IModRegistry registry, EnchantmentData data, String... suffixes){
String prefix = data.enchantment.getName().replace(":", "."); // Compat with WAWLA descriptions
String[] keys = Arrays.stream(suffixes).map(s -> prefix + s).toArray(String[]::new);
registry.addIngredientInfo(data, VanillaTypes.ENCHANT, keys);
}
}
@@ -34,9 +34,7 @@ public class ItemArmourUpgrade extends Item {
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, net.minecraft.client.util.ITooltipFlag flagIn) {
tooltip.add(net.minecraft.client.resources.I18n.format("item." + Wizardry.MODID + ":armour_upgrade.desc1", "\u00A77"));
tooltip.add(
net.minecraft.client.resources.I18n.format("item." + Wizardry.MODID + ":armour_upgrade.desc2", "\u00A77", "\u00A7d"));
Wizardry.proxy.addMultiLineDescription(tooltip, "item." + this.getRegistryName() + ".desc", "\u00A7d");
}
}
@@ -27,8 +27,7 @@ public class ItemWizardHandbook extends Item {
@Override
public void addInformation(ItemStack stack, @Nullable World world, List<String> tooltip, net.minecraft.client.util.ITooltipFlag flag) {
tooltip.add(
"\u00A77" + net.minecraft.client.resources.I18n.format("item." + Wizardry.MODID + ":wizard_handbook.desc", AUTHOR));
tooltip.add("\u00A77" + net.minecraft.client.resources.I18n.format("item." + Wizardry.MODID + ":wizard_handbook.author", AUTHOR));
}
@Override