RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.content.skill.impl.crafting.Crafting Class Reference

Handles the crafting skill. More...

Inheritance diagram for com.runehive.content.skill.impl.crafting.Crafting:
Collaboration diagram for com.runehive.content.skill.impl.crafting.Crafting:

Public Member Functions

boolean craft (Player player, int index, int amount)
 Crafting (int level, double experience)
boolean start (Player player, Craftable craftable, int index, int amount)
Public Member Functions inherited from com.runehive.game.world.entity.skill.Skill
double addExperience (double amount)
 Adds experiences to this skill by the given amount.
void addLevel (int amount)
 Adds levels to this skill by the given amount.
void divideExperience (double amount)
 Divides the current experience of this skill by a given amount.
void divideLevel (double amount)
 Divides the current level of this skill by a given amount.
double getExperience ()
 Gets the skill experience.
int getLevel ()
 Gets the current skill level.
int getMaxLevel ()
 Gets the maximum skill level.
int getRoundedExperience ()
 Gets the floor experience.
int getSkill ()
 Gets the skill id.
boolean isDoingSkill ()
double modifyExperience (Function< Double, Double > function)
 Modifies the current experience with a given function.
double modifyExperience (Function< Double, Double > function, int lowerBounds, int upperBounds)
 Modifies the current experience with a given function.
void modifyLevel (Function< Integer, Integer > function)
 Modifies the current level with a given function.
void modifyLevel (Function< Integer, Integer > function, int lowerBounds, int upperBounds)
 Modifies the current level with a given function.
void multiplyExperience (double amount)
 Multiplies the current experience of this skill by a given amount.
void multiplyLevel (double amount)
 Multiplies the current level of this skill by a given amount.
boolean onEvent (Player player, InteractionEvent interactionEvent)
void removeExperience (double amount)
 Removes experiences from this skill by the given amount.
void removeLevel (int amount)
 Removes levels from this skill by the given amount.
boolean reqLevel (int level)
 Determines if your level is greater than or equal to level.
void setDoingSkill (boolean doingSkill)
void setExperience (double experience)
 Sets the experience for this skill.
void setLevel (int level)
 Sets the level for this skill.
void setMaxLevel (int maxLevel)
 Sets the maximum level for this skill.
 Skill (int skill, int level, double experience)
 Constructs a new Skill.
String toString ()

Static Public Member Functions

static void addCraftable (Craftable craftable)
Static Public Member Functions inherited from com.runehive.game.world.entity.skill.Skill
static Function< Integer, Integer > add (int amount)
 Creates a function that adds a number by an amount.
static Function< Integer, Integer > divide (double amount)
 Creates a function that divides a number by an amount.
static final int getExperienceForLevel (int level)
 Gets the experience for a given level.
static final byte getLevelForExperience (double experience)
 Gets the level for a given experience amount.
static String getName (int skill)
 Gets the name for a skill id.
static Function< Integer, Integer > multiply (double amount)
 Creates a function that multiplies a number by an amount.
static Function< Integer, Integer > subtract (int amount)
 Creates a function that subtracts a number by an amount.

Protected Member Functions

boolean clickButton (Player player, ClickButtonInteractionEvent event)
boolean clickNpc (Player player, NpcInteractionEvent event)
boolean clickObject (Player player, ObjectInteractionEvent event)
boolean useItem (Player player, ItemOnItemInteractionEvent event)
boolean useItem (Player player, ItemOnObjectInteractionEvent event)
Protected Member Functions inherited from com.runehive.game.world.entity.skill.Skill
boolean clickItem (Player player, ItemInteractionEvent event)
boolean itemContainerAction (Player player, ItemContainerInteractionEvent event)
double modifier ()

Private Member Functions

Action< Playercraft (Player player, Craftable craftable, CraftableItem item, int index, int amount)

Static Private Member Functions

static Craftable getCraftable (int use, int with)

Static Private Attributes

static final String CRAFTABLE_KEY = "CRAFTABLE_KEY"
 The craftable key.
static final HashMap< Integer, CraftableCRAFTABLES = new HashMap<>()
 The craftable map.
static final Object[][] LEATHER_ARMOR_IDS
 The leather armour data.

Additional Inherited Members

Public Attributes inherited from com.runehive.game.world.entity.skill.Skill
transient final Stopwatch stopwatch = Stopwatch.start()
Static Public Attributes inherited from com.runehive.game.world.entity.skill.Skill
static final int AGILITY = 16
 The agility skill id.
static final int ATTACK = 0
 The attack skill id.
static final int CONSTRUCTION = 21
 The construction skill id.
