Skip to content

Commit

Permalink
+ Pests Destroyer - new pathfinder (not fully compatible with oringo)
Browse files Browse the repository at this point in the history
= Some fixes to lane changing and rewarp delays
= Caching fixes and tweaks
  • Loading branch information
May2Beez committed Feb 9, 2024
1 parent 15446bc commit 705caa1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ baseGroup=com.jelly.farmhelperv2
mcVersion=1.8.9
modid=farmhelperv2
modName=FarmHelper
version=2.4.4-pre7
shouldRelease=false
version=2.4.5-pre1
shouldRelease=true
Original file line number Diff line number Diff line change
Expand Up @@ -548,12 +548,16 @@ public void onTickExecute(TickEvent.ClientTickEvent event) {
if (getVacuum(currentItem2)) return;

if (!pestsLocations.isEmpty()) {
FlyPathFinderExecutor.getInstance().stop();
state = States.FLY_TO_PEST;
break;
}

if (FlyPathFinderExecutor.getInstance().isRunning()) {
return;
}

if (hasBlocksAround()) {
System.out.println("Going up");
fly();
break;
} else {
Expand Down Expand Up @@ -612,9 +616,6 @@ public void onTickExecute(TickEvent.ClientTickEvent event) {
if (lastFireworkLocation.isPresent()) {
if (lastFireworkTime + 250 < System.currentTimeMillis()) {
RotationHandler.getInstance().reset();
if (state != States.WAIT_FOR_LOCATION) {
return;
}
state = States.FLY_TO_PEST;
delayBetweenFireworks.schedule(3_000);
delayClock.schedule(300);
Expand Down Expand Up @@ -645,8 +646,9 @@ public void onTickExecute(TickEvent.ClientTickEvent event) {
Vec3 firework = new Vec3(lastFireworkLocation.get().xCoord, mc.thePlayer.posY, lastFireworkLocation.get().zCoord);
Vec3 player = mc.thePlayer.getPositionVector();
Vec3 direction = firework.subtract(player).normalize();
Vec3 target = firework.addVector(direction.xCoord * 15, Math.min(direction.yCoord * 15, 10), direction.zCoord * 15);
Vec3 target = firework.addVector(direction.xCoord * 25, Math.min(direction.yCoord * 25, 7), direction.zCoord * 25);
FlyPathFinderExecutor.getInstance().findPath(target, false, true);
state = States.GET_LOCATION;
}
break;
}
Expand Down Expand Up @@ -1089,7 +1091,7 @@ public void onFirework(SpawnParticleEvent event) {
if (type != EnumParticleTypes.REDSTONE) return;

if (lastFireworkLocation.isPresent()) {
if (lastFireworkLocation.get().distanceTo(event.getPos()) > 10) {
if (lastFireworkLocation.get().distanceTo(event.getPos()) > 5) {
return;
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void findPath(Vec3 pos, boolean follow, boolean smooth) {
pathfinderTask.start();
timeoutTask = new Thread(() -> {
try {
Thread.sleep(5_000);
Thread.sleep(10_000);
if (isCalculating()) {
LogUtils.sendError("Pathfinding took too long");
RotationHandler.getInstance().reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void onPacketReceive(ReceivePacketEvent event) {
private void cacheChunk(Chunk c, Coordinate coordinate) {
if (chunkCache.containsKey(coordinate)) return;
for (int x = 0; x < 16; x++)
for (int y = 66; y < 82; y++)
for (int y = 65; y < 100; y++)
for (int z = 0; z < 16; z++) {
BlockPos pos = new BlockPos(x + coordinate.x * 16, y, z + coordinate.z * 16);
BlockPos chunkPos = new BlockPos(x, y, z);
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/jelly/farmhelperv2/util/BlockUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,10 @@ public static boolean blockHasCollision(BlockPos blockPos, IBlockState blockStat
return false;
}

if (block.equals(Blocks.brown_mushroom) || block.equals(Blocks.red_mushroom) || block.equals(Blocks.melon_stem) || block.equals(Blocks.pumpkin_stem) || block.equals(Blocks.reeds)) {
return false;
}

return true;

// if (CropUtils.isCrop(block) && !block.equals(Blocks.melon_block) && !block.equals(Blocks.pumpkin) && !block.equals(Blocks.cactus) && !block.equals(Blocks.cocoa)) {
Expand Down

0 comments on commit 705caa1

Please sign in to comment.