1package com.runehive.content.skill.impl.mining;
3import com.runehive.content.event.impl.ObjectInteractionEvent;
4import com.runehive.content.skill.SkillRepository;
5import com.runehive.game.world.World;
6import com.runehive.game.world.entity.mob.player.Player;
7import com.runehive.game.world.entity.skill.Skill;
8import com.runehive.game.world.items.Item;
9import com.runehive.game.world.object.GameObject;
10import com.runehive.net.packet.out.SendMessage;
11import com.runehive.util.Utility;
12import com.runehive.util.chance.Chance;
13import com.runehive.util.chance.WeightedChance;
15import java.util.Arrays;
43 int[] pieces = {12013, 12014, 12015, 12016, 25549, 25551, 25553, 25555};
44 for (
int piece : pieces) {
72 if (!
object.active()) {
76 switch (
event.getType()) {
77 case FIRST_CLICK_OBJECT:
81 case SECOND_CLICK_OBJECT:
92 if (pickaxe ==
null) {
93 player.
message(
"You don't have a pickaxe.");
98 player.
message(
"You need a level of " + pickaxe.
level +
" to use this pickaxe!");
103 player.
message(
"You need a mining level of " + ore.
level +
" to mine this ore!");
108 start(player,
object, ore, pickaxe);
112 if (!
object.getGenericAttributes().has(
"ores")) {
113 object.getGenericAttributes().set(
"ores", ore.
oreCount);
115 player.
walkTo(
object.getPosition(), () -> {
116 player.
face(
object.getPosition());
123 player.
message(
true,
"You swing your pick at the rock...");
130 playerMiningLevel += 4;
132 double level = (playerMiningLevel + pickaxe.
level) / 2.0D;
133 double successChance = Math.ceil((((
level * 50.0D) - ((
double) ore.
level * 15.0D)) / (
double) ore.
level / 3.0D) * 4.0D);
135 return successChance >= roll;
static boolean isSuccess(int skill, int levelRequired)
Created by Daniel on 2017-12-18.
boolean clickObject(Player player, ObjectInteractionEvent event)
void attempt(Player player, GameObject object, OreData ore)
static final Chance< Item > GEM_ITEMS
void start(Player player, GameObject object, OreData ore, PickaxeData pickaxe)
static double getBonus(Player player)
static boolean success(Player player, OreData ore, PickaxeData pickaxe)
Mining(int level, double experience)
Constructs a new Mining skill.
static boolean success(Player player, int level, PickaxeData pickaxe)
public< A extends Action<?> > void execute(A action)
Represents the game world.
static void schedule(Task task)
Submits a new event.
final SkillManager skills
void animate(int animation)
void face(GameObject object)
Sets the client update flag to face a certain direction.
void walkTo(Position position)
This class represents a character controlled by a player.
void message(String message)
final Equipment equipment
void send(OutgoingPacket encoder)
double experience
The current skill experience.
boolean reqLevel(int level)
Determines if your level is greater than or equal to level.
int level
The current level of the skill.
void setDoingSkill(boolean doingSkill)
Skill(int skill, int level, double experience)
Constructs a new Skill.
int getMaxLevel(int id)
Gets the highest possible level of a skill.
Skill get(int id)
Gets the skill for an id.
The container class that represents an item that can be interacted with.
final int getId(int index)
Gets the item id located on index.
final boolean containsAny(int... identifiers)
Determines if this container contains any identifiers.
boolean contains(int[] bowsWithNoArrowsRequired)
The OutgoingPacket that sends a message to a Players chatbox in the client.
Handles miscellaneous methods.
static int random(int bound)
static String formatEnum(final String string)
Formats name of enum.
An item with a common chance.
static OreData forId(int id)
Gets the ore data.
final int oreCount
The amount of ores that this ore can give.
final int level
The minimum level to mine this node.
Represents types of axes.
static Optional< PickaxeData > getBestPickaxe(Player player)
Gets the definition for this pickaxe.
final int level
The level.
final int animation
The animation.
Represents a game object.