Ejemplo n.º 1
0
 public static void SwitchToDraft(EntityPlayer player, String name) {
   LogHelper.info("switching selection");
   IDraftable draft = DraftableReg.GetDraftable(name);
   if (draft != null) {
     player.getCapability(DraftingProvider.CHROMATPLAYER, EnumFacing.NORTH).SetSelection(name);
     NBTTagCompound toSend = new NBTTagCompound();
     toSend.setString("Selection", name);
     CommonProxy.network.sendTo(new MessageUpdateClientValue(toSend), (EntityPlayerMP) player);
   }
 }
Ejemplo n.º 2
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());
     }
   }
 }
Ejemplo n.º 3
0
 public static void CycleSelection(EntityPlayer player) {
   LogHelper.info("Cycling selection");
   String current =
       player
           .getCapability(DraftingProvider.CHROMATPLAYER, EnumFacing.NORTH)
           .GetSelectedDraftable();
   List<String> drafts = DraftableReg.GetDraftables();
   int selected = -1;
   if (current.equals(Refs.MODID + "_NO_Selection") && drafts.size() > 0) selected = 0;
   else {
     for (int i = 0; i < drafts.size(); i++)
       if (drafts.get(i).equals(current)) selected = (i + 1) % drafts.size();
     LogHelper.info("cycled to " + selected);
   }
   player
       .getCapability(DraftingProvider.CHROMATPLAYER, EnumFacing.NORTH)
       .SetSelection((selected != -1) ? drafts.get(selected) : current);
   if (selected != -1) {
     NBTTagCompound toSend = new NBTTagCompound();
     toSend.setString("Selection", drafts.get(selected));
     CommonProxy.network.sendTo(new MessageUpdateClientValue(toSend), (EntityPlayerMP) player);
   }
 }
Ejemplo n.º 4
0
 @Override
 public void RegisterDraft(IDraftable draftable) {
   super.RegisterDraft(draftable);
   DraftableReg.RegisterDraftableModel(draftable);
 }