Change the Lexicon gui code to pull from the stack used to open the book. Closes #518

This commit is contained in:
Lizbeth Rika committed 2015-02-02 18:27:00 +00:00
1 parent 97d4fd9b3d
commit 96e676c2c7
5 files changed
+14 -4

No files matched your search

@@ -221,6 +221,11 @@ public class ClientProxy extends CommonProxy {
public void setEntryToOpen(LexiconEntry entry) {
GuiLexicon.currentOpenLexicon = new GuiLexiconEntry(entry, new GuiLexiconIndex(entry.category));
}
@Override
public void setLexiconStack(ItemStack stack) {
GuiLexicon.stackUsed = stack;
}
@Override
public boolean isTheClientPlayer(EntityLivingBase entity) {
@@ -69,7 +69,7 @@ public class GuiLexicon extends GuiScreen {
lastTime = ClientTickHandler.ticksInGame;
title = Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem().getDisplayName();
title = stackUsed.getDisplayName();
currentOpenLexicon = this;
left = width / 2 - guiWidth / 2;
@@ -13,6 +13,7 @@ package vazkii.botania.common.core.proxy;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
@@ -128,6 +129,10 @@ public class CommonProxy {
public void setEntryToOpen(LexiconEntry entry) {
// NO-OP
}
public void setLexiconStack(ItemStack stack) {
// NO-OP
}
public boolean isTheClientPlayer(EntityLivingBase entity) {
return false;
@@ -65,6 +65,8 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
LexiconEntry entry = ((ILexiconable) block).getEntry(par3World, par4, par5, par6, par2EntityPlayer, par1ItemStack);
if(entry != null && isKnowledgeUnlocked(par1ItemStack, entry.getKnowledgeType())) {
Botania.proxy.setEntryToOpen(entry);
Botania.proxy.setLexiconStack(par1ItemStack);
par2EntityPlayer.openGui(Botania.instance, LibGuiIDs.LEXICON, par3World, 0, 0, 0);
par2EntityPlayer.addStat(ModAchievements.lexiconUse, 1);
if(!par3World.isRemote)
@@ -136,6 +138,7 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
setForcedPage(par1ItemStack, "");
}
Botania.proxy.setLexiconStack(par1ItemStack);
par3EntityPlayer.addStat(ModAchievements.lexiconUse, 1);
par3EntityPlayer.openGui(Botania.instance, LibGuiIDs.LEXICON, par2World, 0, 0, 0);
if(!par2World.isRemote && !skipSound)
@@ -37,9 +37,6 @@ public class GuiHandler implements IGuiHandler {
switch(ID) {
case LibGuiIDs.LEXICON : {
GuiLexicon lex = GuiLexicon.currentOpenLexicon;
GuiLexicon.stackUsed = player.getCurrentEquippedItem();
if(GuiLexicon.stackUsed == null || !(GuiLexicon.stackUsed.getItem() instanceof ILexicon))
return null;
return lex;
}
case LibGuiIDs.CRAFTING_HALO : {