Package invtweaks

Examples of invtweaks.InvTweaksItemTree


            if (currentSlot != -1) {
                itemPickupPending = false;

                // Find preffered slots
                List<Integer> prefferedPositions = new LinkedList<Integer>();
                InvTweaksItemTree tree = config.getTree();
                ItemStack stack = containerMgr.getItemStack(currentSlot);
                List<InvTweaksItemTreeItem> items = tree.getItems(getItemID(stack),
                        getItemDamage(stack));
                for (InvTweaksConfigSortingRule rule : config.getRules()) {
                    if (tree.matches(items, rule.getKeyword())) {
                        for (int slot : rule.getPreferredSlots()) {
                            prefferedPositions.add(slot);
                        }
                    }
                }
View Full Code Here


        boolean refillBeforeBreak = config.getProperty(InvTweaksConfig.PROP_AUTO_REFILL_BEFORE_BREAK)
                .equals(InvTweaksConfig.VALUE_TRUE);
   
    List<InvTweaksConfigSortingRule> matchingRules = new ArrayList<InvTweaksConfigSortingRule>();
    List<InvTweaksConfigSortingRule> rules = config.getRules();
    InvTweaksItemTree tree = config.getTree();
   
    // Check that the item is in the tree
        if (!tree.isItemUnknown(wantedId, wantedDamage)) {
           
            //// Search replacement
           
        List<InvTweaksItemTreeItem> items = tree.getItems(wantedId, wantedDamage);
   
        // Find rules that match the slot
        for (InvTweaksItemTreeItem item : items) {
          // Since we search a matching item using rules,
            // create a fake one that matches the exact item first
          matchingRules.add(new InvTweaksConfigSortingRule(
              tree, "D"+(slot-27), item.getName(),
              InvTweaksConst.INVENTORY_SIZE, InvTweaksConst.INVENTORY_ROW_SIZE));
        }
        for (InvTweaksConfigSortingRule rule : rules) {
          if (rule.getType() == InvTweaksConfigSortingRuleType.SLOT
                  || rule.getType() == InvTweaksConfigSortingRuleType.COLUMN) {
            for (int preferredSlot : rule.getPreferredSlots()) {
              if (slot == preferredSlot) {
                matchingRules.add(rule);
                break;
              }
            }
          }
        }
   
        // Look only for a matching stack
        // First, look for the same item,
        // else one that matches the slot's rules
        for (InvTweaksConfigSortingRule rule : matchingRules) {
          for (int i = 0; i < InvTweaksConst.INVENTORY_SIZE; i++) {
            candidateStack = container.getItemStack(i);
            if (candidateStack != null) {
              List<InvTweaksItemTreeItem> candidateItems = tree.getItems(
                  getItemID(candidateStack),
                  getItemDamage(candidateStack));
              if (tree.matches(candidateItems, rule.getKeyword())) {
                            // Choose tool of highest damage value
                if (getMaxStackSize(candidateStack) == 1) {
                    if ((replacementStack == null || getItemDamage(candidateStack) > getItemDamage(replacementStack)) &&
                            (!refillBeforeBreak || getMaxDamage(getItem(candidateStack)) - getItemDamage(candidateStack)
                                    > InvTweaksConst.AUTO_REFILL_DAMAGE_TRESHOLD)) {
View Full Code Here

TOP

Related Classes of invtweaks.InvTweaksItemTree

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.