@Override
 public HashSet<String> getPrerequisites(String key) {
   ChromaResearch r = ChromaResearch.getByName(key.toUpperCase());
   if (r == null) {
     ChromatiCraft.logger.logError(
         "A mod tried to fetch the state of an invalid research '" + key + "'!");
     Thread.dumpStack();
     return null;
   }
   Collection<ChromaResearch> c = this.getPreReqsFor(r);
   HashSet<String> h = new HashSet();
   for (ChromaResearch req : c) {
     h.add(req.name());
   }
   return h;
 }
 @Override
 public boolean playerHasResearch(EntityPlayer ep, String key) {
   ChromaResearch r = ChromaResearch.getByName(key.toUpperCase());
   if (r == null) {
     ChromatiCraft.logger.logError(
         "A mod tried to fetch the state of an invalid research '" + key + "'!");
     Thread.dumpStack();
     return false;
   }
   return this.playerHasFragment(ep, r);
 }
 @Override
 public boolean lexiconHasFragment(ItemStack book, String key) {
   ChromaResearch r = ChromaResearch.getByName(key.toUpperCase());
   if (r == null) {
     ChromatiCraft.logger.logError(
         "A mod tried to fetch the state of an invalid research '" + key + "'!");
     Thread.dumpStack();
     return false;
   }
   return ItemChromaBook.hasPage(book, r);
 }
 @Override
 public HashSet<String> getAllResearches() {
   HashSet<String> c = new HashSet();
   for (ChromaResearch r : ChromaResearch.getAllNonParents()) {
     c.add(r.name());
   }
   return c;
 }
예제 #5
0
 private static ArrayList<ChromaResearch> getAllUnder(ChromaResearch parent) {
   ArrayList<ChromaResearch> li = new ArrayList();
   for (int i = parent.ordinal() + 1; i < researchList.length; i++) {
     ChromaResearch r = researchList[i];
     if (r.getParent() == parent) li.add(r);
     else break;
   }
   return li;
 }
 public boolean givePlayerFragment(EntityPlayer ep, ChromaResearch r, boolean notify) {
   if (!this.playerHasFragment(ep, r)) {
     this.getNBTFragments(ep).appendTag(new NBTTagString(r.name()));
     this.checkForUpgrade(ep);
     if (ep instanceof EntityPlayerMP) ReikaPlayerAPI.syncCustomData((EntityPlayerMP) ep);
     if (notify) this.notifyPlayerOfProgression(ep, r);
     ProgressionCacher.instance.updateProgressCache(ep);
     MinecraftForge.EVENT_BUS.post(new ProgressionEvent(ep, r.name(), ResearchType.FRAGMENT));
     return true;
   }
   return false;
 }
예제 #7
0
 public static void loadPostCache() {
   for (int i = 0; i < researchList.length; i++) {
     ChromaResearch r = researchList[i];
     if (!r.isDummiedOut()) {
       Collection<ItemStack> c = r.getItemStacks();
       if (c != null) {
         for (ItemStack is : c) {
           if (is != null && is.getItem() != null) itemMap.put(is, r);
         }
       }
       Collection<CastingRecipe> crc = r.getCraftingRecipes();
       for (CastingRecipe cr : crc) {
         cr.setFragment(r);
       }
     }
   }
 }
