Added lens whitelist and blacklist

Closes #399
This commit is contained in:
Ellpeck 2016-11-23 17:46:08 +01:00
parent ded8ceb529
commit 377973fc9c
5 changed files with 37 additions and 9 deletions

View file

@ -26,6 +26,7 @@ import de.ellpeck.actuallyadditions.mod.gen.OreGen;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.items.ItemCoffee;
import de.ellpeck.actuallyadditions.mod.items.lens.LensMining;
import de.ellpeck.actuallyadditions.mod.items.lens.LensRecipeHandler;
import de.ellpeck.actuallyadditions.mod.items.lens.Lenses;
import de.ellpeck.actuallyadditions.mod.material.InitArmorMaterials;
@ -136,6 +137,7 @@ public class ActuallyAdditions{
TreasureChestHandler.init();
LensRecipeHandler.init();
EmpowererHandler.init();
LensMining.init();
InitBooklet.postInit();
proxy.postInit(event);

View file

@ -16,6 +16,8 @@ public enum ConfigStringListValues{
CRUSHER_RECIPE_EXCEPTIONS("Crusher Recipe Exceptions", ConfigCategories.OTHER, new String[]{"ingotBrick", "ingotBrickNether"}, "Ingots, Dusts and Ores that will be 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 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"),
MINING_LENS_BLACKLIST("Mining Lens Blacklist", ConfigCategories.OTHER, new String[0], "The items that aren't allowed as being generated by the Lens of the Miner. Use REGISTRY NAMES, and if metadata is needed, add it like so: somemod:some_block@3"),
MINING_LENS_EXTRA_WHITELIST("Mining lens Extra Whitelist", ConfigCategories.OTHER, new String[0], "By default, the mining lens has a set number of ores it can generate. If there is an ore that it should be able to generate, add its OreDictionary name followed by an @ and the weight that it should have (the higher, the more often it will generate), followed by another @ and then an s for it to generate in stone and an n for it to generate in netherrack. For instance: oreCheese@100@s would add cheese ore with a weight of 100 that generates in stone."),
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

@ -14,6 +14,9 @@ import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
import de.ellpeck.actuallyadditions.api.lens.Lens;
import de.ellpeck.actuallyadditions.api.recipe.WeightedOre;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockNetherrack;
@ -31,8 +34,7 @@ public class LensMining extends Lens{
public static final int ENERGY_USE = 60000;
static{
public static void init(){
ActuallyAdditionsAPI.addMiningLensStoneOre("oreCoal", 5000);
ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherCoal", 5000);
ActuallyAdditionsAPI.addMiningLensStoneOre("oreIron", 3000);
@ -92,6 +94,28 @@ public class LensMining extends Lens{
ActuallyAdditionsAPI.addMiningLensNetherOre("oreCobalt", 50);
ActuallyAdditionsAPI.addMiningLensNetherOre("oreArdite", 50);
for(String conf : ConfigStringListValues.MINING_LENS_EXTRA_WHITELIST.getValue()){
if(conf.contains("@")){
try{
String[] split = conf.split("@");
String ore = split[0];
int weight = Integer.parseInt(split[1]);
String dim = split[2];
if("n".equals(dim)){
ActuallyAdditionsAPI.addMiningLensNetherOre(ore, weight);
}
else if("s".equals(dim)){
ActuallyAdditionsAPI.addMiningLensStoneOre(ore, weight);
}
}
catch(Exception e){
ModUtil.LOGGER.warn("A config option appears to be incorrect: The entry "+conf+" can't be parsed!");
}
}
}
}
@Override
@ -121,7 +145,7 @@ public class LensMining extends Lens{
List<ItemStack> stacks = OreDictionary.getOres(ore.name, false);
if(stacks != null && !stacks.isEmpty()){
for(ItemStack aStack : stacks){
if(StackUtil.isValid(aStack) && aStack.getItem() instanceof ItemBlock){
if(StackUtil.isValid(aStack) && !CrusherRecipeRegistry.hasBlacklistedOutput(aStack, ConfigStringListValues.MINING_LENS_BLACKLIST.getValue()) && aStack.getItem() instanceof ItemBlock){
adaptedUse += (totalWeight-ore.itemWeight)%40000;
stack = aStack;
@ -163,5 +187,4 @@ public class LensMining extends Lens{
public int getDistance(){
return 10;
}
}

View file

@ -23,6 +23,7 @@ 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.ConfigStringListValues;
import de.ellpeck.actuallyadditions.mod.items.lens.LensRecipeHandler;
import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
@ -219,7 +220,7 @@ public class MethodHandler implements IMethodHandler{
for(ItemStack input : inputs){
if(StackUtil.isValid(input) && CrusherRecipeRegistry.getRecipeFromInput(input) == null){
for(ItemStack outputOne : outputOnes){
if(StackUtil.isValid(outputOne) && !CrusherRecipeRegistry.hasBlacklistedOutput(outputOne)){
if(StackUtil.isValid(outputOne) && !CrusherRecipeRegistry.hasBlacklistedOutput(outputOne, ConfigStringListValues.CRUSHER_OUTPUT_BLACKLIST.getValue())){
ItemStack outputOneCopy = outputOne.copy();
outputOneCopy = StackUtil.setStackSize(outputOneCopy, outputOneAmounts);
@ -229,7 +230,7 @@ public class MethodHandler implements IMethodHandler{
}
else{
for(ItemStack outputTwo : outputTwos){
if(StackUtil.isValid(outputTwo) && !CrusherRecipeRegistry.hasBlacklistedOutput(outputTwo)){
if(StackUtil.isValid(outputTwo) && !CrusherRecipeRegistry.hasBlacklistedOutput(outputTwo, ConfigStringListValues.CRUSHER_OUTPUT_BLACKLIST.getValue())){
ItemStack outputTwoCopy = outputTwo.copy();
outputTwoCopy = StackUtil.setStackSize(outputTwoCopy, outputTwoAmounts);

View file

@ -58,13 +58,13 @@ public final class CrusherRecipeRegistry{
ModUtil.LOGGER.warn("Couldn't add "+oresNoResult.size()+" Crusher Recipes automatically, either because the inputs were missing outputs, or because they exist already: "+oresNoResult);
}
public static boolean hasBlacklistedOutput(ItemStack output){
public static boolean hasBlacklistedOutput(ItemStack output, String[] config){
if(StackUtil.isValid(output)){
Item item = output.getItem();
if(item != null){
String reg = item.getRegistryName().toString();
for(String conf : ConfigStringListValues.CRUSHER_OUTPUT_BLACKLIST.getValue()){
for(String conf : config){
String confReg = conf;
int meta = 0;
@ -75,7 +75,7 @@ public final class CrusherRecipeRegistry{
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!");
ModUtil.LOGGER.warn("A config option appears to be incorrect: The entry "+conf+" can't be parsed!");
}
}