RuneHive-Game
Loading...
Searching...
No Matches
ChopRoots.java
Go to the documentation of this file.
1package com.runehive.content.wintertodt.actions;
2
3import com.runehive.Config;
4import com.runehive.content.skill.impl.woodcutting.AxeData;
5import com.runehive.content.wintertodt.Wintertodt;
6import com.runehive.game.action.Action;
7import com.runehive.game.action.policy.WalkablePolicy;
8import com.runehive.game.world.entity.mob.player.Player;
9import com.runehive.game.world.entity.skill.Skill;
10import com.runehive.game.world.items.Item;
11
12public class ChopRoots extends Action<Player> {
13
14 int tick;
15 public ChopRoots(Player player) {
16 super(player, 1);
17 }
18
19 @Override
23
24 @Override
25 public String getName() {
26 return "Chop roots";
27 }
28
29 @Override
30 protected void execute() {
31 AxeData axeData = AxeData.getDefinition(getMob()).orElse(null);
32
33 if (axeData == null) {
34 getMob().message("You need an axe to chop this tree.");
35 getMob().animate(65535);
36 getMob().action.getCurrentAction().cancel();
37 return;
38 }
39
40 if(getMob().inventory.getFreeSlots() <= 0) {
41 getMob().message("You have no space for that.");
42 getMob().animate(65535);
43 getMob().action.getCurrentAction().cancel();
44 return;
45 }
46
47 getMob().animate(axeData.animation);
48
49 if(tick % 3 == 0) {
50 getMob().inventory.add(new Item(Wintertodt.BRUMA_ROOT));
51 getMob().inventory.refresh();
52 getMob().message("You get a bruma root.");
53 double xp = Skill.getLevelForExperience(getMob().skills.get(Skill.WOODCUTTING).getExperience()) * 0.3;
54 if(xp > 0) getMob().skills.addExperience(Skill.WOODCUTTING, xp * Config.WOODCUTTING_MODIFICATION);
55 }
56 tick++;
57 }
58}
The class that contains setting-related constants for the server.
Definition Config.java:24
static final double WOODCUTTING_MODIFICATION
The experience modification for woodcutting.
Definition Config.java:283
String getName()
Gets the name of this action.
void execute()
A function representing the unit of work that will be carried out.
WalkablePolicy getWalkablePolicy()
Gets the WalkablePolicy of this action.
T getMob()
Gets the player.
Definition Action.java:44
Action(T mob, int delay, boolean instant)
Creates a new Action randomevent.
Definition Action.java:24
This class represents a character controlled by a player.
Definition Player.java:125
Represents a trainable and usable skill.
Definition Skill.java:18
static final int WOODCUTTING
The woodcutting skill id.
Definition Skill.java:45
static final byte getLevelForExperience(double experience)
Gets the level for a given experience amount.
Definition Skill.java:446
The container class that represents an item that can be interacted with.
Definition Item.java:21
static Optional< AxeData > getDefinition(Player player)
Gets the definition for this hatchet.
Definition AxeData.java:74
A queue policy determines whether the action can occur while walking.
NON_WALKABLE
This indicates actions cannot occur while walking.