RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
WaterablePatch.java
1package com.osroyale.content.skill.impl.farming.patches;
2
3import com.osroyale.content.skill.impl.farming.FarmingConstants;
4import com.osroyale.content.skill.impl.farming.zones.FarmingZone;
5import com.osroyale.game.world.Interactable;
6import com.osroyale.game.world.World;
7import com.osroyale.game.world.entity.mob.player.Player;
8import com.osroyale.game.world.items.Item;
9
46
47public abstract class WaterablePatch extends DiseasablePatch {
48
56 public WaterablePatch(Player player, FarmingZone zone, Interactable[] boundaries) {
57 super(player, zone, boundaries);
58 }
59
67 private boolean waterPatch(int itemId, int index) {
68 if (player.locking.locked()) {
69 return false;
70 }
71
72 if (itemId != 5331 && (itemId < 5333 || itemId > 5340)) {
73 return false;
74 }
75
76 if (!isGrowing()) {
77 player.message("This patch needs to be growing something first.");
78 return true;
79 }
80
81 if (isWatered() || fullyGrown) {
82 player.message("This patch doesn't need watering.");
83 return true;
84 }
85
86 if (itemId == 5331) {
87 player.dialogueFactory.sendStatement("This watering can is empty.").execute();
88 return true;
89 }
90
91 player.message("You water the patch.");
92 player.animate(FarmingConstants.WATERING_CAN_ANIM);
93 player.inventory.replace(itemId, itemId == 5333 ? itemId - 2 : itemId - 1, index, true);
94 player.locking.lock(5 * 3 / 5);
95 setWatered();
96
97 World.schedule(5, () -> {
98 player.resetAnimation();
99 zone.sendPatchConfigs(player);
100 });
101 return true;
102 }
103
104 @Override
105 public boolean itemOnObject(Item item, int index) {
106 return waterPatch(item.getId(), index) || super.itemOnObject(item, index);
107 }
108
109/*
110 @Override
111 public boolean rollDisease() {
112 return !isWatered() && super.rollDisease();
113 }
114*/
115
116 @Override
117 protected void onGrowth() {
118 super.onGrowth();
119 if (isWatered()) {
120 setNormal();
121 }
122 }
123
124}
final DialogueFactory sendStatement(String... lines)
WaterablePatch(Player player, FarmingZone zone, Interactable[] boundaries)
static void schedule(Task task)
Definition World.java:284
final boolean replace(int oldId, int newId, int index, boolean refresh)