Package crazypants.enderio.conduit.item.filter

Examples of crazypants.enderio.conduit.item.filter.IItemFilter


    }
    if(!(stack.getItem() instanceof IItemFilterUpgrade)) {
      return null;
    }
    IItemFilterUpgrade upgrade = (IItemFilterUpgrade)stack.getItem();
    IItemFilter res = upgrade.createFilterFromStack(stack);    
    return res;
  }
View Full Code Here


  public static IItemFilter loadFilterFromNbt(NBTTagCompound filterTag) {
    if(filterTag == null) {
      return null;
    }
    IItemFilter filter;   
    //legacy support for release where class names where not stored
    if(!filterTag.hasKey("filterClass")) {
      filter = null;
      Log.warn("Could not load old version of item filter.");
    } else {
View Full Code Here

   

  private static IItemFilter loadFilterFromNbt(String className, NBTTagCompound tag) {
    try {
      Class<?> clz = Class.forName(className);
      IItemFilter filter = (IItemFilter) clz.newInstance();
      filter.readFromNBT(tag);
      return filter;
    } catch (Exception e) {
      Log.error("Could not read item filter with class name: " + className + " from NBT: " + tag + " Error: " + e);
      return null;
    }
View Full Code Here

  private boolean canExtractItem(ItemStack itemStack) {
    if(itemStack == null) {
      return false;
    }
    IItemFilter filter = con.getInputFilter(conDir);
    if(filter == null) {
      return true;
    }
    return filter.doesItemPassFilter(this, itemStack);
  }
View Full Code Here

    Iterable<Target> targets = getTargetIterator();

    //for (Target target : sendPriority) {
    for (Target target : targets) {
      if(target.stickyInput && !matchedStickyInput) {
        IItemFilter of = target.inv.con.getOutputFilter(target.inv.conDir);
        matchedStickyInput = of != null && of.isValid() && of.doesItemPassFilter(this, toExtract);
      }
      if(target.stickyInput || !matchedStickyInput) {
        if(target.inv.recheckInv) {
          target.inv.updateInventory();
        }
View Full Code Here

  private int insertItem(ItemStack item) {
    if(!canInsert() || item == null) {
      return 0;
    }
    IItemFilter filter = con.getOutputFilter(conDir);
    if(filter != null) {
      if(!filter.doesItemPassFilter(this, item)) {
        return 0;
      }
    }
    return ItemUtil.doInsertItem(getInventory(), item, ForgeDirection.values()[inventorySide]);
  }
View Full Code Here

    int filterMeta = metaData;
    if(metaData == 1) {

      for (Entry<ForgeDirection, IItemFilter> entry : inputFilters.entrySet()) {
        if(entry.getValue() != null) {
          IItemFilter f = entry.getValue();
          if(f != null) {
            setSpeedUpgrade(entry.getKey(), new ItemStack(EnderIO.itemExtractSpeedUpgrade, 15, 0));
          }
        }
      }
View Full Code Here

  }
 
  protected void convertToItemUpgrades(int filterMeta, Map<ForgeDirection, ItemStack> converted, EnumMap<ForgeDirection, IItemFilter> sourceFilters) {
    for (Entry<ForgeDirection, IItemFilter> entry : sourceFilters.entrySet()) {
      if(entry.getValue() != null) {
        IItemFilter f = entry.getValue();
        ItemStack up = new ItemStack(EnderIO.itemBasicFilterUpgrade, 1, filterMeta);
        FilterRegister.writeFilterToStack(f, up);
        converted.put(entry.getKey(), up);
      }
    }
View Full Code Here

  public void writeToNBT(NBTTagCompound nbtRoot) {
    super.writeToNBT(nbtRoot);

    for (Entry<ForgeDirection, IItemFilter> entry : inputFilters.entrySet()) {
      if(entry.getValue() != null) {
        IItemFilter f = entry.getValue();
        if(!isDefault(f)) {
          NBTTagCompound itemRoot = new NBTTagCompound();
          FilterRegister.writeFilterToNbt(f, itemRoot);
          nbtRoot.setTag("inFilts." + entry.getKey().name(), itemRoot);
        }
      }
    }

    for (Entry<ForgeDirection, ItemStack> entry : speedUpgrades.entrySet()) {
      if(entry.getValue() != null) {
        ItemStack up = entry.getValue();
        NBTTagCompound itemRoot = new NBTTagCompound();
        up.writeToNBT(itemRoot);
        nbtRoot.setTag("speedUpgrades." + entry.getKey().name(), itemRoot);
      }
    }

    for (Entry<ForgeDirection, IItemFilter> entry : outputFilters.entrySet()) {
      if(entry.getValue() != null) {
        IItemFilter f = entry.getValue();
        if(!isDefault(f)) {
          NBTTagCompound itemRoot = new NBTTagCompound();
          FilterRegister.writeFilterToNbt(f, itemRoot);
          nbtRoot.setTag("outFilts." + entry.getKey().name(), itemRoot);
        }
      }
    }

    for (Entry<ForgeDirection, ItemStack> entry : inputFilterUpgrades.entrySet()) {
      if(entry.getValue() != null) {
        ItemStack up = entry.getValue();
        IItemFilter filter = getInputFilter(entry.getKey());
        FilterRegister.writeFilterToStack(filter, up);

        NBTTagCompound itemRoot = new NBTTagCompound();
        up.writeToNBT(itemRoot);
        nbtRoot.setTag("inputFilterUpgrades." + entry.getKey().name(), itemRoot);
      }
    }

    for (Entry<ForgeDirection, ItemStack> entry : outputFilterUpgrades.entrySet()) {
      if(entry.getValue() != null) {
        ItemStack up = entry.getValue();
        IItemFilter filter = getOutputFilter(entry.getKey());
        FilterRegister.writeFilterToStack(filter, up);

        NBTTagCompound itemRoot = new NBTTagCompound();
        up.writeToNBT(itemRoot);
        nbtRoot.setTag("outputFilterUpgrades." + entry.getKey().name(), itemRoot);
View Full Code Here

      String key = "inFilts." + dir.name();
      if(nbtRoot.hasKey(key)) {
        NBTTagCompound filterTag = (NBTTagCompound) nbtRoot.getTag(key);
        FilterRegister.updateLegacyFilterNbt(filterTag, metaData);
        IItemFilter filter = FilterRegister.loadFilterFromNbt(filterTag);
        inputFilters.put(dir, filter);
      }

      key = "speedUpgrades." + dir.name();
      if(nbtRoot.hasKey(key)) {
        NBTTagCompound upTag = (NBTTagCompound) nbtRoot.getTag(key);
        ItemStack ups = ItemStack.loadItemStackFromNBT(upTag);
        speedUpgrades.put(dir, ups);
      }

      key = "inputFilterUpgrades." + dir.name();
      if(nbtRoot.hasKey(key)) {
        NBTTagCompound upTag = (NBTTagCompound) nbtRoot.getTag(key);
        ItemStack ups = ItemStack.loadItemStackFromNBT(upTag);
        inputFilterUpgrades.put(dir, ups);
      }

      key = "outputFilterUpgrades." + dir.name();
      if(nbtRoot.hasKey(key)) {
        NBTTagCompound upTag = (NBTTagCompound) nbtRoot.getTag(key);
        ItemStack ups = ItemStack.loadItemStackFromNBT(upTag);
        outputFilterUpgrades.put(dir, ups);
      }

      key = "outFilts." + dir.name();
      if(nbtRoot.hasKey(key)) {
        NBTTagCompound filterTag = (NBTTagCompound) nbtRoot.getTag(key);
        FilterRegister.updateLegacyFilterNbt(filterTag, metaData);
        IItemFilter filter = FilterRegister.loadFilterFromNbt(filterTag);
        outputFilters.put(dir, filter);
      }

      key = "extRM." + dir.name();
      if(nbtRoot.hasKey(key)) {
View Full Code Here

TOP

Related Classes of crazypants.enderio.conduit.item.filter.IItemFilter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.