Actually added a feature for once! (Enchanted book splitting)
Added a transformHook in LensConversionRecipe
Made the booklet have max stack size of 1
Moved the text over a bit on reconstructor recipe pages
This commit is contained in:
Shadows_of_Fire 2017-12-12 01:54:12 -05:00
parent 9388605e24
commit 1954da6edb
11 changed files with 99 additions and 28 deletions

View file

@ -10,8 +10,11 @@
package de.ellpeck.actuallyadditions.api.recipe;
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
import de.ellpeck.actuallyadditions.api.lens.LensConversion;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
public class LensConversionRecipe{
@ -26,4 +29,6 @@ public class LensConversionRecipe{
this.energyUse = energyUse;
this.type = type;
}
public void transformHook(ItemStack stack, IBlockState state, BlockPos pos, IAtomicReconstructor tile) {}
}

View file

@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors;
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
@ -184,6 +185,7 @@ public final class InitBooklet{
//Reconstruction
chaptersIntroduction[7] = new BookletChapter("reconstructorLenses", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.LENS.ordinal()), new PageTextOnly(1)).setImportant();
new BookletChapter("additionalRecipes", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(Items.LEATHER), new PageReconstructor(1, LensRecipeHandler.recipeSoulSand).setNoText(), new PageReconstructor(2, LensRecipeHandler.recipeLeather).setNoText(), new PageReconstructor(3, LensRecipeHandler.recipeNetherWart).setNoText(), new PageReconstructor(4, LensRecipeHandler.recipePrismarine).setNoText()).setSpecial();
new BookletChapter("bookSplitting", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(Items.ENCHANTED_BOOK), new PageTextOnly(1), new PageReconstructor(2, new LensConversionRecipe(new ItemStack(Items.ENCHANTED_BOOK), new ItemStack(Items.ENCHANTED_BOOK), 0, ActuallyAdditionsAPI.lensDefaultConversion)).setNoText());
new BookletChapter("lensColor", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(InitItems.itemColorLens), new PageTextOnly(1), new PageReconstructor(2, LensRecipeHandler.recipeColorLens).setNoText());
new BookletChapter("lensDeath", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(InitItems.itemDamageLens), new PageTextOnly(1), new PageReconstructor(2, LensRecipeHandler.recipeDamageLens).setNoText());
new BookletChapter("lensMoreDeath", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(InitItems.itemMoreDamageLens), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeLensMoreDeath).setNoText());

View file

@ -41,7 +41,7 @@ public class PageReconstructor extends BookletPage{
gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS);
GuiUtils.drawTexturedModalRect(startX+30, startY+10, 80, 146, 68, 48, 0);
gui.renderScaledAsciiString("("+StringUtil.localize("booklet."+ModUtil.MOD_ID+".reconstructorRecipe")+")", startX+12, startY+63, 0, false, gui.getMediumFontSize());
gui.renderScaledAsciiString("("+StringUtil.localize("booklet."+ModUtil.MOD_ID+".reconstructorRecipe")+")", startX+6, startY+63, 0, false, gui.getMediumFontSize());
PageTextOnly.renderTextToPage(gui, this, startX+6, startY+88);
}

View file

