RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
FlowerPatch.java
1package com.osroyale.content.skill.impl.farming.patches.impl;
2
3import com.osroyale.content.skill.impl.farming.FarmingConstants;
4import com.osroyale.content.skill.impl.farming.patches.WaterablePatch;
5import com.osroyale.content.skill.impl.farming.plants.Flower;
6import com.osroyale.content.skill.impl.farming.plants.Plant;
7import com.osroyale.content.skill.impl.farming.zones.FarmingZone;
8import com.osroyale.game.world.Interactable;
9import com.osroyale.game.world.World;
10import com.osroyale.game.world.entity.mob.player.Player;
11import com.osroyale.game.world.items.Item;
12
53
54public class FlowerPatch extends WaterablePatch {
55
57 public static final int SCARECROW = 6059;
58
66 public FlowerPatch(Player player, FarmingZone zone, Interactable[] boundaries) {
67 super(player, zone, boundaries);
68 }
69
77 private boolean plantScareCrow(int item, int index) {
78 if (player.locking.locked()) {
79 return false;
80 }
81
82 if (plant == null || item != SCARECROW) {
83 return false;
84 }
85
86 if (!isEmpty()) {
87 player.message("You need to clear the patch before planting a scarecrow.");
88 return false;
89 }
90
91 player.animate(832);
92 player.inventory.remove(new Item(SCARECROW), index, true);
93 player.locking.lock(2 * 3 / 5);
94
95 World.schedule(2, () -> {
96 player.message("You put a scarecrow on the flower patch, and some weeds start to grow around it.");
97 plant = plantForSeed(0x24);
98 timer.reset();
99 zone.sendPatchConfigs(player);
100 });
101 return true;
102 }
103
111 public boolean protectsDisease(int protect) {
112 if (!isDead() && fullyGrown && plant.getSeedId() == protect) {
113 setDead();
114 return true;
115 }
116 return protect == SCARECROW && plant.getSeedId() >= 0x21 && plant.getSeedId() <= 0x24;
117 }
118
119 @Override
120 public Plant plantForSeed(int seedId) {
121 return Flower.forId(seedId);
122 }
123
124 @Override
125 public boolean itemOnObject(Item item, int index) {
126 return plantScareCrow(item.getId(), index) || super.itemOnObject(item, index);
127 }
128
129 @Override
130 protected int getMinAmount() {
131 return 1;
132 }
133
134 @Override
135 protected int getMaxAmount() {
136 return 1;
137 }
138
139 @Override
140 protected int animation() {
141 return FarmingConstants.PICKING_VEGETABLE_ANIM;
142 }
143
144}
WaterablePatch(Player player, FarmingZone zone, Interactable[] boundaries)
FlowerPatch(Player player, FarmingZone zone, Interactable[] boundaries)
static void schedule(Task task)
Definition World.java:284