Moved same target to class variable

This commit is contained in:
smuddgge 2023-01-20 19:58:07 +00:00
parent c4f890d00e
commit e1e352656e
2 changed files with 11 additions and 11 deletions

View File

@ -51,6 +51,7 @@ public class FishingManager extends SkillManager {
private long lastWarnedExhaust = 0L;
private FishHook fishHookReference;
private BoundingBox lastFishingBoundingBox;
private boolean sameTarget;
private Item fishingCatch;
private Location hookLocation;
private int fishCaughtCounter = 1;
@ -127,12 +128,17 @@ public class FishingManager extends SkillManager {
public void processExploiting(Vector centerOfCastVector) {
BoundingBox newCastBoundingBox = makeBoundingBox(centerOfCastVector);
boolean sameTarget = lastFishingBoundingBox != null && lastFishingBoundingBox.overlaps(newCastBoundingBox);
this.sameTarget = lastFishingBoundingBox != null && lastFishingBoundingBox.overlaps(newCastBoundingBox);
if (sameTarget)
if (this.sameTarget) {
fishCaughtCounter++;
else
}
else {
fishCaughtCounter = 1;
}
//If the new bounding box does not intersect with the old one, then update our bounding box reference
if (!this.sameTarget) lastFishingBoundingBox = newCastBoundingBox;
if (fishCaughtCounter + 1 == ExperienceConfig.getInstance().getFishingExploitingOptionOverFishLimit()) {
getPlayer().sendMessage(LocaleLoader.getString("Fishing.LowResourcesTip", ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange()));
@ -147,13 +153,7 @@ public class FishingManager extends SkillManager {
return false;
}*/
BoundingBox newCastBoundingBox = makeBoundingBox(centerOfCastVector);
boolean sameTarget = lastFishingBoundingBox != null && lastFishingBoundingBox.overlaps(newCastBoundingBox);
//If the new bounding box does not intersect with the old one, then update our bounding box reference
if (!sameTarget) lastFishingBoundingBox = newCastBoundingBox;
return sameTarget && fishCaughtCounter >= ExperienceConfig.getInstance().getFishingExploitingOptionOverFishLimit();
return this.sameTarget && fishCaughtCounter >= ExperienceConfig.getInstance().getFishingExploitingOptionOverFishLimit();
}
public static BoundingBox makeBoundingBox(Vector centerOfCastVector) {