mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Closes #1245
This commit is contained in:
parent
474a7874ec
commit
673b4bf52a
2 changed files with 46 additions and 9 deletions
|
@ -78,7 +78,13 @@ public enum ConfigStringListValues {
|
||||||
"Sack Blacklist",
|
"Sack Blacklist",
|
||||||
ConfigCategories.OTHER,
|
ConfigCategories.OTHER,
|
||||||
new String[0],
|
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");
|
"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"),
|
||||||
|
REPAIR_BLACKLIST(
|
||||||
|
"Repair Blacklist",
|
||||||
|
ConfigCategories.OTHER,
|
||||||
|
new String[0],
|
||||||
|
"The items that aren't allowed to be put in the Repairer. 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.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
|
||||||
|
@ -18,7 +24,9 @@ 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.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.energy.IEnergyStorage;
|
import net.minecraftforge.energy.IEnergyStorage;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@ -110,11 +118,6 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public IAcceptor getAcceptor() {
|
|
||||||
return (slot, stack, automation) -> !automation || slot == SLOT_INPUT;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public int getEnergyScaled(int i) {
|
public int getEnergyScaled(int i) {
|
||||||
return this.storage.getEnergyStored() * i / this.storage.getMaxEnergyStored();
|
return this.storage.getEnergyStored() * i / this.storage.getMaxEnergyStored();
|
||||||
|
@ -125,13 +128,41 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IEnergyStorage getEnergyStorage(EnumFacing facing) {
|
||||||
|
return this.storage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IAcceptor getAcceptor() {
|
||||||
|
return (slot, stack, automation) -> !isBlacklisted(stack) && (!automation || slot == SLOT_INPUT);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRemover getRemover() {
|
public IRemover getRemover() {
|
||||||
return (slot, automation) -> !automation || slot == SLOT_OUTPUT;
|
return (slot, automation) -> !automation || slot == SLOT_OUTPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private static final List<Pair<Item, Integer>> BLACKLIST = new ArrayList<>();
|
||||||
public IEnergyStorage getEnergyStorage(EnumFacing facing) {
|
|
||||||
return this.storage;
|
private static boolean runOnce = false;
|
||||||
|
|
||||||
|
public static boolean isBlacklisted(ItemStack stack) {
|
||||||
|
if (!runOnce) {
|
||||||
|
runOnce = true;
|
||||||
|
for (String s : ConfigStringListValues.REPAIR_BLACKLIST.getValue()) {
|
||||||
|
String[] split = s.split("@");
|
||||||
|
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(split[0]));
|
||||||
|
if (item == null) {
|
||||||
|
ActuallyAdditions.LOGGER.error("Invalid item in repair 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