mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-29 18:28:34 +01:00
Added Atomic Reconstructor NEI Handler
This commit is contained in:
parent
2902f5d8a5
commit
4163643299
7 changed files with 151 additions and 10 deletions
|
@ -35,9 +35,9 @@ import ellpeck.actuallyadditions.misc.*;
|
||||||
import ellpeck.actuallyadditions.network.PacketHandler;
|
import ellpeck.actuallyadditions.network.PacketHandler;
|
||||||
import ellpeck.actuallyadditions.ore.InitOreDict;
|
import ellpeck.actuallyadditions.ore.InitOreDict;
|
||||||
import ellpeck.actuallyadditions.proxy.IProxy;
|
import ellpeck.actuallyadditions.proxy.IProxy;
|
||||||
import ellpeck.actuallyadditions.recipe.AtomicReconstructorRecipeHandler;
|
|
||||||
import ellpeck.actuallyadditions.recipe.FuelHandler;
|
import ellpeck.actuallyadditions.recipe.FuelHandler;
|
||||||
import ellpeck.actuallyadditions.recipe.HairyBallHandler;
|
import ellpeck.actuallyadditions.recipe.HairyBallHandler;
|
||||||
|
import ellpeck.actuallyadditions.recipe.ReconstructorRecipeHandler;
|
||||||
import ellpeck.actuallyadditions.recipe.TreasureChestHandler;
|
import ellpeck.actuallyadditions.recipe.TreasureChestHandler;
|
||||||
import ellpeck.actuallyadditions.tile.TileEntityBase;
|
import ellpeck.actuallyadditions.tile.TileEntityBase;
|
||||||
import ellpeck.actuallyadditions.update.UpdateChecker;
|
import ellpeck.actuallyadditions.update.UpdateChecker;
|
||||||
|
@ -100,7 +100,7 @@ public class ActuallyAdditions{
|
||||||
ItemCrafting.initMashedFoodRecipes();
|
ItemCrafting.initMashedFoodRecipes();
|
||||||
HairyBallHandler.init();
|
HairyBallHandler.init();
|
||||||
TreasureChestHandler.init();
|
TreasureChestHandler.init();
|
||||||
AtomicReconstructorRecipeHandler.init();
|
ReconstructorRecipeHandler.init();
|
||||||
InitForeignPaxels.init();
|
InitForeignPaxels.init();
|
||||||
proxy.postInit(event);
|
proxy.postInit(event);
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ import ellpeck.actuallyadditions.booklet.page.BookletPage;
|
||||||
import ellpeck.actuallyadditions.booklet.page.PageCrafting;
|
import ellpeck.actuallyadditions.booklet.page.PageCrafting;
|
||||||
import ellpeck.actuallyadditions.booklet.page.PageReconstructor;
|
import ellpeck.actuallyadditions.booklet.page.PageReconstructor;
|
||||||
import ellpeck.actuallyadditions.crafting.MiscCrafting;
|
import ellpeck.actuallyadditions.crafting.MiscCrafting;
|
||||||
import ellpeck.actuallyadditions.recipe.AtomicReconstructorRecipeHandler;
|
import ellpeck.actuallyadditions.recipe.ReconstructorRecipeHandler;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -45,7 +45,7 @@ public class BookletChapterReconstructor extends BookletChapter{
|
||||||
}
|
}
|
||||||
}.setNoText());
|
}.setNoText());
|
||||||
|
|
||||||
for(AtomicReconstructorRecipeHandler.Recipe recipe : AtomicReconstructorRecipeHandler.recipes){
|
for(ReconstructorRecipeHandler.Recipe recipe : ReconstructorRecipeHandler.recipes){
|
||||||
BookletPage page = new PageReconstructor(allPages.size()+1, recipe.getFirstOutput()).setNoText();
|
BookletPage page = new PageReconstructor(allPages.size()+1, recipe.getFirstOutput()).setNoText();
|
||||||
allPages.add(page);
|
allPages.add(page);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ package ellpeck.actuallyadditions.booklet.page;
|
||||||
import ellpeck.actuallyadditions.blocks.InitBlocks;
|
import ellpeck.actuallyadditions.blocks.InitBlocks;
|
||||||
import ellpeck.actuallyadditions.booklet.GuiBooklet;
|
import ellpeck.actuallyadditions.booklet.GuiBooklet;
|
||||||
import ellpeck.actuallyadditions.proxy.ClientProxy;
|
import ellpeck.actuallyadditions.proxy.ClientProxy;
|
||||||
import ellpeck.actuallyadditions.recipe.AtomicReconstructorRecipeHandler;
|
import ellpeck.actuallyadditions.recipe.ReconstructorRecipeHandler;
|
||||||
import ellpeck.actuallyadditions.util.ModUtil;
|
import ellpeck.actuallyadditions.util.ModUtil;
|
||||||
import ellpeck.actuallyadditions.util.StringUtil;
|
import ellpeck.actuallyadditions.util.StringUtil;
|
||||||
import ellpeck.actuallyadditions.util.Util;
|
import ellpeck.actuallyadditions.util.Util;
|
||||||
|
@ -95,7 +95,7 @@ public class PageReconstructor extends BookletPage{
|
||||||
}
|
}
|
||||||
|
|
||||||
private ItemStack getInputForOutput(ItemStack output){
|
private ItemStack getInputForOutput(ItemStack output){
|
||||||
for(AtomicReconstructorRecipeHandler.Recipe recipe : AtomicReconstructorRecipeHandler.recipes){
|
for(ReconstructorRecipeHandler.Recipe recipe : ReconstructorRecipeHandler.recipes){
|
||||||
ArrayList<ItemStack> stacks = OreDictionary.getOres(recipe.output);
|
ArrayList<ItemStack> stacks = OreDictionary.getOres(recipe.output);
|
||||||
for(ItemStack stack : stacks){
|
for(ItemStack stack : stacks){
|
||||||
if(output.isItemEqual(stack)){
|
if(output.isItemEqual(stack)){
|
||||||
|
|
|
@ -0,0 +1,137 @@
|
||||||
|
/*
|
||||||
|
* This file ("AtomicReconstructorRecipeHandler.java") is part of the Actually Additions Mod for Minecraft.
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
package ellpeck.actuallyadditions.nei;
|
||||||
|
|
||||||
|
import codechicken.lib.gui.GuiDraw;
|
||||||
|
import codechicken.nei.PositionedStack;
|
||||||
|
import codechicken.nei.recipe.RecipeInfo;
|
||||||
|
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||||
|
import ellpeck.actuallyadditions.blocks.InitBlocks;
|
||||||
|
import ellpeck.actuallyadditions.recipe.ReconstructorRecipeHandler;
|
||||||
|
import ellpeck.actuallyadditions.util.ItemUtil;
|
||||||
|
import ellpeck.actuallyadditions.util.ModUtil;
|
||||||
|
import ellpeck.actuallyadditions.util.StringUtil;
|
||||||
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
public class AtomicReconstructorRecipeHandler extends TemplateRecipeHandler implements INeiRecipeHandler{
|
||||||
|
|
||||||
|
public static final String NAME = "actuallyadditions.reconstructor";
|
||||||
|
|
||||||
|
public AtomicReconstructorRecipeHandler(){
|
||||||
|
super();
|
||||||
|
RecipeInfo.setGuiOffset(this.getGuiClass(), 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getStackForInfo(int page){
|
||||||
|
return new ItemStack(InitBlocks.blockAtomicReconstructor);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRecipeName(){
|
||||||
|
return StringUtil.localize("container.nei."+NAME+".name");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadTransferRects(){
|
||||||
|
transferRects.add(new RecipeTransferRect(new Rectangle(31+32, 18, 22, 16), NAME));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadCraftingRecipes(String outputId, Object... results){
|
||||||
|
if(outputId.equals(NAME) && getClass() == AtomicReconstructorRecipeHandler.class){
|
||||||
|
ArrayList<ReconstructorRecipeHandler.Recipe> recipes = ReconstructorRecipeHandler.recipes;
|
||||||
|
for(ReconstructorRecipeHandler.Recipe recipe : recipes){
|
||||||
|
arecipes.add(new CachedReconstructorRecipe(recipe.input, recipe.output));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
super.loadCraftingRecipes(outputId, results);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadCraftingRecipes(ItemStack result){
|
||||||
|
ArrayList<ReconstructorRecipeHandler.Recipe> recipes = ReconstructorRecipeHandler.recipes;
|
||||||
|
for(ReconstructorRecipeHandler.Recipe recipe : recipes){
|
||||||
|
if(ItemUtil.contains(OreDictionary.getOres(recipe.output), result, true)){
|
||||||
|
arecipes.add(new CachedReconstructorRecipe(recipe.input, recipe.output));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadUsageRecipes(ItemStack ingredient){
|
||||||
|
ArrayList<ReconstructorRecipeHandler.Recipe> recipes = ReconstructorRecipeHandler.recipes;
|
||||||
|
for(ReconstructorRecipeHandler.Recipe recipe : recipes){
|
||||||
|
if(ItemUtil.contains(OreDictionary.getOres(recipe.input), ingredient, true)){
|
||||||
|
CachedReconstructorRecipe theRecipe = new CachedReconstructorRecipe(recipe.input, recipe.output);
|
||||||
|
theRecipe.setIngredientPermutation(Collections.singletonList(theRecipe.input), ingredient);
|
||||||
|
arecipes.add(theRecipe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getGuiTexture(){
|
||||||
|
return ModUtil.MOD_ID_LOWER+":textures/gui/guiNEISimple.png";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOverlayIdentifier(){
|
||||||
|
return NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends GuiContainer> getGuiClass(){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawBackground(int recipeIndex){
|
||||||
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
GuiDraw.changeTexture(getGuiTexture());
|
||||||
|
GuiDraw.drawTexturedModalRect(32, 0, 0, 0, 96, 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int recipiesPerPage(){
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CachedReconstructorRecipe extends CachedRecipe{
|
||||||
|
|
||||||
|
public PositionedStack result;
|
||||||
|
public PositionedStack input;
|
||||||
|
|
||||||
|
public CachedReconstructorRecipe(String input, String result){
|
||||||
|
this.result = new PositionedStack(OreDictionary.getOres(result), 67+32, 19);
|
||||||
|
this.input = new PositionedStack(OreDictionary.getOres(input), 5+32, 19);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PositionedStack getResult(){
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PositionedStack getIngredient(){
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -56,6 +56,10 @@ public class NEIActuallyAdditionsConfig implements IConfigureNEI{
|
||||||
API.registerRecipeHandler(coffeeMachineRecipeHandler);
|
API.registerRecipeHandler(coffeeMachineRecipeHandler);
|
||||||
API.registerUsageHandler(coffeeMachineRecipeHandler);
|
API.registerUsageHandler(coffeeMachineRecipeHandler);
|
||||||
|
|
||||||
|
AtomicReconstructorRecipeHandler atomicReconstructorRecipeHandler = new AtomicReconstructorRecipeHandler();
|
||||||
|
API.registerRecipeHandler(atomicReconstructorRecipeHandler);
|
||||||
|
API.registerUsageHandler(atomicReconstructorRecipeHandler);
|
||||||
|
|
||||||
BookletInfoRecipeHandler bookletInfoRecipeHandler = new BookletInfoRecipeHandler();
|
BookletInfoRecipeHandler bookletInfoRecipeHandler = new BookletInfoRecipeHandler();
|
||||||
API.registerRecipeHandler(bookletInfoRecipeHandler);
|
API.registerRecipeHandler(bookletInfoRecipeHandler);
|
||||||
API.registerUsageHandler(bookletInfoRecipeHandler);
|
API.registerUsageHandler(bookletInfoRecipeHandler);
|
||||||
|
|
|
@ -16,7 +16,7 @@ import net.minecraftforge.oredict.OreDictionary;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class AtomicReconstructorRecipeHandler{
|
public class ReconstructorRecipeHandler{
|
||||||
|
|
||||||
public static ArrayList<Recipe> recipes = new ArrayList<Recipe>();
|
public static ArrayList<Recipe> recipes = new ArrayList<Recipe>();
|
||||||
|
|
|
@ -17,7 +17,7 @@ import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
||||||
import ellpeck.actuallyadditions.misc.DamageSources;
|
import ellpeck.actuallyadditions.misc.DamageSources;
|
||||||
import ellpeck.actuallyadditions.network.PacketAtomicReconstructor;
|
import ellpeck.actuallyadditions.network.PacketAtomicReconstructor;
|
||||||
import ellpeck.actuallyadditions.network.PacketHandler;
|
import ellpeck.actuallyadditions.network.PacketHandler;
|
||||||
import ellpeck.actuallyadditions.recipe.AtomicReconstructorRecipeHandler;
|
import ellpeck.actuallyadditions.recipe.ReconstructorRecipeHandler;
|
||||||
import ellpeck.actuallyadditions.util.WorldPos;
|
import ellpeck.actuallyadditions.util.WorldPos;
|
||||||
import ellpeck.actuallyadditions.util.WorldUtil;
|
import ellpeck.actuallyadditions.util.WorldUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -67,7 +67,7 @@ public class TileEntityAtomicReconstructor extends TileEntityBase implements IEn
|
||||||
for(int reachY = -range; reachY < range+1; reachY++){
|
for(int reachY = -range; reachY < range+1; reachY++){
|
||||||
if(this.storage.getEnergyStored() >= usePerBlock){
|
if(this.storage.getEnergyStored() >= usePerBlock){
|
||||||
WorldPos pos = new WorldPos(worldObj, coordsBlock.getX()+reachX, coordsBlock.getY()+reachY, coordsBlock.getZ()+reachZ);
|
WorldPos pos = new WorldPos(worldObj, coordsBlock.getX()+reachX, coordsBlock.getY()+reachY, coordsBlock.getZ()+reachZ);
|
||||||
AtomicReconstructorRecipeHandler.Recipe recipe = AtomicReconstructorRecipeHandler.getRecipe(new ItemStack(pos.getBlock(), pos.getMetadata()));
|
ReconstructorRecipeHandler.Recipe recipe = ReconstructorRecipeHandler.getRecipe(new ItemStack(pos.getBlock(), pos.getMetadata()));
|
||||||
if(recipe != null){
|
if(recipe != null){
|
||||||
ItemStack output = recipe.getFirstOutput();
|
ItemStack output = recipe.getFirstOutput();
|
||||||
if(output != null){
|
if(output != null){
|
||||||
|
@ -93,7 +93,7 @@ public class TileEntityAtomicReconstructor extends TileEntityBase implements IEn
|
||||||
if(this.storage.getEnergyStored() >= usePerBlock){
|
if(this.storage.getEnergyStored() >= usePerBlock){
|
||||||
ItemStack stack = item.getEntityItem();
|
ItemStack stack = item.getEntityItem();
|
||||||
if(stack != null){
|
if(stack != null){
|
||||||
AtomicReconstructorRecipeHandler.Recipe recipe = AtomicReconstructorRecipeHandler.getRecipe(stack);
|
ReconstructorRecipeHandler.Recipe recipe = ReconstructorRecipeHandler.getRecipe(stack);
|
||||||
if(recipe != null){
|
if(recipe != null){
|
||||||
ItemStack output = recipe.getFirstOutput();
|
ItemStack output = recipe.getFirstOutput();
|
||||||
if(output != null){
|
if(output != null){
|
||||||
|
|
Loading…
Reference in a new issue