Apparent tick limitation for mu custom goal

Started by hamza_bhh on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jan 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Apparent tick limitation for mu custom goal

Hello !
 

So I try to code a custom goal where my Manta Ray would swim constantly and most importantly follow long route without any turns, but it seams that I have a 102 tick limits on my goal which automatically reset target position before my manta can reach the previous one. I tried multiple things, but nothing seams to work... Please feel free to look at my data and the code and if you have any idea on why it would really help me ! thanks :)

When set to a radius of 8 blocks around (-8 to 8)

Point Distance (Current Block) Distance (Target Block) Distance Difference (Target - Current) Delta Time (ticks) Speed (Current Block) (blocks/second) Speed (Target Block) (blocks/second)
B 9,737393503 9,381564631 -0,355828872 68 2,863939266 2,759283715
C 1,896451725 3,061725279 1,165273554 18 2,107168583 3,401916976
D 7,221744408 8,179075973 0,957331565 102 1,416028315 1,603740387
E 6,844537868 8,478186423 1,633648556 70 1,955582248 2,422338978
F 3,644444041 5,919295701 2,274851661 34 2,143790612 3,481938648
G 3,138780269 3,626165523 0,487385254 38 1,651989615 1,90850817
H 5,143382308 6,571362034 1,427979726 68 1,512759502 1,932753539
I 1,744656385 2,309041505 0,56438512 18 1,938507094 2,565601672
J 4,686775438 6,334472275 1,647696836 72 1,301882066 1,759575632
K 8,596015252 10,28365399 1,687638734 84 2,046670298 2,448489044
L 6,931073772 7,406323528 0,475249756 102 1,359034073 1,4522203
M 5,277112755 4,306580688 -0,970532067 92 1,147198425 0,936213193
N 2,295238596 6,727931202 4,432692606 60 0,765079532 2,242643734
O 5,988439228 5,478682499 -0,509756729 94 1,274136006 1,165677127
P 4,582176916 5,363128549 0,780951634 102 0,898466062 1,051593833

when set to a radius of 16 blocks :

Point Distance (Current Block) Distance (Target Block) Difference (Target - Current) Delta Time (ticks) Speed (Current Block) (blocks/second) Speed (Target Block) (blocks/second)
B 13,07256857 17,63640477 4,563836203 96 2,723451785 3,674250994
C 7,894964213 8,930473178 1,035508965 102 1,548032199 1,751073172
D 11,06019561 19,94555692 8,885361312 102 2,168665806 3,910893514
E 12,94386987 14,69963836 1,755768487 82 3,157041432 3,585277648
F 10,25495919 17,55555509 7,3005959 102 2,010776312 3,442265704
G 11,49312969 7,798057894 -3,695071797 84 2,73645945 1,856680451
H 6,926906663 7,724276945 0,797370283 48 2,886211109 3,218448727
I 13,39436769 15,47568158 2,081313891 94 2,849865466 3,292698209
J 13,18458518 15,3471936 2,162608423 86 3,0661826 3,569114791
K 9,27699624 16,27186461 6,994868367 102 1,819018871 3,190561688
L 3,473711743 2,545618149 -0,928093595 80 0,868427936 0,636404537

when set to a radius of 32 blocks :

 

Point Distance (Current Block) Distance (Target Block) Distance Difference (Target - Current) Delta Time (ticks) Speed (Current Block) (blocks/second) Speed (Target Block) (blocks/second)
B 12,33830486 17,59864256 5,260337702 102 2,419275462 3,450714227
C 8,449449583 26,00380538 17,5543558 102 1,65675482 5,098785369
D 11,76236514 16,53398853 4,771623395 102 2,306346106 3,241958536
E 9,759328302 28,18614784 18,42681954 102 1,913593785 5,526695656
F 15,19045506 33,12541213 17,93495707 94 3,232011714 7,047960028
G 14,34190311 42,61459093 28,27268782 94 3,051468748 9,06693424
H 10,34433215 21,33167308 10,98734093 102 2,028300422 4,182680996
I 10,77829891 14,47300876 3,694709848 102 2,113391944 2,837844855
J 12,10565717 19,06498495 6,959327781 102 2,373658269 3,738232344
K 8,567309707 23,14876654 14,58145683 102 1,679864648 4,538973831
L 14,98381659 26,94181557 11,95799898 100 2,996763318 5,388363114
M 12,50342627 36,70097441 24,19754813 102 2,45165221 7,196269491
N 14,17664982 16,67870292 2,5020531 100 2,835329963 3,335740583
O 15,02481567 26,5087323 11,48391662 98 3,066288913 5,409945366
P 15,45451735 27,02114082 11,56662347 102 3,03029752 5,298262906

The code :

class ContinuousSwimmingGoal extends RandomSwimmingGoal {
public ContinuousSwimmingGoal(WaterAnimal mob, double speed) {
super(mob, speed, 40); //tried with 100, 200, 400 no changes
}

@Override
public boolean canUse() {
return true; // Always allow this goal to run
}

@Override
public void start() {
super.start();
long currentTick = this.mob.level().getGameTime();
System.out.println("ContinuousSwimmingGoal: Current tick: " + currentTick);

Vec3 currentPos = this.mob.position(); // Get current position
System.out.println("ContinuousSwimmingGoal: Current position: " + currentPos);
Vec3 randomPos = getRandomWaterPosition();
if (randomPos != null) {
// Debugging output for chosen position
System.out.println("ContinuousSwimmingGoal: Target position: " + randomPos);
this.mob.getNavigation().moveTo(randomPos.x, randomPos.y, randomPos.z, this.speedModifier);
} else {
System.out.println("ContinuousSwimmingGoal: No valid position found for swimming.");
}
}

private Vec3 getRandomWaterPosition() {
for (int i = 0; i < 10; i++) { // Try 10 random positions
double x = this.mob.getX() + (this.mob.getRandom().nextDouble() - 0.5) * 64;
double y = this.mob.getY() + (this.mob.getRandom().nextDouble() - 0.5) * 8;
double z = this.mob.getZ() + (this.mob.getRandom().nextDouble() - 0.5) * 64;

BlockPos pos = new BlockPos((int) x, (int) y, (int) z);
if (this.mob.level().getBlockState(pos).is(Blocks.WATER)) {
return new Vec3(x, y, z);
}
}
return null; // No valid position found
}
}