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); } }
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()); } } }