static final int COOKING = 7
 The cooking skill id.
static final int CRAFTING = 12
 The crafting skill id.
static final int DEFENCE = 1
 The defence skill id.
static final int FARMING = 19
 The farming skill id.
static final int FIREMAKING = 11
 The firemaking skill id.
static final int FISHING = 10
 The fishing skill id.
static final int FLETCHING = 9
 The fletching skill id.
static final int HERBLORE = 15
 The herblore skill id.
static final int HITPOINTS = 3
 The hitpoints skill id.
static final int HUNTER = 22
 The hunter skill id.
static final int[][] INTERFACE_DATA
 Skill tab string data.
static final int MAGIC = 6
 The magic skill id.
static final int MINING = 14
 The mining skill id.
static final int PRAYER = 5
 The prayer skill id.
static final int RANGED = 4
 The ranged skill id.
static final int RUNECRAFTING = 20
 The runecrafting skill id.
static final int SKILL_COUNT = 23
 The amount of available skills.
static final int SLAYER = 18
 The slayer skill id.
static final int SMITHING = 13
 The smithing skill id.
static final int STRENGTH = 2
 The strength skill id.
static final int THIEVING = 17
 The thieving skill id.
static final int TOTAL_SKILL_LEVEL = 99 * SKILL_COUNT
 The total skill amount.
static final int WOODCUTTING = 8
 The woodcutting skill id.

Detailed Description

Handles the crafting skill.

Author
Daniel

Definition at line 30 of file Crafting.java.

Constructor & Destructor Documentation

◆ Crafting()

com.runehive.content.skill.impl.crafting.Crafting.Crafting ( int level,
double experience )

Definition at line 49 of file Crafting.java.

49 {
50 super(Skill.CRAFTING, level, experience);
51 }

References com.runehive.game.world.entity.skill.Skill.experience, com.runehive.game.world.entity.skill.Skill.level, and com.runehive.game.world.entity.skill.Skill.Skill().

Here is the call graph for this function:

Member Function Documentation

◆ addCraftable()

void com.runehive.content.skill.impl.crafting.Crafting.addCraftable ( Craftable craftable)
static

Definition at line 53 of file Crafting.java.

53 {
54 if (CRAFTABLES.put(craftable.getWith().getId(), craftable) != null) {
55 System.out.println("[Crafting] Conflicting item values: " + craftable.getWith().getId() + " Type: " + craftable.getName());
56 }
57 }
static final HashMap< Integer, Craftable > CRAFTABLES
The craftable map.
Definition Crafting.java:36
final int getId()
Gets the identification of this item.
Definition Item.java:324
String getName()
Gets the craftable name.
Item getWith()
Gets the craftable item used with.

References CRAFTABLES, com.runehive.game.world.items.Item.getId(), com.runehive.content.skill.impl.crafting.Craftable.getName(), and com.runehive.content.skill.impl.crafting.Craftable.getWith().

Referenced by com.runehive.content.skill.impl.crafting.impl.Gem.load(), and com.runehive.content.skill.impl.crafting.impl.Hide.load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clickButton()

boolean com.runehive.content.skill.impl.crafting.Crafting.clickButton ( Player player,
ClickButtonInteractionEvent event )
protected

Reimplemented from com.runehive.game.world.entity.skill.Skill.

Definition at line 195 of file Crafting.java.

