RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
Farming.java
1package com.osroyale.content.skill.impl.farming;
2
3import com.google.gson.JsonArray;
4import com.google.gson.JsonObject;
5import com.osroyale.content.skill.impl.farming.zones.*;
6import com.osroyale.game.world.entity.mob.player.Player;
7import com.osroyale.game.world.items.Item;
8import com.osroyale.game.world.object.GameObject;
9
10import java.util.LinkedList;
11import java.util.List;
12
39
40public class Farming {
41 private final List<FarmingZone> zones = new LinkedList<>();
42
43 public Farming(Player player) {
44 zones.add(new CatherbyZone(player));
45 zones.add(new ArdougneZone(player));
46 zones.add(new FaladorZone(player));
47 zones.add(new PhasmatyZone(player));
48 }
49
50 public static boolean itemOnObject(Player player, GameObject object, Item item, int slot) {
51 boolean success = false;
52 for (FarmingZone zone : player.farming.zones) {
53 if (zone.isViewable(player.getPosition())) {
54 success |= zone.itemOnObject(object, item, slot);
55 }
56 }
57 return success;
58 }
59
60 public static double getBonus(Player player) {
61 double bonus = 0;
62 if(player.equipment.getId(0) == 13646)
63 bonus += 0.4;
64 if(player.equipment.getId(4) == 13642)
65 bonus += 0.8;
66 if(player.equipment.getId(7) == 13640)
67 bonus += 0.6;
68 if(player.equipment.getId(10) == 13644)
69 bonus += 0.2;
70
71 if(player.equipment.containsAll(13646, 13642, 13640, 13644))
72 bonus = 2.5;
73
74 return bonus;
75 }
76
77
78 public static boolean firstClickObject(Player player, GameObject object) {
79 boolean success = false;
80 for (FarmingZone zone : player.farming.zones) {
81 if (zone.isViewable(player.getPosition())) {
82 success |= zone.clickObject(object, 1);
83 }
84 }
85 return success;
86 }
87
88 public static boolean secondClickObject(Player player, GameObject object) {
89 boolean success = false;
90 for (FarmingZone zone : player.farming.zones) {
91 if (zone.isViewable(player.getPosition())) {
92 success |= zone.clickObject(object, 2);
93 }
94 }
95 return success;
96 }
97
98 public static void tick(Player player) {
99 player.farming.zones.forEach(FarmingZone::tick);
100 }
101
102 public void regionChange(Player player) {
103 zones.forEach(zone -> zone.sendPatchConfigs(player));
104 }
105
106 public JsonObject toJson() {
107 JsonObject object = new JsonObject();
108 for (FarmingZone zone : zones) {
109 object.add(zone.getClass().getSimpleName(), zone.toJson());
110 }
111 return object;
112 }
113
114 public void fromJson(JsonObject object) {
115 for (FarmingZone zone : zones) {
116 if (!object.has(zone.getClass().getSimpleName())) {
117 continue;
118 }
119
120 JsonArray thing = object.get(zone.getClass().getSimpleName()).getAsJsonArray();
121 zone.fromJson(thing);
122 }
123 }
124
125}
boolean itemOnObject(GameObject object, Item item, int slot)
boolean clickObject(GameObject object, int opcode)