Merge branch 'fix-bonegrinder' into 'master'
Fix bonegrinder See merge request 2009scape/2009scape!80
This commit is contained in:
@@ -1,152 +0,0 @@
|
||||
package core.game.content.global;
|
||||
|
||||
import core.game.node.item.Item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents the type of bones.
|
||||
* @author Apache Ah64
|
||||
*/
|
||||
public enum Bones {
|
||||
|
||||
BONES(2530, 4.5),
|
||||
BONES_2(526,4.5),
|
||||
WOLF_BONES(2859, 4.5),
|
||||
BURNST_BONES(528, 4.5),
|
||||
MONKEY_BONES(3183, 5),
|
||||
MONKEY_BONES2(3179, 5),
|
||||
BAT_BONES(530, 5.3),
|
||||
BIG_BONES(532, 15),
|
||||
JOGRE_BONES(3125, 15),
|
||||
ZOGRE_BONES(4812, 12.5),
|
||||
SHAIKAHAN_BONES(3123, 25),
|
||||
BABY_DRAGON_BONES(534, 30),
|
||||
WYVERN_BONES(6812, 50),
|
||||
DRAGON_BONES(536, 72),
|
||||
FAYRG(4830, 84),
|
||||
RAURG_BONES(4832, 96),
|
||||
DAGANNOTH(6729, 125),
|
||||
OURG_BONES(4834, 140),
|
||||
LAVA_DRAGON_BONES(14693, 85);
|
||||
|
||||
/**
|
||||
* Holds all bones.
|
||||
*/
|
||||
private static HashMap<Integer, Bones> bones = new HashMap<Integer, Bones>();
|
||||
|
||||
|
||||
/**
|
||||
* The bone item id.
|
||||
*/
|
||||
private int itemId;
|
||||
|
||||
/**
|
||||
* The experience given by burying the bone.
|
||||
*/
|
||||
private double experience;
|
||||
|
||||
/**
|
||||
* Construct a new {@code Bones} {@code Object}.
|
||||
* @param itemId The item id.
|
||||
* @param experience The experience given by burying the bone.
|
||||
*/
|
||||
private Bones(int itemId, double experience) {
|
||||
this.itemId = itemId;
|
||||
this.experience = experience;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bone meal item.
|
||||
* @return the item.
|
||||
*/
|
||||
public Item getBoneMeal() {
|
||||
return new Item(4255 + ordinal());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bone experience given when you bury the bone.
|
||||
* @return The experience.
|
||||
*/
|
||||
public double getExperience() {
|
||||
return experience;
|
||||
}
|
||||
|
||||
public int getItemId() {
|
||||
return itemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bones for the bone meal.
|
||||
* @param itemId the item.
|
||||
* @return the bones.
|
||||
*/
|
||||
public static Bones forBoneMeal(int itemId) {
|
||||
for (Bones bone : Bones.values()) {
|
||||
if (bone.getBoneMeal().getId() == itemId) {
|
||||
return bone;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the config value for the bone.
|
||||
* @param value the value.
|
||||
* @param hopper hopper.
|
||||
* @return {@code True} if so.
|
||||
*/
|
||||
public static Bones forConfigValue(int value, boolean hopper) {
|
||||
for (Bones bone : Bones.values()) {
|
||||
if (bone.getConfigValue(hopper) == value) {
|
||||
return bone;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the config value for the bone type.
|
||||
* @param hopper the hopper.
|
||||
* @return the value.
|
||||
*/
|
||||
public int getConfigValue(boolean hopper) {
|
||||
return (this == BONES_2 ? ordinal() : ordinal() - 1) | (hopper ? 4 : 8) << 16;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bone ids.
|
||||
* @return the ids.
|
||||
*/
|
||||
public static int[] getArray() {
|
||||
List<Integer> list = new ArrayList<>(20);
|
||||
for (int i : bones.keySet()) {
|
||||
list.add(i);
|
||||
}
|
||||
int[] array = new int[list.size()];
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
array[i] = list.get(i);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bone.
|
||||
* @param itemId The item id.
|
||||
* @return The bone.
|
||||
*/
|
||||
public static Bones forId(int itemId) {
|
||||
return bones.get(itemId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the bones.
|
||||
*/
|
||||
static {
|
||||
for (Bones bone : Bones.values()) {
|
||||
bones.put(bone.itemId, bone);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package core.game.content.global
|
||||
|
||||
import core.game.content.global.Bones
|
||||
import core.game.node.item.Item
|
||||
import java.util.ArrayList
|
||||
import java.util.HashMap
|
||||
|
||||
/**
|
||||
* Represents the type of bones.
|
||||
* @author Apache Ah64
|
||||
*/
|
||||
enum class Bones
|
||||
/**
|
||||
* Construct a new `Bones` `Object`.
|
||||
* @param itemId The item id.
|
||||
* @param experience The experience given by burying the bone.
|
||||
*/(
|
||||
/**
|
||||
* The bone item id.
|
||||
*/
|
||||
val itemId: Int,
|
||||
/**
|
||||
* The experience given by burying the bone.
|
||||
*/
|
||||
val experience: Double) {
|
||||
BONES(2530, 4.5),
|
||||
BONES_2(526, 4.5),
|
||||
WOLF_BONES(2859, 4.5),
|
||||
BURNST_BONES(528, 4.5),
|
||||
MONKEY_BONES(3183, 5.0),
|
||||
MONKEY_BONES2(3179, 5.0),
|
||||
BAT_BONES(530, 5.3),
|
||||
BIG_BONES(532, 15.0),
|
||||
JOGRE_BONES(3125, 15.0),
|
||||
ZOGRE_BONES(4812, 12.5),
|
||||
SHAIKAHAN_BONES(3123, 25.0),
|
||||
BABY_DRAGON_BONES(534, 30.0),
|
||||
WYVERN_BONES(6812, 50.0),
|
||||
DRAGON_BONES(536, 72.0),
|
||||
FAYRG(4830, 84.0),
|
||||
RAURG_BONES(4832, 96.0),
|
||||
DAGANNOTH(6729, 125.0),
|
||||
OURG_BONES(4834, 140.0),
|
||||
LAVA_DRAGON_BONES(14693, 85.0);
|
||||
/**
|
||||
* Get the bone experience given when you bury the bone.
|
||||
* @return The experience.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Gets the bone meal item.
|
||||
* @return the item.
|
||||
*/
|
||||
val boneMeal: Item
|
||||
get() {
|
||||
return when(this){
|
||||
FAYRG -> Item(4852)
|
||||
RAURG_BONES -> Item(4853)
|
||||
OURG_BONES -> Item(4854)
|
||||
else -> Item(4255 + ordinal)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the config value for the bone type.
|
||||
* @param hopper the hopper.
|
||||
* @return the value.
|
||||
*/
|
||||
fun getConfigValue(hopper: Boolean): Int {
|
||||
return (if (this == BONES_2) ordinal else ordinal - 1) or (if (hopper) 4 else 8) shl 16
|
||||
}
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Holds all bones.
|
||||
*/
|
||||
private val bones = HashMap<Int, Bones>()
|
||||
|
||||
/**
|
||||
* Gets the bones for the bone meal.
|
||||
* @param itemId the item.
|
||||
* @return the bones.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun forBoneMeal(itemId: Int): Bones? {
|
||||
for (bone in values()) {
|
||||
if (bone.boneMeal.id == itemId) {
|
||||
return bone
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the config value for the bone.
|
||||
* @param value the value.
|
||||
* @param hopper hopper.
|
||||
* @return `True` if so.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun forConfigValue(value: Int, hopper: Boolean): Bones? {
|
||||
for (bone in values()) {
|
||||
if (bone.getConfigValue(hopper) == value) {
|
||||
return bone
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bone ids.
|
||||
* @return the ids.
|
||||
*/
|
||||
val array: IntArray
|
||||
@JvmStatic get() {
|
||||
val list: MutableList<Int> = ArrayList(20)
|
||||
for (i in bones.keys) {
|
||||
list.add(i)
|
||||
}
|
||||
val array = IntArray(list.size)
|
||||
for (i in list.indices) {
|
||||
array[i] = list[i]
|
||||
}
|
||||
return array
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bone.
|
||||
* @param itemId The item id.
|
||||
* @return The bone.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun forId(itemId: Int): Bones? {
|
||||
return bones[itemId]
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the bones.
|
||||
*/
|
||||
init {
|
||||
for (bone in values()) {
|
||||
bones[bone.itemId] = bone
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user