195 {
196 if (Tanning.click(player, event.getButton())) {
197 return true;
198 }
199
200 if (Glass.click(player, event.getButton())) {
201 return true;
202 }
203
204 if (!player.attributes.has(CRAFTABLE_KEY)) {
205 return false;
206 }
207
208 int button = event.getButton();
209
210 if (button == 2422) {
211 return false;
212 }
213
214 if (String.valueOf(player.attributes.getObject(CRAFTABLE_KEY)).equals("HIDE")) {
215 for (Object[] i : LEATHER_ARMOR_IDS) {
216 if ((int) i[0] == button) {
217 player.interfaceManager.close();
218 start(player, (Craftable) i[2], 0, (int) i[1]);
219 return true;
220 }
221 }
222 }
223
224 Craftable craftable = player.attributes.get(CRAFTABLE_KEY, Craftable.class);
225
226 switch (button) {
227
228 /* Option 1 - Make all */
229 case 1747:
230 start(player, craftable, 0, player.inventory.computeAmountForId(craftable.getWith().getId()));
231 return true;
232
233 /* Option 1 - Make 1 */
234 case 2799:
235 case 8909:
236 case 8874:
237 case 8889:
238 case 8949:
239 start(player, craftable, 0, 1);
240 return true;
241
242 /* Option 1 - Make 5 */
243 case 2798:
244 case 8908:
245 case 8873:
246 case 8888:
247 case 8948:
248 start(player, craftable, 0, 5);
249 return true;
250
251 /* Option 1 - Make 10 */
252 case 1748:
253 case 8907:
254 case 8872:
255 case 8887:
256 case 8947:
257 start(player, craftable, 0, 10);
258 return true;
259
260 /* Option 1 - Make X */
261 case 8906:
262 case 8871:
263 case 8886:
264 case 6212:
265 case 8946:
266 player.send(new SendInputAmount("Enter amount", 10, input -> start(player, craftable, 0, Integer.parseInt(input))));
267 return true;
268
269 /* Option 2 - Make 1 */
270 case 8913:
271 case 8878:
272 case 8893:
273 case 8953:
274 start(player, craftable, 1, 1);
275 return true;
276
277 /* Option 2 - Make 5 */
278 case 8912:
279 case 8877:
280 case 8892:
281 case 8952:
282 start(player, craftable, 1, 5);
283 return true;
284
285 /* Option 2 - Make 10 */
286 case 8911:
287 case 8876:
288 case 8891:
289 case 8951:
290 start(player, craftable, 1, 10);
291 return true;
292
293 /* Option 2 - Make X */
294 case 8910:
295 case 8875:
296 case 8890:
297 case 8950:
298 player.send(new SendInputAmount("Enter amount", 10, input -> start(player, craftable, 1, Integer.parseInt(input))));
299 return true;
300
301 /* Option 3 - Make 1 */
302 case 8917:
303 case 8897:
304 case 8957:
305 start(player, craftable, 2, 1);
306 return true;
307
308 /* Option 3 - Make 5 */
309 case 8916:
310 case 8896:
311 case 8956:
312 start(player, craftable, 2, 5);
313 return true;
314
315 /* Option 3 - Make 10 */
316 case 8915:
317 case 8895:
318 case 8955:
319 start(player, craftable, 2, 10);
320 return true;
321
322 /* Option 3 - Make X */
323 case 8914:
324 case 8894:
325 case 8954:
326 player.send(new SendInputAmount("Enter amount", 10, input -> start(player, craftable, 2, Integer.parseInt(input))));
327 return true;
328
329 /* Option 4 - Make 1 */
330 case 8921:
331 case 8961:
332 start(player, craftable, 3, 1);
333 return true;
334
335 /* Option 4 - Make 5 */
336 case 8920:
337 case 8960:
338 start(player, craftable, 3, 5);
339 return true;
340
341 /* Option 4 - Make 10 */
342 case 8919:
343 case 8959:
344 start(player, craftable, 3, 10);
345 return true;
346
347 /* Option 4 - Make X */
348 case 8918:
349 case 8958:
350 player.send(new SendInputAmount("Enter amount", 10, input -> start(player, craftable, 3, Integer.parseInt(input))));
351 return true;
352
353 /* Option 5 - Make 1 */
354 case 8965:
355 start(player, craftable, 4, 1);
356 return true;
357
358 /* Option 5 - Make 5 */
359 case 8964:
360 start(player, craftable, 4, 5);
361 return true;
362
363 /* Option 5 - Make 10 */
364 case 8963:
365 start(player, craftable, 4, 10);
366 return true;
367
368 /* Option 5 - Make X */
369 case 8962:
370 player.send(new SendInputAmount("Enter amount", 10, input -> start(player, craftable, 4, Integer.parseInt(input))));
371 return true;
372
373 default:
374 return false;
375 }
376 }
static final String CRAFTABLE_KEY
The craftable key.
Definition Crafting.java:33
boolean start(Player player, Craftable craftable, int index, int amount)
static final Object[][] LEATHER_ARMOR_IDS
The leather armour data.
Definition Crafting.java:39
final GenericAttributes attributes
Definition Mob.java:95
final int computeAmountForId(int id)
Computes the total quantity of the Items in this container with id.
public< K, E > E get(K key)
Gets a generic attribute.
public< K > Object getObject(K key)
Gets a generic attribute.
public< K > boolean has(K key)
Checks if a key is in the list of generic attribute.

