2015-11-24 19:59:33 +01:00
|
|
|
/*
|
2015-12-30 22:02:15 +01:00
|
|
|
* This file ("GuiBookletStand.java") is part of the Actually Additions Mod for Minecraft.
|
2015-11-24 19:59:33 +01:00
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
|
|
|
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
|
|
|
* © 2015 Ellpeck
|
|
|
|
*/
|
|
|
|
|
2015-12-30 22:02:15 +01:00
|
|
|
package de.ellpeck.actuallyadditions.booklet;
|
2015-11-24 19:59:33 +01:00
|
|
|
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2015-12-30 22:02:15 +01:00
|
|
|
import de.ellpeck.actuallyadditions.network.PacketBookletStandButton;
|
|
|
|
import de.ellpeck.actuallyadditions.network.PacketHandler;
|
|
|
|
import de.ellpeck.actuallyadditions.tile.TileEntityBase;
|
|
|
|
import de.ellpeck.actuallyadditions.tile.TileEntityBookletStand;
|
2015-11-24 19:59:33 +01:00
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.client.gui.GuiButton;
|
|
|
|
|
2015-11-29 14:30:44 +01:00
|
|
|
import java.util.Objects;
|
|
|
|
|
2015-11-24 19:59:33 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public class GuiBookletStand extends GuiBooklet{
|
|
|
|
|
|
|
|
private GuiButton buttonSetPage;
|
|
|
|
|
|
|
|
private TileEntityBookletStand theStand;
|
|
|
|
|
|
|
|
public GuiBookletStand(TileEntityBase theStand){
|
|
|
|
super(null, false, false);
|
|
|
|
this.theStand = (TileEntityBookletStand)theStand;
|
|
|
|
}
|
|
|
|
|
2015-12-01 19:48:09 +01:00
|
|
|
@Override
|
|
|
|
public void actionPerformed(GuiButton button){
|
|
|
|
if(button == this.buttonSetPage){
|
2015-12-04 18:55:50 +01:00
|
|
|
PacketHandler.theNetwork.sendToServer(new PacketBookletStandButton(this.theStand.xCoord, this.theStand.yCoord, this.theStand.zCoord, this.theStand.getWorldObj(), Minecraft.getMinecraft().thePlayer, this.currentEntrySet));
|
2015-12-01 19:48:09 +01:00
|
|
|
}
|
|
|
|
super.actionPerformed(button);
|
|
|
|
}
|
|
|
|
|
2015-11-24 19:59:33 +01:00
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@Override
|
|
|
|
public void initGui(){
|
|
|
|
super.initGui();
|
|
|
|
|
2015-11-24 21:45:03 +01:00
|
|
|
//Remove Bookmark Buttons
|
|
|
|
for(GuiButton bookmarkButton : this.bookmarkButtons){
|
|
|
|
bookmarkButton.visible = false;
|
|
|
|
}
|
|
|
|
|
2015-11-24 19:59:33 +01:00
|
|
|
this.buttonSetPage = new GuiButton(-100, this.guiLeft+this.xSize+10, this.guiTop+10, 100, 20, "Set Page"){
|
|
|
|
@Override
|
|
|
|
public void drawButton(Minecraft mc, int x, int y){
|
|
|
|
boolean unicodeBefore = mc.fontRenderer.getUnicodeFlag();
|
|
|
|
mc.fontRenderer.setUnicodeFlag(false);
|
|
|
|
super.drawButton(mc, x, y);
|
|
|
|
mc.fontRenderer.setUnicodeFlag(unicodeBefore);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
this.buttonList.add(this.buttonSetPage);
|
|
|
|
|
2015-11-29 14:30:44 +01:00
|
|
|
this.buttonSetPage.visible = Objects.equals(Minecraft.getMinecraft().thePlayer.getCommandSenderName(), this.theStand.assignedPlayer);
|
2015-11-24 19:59:33 +01:00
|
|
|
|
|
|
|
//Open the pages the book was assigned
|
2015-12-04 18:55:50 +01:00
|
|
|
BookletUtils.openIndexEntry(this, this.theStand.assignedEntry.entry, this.theStand.assignedEntry.pageInIndex, true);
|
|
|
|
BookletUtils.openChapter(this, this.theStand.assignedEntry.chapter, this.theStand.assignedEntry.page);
|
2015-11-24 19:59:33 +01:00
|
|
|
}
|
|
|
|
}
|