mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
Adds Sack Blacklist (Closes #974)
also apparently the common capabilities maven is throwing 403's so i've set it to the version in my cache.
This commit is contained in:
parent
872e124cd8
commit
2a751355d7
3 changed files with 45 additions and 4 deletions
|
@ -55,7 +55,7 @@ dependencies {
|
||||||
deobfCompile "mezz.jei:jei_1.12.1:+"
|
deobfCompile "mezz.jei:jei_1.12.1:+"
|
||||||
deobfCompile "mcp.mobius.waila:Hwyla:+"
|
deobfCompile "mcp.mobius.waila:Hwyla:+"
|
||||||
compile "net.darkhax.tesla:Tesla-1.12:+"
|
compile "net.darkhax.tesla:Tesla-1.12:+"
|
||||||
deobfCompile "org.cyclops.commoncapabilities:CommonCapabilities:1.12-1.3.3+"
|
deobfCompile "org.cyclops.commoncapabilities:CommonCapabilities:1.12-1.3.3-126"
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
|
|
|
@ -25,7 +25,8 @@ public enum ConfigStringListValues{
|
||||||
MINER_EXTRA_WHITELIST("Vertical Digger Extra Whitelist", ConfigCategories.MACHINE_VALUES, new String[0], "By default, the Vertical Digger mines everything that starts with 'ore' in the OreDictionary. 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. This Config Option only applies if the miner is in Ores Only Mode."),
|
MINER_EXTRA_WHITELIST("Vertical Digger Extra Whitelist", ConfigCategories.MACHINE_VALUES, new String[0], "By default, the Vertical Digger mines everything that starts with 'ore' in the OreDictionary. 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. This Config Option only applies if the miner is in Ores Only Mode."),
|
||||||
MINER_BLACKLIST("Vertical Digger Blacklist", ConfigCategories.MACHINE_VALUES, new String[0], "By default, the Vertical Digger mines everything that starts with 'ore' in the OreDictionary. If there is one that it can mine, but shouldn't 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. This Config Option will apply in both modes."),
|
MINER_BLACKLIST("Vertical Digger Blacklist", ConfigCategories.MACHINE_VALUES, new String[0], "By default, the Vertical Digger mines everything that starts with 'ore' in the OreDictionary. If there is one that it can mine, but shouldn't 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. This Config Option will apply in both modes."),
|
||||||
REPAIRER_EXTRA_WHITELIST("Item Repairer Extra Whitelist", ConfigCategories.MACHINE_VALUES, new String[]{"tconstruct:pickaxe", "tconstruct:shovel", "tconstruct:hatchet", "tconstruct:mattock", "tconstruct:broadsword", "tconstruct:longsword", "tconstruct:frypan", "tconstruct:battlesign", "tconstruct:hammer", "tconstruct:excavator", "tconstruct:lumberaxe", "tconstruct:cleaver", "tconstruct:rapier"}, "By default, the Item Repairer only repairs items which are repairable in an anvil. Add an item's REGISTRY NAME here if you want it to be repairable."),
|
REPAIRER_EXTRA_WHITELIST("Item Repairer Extra Whitelist", ConfigCategories.MACHINE_VALUES, new String[]{"tconstruct:pickaxe", "tconstruct:shovel", "tconstruct:hatchet", "tconstruct:mattock", "tconstruct:broadsword", "tconstruct:longsword", "tconstruct:frypan", "tconstruct:battlesign", "tconstruct:hammer", "tconstruct:excavator", "tconstruct:lumberaxe", "tconstruct:cleaver", "tconstruct:rapier"}, "By default, the Item Repairer only repairs items which are repairable in an anvil. Add an item's REGISTRY NAME here if you want it to be repairable."),
|
||||||
SPAWNER_CHANGER_BLACKLIST("Spawner Changer Blacklist", ConfigCategories.OTHER, new String[]{"minecraft:villager_golem"}, "By default, the Spawner Changer allows every living entity to be put into a spawner. If there is one that shouldn't be able to, put its MAPPING NAME here.");
|
SPAWNER_CHANGER_BLACKLIST("Spawner Changer Blacklist", ConfigCategories.OTHER, new String[]{"minecraft:villager_golem"}, "By default, the Spawner Changer allows every living entity to be put into a spawner. If there is one that shouldn't be able to, put its MAPPING NAME here."),
|
||||||
|
SACK_BLACKLIST("Sack Blacklist", ConfigCategories.OTHER, new String[0], "The items that aren't allowed to be put in the Traveller's Sack. Use REGISTRY NAMES, and if metadata is needed, add it like so: somemod:some_block@3");
|
||||||
|
|
||||||
public final String name;
|
public final String name;
|
||||||
public final String category;
|
public final String category;
|
||||||
|
|
|
@ -10,6 +10,12 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.inventory;
|
package de.ellpeck.actuallyadditions.mod.inventory;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotDeletion;
|
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotDeletion;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotFilter;
|
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotFilter;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotImmovable;
|
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotImmovable;
|
||||||
|
@ -19,6 +25,7 @@ import de.ellpeck.actuallyadditions.mod.items.ItemDrill;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.FilterSettings;
|
import de.ellpeck.actuallyadditions.mod.tile.FilterSettings;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerCustom;
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerCustom;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
@ -26,8 +33,11 @@ import net.minecraft.inventory.ClickType;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.inventory.IContainerListener;
|
import net.minecraft.inventory.IContainerListener;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
@ -43,7 +53,13 @@ public class ContainerBag extends Container implements IButtonReactor{
|
||||||
|
|
||||||
public ContainerBag(ItemStack sack, InventoryPlayer inventory, boolean isVoid){
|
public ContainerBag(ItemStack sack, InventoryPlayer inventory, boolean isVoid){
|
||||||
this.inventory = inventory;
|
this.inventory = inventory;
|
||||||
this.bagInventory = new ItemStackHandlerCustom(getSlotAmount(isVoid));
|
this.bagInventory = new ItemStackHandlerCustom(getSlotAmount(isVoid)) {
|
||||||
|
@Override
|
||||||
|
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
|
||||||
|
if(isBlacklisted(stack)) return stack;
|
||||||
|
return super.insertItem(slot, stack, simulate);
|
||||||
|
};
|
||||||
|
};
|
||||||
this.isVoid = isVoid;
|
this.isVoid = isVoid;
|
||||||
this.sack = sack;
|
this.sack = sack;
|
||||||
|
|
||||||
|
@ -65,7 +81,7 @@ public class ContainerBag extends Container implements IButtonReactor{
|
||||||
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.bagInventory, j+i*7, 10+j*18, 10+i*18){
|
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.bagInventory, j+i*7, 10+j*18, 10+i*18){
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValid(ItemStack stack){
|
public boolean isItemValid(ItemStack stack){
|
||||||
return ContainerBag.this.filter.check(stack);
|
return !isBlacklisted(stack) && ContainerBag.this.filter.check(stack);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -231,4 +247,28 @@ public class ContainerBag extends Container implements IButtonReactor{
|
||||||
this.filter.onButtonPressed(buttonID);
|
this.filter.onButtonPressed(buttonID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final List<Pair<Item, Integer>> BLACKLIST = new ArrayList<>();
|
||||||
|
|
||||||
|
private static boolean runOnce = false;
|
||||||
|
|
||||||
|
public static boolean isBlacklisted(ItemStack stack) {
|
||||||
|
if(!runOnce) {
|
||||||
|
runOnce = true;
|
||||||
|
for(String s : ConfigStringListValues.SACK_BLACKLIST.getValue()) {
|
||||||
|
String[] split = s.split("@");
|
||||||
|
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(split[0]));
|
||||||
|
if(item == null) {
|
||||||
|
ModUtil.LOGGER.error("Invalid item in sack blacklist: " + s);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(split.length == 1)
|
||||||
|
BLACKLIST.add(Pair.of(item, 0));
|
||||||
|
else if(split.length == 2) {
|
||||||
|
BLACKLIST.add(Pair.of(item, Integer.parseInt(split[1])));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return BLACKLIST.contains(Pair.of(stack.getItem(), stack.getMetadata()));
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue