mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 16:58:34 +01:00
parent
3a324ee09d
commit
f1eebaadf3
4 changed files with 66 additions and 3 deletions
|
@ -148,6 +148,19 @@ public final class ActuallyAdditionsAPI{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
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 Oil generator
|
* Adds a Recipe to the Oil generator
|
||||||
*
|
*
|
||||||
|
|
|
@ -24,6 +24,11 @@ public class CrusherRecipe{
|
||||||
public ItemStack outputOneStack;
|
public ItemStack outputOneStack;
|
||||||
public ItemStack outputTwoStack;
|
public ItemStack outputTwoStack;
|
||||||
|
|
||||||
|
public CrusherRecipe(String input, ItemStack outputOne){
|
||||||
|
this.input = input;
|
||||||
|
this.outputOneStack = outputOne;
|
||||||
|
}
|
||||||
|
|
||||||
public CrusherRecipe(ItemStack input, String outputOne, int outputOneAmount){
|
public CrusherRecipe(ItemStack input, String outputOne, int outputOneAmount){
|
||||||
this.inputStack = input;
|
this.inputStack = input;
|
||||||
this.outputOne = outputOne;
|
this.outputOne = outputOne;
|
||||||
|
|
|
@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.mod.config.ConfigCategories;
|
||||||
public enum ConfigStringListValues{
|
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_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"),
|
||||||
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."),
|
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."),
|
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."),
|
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."),
|
||||||
|
|
|
@ -16,6 +16,7 @@ import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.RecipeUtil;
|
import de.ellpeck.actuallyadditions.mod.util.RecipeUtil;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
|
|
||||||
|
@ -39,8 +40,18 @@ public final class CrusherRecipeRegistry{
|
||||||
String output = theCase.resultPreString+ore.substring(theCase.theCase.length());
|
String output = theCase.resultPreString+ore.substring(theCase.theCase.length());
|
||||||
|
|
||||||
if(!hasOreRecipe(ore)){
|
if(!hasOreRecipe(ore)){
|
||||||
if(!OreDictionary.getOres(output, false).isEmpty() && !OreDictionary.getOres(ore, false).isEmpty()){
|
List<ItemStack> outputs = OreDictionary.getOres(output, false);
|
||||||
ActuallyAdditionsAPI.addCrusherRecipe(ore, output, theCase.resultAmount);
|
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{
|
else{
|
||||||
oresNoResult.add(ore);
|
oresNoResult.add(ore);
|
||||||
|
@ -57,12 +68,45 @@ public final class CrusherRecipeRegistry{
|
||||||
ArrayList<String> addedRecipes = new ArrayList<String>();
|
ArrayList<String> addedRecipes = new ArrayList<String>();
|
||||||
for(int i = recipeStartedAt; i < ActuallyAdditionsAPI.CRUSHER_RECIPES.size(); i++){
|
for(int i = recipeStartedAt; i < ActuallyAdditionsAPI.CRUSHER_RECIPES.size(); i++){
|
||||||
CrusherRecipe recipe = ActuallyAdditionsAPI.CRUSHER_RECIPES.get(i);
|
CrusherRecipe recipe = ActuallyAdditionsAPI.CRUSHER_RECIPES.get(i);
|
||||||
addedRecipes.add(recipe.input+" -> "+recipe.outputOneAmount+"x "+recipe.outputOne);
|
addedRecipes.add(recipe.input+" -> "+recipe.outputOneStack);
|
||||||
}
|
}
|
||||||
ModUtil.LOGGER.info("Added "+addedRecipes.size()+" Crusher Recipes automatically: "+addedRecipes.toString());
|
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 because the inputs were missing outputs: "+oresNoResult.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean hasBlacklistedOutput(ItemStack output){
|
||||||
|
if(output != null){
|
||||||
|
Item item = output.getItem();
|
||||||
|
if(item != null){
|
||||||
|
String reg = item.getRegistryName().toString();
|
||||||
|
|
||||||
|
for(String conf : ConfigStringListValues.CRUSHER_OUTPUT_BLACKLIST.getValue()){
|
||||||
|
String confReg = conf;
|
||||||
|
int meta = 0;
|
||||||
|
|
||||||
|
if(conf.contains("@")){
|
||||||
|
try{
|
||||||
|
String[] split = conf.split("@");
|
||||||
|
confReg = split[0];
|
||||||
|
meta = Integer.parseInt(split[1]);
|
||||||
|
}
|
||||||
|
catch(Exception e){
|
||||||
|
ModUtil.LOGGER.warn("A config option appears to be incorrect: The Crusher Output Blacklist entry "+conf+" can't be parsed!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(reg.equals(confReg) && output.getItemDamage() == meta){
|
||||||
|
System.out.println("Blacklisting "+output);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean hasException(String ore){
|
private static boolean hasException(String ore){
|
||||||
for(String conf : ConfigStringListValues.CRUSHER_RECIPE_EXCEPTIONS.getValue()){
|
for(String conf : ConfigStringListValues.CRUSHER_RECIPE_EXCEPTIONS.getValue()){
|
||||||
if(conf.equals(ore)){
|
if(conf.equals(ore)){
|
||||||
|
|
Loading…
Reference in a new issue