use of crazypants.enderio.base.filter.IItemFilter in project EnderIO by SleepyTrousers.
the class ItemConduit method writeToNBT.
@Override
public void writeToNBT(@Nonnull NBTTagCompound nbtRoot) {
super.writeToNBT(nbtRoot);
for (Entry<EnumFacing, IItemFilter> entry : inputFilters.entrySet()) {
if (entry.getValue() != null) {
IItemFilter f = entry.getValue();
if (!isDefault(f)) {
NBTTagCompound itemRoot = new NBTTagCompound();
FilterRegistry.writeFilterToNbt(f, itemRoot);
nbtRoot.setTag("inFilts." + entry.getKey().name(), itemRoot);
}
}
}
for (Entry<EnumFacing, ItemStack> entry : functionUpgrades.entrySet()) {
if (entry.getValue() != null) {
ItemStack up = entry.getValue();
NBTTagCompound itemRoot = new NBTTagCompound();
up.writeToNBT(itemRoot);
nbtRoot.setTag("functionUpgrades." + entry.getKey().name(), itemRoot);
}
}
for (Entry<EnumFacing, IItemFilter> entry : outputFilters.entrySet()) {
if (entry.getValue() != null) {
IItemFilter f = entry.getValue();
if (!isDefault(f)) {
NBTTagCompound itemRoot = new NBTTagCompound();
FilterRegistry.writeFilterToNbt(f, itemRoot);
nbtRoot.setTag("outFilts." + entry.getKey().name(), itemRoot);
}
}
}
for (Entry<EnumFacing, ItemStack> entry : inputFilterUpgrades.entrySet()) {
if (entry.getValue() != null) {
ItemStack up = entry.getValue();
IItemFilter filter = getInputFilter(entry.getKey());
FilterRegistry.writeFilterToStack(filter, up);
NBTTagCompound itemRoot = new NBTTagCompound();
up.writeToNBT(itemRoot);
nbtRoot.setTag("inputFilterUpgrades." + entry.getKey().name(), itemRoot);
}
}
for (Entry<EnumFacing, ItemStack> entry : outputFilterUpgrades.entrySet()) {
if (entry.getValue() != null) {
ItemStack up = entry.getValue();
IItemFilter filter = getOutputFilter(entry.getKey());
FilterRegistry.writeFilterToStack(filter, up);
NBTTagCompound itemRoot = new NBTTagCompound();
up.writeToNBT(itemRoot);
nbtRoot.setTag("outputFilterUpgrades." + entry.getKey().name(), itemRoot);
}
}
for (Entry<EnumFacing, RedstoneControlMode> entry : extractionModes.entrySet()) {
if (entry.getValue() != null) {
short ord = (short) entry.getValue().ordinal();
nbtRoot.setShort("extRM." + entry.getKey().name(), ord);
}
}
for (Entry<EnumFacing, DyeColor> entry : extractionColors.entrySet()) {
if (entry.getValue() != null) {
short ord = (short) entry.getValue().ordinal();
nbtRoot.setShort("extSC." + entry.getKey().name(), ord);
}
}
for (Entry<EnumFacing, Boolean> entry : selfFeed.entrySet()) {
if (entry.getValue() != null) {
nbtRoot.setBoolean("selfFeed." + entry.getKey().name(), entry.getValue());
}
}
for (Entry<EnumFacing, Boolean> entry : roundRobin.entrySet()) {
if (entry.getValue() != null) {
nbtRoot.setBoolean("roundRobin." + entry.getKey().name(), entry.getValue());
}
}
for (Entry<EnumFacing, Integer> entry : priority.entrySet()) {
if (entry.getValue() != null) {
nbtRoot.setInteger("priority." + entry.getKey().name(), entry.getValue());
}
}
for (Entry<EnumFacing, DyeColor> entry : inputColors.entrySet()) {
if (entry.getValue() != null) {
short ord = (short) entry.getValue().ordinal();
nbtRoot.setShort("inSC." + entry.getKey().name(), ord);
}
}
for (Entry<EnumFacing, DyeColor> entry : outputColors.entrySet()) {
if (entry.getValue() != null) {
short ord = (short) entry.getValue().ordinal();
nbtRoot.setShort("outSC." + entry.getKey().name(), ord);
}
}
}
use of crazypants.enderio.base.filter.IItemFilter in project EnderIO by SleepyTrousers.
the class ItemConduit method readFromNBT.
@Override
public void readFromNBT(@Nonnull NBTTagCompound nbtRoot) {
super.readFromNBT(nbtRoot);
if (nbtRoot.hasKey("metaData")) {
metaData = nbtRoot.getShort("metaData");
} else {
metaData = 0;
}
for (EnumFacing dir : EnumFacing.VALUES) {
String key = "inFilts." + dir.name();
if (nbtRoot.hasKey(key)) {
NBTTagCompound filterTag = (NBTTagCompound) nbtRoot.getTag(key);
IItemFilter filter = FilterRegistry.loadFilterFromNbt(filterTag);
inputFilters.put(dir, filter);
}
key = "functionUpgrades." + dir.name();
if (nbtRoot.hasKey(key)) {
NBTTagCompound upTag = (NBTTagCompound) nbtRoot.getTag(key);
ItemStack ups = new ItemStack(upTag);
functionUpgrades.put(dir, ups);
}
key = "inputFilterUpgrades." + dir.name();
if (nbtRoot.hasKey(key)) {
NBTTagCompound upTag = (NBTTagCompound) nbtRoot.getTag(key);
ItemStack ups = new ItemStack(upTag);
inputFilterUpgrades.put(dir, ups);
}
key = "outputFilterUpgrades." + dir.name();
if (nbtRoot.hasKey(key)) {
NBTTagCompound upTag = (NBTTagCompound) nbtRoot.getTag(key);
ItemStack ups = new ItemStack(upTag);
outputFilterUpgrades.put(dir, ups);
}
key = "outFilts." + dir.name();
if (nbtRoot.hasKey(key)) {
NBTTagCompound filterTag = (NBTTagCompound) nbtRoot.getTag(key);
IItemFilter filter = FilterRegistry.loadFilterFromNbt(filterTag);
outputFilters.put(dir, filter);
}
key = "extRM." + dir.name();
if (nbtRoot.hasKey(key)) {
short ord = nbtRoot.getShort(key);
if (ord >= 0 && ord < RedstoneControlMode.values().length) {
extractionModes.put(dir, RedstoneControlMode.values()[ord]);
}
}
key = "extSC." + dir.name();
if (nbtRoot.hasKey(key)) {
short ord = nbtRoot.getShort(key);
if (ord >= 0 && ord < DyeColor.values().length) {
extractionColors.put(dir, DyeColor.values()[ord]);
}
}
key = "selfFeed." + dir.name();
if (nbtRoot.hasKey(key)) {
boolean val = nbtRoot.getBoolean(key);
selfFeed.put(dir, val);
}
key = "roundRobin." + dir.name();
if (nbtRoot.hasKey(key)) {
boolean val = nbtRoot.getBoolean(key);
roundRobin.put(dir, val);
}
key = "priority." + dir.name();
if (nbtRoot.hasKey(key)) {
int val = nbtRoot.getInteger(key);
priority.put(dir, val);
}
key = "inSC." + dir.name();
if (nbtRoot.hasKey(key)) {
short ord = nbtRoot.getShort(key);
if (ord >= 0 && ord < DyeColor.values().length) {
inputColors.put(dir, DyeColor.values()[ord]);
}
}
key = "outSC." + dir.name();
if (nbtRoot.hasKey(key)) {
short ord = nbtRoot.getShort(key);
if (ord >= 0 && ord < DyeColor.values().length) {
outputColors.put(dir, DyeColor.values()[ord]);
}
}
}
connectionsDirty = true;
}
use of crazypants.enderio.base.filter.IItemFilter in project EnderIO by SleepyTrousers.
the class ItemConduitNetwork method getTargetsForExtraction.
public List<String> getTargetsForExtraction(@Nonnull BlockPos extractFrom, @Nonnull IItemConduit con, @Nonnull ItemStack input) {
List<String> result = new ArrayList<String>();
List<NetworkedInventory> invs = getOrCreate(extractFrom);
for (NetworkedInventory source : invs) {
if (source.getCon().getBundle().getLocation().equals(con.getBundle().getLocation())) {
List<Target> sendPriority = source.getSendPriority();
if (sendPriority != null) {
for (Target t : sendPriority) {
IItemFilter f = t.inv.getCon().getOutputFilter(t.inv.getConDir());
if (input.isEmpty() || f == null || f.doesItemPassFilter(getTargetInventory(t), input)) {
String s = t.inv.getLocalizedInventoryName() + " " + t.inv.getLocation().toString() + " Distance [" + t.distance + "] ";
result.add(s);
}
}
}
}
}
return result;
}
use of crazypants.enderio.base.filter.IItemFilter in project EnderIO by SleepyTrousers.
the class ItemBasicItemFilter method createFilterFromStack.
@Override
public IItemFilter createFilterFromStack(@Nonnull ItemStack stack) {
ItemFilter filter = new ItemFilter(filterType);
NBTTagCompound tag = NbtValue.FILTER.getTag(stack);
// ^ Response to above - need to move filters to use @Store in conduits
if (!tag.hasNoTags() || filterType == BasicFilterTypes.filterUpgradeBasic) {
filter.readFromNBT(tag);
}
return filter;
}
use of crazypants.enderio.base.filter.IItemFilter in project EnderIO by SleepyTrousers.
the class ItemExistingItemFilter method createFilterFromStack.
@Override
public IItemFilter createFilterFromStack(@Nonnull ItemStack stack) {
IItemFilter filter = new ExistingItemFilter();
NBTTagCompound tag = NbtValue.FILTER.getTag(stack);
filter.readFromNBT(tag);
return filter;
}
Aggregations