References com.runehive.game.world.entity.mob.Mob.attributes, com.runehive.content.skill.impl.crafting.impl.Glass.click(), com.runehive.content.skill.impl.crafting.impl.Tanning.click(), com.runehive.game.world.entity.mob.player.InterfaceManager.close(), com.runehive.game.world.items.containers.ItemContainer.computeAmountForId(), CRAFTABLE_KEY, com.runehive.util.generic.GenericAttributes.get(), com.runehive.game.world.items.Item.getId(), com.runehive.util.generic.GenericAttributes.getObject(), com.runehive.content.skill.impl.crafting.Craftable.getWith(), com.runehive.util.generic.GenericAttributes.has(), com.runehive.game.world.entity.mob.player.Player.interfaceManager, com.runehive.game.world.entity.mob.player.Player.inventory, LEATHER_ARMOR_IDS, com.runehive.game.world.entity.mob.player.Player.send(), and start().

Here is the call graph for this function:

◆ clickNpc()

boolean com.runehive.content.skill.impl.crafting.Crafting.clickNpc ( Player player,
NpcInteractionEvent event )
protected

Reimplemented from com.runehive.game.world.entity.skill.Skill.

Definition at line 79 of file Crafting.java.

79 {
80 if (event.getNpc().id == 5811) {
81 if (event.getOpcode() == 0) {
82 Tanning.open(player);
83 } else if (event.getOpcode() == 1) {
84 Store.STORES.get("Crafting Store").open(player);
85 }
86 return true;
87 }
88
89 return false;
90 }

References com.runehive.content.skill.impl.crafting.impl.Tanning.open(), and com.runehive.content.store.Store.STORES.

Here is the call graph for this function:

◆ clickObject()

boolean com.runehive.content.skill.impl.crafting.Crafting.clickObject ( Player player,
ObjectInteractionEvent event )
protected

Reimplemented from com.runehive.game.world.entity.skill.Skill.

Definition at line 64 of file Crafting.java.

64 {
65 if (event.getObject().getId() == 4309 && event.getOpcode() == 1) {
66 Spinning.open(player);
67 return true;
68 }
69
70 if (event.getObject().getId() == 11601 && event.getOpcode() == 0) {
71 Jewellery.open(player);
72 return true;
73 }
74
75 return false;
76 }
default int getId()
Gets the object id.

References com.runehive.content.skill.impl.crafting.impl.Jewellery.open(), and com.runehive.content.skill.impl.crafting.impl.Spinning.open().

Here is the call graph for this function:

◆ craft() [1/2]

Action< Player > com.runehive.content.skill.impl.crafting.Crafting.craft ( Player player,
Craftable craftable,
CraftableItem item,
int index,
int amount )
private

Definition at line 418 of file Crafting.java.

418 {
419 return new Action<Player>(player, 2, true) {
420 int iterations = 0;
421
422 @Override
423 public void execute() {
424 player.animate(new Animation(craftable.getAnimation()));
425 player.skills.addExperience(Skill.CRAFTING, item.getExperience() * Config.CRAFTING_MODIFICATION);
426
427 final boolean saveMaterial = SkillCape.isEquipped(player, SkillCape.CRAFTING) && Utility.random(1, 3) == 1;
428 if (!saveMaterial) {
429 player.inventory.removeAll(craftable.getIngredients(index));
430 }
431 player.inventory.addOrDrop(item.getProduct());
433 RandomEventHandler.trigger(player);
434
435 if (craftable.getProductionMessage() != null) {
436 player.send(new SendMessage(craftable.getProductionMessage()));
437 }
438
439// if (craftable.getName() == "Gem") {
440// AchievementHandler.activateTask(player, AchievementList.CUT_250_GEMS, 1);
441// }
442
443 if (++iterations == amount) {
444 cancel();
445 return;
446 }
447
448 if (!player.inventory.containsAll(craftable.getIngredients(index))) {
449 cancel();
450 player.send(new SendMessage("<col=369>You have run out of materials."));
451 return;
452 }
453 }
454
455 @Override
456 public String getName() {
457 return "Crafting";
458 }
459
460 @Override
461 public boolean prioritized() {
462 return false;
463 }
464
465 @Override
466 public WalkablePolicy getWalkablePolicy() {
467 return WalkablePolicy.NON_WALKABLE;
468 }
469 };
470 }
double getExperience()
Gets the experience rewarded.
void addExperience(int id, double experience)
Adds experience to a given skill.
boolean removeAll(Collection<? extends Item > items)
Attempts to withdraw items in bulk from this container.
final boolean containsAll(int... identifiers)
Determines if this container contains all identifiers.
void addOrDrop(List< Item > items)
Attempts to deposit an item to the players inventory, if there is no space it'll bank the item instea...
Item[] getIngredients(int index)
Gets the craftable ingredients.
String getProductionMessage()
Gets the craftable production message.
int getAnimation()
Gets the craftable animation.

