use of mcjty.rftools.items.modifier.ModifierEntry in project RFTools by McJty.
the class ScannerTileEntity method mapState.
private IBlockState mapState(List<ModifierEntry> modifiers, Map<IBlockState, IBlockState> modifierMapping, BlockPos pos, IBlockState inState) {
if (modifiers.isEmpty()) {
return inState;
}
if (!modifierMapping.containsKey(inState)) {
IBlockState outState = inState;
boolean stop = false;
for (ModifierEntry modifier : modifiers) {
if (stop) {
break;
}
switch(modifier.getType()) {
case FILTER_SLOT:
{
ItemStack inputItem = inState.getBlock().getItem(getWorld(), pos, inState);
if (!modifier.getIn().isEmpty() && modifier.getIn().getItem() == ModularStorageSetup.storageFilterItem) {
StorageFilterCache filter = StorageFilterItem.getCache(modifier.getIn());
if (filter.match(inputItem)) {
outState = getOutput(inState, modifier);
stop = true;
}
} else {
// Empty input stack in modifier also matches
if (modifier.getIn().isEmpty() || ItemStack.areItemsEqual(inputItem, modifier.getIn())) {
outState = getOutput(inState, modifier);
stop = true;
}
}
break;
}
case FILTER_ORE:
{
ItemStack inputItem = inState.getBlock().getItem(getWorld(), pos, inState);
if (!inputItem.isEmpty()) {
int[] oreIDs = OreDictionary.getOreIDs(inputItem);
for (int id : oreIDs) {
if (OreDictionary.getOreName(id).startsWith("ore")) {
outState = getOutput(inState, modifier);
stop = true;
break;
}
}
}
break;
}
case FILTER_LIQUID:
if (inState.getBlock() instanceof BlockLiquid) {
outState = getOutput(inState, modifier);
stop = true;
}
break;
case FILTER_TILEENTITY:
if (getWorld().getTileEntity(pos) != null) {
outState = getOutput(inState, modifier);
stop = true;
}
break;
}
}
modifierMapping.put(inState, outState);
}
return modifierMapping.get(inState);
}
Aggregations