From df526dc76fabeae40fea6ac6f5ded4912b074783 Mon Sep 17 00:00:00 2001 From: Electroblob77 <35599699+Electroblob77@users.noreply.github.com> Date: Tue, 14 Apr 2020 23:06:49 +0100 Subject: [PATCH] Search trees don't like this very much :( --- src/main/java/electroblob/wizardry/item/ItemSpellBook.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/electroblob/wizardry/item/ItemSpellBook.java b/src/main/java/electroblob/wizardry/item/ItemSpellBook.java index 037dfeda..7cb48615 100644 --- a/src/main/java/electroblob/wizardry/item/ItemSpellBook.java +++ b/src/main/java/electroblob/wizardry/item/ItemSpellBook.java @@ -57,6 +57,10 @@ public class ItemSpellBook extends Item { return ActionResult.newResult(EnumActionResult.SUCCESS, stack); } + // This is accessed during loading (before we even get to the main menu) for search tree population + // Obviously the world is always null at that point, because no world objects exist! However, outside of a world + // there are no guarantees as to spell metadata order so we just have to give up (and we can't account for discovery) + // TODO: Search trees seem to get reloaded when the mappings change so in theory this should work ok, why doesn't it? @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, World world, List tooltip, net.minecraft.client.util.ITooltipFlag advanced){ @@ -64,7 +68,7 @@ public class ItemSpellBook extends Item { if(world == null) world = Wizardry.proxy.getTheWorld(); // But... I need the world! // Tooltip is left blank for wizards buying generic spell books. - if(itemstack.getItemDamage() != OreDictionary.WILDCARD_VALUE){ + if(world != null && itemstack.getItemDamage() != OreDictionary.WILDCARD_VALUE){ Spell spell = Spell.byMetadata(itemstack.getItemDamage());