References com.runehive.game.world.entity.mob.player.PlayerAssistant.activateSkilling(), com.runehive.game.world.entity.skill.SkillManager.addExperience(), com.runehive.game.world.items.containers.inventory.Inventory.addOrDrop(), com.runehive.game.world.entity.mob.Mob.animate(), com.runehive.game.world.items.containers.ItemContainer.containsAll(), com.runehive.content.skillcape.SkillCape.CRAFTING, com.runehive.Config.CRAFTING_MODIFICATION, com.runehive.content.skill.impl.crafting.Craftable.getAnimation(), com.runehive.content.skill.impl.crafting.CraftableItem.getExperience(), com.runehive.content.skill.impl.crafting.Craftable.getIngredients(), com.runehive.game.world.entity.skill.Skill.getName(), com.runehive.content.skill.impl.crafting.CraftableItem.getProduct(), com.runehive.content.skill.impl.crafting.Craftable.getProductionMessage(), com.runehive.game.world.entity.mob.player.Player.inventory, com.runehive.content.skillcape.SkillCape.isEquipped(), com.runehive.game.action.policy.WalkablePolicy.NON_WALKABLE, com.runehive.game.world.entity.mob.player.Player.playerAssistant, com.runehive.util.Utility.random(), com.runehive.game.world.items.containers.ItemContainer.removeAll(), com.runehive.game.world.entity.mob.player.Player.send(), com.runehive.game.world.entity.skill.Skill.Skill(), com.runehive.game.world.entity.mob.Mob.skills, and com.runehive.content.activity.randomevent.RandomEventHandler.trigger().

Here is the call graph for this function:

◆ craft() [2/2]

boolean com.runehive.content.skill.impl.crafting.Crafting.craft ( Player player,
int index,
int amount )

Definition at line 378 of file Crafting.java.

378 {
379 Craftable craftable = player.attributes.get(CRAFTABLE_KEY);
380 return start(player, craftable, index, amount);
381 }

References com.runehive.game.world.entity.mob.Mob.attributes, CRAFTABLE_KEY, com.runehive.util.generic.GenericAttributes.get(), and start().

Referenced by start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCraftable()

Craftable com.runehive.content.skill.impl.crafting.Crafting.getCraftable ( int use,
int with )
staticprivate

Definition at line 59 of file Crafting.java.

59 {
60 return CRAFTABLES.get(use) == null ? CRAFTABLES.get(with) : CRAFTABLES.get(use);
61 }

References CRAFTABLES.

Referenced by useItem().

Here is the caller graph for this function:

◆ start()

boolean com.runehive.content.skill.impl.crafting.Crafting.start ( Player player,
Craftable craftable,
int index,
int amount )

Definition at line 383 of file Crafting.java.

383 {
384 if (craftable == null) {
385 return false;
386 }
387
389
390 CraftableItem item = craftable.getCraftableItems()[index];
391
392 player.interfaceManager.close();
393
394 if (player.skills.getLevel(Skill.CRAFTING) < item.getLevel()) {
395 player.dialogueFactory.sendStatement("<col=369>You need a Crafting level of " + item.getLevel() + " to do that.").execute();
396 return true;
397 }
398
399 if (!player.inventory.containsAll(craftable.getIngredients(index))) {
400 Item requiredItem = craftable.getCraftableItems()[index].getRequiredItem();
401 Item product = craftable.getCraftableItems()[index].getProduct();
402 String productAmount = "";
403
404 if (product.getName().contains("vamb")) {
405 productAmount = " pair of";
406 } else if (!product.getName().endsWith("s")) {
407 productAmount = " " + Utility.getAOrAn(product.getName());
408 }
409
410 player.send(new SendMessage("You need " + requiredItem.getAmount() + " piece" + (requiredItem.getAmount() > 1 ? "s" : "") + " of " + requiredItem.getName().toLowerCase() + " to make" + productAmount + " " + product.getName().toLowerCase() + "."));
411 return true;
412 }
413
414 player.action.execute(craft(player, craftable, item, index, amount), true);
415 return true;
416 }
final DialogueFactory execute()
Retrieves the next dialogue in the chain and executes it.
final DialogueFactory sendStatement(String... lines)
Appends a StatementDialogue to the current dialogue chain.
boolean craft(Player player, int index, int amount)
public< A extends Action<?> > void execute(A action)
int getLevel(int id)
Gets the level of a skill.
final int getAmount()
Gets the quantity of this item.
Definition Item.java:342
public< K > void remove(K key)
Removes a generic attribute.
CraftableItem[] getCraftableItems()
Gets the craftable items.
val index

