Пример #1
0
 public static void PerformDrafting(EntityPlayer player) {
   LogHelper.info("Performing Drafting");
   IDrafter drafter = DraftingProvider.get(player);
   if (drafter == null) return;
   IDraftable toDraft = DraftableReg.GetDraftable(drafter.GetSelectedDraftable());
   if (toDraft == null) return;
   ItemStack held = player.getHeldItem();
   LogHelper.info("attempting draft of " + toDraft.GetName());
   if (held == null) {
     if (drafter.AttemptDrafting(toDraft.GetCost())) {
       convertCostToExperience(drafter, toDraft.GetCost());
       ItemStack drafted = toDraft.CreateItem();
       LogHelper.info(((IDraftable) drafted.getItem()).GetName() + " Created");
       player.setCurrentItemOrArmor(player.inventory.currentItem, drafted);
     } else drafter.MakeSick();
     try {
       drafter.dataChanged(player);
     } catch (Exception e) {
       LogHelper.warn("Drafting errored");
       System.out.println(e.getMessage());
     }
   }
 }
Пример #2
0
 private static void convertCostToExperience(IDrafter drafter, HashMap<String, Float> costs) {
   for (String luxin : costs.keySet()) drafter.GrantExperience(luxin, costs.get(luxin));
 }