@ -49,7 +49,7 @@ public class ItemBooklet extends ItemBase implements IHudDisplay{
public ItemBooklet(String name){
super(name);
this.setMaxStackSize(16);
this.setMaxStackSize(1);
this.setMaxDamage(0);
}

View file

@ -10,6 +10,8 @@
package de.ellpeck.actuallyadditions.mod.items.lens;
import java.util.ArrayList;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.recipe.ColorLensChangerByDyeMeta;
import de.ellpeck.actuallyadditions.api.recipe.IColorLensChanger;
@ -18,6 +20,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
import de.ellpeck.actuallyadditions.mod.recipe.EnchBookConversion;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.RecipeUtil;
import net.minecraft.init.Blocks;
@ -25,8 +28,6 @@ import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
public final class LensRecipeHandler{
public static final ArrayList<LensConversionRecipe> MAIN_PAGE_RECIPES = new ArrayList<LensConversionRecipe>();
@ -42,6 +43,7 @@ public final class LensRecipeHandler{
public static LensConversionRecipe recipeCrystallizedCanolaSeed;
public static LensConversionRecipe recipeItemLaser;
public static LensConversionRecipe recipeFluidLaser;
public static EnchBookConversion recipeEnchBook;
public static void init(){
//Crystal Blocks
@ -105,6 +107,8 @@ public final class LensRecipeHandler{
recipeWhiteWall = RecipeUtil.lastReconstructorRecipe();
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Blocks.QUARTZ_BLOCK, 1, 1), new ItemStack(InitBlocks.blockTestifiBucksGreenWall), 10);
recipeGreenWall = RecipeUtil.lastReconstructorRecipe();
ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES.add(recipeEnchBook = new EnchBookConversion());
IColorLensChanger changer = new ColorLensChangerByDyeMeta();
ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Items.DYE, changer);

View file

@ -37,9 +37,11 @@ import de.ellpeck.actuallyadditions.mod.jei.empowerer.EmpowererRecipeWrapper;
import de.ellpeck.actuallyadditions.mod.jei.reconstructor.ReconstructorRecipeCategory;
import de.ellpeck.actuallyadditions.mod.jei.reconstructor.ReconstructorRecipeWrapper;
import de.ellpeck.actuallyadditions.mod.util.Util;
import mezz.jei.api.*;
import mezz.jei.api.IJeiHelpers;
import mezz.jei.api.IModPlugin;
import mezz.jei.api.IModRegistry;
import mezz.jei.api.JEIPlugin;
import mezz.jei.api.ingredients.IIngredientBlacklist;
import mezz.jei.api.ingredients.IModIngredientRegistration;
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
import mezz.jei.api.recipe.transfer.IRecipeTransferRegistry;
@ -47,16 +49,6 @@ import net.minecraft.item.ItemStack;
@JEIPlugin
public class JEIActuallyAdditionsPlugin implements IModPlugin{
@Override
public void registerItemSubtypes(ISubtypeRegistry subtypeRegistry){
}
@Override
public void registerIngredients(IModIngredientRegistration registry){
}
@Override
public void registerCategories(IRecipeCategoryRegistration registry) {
@ -77,7 +69,7 @@ public class JEIActuallyAdditionsPlugin implements IModPlugin{
registry.handleRecipes(IBookletPage.class, BookletRecipeWrapper::new, BookletRecipeCategory.NAME);
registry.handleRecipes(CoffeeIngredient.class, CoffeeMachineRecipeWrapper::new, CoffeeMachineRecipeCategory.NAME);
registry.handleRecipes(CrusherRecipe.class, CrusherRecipeWrapper::new, CrusherRecipeCategory.NAME);
registry.handleRecipes(LensConversionRecipe.class, ReconstructorRecipeWrapper::new, ReconstructorRecipeCategory.NAME);
registry.handleRecipes(LensConversionRecipe.class, ReconstructorRecipeWrapper.FACTORY, ReconstructorRecipeCategory.NAME);
registry.handleRecipes(EmpowererRecipe.class, EmpowererRecipeWrapper::new, EmpowererRecipeCategory.NAME);
registry.handleRecipes(CompostRecipe.class, CompostRecipeWrapper::new, CompostRecipeCategory.NAME);
@ -115,9 +107,4 @@ public class JEIActuallyAdditionsPlugin implements IModPlugin{
registry.addRecipeCatalyst(new ItemStack(InitItems.itemBooklet), BookletRecipeCategory.NAME);
registry.addRecipeCatalyst(new ItemStack(InitBlocks.blockCompost), CompostRecipeCategory.NAME);
}
@Override
public void onRuntimeAvailable(IJeiRuntime jeiRuntime){
}
}

View file

@ -61,9 +61,8 @@ public class ReconstructorRecipeCategory implements IRecipeCategory<Reconstructo
@Override
public void setRecipe(IRecipeLayout recipeLayout, ReconstructorRecipeWrapper wrapper, IIngredients ingredients){
recipeLayout.getItemStacks().init(0, true, 4, 18);
recipeLayout.getItemStacks().set(0, wrapper.theRecipe.inputStack);
recipeLayout.getItemStacks().set(0, ingredients.getInputs(ItemStack.class).get(0).get(0));
recipeLayout.getItemStacks().init(1, false, 66, 18);
recipeLayout.getItemStacks().set(1, wrapper.theRecipe.outputStack);
recipeLayout.getItemStacks().set(1, ingredients.getOutputs(ItemStack.class).get(0).get(0));
}
}

View file

@ -15,11 +15,22 @@ import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton;
import de.ellpeck.actuallyadditions.mod.recipe.EnchBookConversion;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeWrapperFactory;
import net.minecraft.client.Minecraft;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
public class ReconstructorRecipeWrapper extends RecipeWrapperWithButton{
public static final IRecipeWrapperFactory<LensConversionRecipe> FACTORY = (recipe) -> {
if(recipe instanceof EnchBookConversion) return new EnchBookWrapper((EnchBookConversion) recipe);
return new ReconstructorRecipeWrapper(recipe);
};
public final LensConversionRecipe theRecipe;
@ -53,4 +64,29 @@ public class ReconstructorRecipeWrapper extends RecipeWrapperWithButton{
public IBookletPage getPage(){
return BookletUtils.findFirstPageForStack(new ItemStack(InitBlocks.blockAtomicReconstructor));
}
public static class EnchBookWrapper extends ReconstructorRecipeWrapper {
private static final ItemStack BOOK = new ItemStack(Items.ENCHANTED_BOOK);
private static final ItemStack OUT = new ItemStack(Items.ENCHANTED_BOOK);
static {
OUT.setStackDisplayName("Split Book");
NBTTagCompound t = OUT.getTagCompound().getCompoundTag("display");
NBTTagList l = new NBTTagList();
l.appendTag(new NBTTagString("Book will be split based on enchantments!"));
t.setTag("Lore", l);
}
public EnchBookWrapper(EnchBookConversion recipe) {
super(recipe);
}
@Override
public void getIngredients(IIngredients ingredients){
ingredients.setInput(ItemStack.class, BOOK);
ingredients.setOutput(ItemStack.class, OUT);
}
}
}

View file

@ -173,8 +173,8 @@ public class MethodHandler implements IMethodHandler{
if(recipe != null && recipe.type == tile.getLens() && tile.getEnergy() >= recipe.energyUse){
ItemStack output = recipe.outputStack;
if(StackUtil.isValid(output)){
tile.getWorldObject().playEvent(2001, pos, Block.getStateId(tile.getWorldObject().getBlockState(pos)));
//This change might break something? Not sure. It could.
tile.getWorldObject().playEvent(2001, pos, Block.getStateId(state));
recipe.transformHook(ItemStack.EMPTY, state, pos, tile);
if(output.getItem() instanceof ItemBlock){
Block toPlace = Block.getBlockFromItem(output.getItem());
IBlockState state2Place = toPlace.getStateForPlacement(tile.getWorldObject(), pos, facing, 0, 0, 0, output.getMetadata(), FakePlayerFactory.getMinecraft((WorldServer) tile.getWorldObject()), EnumHand.MAIN_HAND);
@ -197,7 +197,7 @@ public class MethodHandler implements IMethodHandler{
}
//Converting the Items
ArrayList<EntityItem> items = (ArrayList<EntityItem>)tile.getWorldObject().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(hitBlock.getX()-rangeX, hitBlock.getY()-rangeY, hitBlock.getZ()-rangeZ, hitBlock.getX()+1+rangeX, hitBlock.getY()+1+rangeY, hitBlock.getZ()+1+rangeZ));
List<EntityItem> items = tile.getWorldObject().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(hitBlock.getX()-rangeX, hitBlock.getY()-rangeY, hitBlock.getZ()-rangeZ, hitBlock.getX()+1+rangeX, hitBlock.getY()+1+rangeY, hitBlock.getZ()+1+rangeZ));
for(EntityItem item : items){
ItemStack stack = item.getItem();
if(!item.isDead && StackUtil.isValid(stack)){
@ -207,6 +207,7 @@ public class MethodHandler implements IMethodHandler{
int itemsPossible = Math.min(tile.getEnergy()/recipe.energyUse, StackUtil.getStackSize(stack));
if(itemsPossible > 0){
recipe.transformHook(item.getItem(), null, item.getPosition(), tile);
item.setDead();
if(StackUtil.getStackSize(stack)-itemsPossible > 0){

View file

@ -0,0 +1,34 @@
package de.ellpeck.actuallyadditions.mod.recipe;
import java.util.Map;
import com.google.common.collect.ImmutableMap;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
public class EnchBookConversion extends LensConversionRecipe {
public EnchBookConversion() {
super(new ItemStack(Items.ENCHANTED_BOOK), ItemStack.EMPTY, 155000, ActuallyAdditionsAPI.lensDefaultConversion);
}
@Override
public void transformHook(ItemStack stack, IBlockState state, BlockPos pos, IAtomicReconstructor tile) {
for(Map.Entry<Enchantment,Integer> e : EnchantmentHelper.getEnchantments(stack).entrySet()) {
ItemStack book = new ItemStack(Items.ENCHANTED_BOOK);
Map<Enchantment, Integer> ench = ImmutableMap.of(e.getKey(), e.getValue());
EnchantmentHelper.setEnchantments(ench, book);
Block.spawnAsEntity(tile.getWorldObject(), pos, book);
}
}
}

View file

@ -1085,6 +1085,9 @@ booklet.actuallyadditions.chapter.reconstructorLenses.text.1=The <item>Atomic Re
booklet.actuallyadditions.chapter.additionalRecipes.name=Additional Recipes
booklet.actuallyadditions.chapter.bookSplitting.name=Splitting Enchanted Books
booklet.actuallyadditions.chapter.bookSplitting.text.1=The <item>Atomic Reconstructor<r> has the ability to split books with multiple enchantments into more books, with only a single enchantment each. This costs <imp>155000 CF<r>, so you will only ever be able to split a single book at a time. Be careful to not leave multiple books in the path of the reconstructor, or it might hit one with only a single enchantment, <imp>voiding 155000 CF<r>! As a side effect, this process generates enchanted books out of thin air to fulfill it's purpose. Magic, right?
booklet.actuallyadditions.chapter.lensColor.name=Lens of Color
booklet.actuallyadditions.chapter.lensColor.text.1=The <item>Lens of Color<r> changes the color of <imp>Stained Glass and Panes, Stained Clay, Carpet, Dye, Lamps, Wool<r> in its sight. <n>Contrary to using no lens, it goes <imp>through blocks<r> and only converts blocks it touches.