References com.runehive.game.world.entity.mob.Mob.action, com.runehive.game.world.entity.mob.Mob.attributes, com.runehive.game.world.entity.mob.player.InterfaceManager.close(), com.runehive.game.world.items.containers.ItemContainer.containsAll(), craft(), CRAFTABLE_KEY, com.runehive.game.world.entity.mob.player.Player.dialogueFactory, com.runehive.content.dialogue.DialogueFactory.execute(), com.runehive.game.action.ActionManager.execute(), com.runehive.game.world.items.Item.getAmount(), com.runehive.util.Utility.getAOrAn(), com.runehive.content.skill.impl.crafting.Craftable.getCraftableItems(), com.runehive.content.skill.impl.crafting.Craftable.getIngredients(), com.runehive.content.skill.impl.crafting.CraftableItem.getLevel(), com.runehive.game.world.entity.skill.SkillManager.getLevel(), com.runehive.game.world.items.Item.getName(), com.runehive.content.skill.impl.crafting.CraftableItem.getProduct(), com.runehive.content.skill.impl.crafting.CraftableItem.getRequiredItem(), com.runehive.game.world.entity.mob.player.Player.interfaceManager, com.runehive.game.world.entity.mob.player.Player.inventory, com.runehive.util.generic.GenericAttributes.remove(), com.runehive.game.world.entity.mob.player.Player.send(), com.runehive.content.dialogue.DialogueFactory.sendStatement(), com.runehive.game.world.entity.skill.Skill.Skill(), and com.runehive.game.world.entity.mob.Mob.skills.

Referenced by clickButton(), and craft().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ useItem() [1/2]

boolean com.runehive.content.skill.impl.crafting.Crafting.useItem ( Player player,
ItemOnItemInteractionEvent event )
protected

Reimplemented from com.runehive.game.world.entity.skill.Skill.

Definition at line 106 of file Crafting.java.

