mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 16:58:34 +01:00
Some more booklet work
This commit is contained in:
parent
81584c2fb1
commit
c85a3c72a1
5 changed files with 48 additions and 14 deletions
|
@ -33,7 +33,7 @@ public abstract class GuiBooklet extends GuiBookletBase{
|
||||||
public static final ResourceLocation RES_LOC_GADGETS = AssetUtil.getBookletGuiLocation("guiBookletGadgets");
|
public static final ResourceLocation RES_LOC_GADGETS = AssetUtil.getBookletGuiLocation("guiBookletGadgets");
|
||||||
|
|
||||||
public GuiScreen previousScreen;
|
public GuiScreen previousScreen;
|
||||||
protected GuiBookletBase parentPage;
|
public GuiBookletBase parentPage;
|
||||||
|
|
||||||
private GuiButton buttonLeft;
|
private GuiButton buttonLeft;
|
||||||
private GuiButton buttonRight;
|
private GuiButton buttonRight;
|
||||||
|
|
|
@ -93,6 +93,33 @@ public class GuiEntry extends GuiBooklet{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPageLeftButton(){
|
||||||
|
return this.entryPage > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageLeftButtonPressed(){
|
||||||
|
this.mc.displayGuiScreen(new GuiEntry(this.previousScreen, this.parentPage, this.entry, this.entryPage-1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPageRightButton(){
|
||||||
|
if(!this.chapters.isEmpty()){
|
||||||
|
IBookletChapter lastChap = this.chapters.get(this.chapters.size()-1);
|
||||||
|
if(lastChap != null){
|
||||||
|
int lastPage = calcEntryPage(this.entry, lastChap);
|
||||||
|
return this.entryPage < lastPage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageRightButtonPressed(){
|
||||||
|
this.mc.displayGuiScreen(new GuiEntry(this.previousScreen, this.parentPage, this.entry, this.entryPage+1));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasBackButton(){
|
public boolean hasBackButton(){
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -32,19 +32,16 @@ public class GuiMainPage extends GuiBooklet{
|
||||||
public void initGui(){
|
public void initGui(){
|
||||||
super.initGui();
|
super.initGui();
|
||||||
|
|
||||||
for(int x = 0; x < 2; x++){
|
for(int i = 0; i < BUTTONS_PER_PAGE; i++){
|
||||||
for(int y = 0; y < BUTTONS_PER_PAGE; y++){
|
if(ActuallyAdditionsAPI.BOOKLET_ENTRIES.size() > i){
|
||||||
int id = y+x*BUTTONS_PER_PAGE;
|
IBookletEntry entry = ActuallyAdditionsAPI.BOOKLET_ENTRIES.get(i);
|
||||||
if(ActuallyAdditionsAPI.BOOKLET_ENTRIES.size() > id){
|
this.buttonList.add(new EntryButton(i, this.guiLeft+156, this.guiTop+11+i*16, 115, 10, entry.getLocalizedNameWithFormatting(), null));
|
||||||
IBookletEntry entry = ActuallyAdditionsAPI.BOOKLET_ENTRIES.get(id);
|
|
||||||
this.buttonList.add(new EntryButton(id, this.guiLeft+14+x*142, this.guiTop+11+y*16, 115, 10, entry.getLocalizedNameWithFormatting(), null));
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void actionPerformed(GuiButton button) throws IOException{
|
protected void actionPerformed(GuiButton button) throws IOException{
|
||||||
|
|
|
@ -13,7 +13,9 @@ package de.ellpeck.actuallyadditions.mod.inventory;
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
|
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
|
||||||
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiMainPage;
|
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiMainPage;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.gui.*;
|
import de.ellpeck.actuallyadditions.mod.inventory.gui.*;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.items.ItemBooklet;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -169,7 +171,14 @@ public class GuiHandler implements IGuiHandler{
|
||||||
case CLOUD:
|
case CLOUD:
|
||||||
return new GuiSmileyCloud(tile, x, y, z, world);
|
return new GuiSmileyCloud(tile, x, y, z, world);
|
||||||
case BOOK:
|
case BOOK:
|
||||||
|
if(ItemBooklet.forcedPage != null){
|
||||||
|
GuiBooklet gui = BookletUtils.createBookletGuiFromPage(null, ItemBooklet.forcedPage);
|
||||||
|
ItemBooklet.forcedPage = null;
|
||||||
|
return gui;
|
||||||
|
}
|
||||||
|
else{
|
||||||
return new GuiMainPage(null);
|
return new GuiMainPage(null);
|
||||||
|
}
|
||||||
case DIRECTIONAL_BREAKER:
|
case DIRECTIONAL_BREAKER:
|
||||||
return new GuiDirectionalBreaker(player.inventory, tile);
|
return new GuiDirectionalBreaker(player.inventory, tile);
|
||||||
case RANGED_COLLECTOR:
|
case RANGED_COLLECTOR:
|
||||||
|
|
|
@ -35,14 +35,15 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ItemBooklet extends ItemBase implements IHudDisplay{
|
public class ItemBooklet extends ItemBase implements IHudDisplay{
|
||||||
|
|
||||||
//TODO Fix this
|
@SideOnly(Side.CLIENT)
|
||||||
//@SideOnly(Side.CLIENT)
|
public static IBookletPage forcedPage;
|
||||||
//public static EntrySet forcedEntry;
|
|
||||||
|
|
||||||
public ItemBooklet(String name){
|
public ItemBooklet(String name){
|
||||||
super(name);
|
super(name);
|
||||||
|
@ -56,11 +57,11 @@ public class ItemBooklet extends ItemBase implements IHudDisplay{
|
||||||
if(player.isSneaking()){
|
if(player.isSneaking()){
|
||||||
IBlockState state = world.getBlockState(pos);
|
IBlockState state = world.getBlockState(pos);
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
ItemStack blockStack = new ItemStack(block, 1, block.getMetaFromState(state));
|
ItemStack blockStack = new ItemStack(block, 1, block.damageDropped(state));
|
||||||
IBookletPage page = BookletUtils.findFirstPageForStack(blockStack);
|
IBookletPage page = BookletUtils.findFirstPageForStack(blockStack);
|
||||||
if(page != null){
|
if(page != null){
|
||||||
if(world.isRemote){
|
if(world.isRemote){
|
||||||
//forcedEntry = new EntrySet(page, page.getChapter(), page.getChapter().getEntry(), ActuallyAdditionsAPI.BOOKLET_ENTRIES.indexOf(page.getChapter().getEntry())/GuiBooklet.CHAPTER_BUTTONS_AMOUNT+1);
|
forcedPage = page;
|
||||||
}
|
}
|
||||||
this.onItemRightClick(stack, world, player, hand);
|
this.onItemRightClick(stack, world, player, hand);
|
||||||
return EnumActionResult.SUCCESS;
|
return EnumActionResult.SUCCESS;
|
||||||
|
|
Loading…
Reference in a new issue