Changed the way crusher recipes are registered

Closes #297
This commit is contained in:
Ellpeck 2016-10-30 17:13:46 +01:00
parent 8f53736f6d
commit acebcb2fbd
19 changed files with 240 additions and 355 deletions

View file

@ -44,7 +44,7 @@ repositories {
}
dependencies {
compile "net.darkhax.tesla:Tesla:1.10.2-1.2.1.42"
compile "net.darkhax.tesla:Tesla:1.10.2-1.2.1.49"
deobfCompile "mezz.jei:jei_1.10.2:3.13.0.335"
}

View file

@ -20,7 +20,6 @@ import de.ellpeck.actuallyadditions.api.recipe.*;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList;
import java.util.HashMap;
@ -31,7 +30,7 @@ public final class ActuallyAdditionsAPI{
public static final String MOD_ID = "actuallyadditions";
public static final String API_ID = MOD_ID+"api";
public static final String API_VERSION = "23";
public static final String API_VERSION = "24";
public static final List<CrusherRecipe> CRUSHER_RECIPES = new ArrayList<CrusherRecipe>();
public static final List<BallOfFurReturn> BALL_OF_FUR_RETURN_ITEMS = new ArrayList<BallOfFurReturn>();
@ -90,8 +89,8 @@ public final class ActuallyAdditionsAPI{
* @param outputOne The first output's OreDictionary name
* @param outputOneAmount The amount of the first output
*/
@Deprecated //Use new version below
public static void addCrusherRecipe(String input, String outputOne, int outputOneAmount){
addCrusherRecipe(input, outputOne, outputOneAmount, "", 0, 0);
}
/**
@ -104,10 +103,8 @@ public final class ActuallyAdditionsAPI{
* @param outputTwoAmount The amount of the second output
* @param outputTwoChance The chance of the second output (0 won't occur at all, 100 will all the time)
*/
@Deprecated //Use new version below
public static void addCrusherRecipe(String input, String outputOne, int outputOneAmount, String outputTwo, int outputTwoAmount, int outputTwoChance){
if(!OreDictionary.getOres(input, false).isEmpty() && !OreDictionary.getOres(outputOne, false).isEmpty() && (outputTwo == null || outputTwo.isEmpty() || !OreDictionary.getOres(outputTwo, false).isEmpty())){
CRUSHER_RECIPES.add(new CrusherRecipe(input, outputOne, outputOneAmount, outputTwo, outputTwoAmount, outputTwoChance));
}
}
/**
@ -117,21 +114,8 @@ public final class ActuallyAdditionsAPI{
* @param input The input as an ItemStack
* @param outputOne The first output as an ItemStack
*/
@Deprecated //Use new version below
public static void addCrusherRecipe(ItemStack input, ItemStack outputOne){
addCrusherRecipe(input, outputOne, null, 0);
}
/**
* Adds a Recipe to the Crusher Recipe Registry
* The second output will be nothing
*
* @param input The input as an ItemStack
* @param outputOne The first output as an ItemStack
* @param outputTwo The second output as an ItemStack
* @param outputTwoChance The chance of the second output (0 won't occur at all, 100 will all the time)
*/
public static void addCrusherRecipe(ItemStack input, ItemStack outputOne, ItemStack outputTwo, int outputTwoChance){
CRUSHER_RECIPES.add(new CrusherRecipe(input, outputOne, outputTwo, outputTwoChance));
}
/**
@ -142,23 +126,46 @@ public final class ActuallyAdditionsAPI{
* @param outputOne The first output's OreDictionary name
* @param outputOneAmount The amount of the first output
*/
@Deprecated //Use new version below
public static void addCrusherRecipe(ItemStack input, String outputOne, int outputOneAmount){
if(!OreDictionary.getOres(outputOne, false).isEmpty()){
CRUSHER_RECIPES.add(new CrusherRecipe(input, outputOne, outputOneAmount));
}
}
/**
* Adds a Recipe to the Crusher Recipe Registry
* The second output will be nothing
*
* @param input The input as an ItemStack
* @param outputOne The first output's OreDictionary name
* @param input The input as an ItemStack
* @param outputOne The first output's OreDictionary name
*/
@Deprecated //Use new version below
public static void addCrusherRecipe(String input, ItemStack outputOne){
if(!OreDictionary.getOres(input, false).isEmpty()){
CRUSHER_RECIPES.add(new CrusherRecipe(input, outputOne));
}
}
/**
* Adds a Recipe to the Crusher Recipe Registry
*
* @param input The input as an ItemStack
* @param outputOne The first output as an ItemStack
* @param outputTwo The second output as an ItemStack (can be null if there should be none)
* @param outputTwoChance The chance of the second output (0 won't occur at all, 100 will all the time)
*/
public static void addCrusherRecipe(ItemStack input, ItemStack outputOne, ItemStack outputTwo, int outputTwoChance){
CRUSHER_RECIPES.add(new CrusherRecipe(input, outputOne, outputTwo, outputTwoChance));
}
/**
* Adds multiple Recipes to the Crusher Recipe Registry
* Use this if you want to add OreDictionary recipes easier
*
* @param inputs The inputs as an ItemStack List, stacksizes are ignored
* @param outputOnes The first outputs as an ItemStack List, stacksizes are ignored
* @param outputOneAmounts The amount of the first output, will be equal for all entries in the list
* @param outputTwos The second outputs as an ItemStack List (can be null or empty if there should be none)
* @param outputTwoAmounts The amount of the second output, will be equal for all entries in the list
* @param outputTwoChance The chance of the second output (0 won't occur at all, 100 will all the time)
*/
public static boolean addCrusherRecipes(List<ItemStack> inputs, List<ItemStack> outputOnes, int outputOneAmounts, List<ItemStack> outputTwos, int outputTwoAmounts, int outputTwoChance){
return methodHandler.addCrusherRecipes(inputs, outputOnes, outputOneAmounts, outputTwos, outputTwoAmounts, outputTwoChance);
}
/**
@ -237,12 +244,12 @@ public final class ActuallyAdditionsAPI{
* @param type The type of lens used for the conversion. To use the default type, use method below
* Note how this always has to be the same instance of the lens type that the item also has for it to work!
*/
@Deprecated //Use ItemStack recipes
public static void addReconstructorLensConversionRecipe(String input, String output, int energyUse, LensConversion type){
RECONSTRUCTOR_LENS_CONVERSION_RECIPES.add(new LensConversionRecipe(input, output, energyUse, type));
}
@Deprecated //Use ItemStack recipes
public static void addReconstructorLensConversionRecipe(String input, String output, int energyUse){
addReconstructorLensConversionRecipe(input, output, energyUse, lensDefaultConversion);
}
/**

View file

@ -21,6 +21,8 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import java.util.List;
/**
* This is the internal method handler.
* Use ActuallyAdditionsAPI.methodHandler for calling
@ -49,4 +51,6 @@ public interface IMethodHandler{
BookletPage generateFurnacePage(int id, ItemStack input, ItemStack result);
IBookletChapter generateBookletChapter(String identifier, IBookletEntry entry, ItemStack displayStack, BookletPage... pages);
boolean addCrusherRecipes(List<ItemStack> inputs, List<ItemStack> outputOnes, int outputOneAmounts, List<ItemStack> outputTwos, int outputTwoAmounts, int outputTwoChance);
}

View file

@ -14,41 +14,17 @@ import net.minecraft.item.ItemStack;
public class CrusherRecipe{
public int outputTwoChance;
public String input;
public String outputOne;
public int outputOneAmount;
public String outputTwo;
public int outputTwoAmount;
public ItemStack inputStack;
public ItemStack outputOneStack;
public ItemStack outputTwoStack;
public int outputTwoChance;
public CrusherRecipe(String input, ItemStack outputOne){
this.input = input;
this.outputOneStack = outputOne;
}
public CrusherRecipe(ItemStack input, String outputOne, int outputOneAmount){
this.inputStack = input;
this.outputOne = outputOne;
this.outputOneAmount = outputOneAmount;
}
public CrusherRecipe(ItemStack input, ItemStack outputOne, ItemStack outputTwo, int outputTwoChance){
this.inputStack = input;
this.outputOneStack = outputOne;
this.outputTwoStack = outputTwo;
public CrusherRecipe(ItemStack inputStack, ItemStack outputOneStack, ItemStack outputTwoStack, int outputTwoChance){
this.inputStack = inputStack;
this.outputOneStack = outputOneStack;
this.outputTwoStack = outputTwoStack;
this.outputTwoChance = outputTwoChance;
}
public CrusherRecipe(String input, String outputOne, int outputOneAmount, String outputTwo, int outputTwoAmount, int outputTwoChance){
this.input = input;
this.outputOne = outputOne;
this.outputOneAmount = outputOneAmount;
this.outputTwo = outputTwo;
this.outputTwoAmount = outputTwoAmount;
this.outputTwoChance = outputTwoChance;
}
}

View file

@ -17,8 +17,6 @@ public class LensConversionRecipe{
public final int energyUse;
public final LensConversion type;
public String input;
public String output;
public ItemStack inputStack;
public ItemStack outputStack;
@ -28,12 +26,4 @@ public class LensConversionRecipe{
this.energyUse = energyUse;
this.type = type;
}
public LensConversionRecipe(String input, String output, int energyUse, LensConversion type){
this.input = input;
this.output = output;
this.energyUse = energyUse;
this.type = type;
}
}

View file

@ -27,8 +27,6 @@ public class PageCrusherRecipe extends BookletPageAA{
public final CrusherRecipe recipe;
private int recipePos;
public PageCrusherRecipe(int id, CrusherRecipe recipe){
super(id);
this.recipe = recipe;
@ -65,41 +63,36 @@ public class PageCrusherRecipe extends BookletPageAA{
Minecraft.getMinecraft().fontRendererObj.drawString(this.recipe.outputTwoChance+"%", gui.getGuiLeft()+37+62, gui.getGuiTop()+20+33, 0);
}
List<ItemStack> outputOnes = RecipeUtil.getCrusherRecipeOutputOnes(this.recipe);
if(outputOnes != null){
for(int i = 0; i < 2; i++){
for(int j = 0; j < 3; j++){
ItemStack stack;
switch(j){
case 0:
List<ItemStack> inputs = RecipeUtil.getCrusherRecipeInputs(this.recipe);
stack = inputs.get(Math.min(inputs.size()-1, this.recipePos));
break;
case 1:
stack = outputOnes.get(Math.min(outputOnes.size()-1, this.recipePos));
break;
default:
List<ItemStack> outputTwos = RecipeUtil.getCrusherRecipeOutputTwos(this.recipe);
stack = outputTwos == null ? null : outputTwos.get(Math.min(outputTwos.size()-1, this.recipePos));
break;
for(int i = 0; i < 2; i++){
for(int j = 0; j < 3; j++){
ItemStack stack;
switch(j){
case 0:
stack = this.recipe.inputStack;
break;
case 1:
stack = this.recipe.outputOneStack;
break;
default:
stack = this.recipe.outputTwoStack;
break;
}
if(stack != null){
if(stack.getItemDamage() == Util.WILDCARD){
stack.setItemDamage(0);
}
if(stack != null){
if(stack.getItemDamage() == Util.WILDCARD){
stack.setItemDamage(0);
}
boolean tooltip = i == 1;
boolean tooltip = i == 1;
int xShow = gui.getGuiLeft()+37+(j == 0 ? 1 : (j == 1 ? 43 : (j == 2 ? 43 : 0)));
int yShow = gui.getGuiTop()+20+(j == 0 ? 21 : (j == 1 ? 11 : (j == 2 ? 29 : 0)));
if(!tooltip){
AssetUtil.renderStackToGui(stack, xShow, yShow, 1.0F);
}
else{
if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){
gui.renderTooltipAndTransferButton(this, stack, mouseX, mouseY, j == 0, mousePressed);
}
int xShow = gui.getGuiLeft()+37+(j == 0 ? 1 : (j == 1 ? 43 : (j == 2 ? 43 : 0)));
int yShow = gui.getGuiTop()+20+(j == 0 ? 21 : (j == 1 ? 11 : (j == 2 ? 29 : 0)));
if(!tooltip){
AssetUtil.renderStackToGui(stack, xShow, yShow, 1.0F);
}
else{
if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){
gui.renderTooltipAndTransferButton(this, stack, mouseX, mouseY, j == 0, mousePressed);
}
}
}
@ -108,23 +101,8 @@ public class PageCrusherRecipe extends BookletPageAA{
}
}
@Override
@SideOnly(Side.CLIENT)
public void updateScreen(int ticksElapsed){
if(ticksElapsed%10 == 0){
List<ItemStack> outputTwos = RecipeUtil.getCrusherRecipeOutputTwos(this.recipe);
if(this.recipePos+1 >= Math.max(RecipeUtil.getCrusherRecipeInputs(this.recipe).size(), Math.max(RecipeUtil.getCrusherRecipeOutputOnes(this.recipe).size(), outputTwos == null ? 0 : outputTwos.size()))){
this.recipePos = 0;
}
else{
this.recipePos++;
}
}
}
@Override
public ItemStack[] getItemStacksForPage(){
List<ItemStack> outputOnes = RecipeUtil.getCrusherRecipeOutputOnes(this.recipe);
return this.recipe == null ? new ItemStack[0] : outputOnes.toArray(new ItemStack[outputOnes.size()]);
return this.recipe == null ? new ItemStack[0] : new ItemStack[]{this.recipe.outputOneStack, this.recipe.outputTwoStack};
}
}

View file

@ -22,7 +22,6 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.List;
public class PageReconstructor extends BookletPageAA{
@ -69,24 +68,21 @@ public class PageReconstructor extends BookletPageAA{
AssetUtil.renderStackToGui(new ItemStack(InitBlocks.blockAtomicReconstructor), gui.getGuiLeft()+37+22, gui.getGuiTop()+20+21, 1.0F);
for(int i = 0; i < 2; i++){
for(int x = 0; x < 2; x++){
List<ItemStack> stacks = x == 0 ? RecipeUtil.getConversionLensInputs(recipe) : RecipeUtil.getConversionLensOutputs(recipe);
if(stacks != null && !stacks.isEmpty()){
ItemStack stack = stacks.get(0);
ItemStack stack = x == 0 ? recipe.inputStack : recipe.outputStack;
if(stack.getItemDamage() == Util.WILDCARD){
stack.setItemDamage(0);
}
boolean tooltip = i == 1;
if(stack.getItemDamage() == Util.WILDCARD){
stack.setItemDamage(0);
}
boolean tooltip = i == 1;
int xShow = gui.getGuiLeft()+37+1+x*42;
int yShow = gui.getGuiTop()+20+21;
if(!tooltip){
AssetUtil.renderStackToGui(stack, xShow, yShow, 1.0F);
}
else{
if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){
gui.renderTooltipAndTransferButton(this, stack, mouseX, mouseY, x == 0, mousePressed);
}
int xShow = gui.getGuiLeft()+37+1+x*42;
int yShow = gui.getGuiTop()+20+21;
if(!tooltip){
AssetUtil.renderStackToGui(stack, xShow, yShow, 1.0F);
}
else{
if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){
gui.renderTooltipAndTransferButton(this, stack, mouseX, mouseY, x == 0, mousePressed);
}
}
}
@ -113,7 +109,7 @@ public class PageReconstructor extends BookletPageAA{
ArrayList<ItemStack> stacks = new ArrayList<ItemStack>();
for(LensConversionRecipe recipe : this.recipes){
if(recipe != null){
stacks.addAll(RecipeUtil.getConversionLensOutputs(recipe));
stacks.add(recipe.outputStack);
}
}
return stacks.toArray(new ItemStack[stacks.size()]);

View file

@ -15,7 +15,7 @@ import de.ellpeck.actuallyadditions.mod.config.ConfigCategories;
public enum ConfigStringListValues{
CRUSHER_RECIPE_EXCEPTIONS("Crusher Recipe Exceptions", ConfigCategories.OTHER, new String[]{"ingotBrick", "ingotBrickNether"}, "The Ingots, Dusts and Ores blacklisted from being auto-registered to be crushed by the Crusher. This list uses OreDictionary Names of the Inputs only."),
CRUSHER_OUTPUT_BLACKLIST("Crusher Output Blacklist", ConfigCategories.OTHER, new String[0], "The items that aren't allowed as outputs from automatically generated Crusher recipes. Use this in case a mod, for example, adds a dust variant that can't be smelted into an ingot. Use REGISTRY NAMES, and if metadata is needed, add it like so: somemod:some_item@3"),
CRUSHER_OUTPUT_BLACKLIST("Crusher Output Blacklist", ConfigCategories.OTHER, new String[0], "The items that aren't allowed as outputs from OreDict Crusher recipes. Use this in case a mod, for example, adds a dust variant that can't be smelted into an ingot. Use REGISTRY NAMES, and if metadata is needed, add it like so: somemod:some_item@3"),
MASHED_FOOD_CRAFTING_EXCEPTIONS("Mashed Food Crafting Exceptions", ConfigCategories.ITEMS_CRAFTING, new String[]{"ActuallyAdditions:itemCoffee"}, "The ItemFood, IGrowable and IPlantable Items that can not be used to craft Mashed Food. These are the actual registered Item Names, the ones you use, for example, when using the /give Command."),
PAXEL_EXTRA_MINING_WHITELIST("AIOT Extra Whitelist", ConfigCategories.TOOL_VALUES, new String[]{"TConstruct:GravelOre"}, "By default, the AIOT can mine certain blocks. If there is one that it can't mine, but should be able to, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command."),
DRILL_EXTRA_MINING_WHITELIST("Drill Extra Whitelist", ConfigCategories.TOOL_VALUES, new String[]{"TConstruct:GravelOre"}, "By default, the Drill can mine certain blocks. If there is one that it can't mine, but should be able to, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command."),

View file

@ -21,8 +21,10 @@ import de.ellpeck.actuallyadditions.mod.util.RecipeUtil;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList;
import java.util.Collections;
public final class CrusherCrafting{
@ -34,67 +36,67 @@ public final class CrusherCrafting{
public static void init(){
ModUtil.LOGGER.info("Initializing Crusher Recipes...");
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.BONE), new ItemStack(Items.DYE, 6, 15));
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.BONE), new ItemStack(Items.DYE, 6, 15), null, 0);
MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe());
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.REEDS), new ItemStack(Items.SUGAR, 3));
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.REEDS), new ItemStack(Items.SUGAR, 3), null, 0);
MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe());
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.YELLOW_FLOWER), new ItemStack(Items.DYE, 3, 11));
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.YELLOW_FLOWER), new ItemStack(Items.DYE, 3, 11), null, 0);
MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe());
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.RED_FLOWER, 1, 0), new ItemStack(Items.DYE, 3, 1));
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.RED_FLOWER, 1, 0), new ItemStack(Items.DYE, 3, 1), null, 0);
MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe());
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.RED_FLOWER, 1, 1), new ItemStack(Items.DYE, 3, 12));
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.RED_FLOWER, 1, 1), new ItemStack(Items.DYE, 3, 12), null, 0);
MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe());
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.RED_FLOWER, 1, 2), new ItemStack(Items.DYE, 3, 13));
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.RED_FLOWER, 1, 2), new ItemStack(Items.DYE, 3, 13), null, 0);
MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe());
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.RED_FLOWER, 1, 3), new ItemStack(Items.DYE, 3, 7));
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.RED_FLOWER, 1, 3), new ItemStack(Items.DYE, 3, 7), null, 0);
MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe());
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.RED_FLOWER, 1, 4), new ItemStack(Items.DYE, 3, 1));
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.RED_FLOWER, 1, 4), new ItemStack(Items.DYE, 3, 1), null, 0);
MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe());
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.RED_FLOWER, 1, 5), new ItemStack(Items.DYE, 3, 14));
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.RED_FLOWER, 1, 5), new ItemStack(Items.DYE, 3, 14), null, 0);
MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe());
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.RED_FLOWER, 1, 6), new ItemStack(Items.DYE, 3, 7));
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.RED_FLOWER, 1, 6), new ItemStack(Items.DYE, 3, 7), null, 0);
MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe());
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.RED_FLOWER, 1, 7), new ItemStack(Items.DYE, 3, 9));
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.RED_FLOWER, 1, 7), new ItemStack(Items.DYE, 3, 9), null, 0);
MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe());
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.RED_FLOWER, 1, 8), new ItemStack(Items.DYE, 3, 7));
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.RED_FLOWER, 1, 8), new ItemStack(Items.DYE, 3, 7), null, 0);
MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe());
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.DOUBLE_PLANT, 1, 0), new ItemStack(Items.DYE, 4, 11));
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.DOUBLE_PLANT, 1, 0), new ItemStack(Items.DYE, 4, 11), null, 0);
MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe());
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.DOUBLE_PLANT, 1, 1), new ItemStack(Items.DYE, 4, 13));
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.DOUBLE_PLANT, 1, 1), new ItemStack(Items.DYE, 4, 13), null, 0);
MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe());
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.DOUBLE_PLANT, 1, 4), new ItemStack(Items.DYE, 4, 1));
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.DOUBLE_PLANT, 1, 4), new ItemStack(Items.DYE, 4, 1), null, 0);
MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe());
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.DOUBLE_PLANT, 1, 5), new ItemStack(Items.DYE, 4, 9));
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.DOUBLE_PLANT, 1, 5), new ItemStack(Items.DYE, 4, 9), null, 0);
MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe());
ActuallyAdditionsAPI.addCrusherRecipe("oreRedstone", "dustRedstone", 10);
ActuallyAdditionsAPI.addCrusherRecipe("oreLapis", "gemLapis", 12);
ActuallyAdditionsAPI.addCrusherRecipe("coal", "dustCoal", 1);
ActuallyAdditionsAPI.addCrusherRecipe("oreCoal", "coal", 3);
ActuallyAdditionsAPI.addCrusherRecipe("blockCoal", "coal", 9);
ActuallyAdditionsAPI.addCrusherRecipe("oreQuartz", "gemQuartz", 3);
ActuallyAdditionsAPI.addCrusherRecipe("cobblestone", "sand", 1);
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("oreRedstone", false), OreDictionary.getOres("dustRedstone", false), 10, null, 0, 0);
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("oreLapis", false), OreDictionary.getOres("gemLapis", false), 12, null, 0, 0);
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("coal", false), OreDictionary.getOres("dustCoal", false), 1, null, 0, 0);
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("oreCoal", false), OreDictionary.getOres("coal", false), 3, null, 0, 0);
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("blockCoal", false), OreDictionary.getOres("coal", false), 9, null, 0, 0);
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("oreQuartz", false), OreDictionary.getOres("gemQuartz", false), 3, null, 0, 0);
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("cobblestone", false), OreDictionary.getOres("sand", false), 1, null, 0, 0);
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.GRAVEL), new ItemStack(Items.FLINT), new ItemStack(Items.FLINT), 50);
ActuallyAdditionsAPI.addCrusherRecipe("stone", "cobblestone", 1);
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("stone", false), OreDictionary.getOres("cobblestone", false), 1, null, 0, 0);
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE.ordinal()), new ItemStack(Items.SUGAR, 2));
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE.ordinal()), new ItemStack(Items.SUGAR, 2), null, 0);
MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe());
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.GLOWSTONE), new ItemStack(Items.GLOWSTONE_DUST, 4));
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.GLOWSTONE), new ItemStack(Items.GLOWSTONE_DUST, 4), null, 0);
MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe());
ActuallyAdditionsAPI.addCrusherRecipe("oreNickel", "dustNickel", 2, "dustPlatinum", 1, 15);
ActuallyAdditionsAPI.addCrusherRecipe("oreIron", "dustIron", 2, "dustGold", 1, 20);
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("oreNickel", false), OreDictionary.getOres("dustNickel", false), 2, OreDictionary.getOres("dustPlatinum", false), 1, 15);
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("oreIron", false), OreDictionary.getOres("dustIron", false), 2, OreDictionary.getOres("dustGold", false), 1, 20);
if(ConfigCrafting.HORSE_ARMORS.isEnabled()){
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.IRON_HORSE_ARMOR), "dustIron", 8);
ActuallyAdditionsAPI.addCrusherRecipes(Collections.singletonList(new ItemStack(Items.IRON_HORSE_ARMOR)), OreDictionary.getOres("dustIron", false), 8, null, 0, 0);
recipeIronHorseArmor = RecipeUtil.lastCrusherRecipe();
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.GOLDEN_HORSE_ARMOR), "dustGold", 8);
ActuallyAdditionsAPI.addCrusherRecipes(Collections.singletonList(new ItemStack(Items.GOLDEN_HORSE_ARMOR)), OreDictionary.getOres("dustGold"), 8, null, 0, 0);
recipeGoldHorseArmor = RecipeUtil.lastCrusherRecipe();
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.DIAMOND_HORSE_ARMOR), "dustDiamond", 8);
ActuallyAdditionsAPI.addCrusherRecipes(Collections.singletonList(new ItemStack(Items.DIAMOND_HORSE_ARMOR)), OreDictionary.getOres("dustDiamond"), 8, null, 0, 0);
recipeDiamondHorseArmor = RecipeUtil.lastCrusherRecipe();
}

View file

@ -73,13 +73,13 @@ public class OreGen implements IWorldGenerator{
if(ConfigBoolValues.GEN_LUSH_CAVES.isEnabled()){
StructureBoundingBox box = new StructureBoundingBox(x*16+8, 0, z*16+8, x*16+8+15, 255, z*16+8+15);
int chunkRadius = 1;
for(int dx = -chunkRadius; dx <= chunkRadius; dx++) {
for(int dz = -chunkRadius; dz <= chunkRadius; dz++) {
for(int dx = -chunkRadius; dx <= chunkRadius; dx++){
for(int dz = -chunkRadius; dz <= chunkRadius; dz++){
int chunkX = x+dx;
int chunkZ = z+dz;
int randConst = 0x969ce69d;//so that it won't generate the same numbers as other mod that does the same thing
Random chunkRand = new Random(randConst ^ world.getSeed() ^ (chunkX*29+chunkZ*31));
if(chunkRand.nextInt(ConfigIntValues.LUSH_CAVE_CHANCE.getValue()) <= 0) {
if(chunkRand.nextInt(ConfigIntValues.LUSH_CAVE_CHANCE.getValue()) <= 0){
BlockPos randPos = new BlockPos(chunkX*16+chunkRand.nextInt(16)+8, 64, chunkZ*16+chunkRand.nextInt(16)+8);
BlockPos pos = randPos.down(MathHelper.getRandomIntegerInRange(chunkRand, 15, randPos.getY()-15));
this.caveGen.generate(world, chunkRand, pos, box);
@ -90,17 +90,11 @@ public class OreGen implements IWorldGenerator{
}
public void addOreSpawn(Block block, int meta, Block blockIn, World world, Random random, int blockXPos, int blockZPos, int maxVeinSize, int chancesToSpawn, int minY, int maxY){
if(maxY > minY){
int yDiff = maxY-minY;
for(int i = 0; i < chancesToSpawn; i++){
int posX = blockXPos+random.nextInt(16);
int posY = minY+random.nextInt(yDiff);
int posZ = blockZPos+random.nextInt(16);
new WorldGenMinable(block.getStateFromMeta(meta), maxVeinSize, BlockMatcher.forBlock(blockIn)).generate(world, random, new BlockPos(posX, posY, posZ));
}
}
else{
ModUtil.LOGGER.fatal("Couldn't generate '"+block.getUnlocalizedName()+"' into the world because the Min Y coordinate is bigger than the Max! This is definitely a Config Error! Check the Files!");
for(int i = 0; i < chancesToSpawn; i++){
int posX = blockXPos+random.nextInt(16);
int posY = minY+random.nextInt(maxY-minY);
int posZ = blockZPos+random.nextInt(16);
new WorldGenMinable(block.getStateFromMeta(meta), maxVeinSize, BlockMatcher.forBlock(blockIn)).generate(world, random, new BlockPos(posX, posY, posZ));
}
}

View file

@ -122,7 +122,7 @@ public final class LensRecipeHandler{
public static ArrayList<LensConversionRecipe> getRecipesFor(ItemStack input){
ArrayList<LensConversionRecipe> possibleRecipes = new ArrayList<LensConversionRecipe>();
for(LensConversionRecipe recipe : ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES){
if(ItemUtil.contains(RecipeUtil.getConversionLensInputs(recipe), input, true)){
if(ItemUtil.areItemsEqual(recipe.inputStack, input, true)){
possibleRecipes.add(recipe);
}
}

View file

@ -72,15 +72,14 @@ public class CrusherRecipeCategory implements IRecipeCategory{
CrusherRecipeWrapper wrapper = (CrusherRecipeWrapper)recipeWrapper;
recipeLayout.getItemStacks().init(0, true, 19, 7);
recipeLayout.getItemStacks().set(0, RecipeUtil.getCrusherRecipeInputs(wrapper.theRecipe));
recipeLayout.getItemStacks().set(0, wrapper.theRecipe.inputStack);
recipeLayout.getItemStacks().init(1, false, 7, 55);
recipeLayout.getItemStacks().set(1, RecipeUtil.getCrusherRecipeOutputOnes(wrapper.theRecipe));
recipeLayout.getItemStacks().set(1, wrapper.theRecipe.outputOneStack);
List<ItemStack> outputTwos = RecipeUtil.getCrusherRecipeOutputTwos(wrapper.theRecipe);
if(outputTwos != null && !outputTwos.isEmpty()){
if(wrapper.theRecipe.outputTwoStack != null){
recipeLayout.getItemStacks().init(2, false, 31, 55);
recipeLayout.getItemStacks().set(2, outputTwos);
recipeLayout.getItemStacks().set(2, wrapper.theRecipe.outputTwoStack);
}
}
}

View file

@ -24,6 +24,7 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class CrusherRecipeWrapper extends RecipeWrapperWithButton implements IRecipeWrapper{
@ -41,19 +42,16 @@ public class CrusherRecipeWrapper extends RecipeWrapperWithButton implements IRe
@Override
public List getInputs(){
return RecipeUtil.getCrusherRecipeInputs(this.theRecipe);
return Collections.singletonList(this.theRecipe.inputStack);
}
@Override
public List getOutputs(){
List list = new ArrayList();
list.addAll(RecipeUtil.getCrusherRecipeOutputOnes(this.theRecipe));
List<ItemStack> outputTwos = RecipeUtil.getCrusherRecipeOutputTwos(this.theRecipe);
if(outputTwos != null && !outputTwos.isEmpty()){
list.addAll(outputTwos);
list.add(this.theRecipe.outputOneStack);
if(this.theRecipe.outputTwoStack != null){
list.add(this.theRecipe.outputTwoStack);
}
return list;
}
@ -71,8 +69,7 @@ public class CrusherRecipeWrapper extends RecipeWrapperWithButton implements IRe
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY){
this.updateButton(minecraft, mouseX, mouseY);
List<ItemStack> outputTwos = RecipeUtil.getCrusherRecipeOutputTwos(this.theRecipe);
if(outputTwos != null && !outputTwos.isEmpty()){
if(this.theRecipe.outputTwoStack != null){
minecraft.fontRendererObj.drawString(this.theRecipe.outputTwoChance+"%", 60, 60, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
}
}

View file

@ -72,10 +72,10 @@ public class ReconstructorRecipeCategory implements IRecipeCategory{
ReconstructorRecipeWrapper wrapper = (ReconstructorRecipeWrapper)recipeWrapper;
recipeLayout.getItemStacks().init(0, true, 4, 18);
recipeLayout.getItemStacks().set(0, RecipeUtil.getConversionLensInputs(wrapper.theRecipe));
recipeLayout.getItemStacks().set(0, wrapper.theRecipe.inputStack);
recipeLayout.getItemStacks().init(1, false, 66, 18);
recipeLayout.getItemStacks().set(1, RecipeUtil.getConversionLensOutputs(wrapper.theRecipe));
recipeLayout.getItemStacks().set(1, wrapper.theRecipe.outputStack);
}
}

View file

@ -23,6 +23,7 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class ReconstructorRecipeWrapper extends RecipeWrapperWithButton implements IRecipeWrapper{
@ -40,12 +41,12 @@ public class ReconstructorRecipeWrapper extends RecipeWrapperWithButton implemen
@Override
public List getInputs(){
return RecipeUtil.getConversionLensInputs(this.theRecipe);
return Collections.singletonList(this.theRecipe.inputStack);
}
@Override
public List getOutputs(){
return RecipeUtil.getConversionLensOutputs(this.theRecipe);
return Collections.singletonList(this.theRecipe.outputStack);
}
@Override

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.misc;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
@ -24,6 +25,7 @@ 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 de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry;
import de.ellpeck.actuallyadditions.mod.util.RecipeUtil;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
@ -145,26 +147,23 @@ public class MethodHandler implements IMethodHandler{
List<LensConversionRecipe> recipes = LensRecipeHandler.getRecipesFor(new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)));
for(LensConversionRecipe recipe : recipes){
if(recipe != null && recipe.type == tile.getLens() && tile.getEnergy() >= recipe.energyUse){
List<ItemStack> outputs = RecipeUtil.getConversionLensOutputs(recipe);
if(outputs != null && !outputs.isEmpty()){
ItemStack output = outputs.get(0);
if(output != null){
if(!ConfigBoolValues.LESS_BLOCK_BREAKING_EFFECTS.isEnabled()){
tile.getWorldObject().playEvent(2001, pos, Block.getStateId(tile.getWorldObject().getBlockState(pos)));
}
if(output.getItem() instanceof ItemBlock){
tile.getWorldObject().setBlockState(pos, Block.getBlockFromItem(output.getItem()).getStateFromMeta(output.getItemDamage()), 2);
}
else{
EntityItem item = new EntityItem(tile.getWorldObject(), pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5, output.copy());
tile.getWorldObject().spawnEntityInWorld(item);
tile.getWorldObject().setBlockToAir(pos);
}
tile.extractEnergy(recipe.energyUse);
break;
ItemStack output = recipe.outputStack;
if(output != null){
if(!ConfigBoolValues.LESS_BLOCK_BREAKING_EFFECTS.isEnabled()){
tile.getWorldObject().playEvent(2001, pos, Block.getStateId(tile.getWorldObject().getBlockState(pos)));
}
if(output.getItem() instanceof ItemBlock){
tile.getWorldObject().setBlockState(pos, Block.getBlockFromItem(output.getItem()).getStateFromMeta(output.getItemDamage()), 2);
}
else{
EntityItem item = new EntityItem(tile.getWorldObject(), pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5, output.copy());
tile.getWorldObject().spawnEntityInWorld(item);
tile.getWorldObject().setBlockToAir(pos);
}
tile.extractEnergy(recipe.energyUse);
break;
}
}
}
@ -186,9 +185,7 @@ public class MethodHandler implements IMethodHandler{
List<LensConversionRecipe> recipes = LensRecipeHandler.getRecipesFor(stack);
for(LensConversionRecipe recipe : recipes){
if(recipe != null && recipe.type == tile.getLens() && tile.getEnergy() >= recipe.energyUse*stack.stackSize){
List<ItemStack> outputs = RecipeUtil.getConversionLensOutputs(recipe);
if(outputs != null && !outputs.isEmpty()){
ItemStack outputCopy = outputs.get(0).copy();
ItemStack outputCopy = recipe.outputStack.copy();
outputCopy.stackSize = stack.stackSize;
item.setDead();
@ -198,7 +195,6 @@ public class MethodHandler implements IMethodHandler{
tile.extractEnergy(recipe.energyUse*stack.stackSize);
break;
}
}
}
}
@ -232,4 +228,36 @@ public class MethodHandler implements IMethodHandler{
public IBookletChapter generateBookletChapter(String identifier, IBookletEntry entry, ItemStack displayStack, BookletPage... pages){
return new BookletChapter(identifier, entry, displayStack, pages);
}
@Override
public boolean addCrusherRecipes(List<ItemStack> inputs, List<ItemStack> outputOnes, int outputOneAmounts, List<ItemStack> outputTwos, int outputTwoAmounts, int outputTwoChance){
boolean hasWorkedOnce = false;
for(ItemStack input : inputs){
if(input != null && CrusherRecipeRegistry.getRecipeFromInput(input) == null){
for(ItemStack outputOne : outputOnes){
if(outputOne != null && !CrusherRecipeRegistry.hasBlacklistedOutput(outputOne)){
ItemStack outputOneCopy = outputOne.copy();
outputOneCopy.stackSize = outputOneAmounts;
if(outputTwos == null || outputTwos.isEmpty()){
ActuallyAdditionsAPI.addCrusherRecipe(input, outputOneCopy, null, 0);
hasWorkedOnce = true;
}
else{
for(ItemStack outputTwo : outputTwos){
if(outputTwo != null && !CrusherRecipeRegistry.hasBlacklistedOutput(outputTwo)){
ItemStack outputTwoCopy = outputTwo.copy();
outputTwoCopy.stackSize = outputTwoAmounts;
ActuallyAdditionsAPI.addCrusherRecipe(input, outputOneCopy, outputTwoCopy, outputTwoChance);
hasWorkedOnce = true;
}
}
}
}
}
}
}
return hasWorkedOnce;
}
}

View file

@ -15,13 +15,11 @@ import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.RecipeUtil;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList;
import java.util.List;
public final class CrusherRecipeRegistry{
@ -39,23 +37,8 @@ public final class CrusherRecipeRegistry{
if(ore.substring(0, theCase.theCase.length()).equals(theCase.theCase)){
String output = theCase.resultPreString+ore.substring(theCase.theCase.length());
if(!hasOreRecipe(ore)){
List<ItemStack> outputs = OreDictionary.getOres(output, false);
if(!outputs.isEmpty() && !OreDictionary.getOres(ore, false).isEmpty()){
for(ItemStack stack : outputs){
if(!hasBlacklistedOutput(stack)){
ItemStack copy = stack.copy();
copy.stackSize = theCase.resultAmount;
ActuallyAdditionsAPI.addCrusherRecipe(ore, copy);
}
else if(!oresNoResult.contains(ore)){
oresNoResult.add(ore);
}
}
}
else{
oresNoResult.add(ore);
}
if(!ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres(ore, false), OreDictionary.getOres(output, false), theCase.resultAmount, null, 0, 0)){
oresNoResult.add(ore);
}
break;
@ -68,13 +51,13 @@ public final class CrusherRecipeRegistry{
ArrayList<String> addedRecipes = new ArrayList<String>();
for(int i = recipeStartedAt; i < ActuallyAdditionsAPI.CRUSHER_RECIPES.size(); i++){
CrusherRecipe recipe = ActuallyAdditionsAPI.CRUSHER_RECIPES.get(i);
addedRecipes.add(recipe.input+" -> "+recipe.outputOneStack);
addedRecipes.add(recipe.inputStack+" -> "+recipe.outputOneStack);
}
ModUtil.LOGGER.info("Added "+addedRecipes.size()+" Crusher Recipes automatically: "+addedRecipes.toString());
ModUtil.LOGGER.warn("Couldn't add "+oresNoResult.size()+" Crusher Recipes automatically because the inputs were missing outputs: "+oresNoResult.toString());
ModUtil.LOGGER.warn("Couldn't add "+oresNoResult.size()+" Crusher Recipes automatically, either because the inputs were missing outputs, or because they exist already: "+oresNoResult.toString());
}
private static boolean hasBlacklistedOutput(ItemStack output){
public static boolean hasBlacklistedOutput(ItemStack output){
if(output != null){
Item item = output.getItem();
if(item != null){
@ -115,32 +98,23 @@ public final class CrusherRecipeRegistry{
return false;
}
public static boolean hasOreRecipe(String input){
for(CrusherRecipe recipe : ActuallyAdditionsAPI.CRUSHER_RECIPES){
if(recipe.input != null && recipe.input.equals(input)){
return true;
}
}
return false;
}
public static List<ItemStack> getOutputOnes(ItemStack input){
public static ItemStack getOutputOnes(ItemStack input){
CrusherRecipe recipe = getRecipeFromInput(input);
return recipe == null ? null : RecipeUtil.getCrusherRecipeOutputOnes(recipe);
return recipe == null ? null : recipe.outputOneStack;
}
public static CrusherRecipe getRecipeFromInput(ItemStack input){
for(CrusherRecipe recipe : ActuallyAdditionsAPI.CRUSHER_RECIPES){
if(ItemUtil.contains(RecipeUtil.getCrusherRecipeInputs(recipe), input, true)){
if(ItemUtil.areItemsEqual(recipe.inputStack, input, true)){
return recipe;
}
}
return null;
}
public static List<ItemStack> getOutputTwos(ItemStack input){
public static ItemStack getOutputTwos(ItemStack input){
CrusherRecipe recipe = getRecipeFromInput(input);
return recipe == null ? null : RecipeUtil.getCrusherRecipeOutputTwos(recipe);
return recipe == null ? null : recipe.outputTwoStack;
}
public static int getOutputTwoChance(ItemStack input){

View file

@ -27,8 +27,6 @@ import net.minecraft.util.SoundCategory;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List;
public class TileEntityGrinder extends TileEntityInventoryBase implements ICustomEnergyReceiver, IButtonReactor{
public static final int SLOT_INPUT_1 = 0;
@ -188,21 +186,17 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements ICusto
public boolean canCrushOn(int theInput, int theFirstOutput, int theSecondOutput){
if(this.slots[theInput] != null){
List<ItemStack> outputOnes = CrusherRecipeRegistry.getOutputOnes(this.slots[theInput]);
if(outputOnes != null && !outputOnes.isEmpty()){
ItemStack outputOne = outputOnes.get(0);
List<ItemStack> outputTwos = CrusherRecipeRegistry.getOutputTwos(this.slots[theInput]);
ItemStack outputTwo = outputTwos == null ? null : outputTwos.get(0);
if(outputOne != null){
if(outputOne.getItemDamage() == Util.WILDCARD){
outputOne.setItemDamage(0);
}
if(outputTwo != null && outputTwo.getItemDamage() == Util.WILDCARD){
outputTwo.setItemDamage(0);
}
if((this.slots[theFirstOutput] == null || (this.slots[theFirstOutput].isItemEqual(outputOne) && this.slots[theFirstOutput].stackSize <= this.slots[theFirstOutput].getMaxStackSize()-outputOne.stackSize)) && (outputTwo == null || (this.slots[theSecondOutput] == null || (this.slots[theSecondOutput].isItemEqual(outputTwo) && this.slots[theSecondOutput].stackSize <= this.slots[theSecondOutput].getMaxStackSize()-outputTwo.stackSize)))){
return true;
}
ItemStack outputOne = CrusherRecipeRegistry.getOutputOnes(this.slots[theInput]);
ItemStack outputTwo = CrusherRecipeRegistry.getOutputTwos(this.slots[theInput]);
if(outputOne != null){
if(outputOne.getItemDamage() == Util.WILDCARD){
outputOne.setItemDamage(0);
}
if(outputTwo != null && outputTwo.getItemDamage() == Util.WILDCARD){
outputTwo.setItemDamage(0);
}
if((this.slots[theFirstOutput] == null || (this.slots[theFirstOutput].isItemEqual(outputOne) && this.slots[theFirstOutput].stackSize <= this.slots[theFirstOutput].getMaxStackSize()-outputOne.stackSize)) && (outputTwo == null || (this.slots[theSecondOutput] == null || (this.slots[theSecondOutput].isItemEqual(outputTwo) && this.slots[theSecondOutput].stackSize <= this.slots[theSecondOutput].getMaxStackSize()-outputTwo.stackSize)))){
return true;
}
}
}
@ -214,37 +208,31 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements ICusto
}
public void finishCrushing(int theInput, int theFirstOutput, int theSecondOutput){
List<ItemStack> outputOnes = CrusherRecipeRegistry.getOutputOnes(this.slots[theInput]);
if(outputOnes != null){
ItemStack outputOne = outputOnes.get(0);
if(outputOne != null){
if(outputOne.getItemDamage() == Util.WILDCARD){
outputOne.setItemDamage(0);
}
if(this.slots[theFirstOutput] == null){
this.slots[theFirstOutput] = outputOne.copy();
}
else if(this.slots[theFirstOutput].getItem() == outputOne.getItem()){
this.slots[theFirstOutput].stackSize += outputOne.stackSize;
}
ItemStack outputOne = CrusherRecipeRegistry.getOutputOnes(this.slots[theInput]);
if(outputOne != null){
if(outputOne.getItemDamage() == Util.WILDCARD){
outputOne.setItemDamage(0);
}
if(this.slots[theFirstOutput] == null){
this.slots[theFirstOutput] = outputOne.copy();
}
else if(this.slots[theFirstOutput].getItem() == outputOne.getItem()){
this.slots[theFirstOutput].stackSize += outputOne.stackSize;
}
}
List<ItemStack> outputTwos = CrusherRecipeRegistry.getOutputTwos(this.slots[theInput]);
if(outputTwos != null){
ItemStack outputTwo = outputTwos.get(0);
if(outputTwo != null){
if(outputTwo.getItemDamage() == Util.WILDCARD){
outputTwo.setItemDamage(0);
ItemStack outputTwo = CrusherRecipeRegistry.getOutputTwos(this.slots[theInput]);
if(outputTwo != null){
if(outputTwo.getItemDamage() == Util.WILDCARD){
outputTwo.setItemDamage(0);
}
int rand = Util.RANDOM.nextInt(100)+1;
if(rand <= CrusherRecipeRegistry.getOutputTwoChance(this.slots[theInput])){
if(this.slots[theSecondOutput] == null){
this.slots[theSecondOutput] = outputTwo.copy();
}
int rand = Util.RANDOM.nextInt(100)+1;
if(rand <= CrusherRecipeRegistry.getOutputTwoChance(this.slots[theInput])){
if(this.slots[theSecondOutput] == null){
this.slots[theSecondOutput] = outputTwo.copy();
}
else if(this.slots[theSecondOutput].getItem() == outputTwo.getItem()){
this.slots[theSecondOutput].stackSize += outputTwo.stackSize;
}
else if(this.slots[theSecondOutput].getItem() == outputTwo.getItem()){
this.slots[theSecondOutput].stackSize += outputTwo.stackSize;
}
}
}

View file

@ -14,13 +14,8 @@ import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe;
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public final class RecipeUtil{
@ -44,48 +39,4 @@ public final class RecipeUtil{
List<EmpowererRecipe> list = ActuallyAdditionsAPI.EMPOWERER_RECIPES;
return list.get(list.size()-1);
}
public static List<ItemStack> getCrusherRecipeOutputOnes(CrusherRecipe recipe){
return doRecipeOrWhatever(recipe.outputOneStack, recipe.outputOne, recipe.outputOneAmount);
}
public static List<ItemStack> getCrusherRecipeOutputTwos(CrusherRecipe recipe){
return doRecipeOrWhatever(recipe.outputTwoStack, recipe.outputTwo, recipe.outputTwoAmount);
}
public static List<ItemStack> getCrusherRecipeInputs(CrusherRecipe recipe){
return doRecipeOrWhatever(recipe.inputStack, recipe.input, 1);
}
public static List<ItemStack> getConversionLensInputs(LensConversionRecipe recipe){
return doRecipeOrWhatever(recipe.inputStack, recipe.input, 1);
}
public static List<ItemStack> getConversionLensOutputs(LensConversionRecipe recipe){
return doRecipeOrWhatever(recipe.outputStack, recipe.output, 1);
}
private static List<ItemStack> doRecipeOrWhatever(ItemStack stack, String oredict, int amount){
if(stack != null){
return Collections.singletonList(stack.copy());
}
if(oredict == null || oredict.isEmpty()){
return null;
}
List<ItemStack> stacks = OreDictionary.getOres(oredict, false);
if(stacks != null && !stacks.isEmpty()){
List<ItemStack> stacksCopy = new ArrayList<ItemStack>();
for(ItemStack aStack : stacks){
if(aStack != null){
ItemStack stackCopy = aStack.copy();
stackCopy.stackSize = amount;
stacksCopy.add(stackCopy);
}
}
return stacksCopy;
}
return null;
}
}