106 {
107 Item first = event.getFirst();
108 Item second = event.getSecond();
109
110 if (Stringing.useItem(player, first, second)) {
111 return true;
112 }
113
114 if (first.getId() == 1785 && second.getId() == 1775 || first.getId() == 1775 && second.getId() == 1785) {
115 Glass.open(player);
116 return true;
117 }
118
119 if ((first.getId() == 1733 && second.getId() == 1741) || (first.getId() == 1741 && second.getId() == 1733)) {
120 player.attributes.set(CRAFTABLE_KEY, "HIDE");
121 player.interfaceManager.open(2311);
122 return true;
123 }
124
125 Craftable craftable = getCraftable(first.getId(), second.getId());
126
127 if (craftable == null) {
128 return false;
129 }
130
131 if (!craftable.getUse().equalIds(first) && !craftable.getUse().equalIds(second)) {
132 player.message("You need to use this with " + Utility.getAOrAn(craftable.getUse().getName()) + " " + craftable.getUse().getName().toLowerCase() + " to craft this item.");
133 return true;
134 }
135
136 switch (craftable.getCraftableItems().length) {
137
138 case 1:
139 player.attributes.set(CRAFTABLE_KEY, craftable);
140 player.send(new SendString("\\n \\n \\n \\n" + craftable.getCraftableItems()[0].getProduct().getName(), 2799));
141 player.send(new SendItemOnInterfaceZoom(1746, 170, craftable.getCraftableItems()[0].getProduct().getId()));
142 player.send(new SendChatBoxInterface(4429));
143 return true;
144 case 2:
145 player.attributes.set(CRAFTABLE_KEY, craftable);
146 player.send(new SendItemOnInterfaceZoom(8869, 170, craftable.getCraftableItems()[0].getProduct().getId()));
147 player.send(new SendItemOnInterfaceZoom(8870, 170, craftable.getCraftableItems()[1].getProduct().getId()));
148 player.send(new SendString("\\n \\n \\n \\n".concat(craftable.getCraftableItems()[0].getProduct().getName().replace("d'hide ", "")), 8874));
149 player.send(new SendString("\\n \\n \\n \\n".concat(craftable.getCraftableItems()[1].getProduct().getName().replace("d'hide ", "")), 8878));
150 player.send(new SendChatBoxInterface(8866));
151 return true;
152 case 3:
153 player.attributes.set(CRAFTABLE_KEY, craftable);
154 player.send(new SendItemOnInterfaceZoom(8883, 170, craftable.getCraftableItems()[0].getProduct().getId()));
155 player.send(new SendItemOnInterfaceZoom(8884, 170, craftable.getCraftableItems()[1].getProduct().getId()));
156 player.send(new SendItemOnInterfaceZoom(8885, 170, craftable.getCraftableItems()[2].getProduct().getId()));
157 player.send(new SendString("\\n \\n \\n \\n".concat(craftable.getCraftableItems()[0].getProduct().getName().replace("d'hide ", "")), 8889));
158 player.send(new SendString("\\n \\n \\n \\n".concat(craftable.getCraftableItems()[1].getProduct().getName().replace("d'hide ", "")), 8893));
159 player.send(new SendString("\\n \\n \\n \\n".concat(craftable.getCraftableItems()[2].getProduct().getName().replace("d'hide ", "")), 8897));
160 player.send(new SendChatBoxInterface(8880));
161 return true;
162 case 4:
163 player.attributes.set(CRAFTABLE_KEY, craftable);
164 player.send(new SendItemOnInterfaceZoom(8902, 170, craftable.getCraftableItems()[0].getProduct().getId()));
165 player.send(new SendItemOnInterfaceZoom(8903, 170, craftable.getCraftableItems()[1].getProduct().getId()));
166 player.send(new SendItemOnInterfaceZoom(8904, 170, craftable.getCraftableItems()[2].getProduct().getId()));
167 player.send(new SendItemOnInterfaceZoom(8905, 170, craftable.getCraftableItems()[3].getProduct().getId()));
168 player.send(new SendString("\\n \\n \\n \\n".concat(craftable.getCraftableItems()[0].getProduct().getName().replace("d'hide ", "")), 8909));
169 player.send(new SendString("\\n \\n \\n \\n".concat(craftable.getCraftableItems()[1].getProduct().getName().replace("d'hide ", "")), 8913));
170 player.send(new SendString("\\n \\n \\n \\n".concat(craftable.getCraftableItems()[2].getProduct().getName().replace("d'hide ", "")), 8917));
171 player.send(new SendString("\\n \\n \\n \\n".concat(craftable.getCraftableItems()[3].getProduct().getName().replace("d'hide ", "")), 8921));
172 player.send(new SendChatBoxInterface(8899));
173 return true;
174 case 5:
175 player.attributes.set(CRAFTABLE_KEY, craftable);
176 player.send(new SendItemOnInterfaceZoom(8941, 170, craftable.getCraftableItems()[0].getProduct().getId()));
177 player.send(new SendItemOnInterfaceZoom(8942, 170, craftable.getCraftableItems()[1].getProduct().getId()));
178 player.send(new SendItemOnInterfaceZoom(8943, 170, craftable.getCraftableItems()[2].getProduct().getId()));
179 player.send(new SendItemOnInterfaceZoom(8944, 170, craftable.getCraftableItems()[3].getProduct().getId()));
180 player.send(new SendItemOnInterfaceZoom(8945, 170, craftable.getCraftableItems()[4].getProduct().getId()));
181 player.send(new SendString("\\n \\n \\n \\n".concat("Body"), 8949));
182 player.send(new SendString("\\n \\n \\n \\n".concat("Chaps"), 8953));
183 player.send(new SendString("\\n \\n \\n \\n".concat("Vambraces"), 8957));
184 player.send(new SendString("\\n \\n \\n \\n".concat("Bandana"), 8961));
185 player.send(new SendString("\\n \\n \\n \\n".concat("Boots"), 8965));
186 player.send(new SendChatBoxInterface(8938));
187 return true;
188
189 default:
190 return false;
191 }
192 }
static Craftable getCraftable(int use, int with)
Definition Crafting.java:59
void open(int identification)
Opens an interface for the player.
boolean equalIds(Item other)
Definition Item.java:461
public< K, E > void set(K key, E attribute)
Sets a generic attribute.
Item getUse()
Gets the craftable used item.

References com.runehive.game.world.entity.mob.Mob.attributes, CRAFTABLE_KEY, com.runehive.game.world.items.Item.equalIds(), com.runehive.util.Utility.getAOrAn(), getCraftable(), com.runehive.content.skill.impl.crafting.Craftable.getCraftableItems(), com.runehive.game.world.items.Item.getId(), com.runehive.game.world.items.Item.getName(), com.runehive.content.skill.impl.crafting.CraftableItem.getProduct(), com.runehive.content.skill.impl.crafting.Craftable.getUse(), com.runehive.game.world.entity.mob.player.Player.interfaceManager, com.runehive.game.world.entity.mob.player.Player.message(), com.runehive.content.skill.impl.crafting.impl.Glass.open(), com.runehive.game.world.entity.mob.player.InterfaceManager.open(), com.runehive.game.world.entity.mob.player.Player.send(), com.runehive.util.generic.GenericAttributes.set(), and com.runehive.content.skill.impl.crafting.impl.Stringing.useItem().