예제 #8
0
 static {
   for (int i = 0; i < researchList.length; i++) {
     ChromaResearch r = researchList[i];
     if (!r.isDummiedOut()) {
       if (r.level != null) levelMap.addValue(r.level, r);
       byName.put(r.name(), r);
       if (r.isParent) parents.add(r);
       else nonParents.add(r);
     }
     ChromaResearch pre = duplicateChecker.get(r.getIDObject());
     if (pre != null)
       throw new RegistrationException(
           ChromatiCraft.instance,
           "Two research fragments have the same block/item/ability/etc: " + r + " & " + pre);
     duplicateChecker.put(r.getIDObject(), r);
     ChromaResearchManager.instance.register(r);
   }
 }
 public Collection<ChromaResearch> getFragments(EntityPlayer ep) {
   Collection<ChromaResearch> c = new HashSet();
   NBTTagList li = this.getNBTFragments(ep);
   for (Object o : li.tagList) {
     ChromaResearch r = ChromaResearch.getByName(((NBTTagString) o).func_150285_a_());
     if (r != null) // may be null if a key is removed
     c.add(r);
   }
   return c;
 }
 public void maxPlayerResearch(EntityPlayer ep, boolean notify) {
   this.setPlayerResearchLevel(
       ep, ResearchLevel.levelList[ResearchLevel.levelList.length - 1], notify);
   for (ChromaResearch r : ChromaResearch.getAllObtainableFragments()) {
     this.givePlayerFragment(ep, r, notify);
   }
   for (CastingRecipe r : RecipesCastingTable.instance.getAllRecipes()) {
     this.givePlayerRecipe(ep, r);
   }
   if (ep instanceof EntityPlayerMP) ReikaPlayerAPI.syncCustomData((EntityPlayerMP) ep);
 }
 private ArrayList<ChromaResearch> getNextResearchesFor(EntityPlayer ep, boolean debug) {
   ChromaResearch pri = this.getPriorityResearchFor(ep);
   if (pri != null) {
     ArrayList li = new ArrayList();
     li.add(pri);
     return li;
   }
   this.checkForUpgrade(ep);
   ArrayList<ChromaResearch> li = new ArrayList();
   for (ChromaResearch r : ChromaResearch.getAllObtainableFragments()) {
     if (!this.playerHasFragment(ep, r)) {
       if (r.level == null || this.getPlayerResearchLevel(ep).isAtLeast(r.level)) {
         boolean missingdep = false;
         if (!r.playerHasProgress(ep)) {
           missingdep = true;
           if (debug)
             ChromatiCraft.logger.log(
                 "Fragment "
                     + r
                     + " rejected; insufficient progress "
                     + Arrays.toString(r.getRequiredProgress())
                     + ".");
         } else {
           if (!this.playerHasDependencies(r, ep)) {
             if (debug)
               ChromatiCraft.logger.log(
                   "Fragment " + r + " rejected; missing dependency."); // "+p+".");
             missingdep = true;
           }
         }
         if (!missingdep) li.add(r);
       } else if (debug) {
         ChromatiCraft.logger.log("Fragment " + r + " rejected; insufficient research level.");
       }
     }
   }
   return li;
 }
 public boolean removePlayerFragment(EntityPlayer ep, ChromaResearch r, boolean notify) {
   if (this.playerHasFragment(ep, r)) {
     NBTTagList li = this.getNBTFragments(ep);
     Iterator<NBTTagString> it = li.tagList.iterator();
     while (it.hasNext()) {
       NBTTagString s = it.next();
       if (s.func_150285_a_().equals(r.name())) it.remove();
     }
     if (ep instanceof EntityPlayerMP) ReikaPlayerAPI.syncCustomData((EntityPlayerMP) ep);
     ProgressionCacher.instance.updateProgressCache(ep);
     return true;
   }
   return false;
 }
 @Override
 public int compare(ChromaResearch o1, ChromaResearch o2) {
   return 1000 * (o1.level.ordinal() - o2.level.ordinal()) + o1.ordinal() - o2.ordinal();
 }
 private boolean playerHasAllFragmentsThatMatter(EntityPlayer ep, Collection<ChromaResearch> li) {
   for (ChromaResearch r : li) if (r.isGating() && !this.playerHasFragment(ep, r)) return false;
   return true;
 }
 public boolean playerHasFragment(EntityPlayer ep, ChromaResearch r) {
   return r.isAlwaysPresent()
       || r == ChromaResearch.PACKCHANGES
       || this.getFragments(ep).contains(r);
 }
 /**
  * Is this research one of the next ones available to the player, but without the player already
  * having it
  */
 public boolean canPlayerStepTo(EntityPlayer ep, ChromaResearch r) {
   return !r.isDummiedOut() && this.getNextResearchesFor(ep).contains(r);
 }