Added an easy ability to add booklet pages through the API

This commit is contained in:
Ellpeck 2016-07-31 17:20:49 +02:00
parent 45df4e0c35
commit ab734ff839
3 changed files with 43 additions and 1 deletions

View file

@ -10,10 +10,13 @@
package de.ellpeck.actuallyadditions.api.internal;
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
/**
@ -34,4 +37,12 @@ public interface IMethodHandler{
PotionEffect[] getEffectsFromStack(ItemStack stack);
boolean invokeConversionLens(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile);
BookletPage generateTextPage(int id);
BookletPage generatePicturePage(int id, ResourceLocation resLoc, int textStartY);
BookletPage generateCraftingPage(int id, IRecipe... recipes);
BookletPage generateFurnacePage(int id, ItemStack input, ItemStack result);
}

View file

@ -24,9 +24,13 @@ public class PagePicture extends PageTextOnly{
private final int textStartY;
public PagePicture(int id, String resLocName, int textStartY){
this(id, AssetUtil.getBookletGuiLocation(resLocName), textStartY);
}
public PagePicture(int id, ResourceLocation resLoc, int textStartY){
super(id);
this.textStartY = textStartY;
this.resLoc = AssetUtil.getBookletGuiLocation(resLocName);
this.resLoc = resLoc;
}
@Override

View file

@ -10,10 +10,15 @@
package de.ellpeck.actuallyadditions.mod.misc;
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
import de.ellpeck.actuallyadditions.api.internal.IMethodHandler;
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
import de.ellpeck.actuallyadditions.mod.booklet.page.PageCrafting;
import de.ellpeck.actuallyadditions.mod.booklet.page.PageFurnace;
import de.ellpeck.actuallyadditions.mod.booklet.page.PagePicture;
import de.ellpeck.actuallyadditions.mod.booklet.page.PageTextOnly;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.items.lens.LensRecipeHandler;
import net.minecraft.block.Block;
@ -21,9 +26,11 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
@ -182,4 +189,24 @@ public class MethodHandler implements IMethodHandler{
}
return false;
}
@Override
public BookletPage generateTextPage(int id){
return new PageTextOnly(id);
}
@Override
public BookletPage generatePicturePage(int id, ResourceLocation resLoc, int textStartY){
return new PagePicture(id, resLoc, textStartY);
}
@Override
public BookletPage generateCraftingPage(int id, IRecipe... recipes){
return new PageCrafting(id, recipes);
}
@Override
public BookletPage generateFurnacePage(int id, ItemStack input, ItemStack result){
return new PageFurnace(id, input, result);
}
}