Here is the call graph for this function:

◆ useItem() [2/2]

boolean com.runehive.content.skill.impl.crafting.Crafting.useItem ( Player player,
ItemOnObjectInteractionEvent event )
protected

Reimplemented from com.runehive.game.world.entity.skill.Skill.

Definition at line 93 of file Crafting.java.

93 {
94 Item item = event.getItem();
95 GameObject object = event.getObject();
96
97 if (object.getId() == 16469 && (item.getId() == 1783 || item.getId() == 1781)) {
98 Glass.craft(player, Glass.GlassData.MOLTEN_GLASS, 28);
99 return true;
100 }
101
102 return false;
103 }

References com.runehive.content.skill.impl.crafting.impl.Glass.craft(), com.runehive.game.world.items.Item.getId(), and com.runehive.content.skill.impl.crafting.impl.Glass.GlassData.MOLTEN_GLASS.

Here is the call graph for this function:

Member Data Documentation

◆ CRAFTABLE_KEY

final String com.runehive.content.skill.impl.crafting.Crafting.CRAFTABLE_KEY = "CRAFTABLE_KEY"
staticprivate

The craftable key.

Definition at line 33 of file Crafting.java.

Referenced by clickButton(), craft(), start(), and useItem().

◆ CRAFTABLES

final HashMap<Integer, Craftable> com.runehive.content.skill.impl.crafting.Crafting.CRAFTABLES = new HashMap<>()
staticprivate

The craftable map.

Definition at line 36 of file Crafting.java.

Referenced by addCraftable(), and getCraftable().

◆ LEATHER_ARMOR_IDS

final Object [][] com.runehive.content.skill.impl.crafting.Crafting.LEATHER_ARMOR_IDS
staticprivate
Initial value:
= {
{8635, 1, Leather.LEATHER_BODY}, {8634, 5, Leather.LEATHER_BODY}, {8633, 10, Leather.LEATHER_BODY},
{8638, 1, Leather.LEATHER_GLOVES}, {8637, 5, Leather.LEATHER_GLOVES}, {8636, 10, Leather.LEATHER_GLOVES},
{8641, 1, Leather.LEATHER_BOOTS}, {8640, 5, Leather.LEATHER_BOOTS}, {8639, 10, Leather.LEATHER_BOOTS},
{8644, 1, Leather.LEATHER_VANBRACES}, {8643, 5, Leather.LEATHER_VANBRACES}, {8642, 10, Leather.LEATHER_VANBRACES},
{8647, 1, Leather.LEATHER_CHAPS}, {8646, 5, Leather.LEATHER_CHAPS}, {8645, 10, Leather.LEATHER_CHAPS},
{8650, 1, Leather.LEATHER_COIF}, {8649, 5, Leather.LEATHER_COIF}, {8648, 10, Leather.LEATHER_COIF},
{8653, 1, Leather.LEATHER_COWL}, {8652, 5, Leather.LEATHER_COWL}, {8651, 10, Leather.LEATHER_COWL},
}

The leather armour data.

Definition at line 39 of file Crafting.java.

39 {
40 {8635, 1, Leather.LEATHER_BODY}, {8634, 5, Leather.LEATHER_BODY}, {8633, 10, Leather.LEATHER_BODY},
41 {8638, 1, Leather.LEATHER_GLOVES}, {8637, 5, Leather.LEATHER_GLOVES}, {8636, 10, Leather.LEATHER_GLOVES},
42 {8641, 1, Leather.LEATHER_BOOTS}, {8640, 5, Leather.LEATHER_BOOTS}, {8639, 10, Leather.LEATHER_BOOTS},
43 {8644, 1, Leather.LEATHER_VANBRACES}, {8643, 5, Leather.LEATHER_VANBRACES}, {8642, 10, Leather.LEATHER_VANBRACES},
44 {8647, 1, Leather.LEATHER_CHAPS}, {8646, 5, Leather.LEATHER_CHAPS}, {8645, 10, Leather.LEATHER_CHAPS},
45 {8650, 1, Leather.LEATHER_COIF}, {8649, 5, Leather.LEATHER_COIF}, {8648, 10, Leather.LEATHER_COIF},
46 {8653, 1, Leather.LEATHER_COWL}, {8652, 5, Leather.LEATHER_COWL}, {8651, 10, Leather.LEATHER_COWL},
47 };

Referenced by clickButton().


The documentation for this class was generated from the following file: