Add additional areas to FarmingRegions

This commit is contained in:
Morgan Lewis
2020-12-21 17:58:17 -07:00
parent 27ea3fbab6
commit 0381abddcb

View File

@@ -29,6 +29,7 @@ import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
import com.google.inject.Singleton;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
@@ -36,6 +37,7 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.stream.Collectors;
import lombok.Getter;
import net.runelite.api.Varbits;
import net.runelite.api.coords.WorldPoint;
@@ -44,7 +46,7 @@ import net.runelite.client.plugins.timetracking.Tab;
@Singleton
class FarmingWorld
{
@Getter
@SuppressWarnings("PMD.ImmutableField")
private Multimap<Integer, FarmingRegion> regions = HashMultimap.create();
@Getter
@@ -64,11 +66,11 @@ class FarmingWorld
// It may be worth it to add a specialization for these patches
add(new FarmingRegion("Al Kharid", 13106,
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.CACTUS)
));
), 13362, 13105);
add(new FarmingRegion("Ardougne", 10290,
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.BUSH)
));
), 10546);
add(new FarmingRegion("Ardougne", 10548,
new FarmingPatch("North", Varbits.FARMING_4771, PatchImplementation.ALLOTMENT),
new FarmingPatch("South", Varbits.FARMING_4772, PatchImplementation.ALLOTMENT),
@@ -80,7 +82,7 @@ class FarmingWorld
add(new FarmingRegion("Brimhaven", 11058,
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.FRUIT_TREE),
new FarmingPatch("", Varbits.FARMING_4772, PatchImplementation.SPIRIT_TREE)
));
), 11057);
add(new FarmingRegion("Catherby", 11062,
new FarmingPatch("North", Varbits.FARMING_4771, PatchImplementation.ALLOTMENT),
@@ -93,9 +95,10 @@ class FarmingWorld
@Override
public boolean isInBounds(WorldPoint loc)
{
if (loc.getY() < 3456)
if (loc.getX() >= 2816 && loc.getY() < 3456)
{
return loc.getX() <= 2840 && loc.getY() > 3440;
//Upstairs sends different varbits
return loc.getX() < 2840 && loc.getY() >= 3440 && loc.getPlane() == 0;
}
return true;
}
@@ -104,10 +107,11 @@ class FarmingWorld
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.FRUIT_TREE)
)
{
//The fruit tree patch is always sent when upstairs in 11317
@Override
public boolean isInBounds(WorldPoint loc)
{
return loc.getX() > 2840 || loc.getY() < 3440;
return loc.getX() >= 2840 || loc.getY() < 3440 || loc.getPlane() == 1;
}
});
@@ -121,7 +125,7 @@ class FarmingWorld
add(new FarmingRegion("Entrana", 11060,
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.HOPS)
));
), 11316);
add(new FarmingRegion("Etceteria", 10300,
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.BUSH),
@@ -130,7 +134,7 @@ class FarmingWorld
add(new FarmingRegion("Falador", 11828,
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.TREE)
));
), 12084);
add(new FarmingRegion("Falador", 12083,
new FarmingPatch("North West", Varbits.FARMING_4771, PatchImplementation.ALLOTMENT),
new FarmingPatch("South East", Varbits.FARMING_4772, PatchImplementation.ALLOTMENT),
@@ -142,7 +146,8 @@ class FarmingWorld
@Override
public boolean isInBounds(WorldPoint loc)
{
return loc.getY() > 3280;
//Not on region boundary due to Port Sarim Spirit Tree patch
return loc.getY() >= 3272;
}
});
@@ -150,7 +155,30 @@ class FarmingWorld
new FarmingPatch("East", Varbits.FARMING_4771, PatchImplementation.HARDWOOD_TREE),
new FarmingPatch("Middle", Varbits.FARMING_4772, PatchImplementation.HARDWOOD_TREE),
new FarmingPatch("West", Varbits.FARMING_4773, PatchImplementation.HARDWOOD_TREE)
), 14907);
)
{
@Override
public boolean isInBounds(WorldPoint loc)
{
//Hardwood tree varbits are sent anywhere on plane 0 of fossil island.
//Varbits get sent 1 tick earlier than expected when climbing certain ladders and stairs
//Stairs to house on the hill
if (loc.getX() == 3753 && loc.getY() >= 3868 && loc.getY() <= 3870)
{
return false;
}
//East and west ladders to rope bridge
if ((loc.getX() == 3729 || loc.getX() == 3728 || loc.getX() == 3747 || loc.getX() == 3746)
&& loc.getY() <= 3832 && loc.getY() >= 3830)
{
return false;
}
return loc.getPlane() == 0;
}
}, 14907, 14908, 15164, 14652, 14906, 14650, 15162, 15163);
add(new FarmingRegion("Seaweed", 15008,
new FarmingPatch("North", Varbits.FARMING_4771, PatchImplementation.SEAWEED),
new FarmingPatch("South", Varbits.FARMING_4772, PatchImplementation.SEAWEED)
@@ -159,7 +187,7 @@ class FarmingWorld
add(new FarmingRegion("Gnome Stronghold", 9781,
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.TREE),
new FarmingPatch("", Varbits.FARMING_4772, PatchImplementation.FRUIT_TREE)
));
), 9782, 9526, 9525);
add(new FarmingRegion("Harmony", 15148,
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.ALLOTMENT),
@@ -171,11 +199,9 @@ class FarmingWorld
new FarmingPatch("South West", Varbits.FARMING_4772, PatchImplementation.ALLOTMENT),
new FarmingPatch("", Varbits.FARMING_4773, PatchImplementation.FLOWER),
new FarmingPatch("", Varbits.FARMING_4774, PatchImplementation.HERB),
new FarmingPatch("", Varbits.FARMING_4775, PatchImplementation.COMPOST)
));
add(new FarmingRegion("Kourend", 6711,
new FarmingPatch("", Varbits.FARMING_4775, PatchImplementation.COMPOST),
new FarmingPatch("", Varbits.FARMING_7904, PatchImplementation.SPIRIT_TREE)
));
), 6711);
add(new FarmingRegion("Kourend", 7223,
new FarmingPatch("East 1", Varbits.GRAPES_4953, PatchImplementation.GRAPES),
new FarmingPatch("East 2", Varbits.GRAPES_4954, PatchImplementation.GRAPES),
@@ -200,23 +226,29 @@ class FarmingWorld
));
add(new FarmingRegion("Lumbridge", 12594,
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.TREE)
));
), 12850);
add(new FarmingRegion("Morytania", 13622,
new FarmingPatch("Mushroom", Varbits.FARMING_4771, PatchImplementation.MUSHROOM)
));
), 13878);
add(new FarmingRegion("Morytania", 14391,
new FarmingPatch("North West", Varbits.FARMING_4771, PatchImplementation.ALLOTMENT),
new FarmingPatch("South East", Varbits.FARMING_4772, PatchImplementation.ALLOTMENT),
new FarmingPatch("", Varbits.FARMING_4773, PatchImplementation.FLOWER),
new FarmingPatch("", Varbits.FARMING_4774, PatchImplementation.HERB),
new FarmingPatch("", Varbits.FARMING_4775, PatchImplementation.COMPOST)
));
), 14390);
add(new FarmingRegion("Port Sarim", 12082,
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.SPIRIT_TREE)
));
)
{
@Override
public boolean isInBounds(WorldPoint loc)
{
return loc.getY() < 3272;
}
}, 12083);
add(new FarmingRegion("Rimmington", 11570,
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.BUSH)
@@ -224,7 +256,7 @@ class FarmingWorld
add(new FarmingRegion("Seers' Village", 10551,
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.HOPS)
));
), 10550);
add(new FarmingRegion("Tai Bwo Wannai", 11056,
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.CALQUAT)
@@ -232,11 +264,11 @@ class FarmingWorld
add(new FarmingRegion("Taverley", 11573,
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.TREE)
));
), 11829);
add(new FarmingRegion("Tree Gnome Village", 9777,
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.FRUIT_TREE)
));
), 10033);
add(new FarmingRegion("Troll Stronghold", 11321,
new FarmingPatch("", Varbits.FARMING_4771, PatchImplementation.HERB)
@@ -258,6 +290,7 @@ class FarmingWorld
new FarmingPatch("Hespori", Varbits.FARMING_7908, PatchImplementation.HESPORI)
));
//Full 3x3 region area centered on farming guild
add(farmingGuildRegion = new FarmingRegion("Farming Guild", 4922,
new FarmingPatch("", Varbits.FARMING_7905, PatchImplementation.TREE),
new FarmingPatch("", Varbits.FARMING_4775, PatchImplementation.HERB),
@@ -272,18 +305,20 @@ class FarmingWorld
new FarmingPatch("Anima", Varbits.FARMING_7911, PatchImplementation.ANIMA),
new FarmingPatch("", Varbits.FARMING_7910, PatchImplementation.CELASTRUS),
new FarmingPatch("", Varbits.FARMING_7907, PatchImplementation.REDWOOD)
));
), 5177, 5178, 5179, 4921, 4923, 4665, 4666, 4667);
//All of Prifddinas, and all of Prifddinas Underground
add(new FarmingRegion("Prifddinas", 13151,
new FarmingPatch("North", Varbits.FARMING_4771, PatchImplementation.ALLOTMENT),
new FarmingPatch("South", Varbits.FARMING_4772, PatchImplementation.ALLOTMENT),
new FarmingPatch("", Varbits.FARMING_4773, PatchImplementation.FLOWER),
new FarmingPatch("", Varbits.FARMING_4775, PatchImplementation.CRYSTAL_TREE),
new FarmingPatch("", Varbits.FARMING_4774, PatchImplementation.COMPOST) // TODO: Find correct varbit
));
new FarmingPatch("North", Varbits.FARMING_4771, PatchImplementation.ALLOTMENT),
new FarmingPatch("South", Varbits.FARMING_4772, PatchImplementation.ALLOTMENT),
new FarmingPatch("", Varbits.FARMING_4773, PatchImplementation.FLOWER),
new FarmingPatch("", Varbits.FARMING_4775, PatchImplementation.CRYSTAL_TREE),
new FarmingPatch("", Varbits.FARMING_4774, PatchImplementation.COMPOST) // TODO: Find correct varbit
), 12895, 12894, 13150,
/* Underground */ 12994, 12993, 12737, 12738, 12126, 12127, 13250);
// Finalize
this.regions = Multimaps.unmodifiableMultimap(regions);
this.regions = Multimaps.unmodifiableMultimap(this.regions);
Map<Tab, Set<FarmingPatch>> umtabs = new TreeMap<>();
for (Map.Entry<Tab, Set<FarmingPatch>> e : tabs.entrySet())
{
@@ -306,4 +341,11 @@ class FarmingWorld
.add(p);
}
}
Collection<FarmingRegion> getRegionsForLocation(WorldPoint location)
{
return this.regions.get(location.getRegionID()).stream()
.filter(region -> region.isInBounds(location))
.collect(Collectors.toSet());
}
}