Skip to content

Commit

Permalink
Improved spawnpoint obstruction check
Browse files Browse the repository at this point in the history
  • Loading branch information
onixiya1337 committed Dec 22, 2023
1 parent 3a27226 commit dcf9a37
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -401,11 +401,13 @@ public void onTickExecute(TickEvent.ClientTickEvent event) {
Multithreading.schedule(() -> {
mc.thePlayer.sendChatMessage("/warp garden");
Multithreading.schedule(() -> {
if (PlayerUtils.isStandingOnSpawnPoint() && hasBlockAboveThePlayer()) {
if (!BlockUtils.canFlyHigher(5)) {
LogUtils.sendError("[Pests Destroyer] Your spawnpoint is obstructed! Make sure there is no block above your spawnpoint!");
stop();
} else
} else {
state = States.GET_LOCATION;
LogUtils.sendDebug("[Pests Destroyer] Spawnpoint is not obstructed");
}
}, (long) (600 + Math.random() * 300), TimeUnit.MILLISECONDS);
}, (long) (600 + Math.random() * 300), TimeUnit.MILLISECONDS);
return;
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/jelly/farmhelperv2/util/BlockUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,22 @@ public static boolean canWalkThroughDoor(BlockPos blockPos, Direction direction)
return canWalkThroughDoorWithDirection(direction, playerFacing, doorFacing, standingOnDoor);
}

public static boolean canFlyHigher(int distance) {
AxisAlignedBB playerAABB = mc.thePlayer.getEntityBoundingBox();
Vec3[] corners = {
new Vec3(playerAABB.minX + 0.0001, playerAABB.minY + mc.thePlayer.height, playerAABB.minZ + 0.0001),
new Vec3(playerAABB.minX + 0.0001, playerAABB.minY + mc.thePlayer.height, playerAABB.maxZ - 0.0001),
new Vec3(playerAABB.maxX - 0.0001, playerAABB.minY + mc.thePlayer.height, playerAABB.minZ + 0.0001),
new Vec3(playerAABB.maxX - 0.0001, playerAABB.minY + mc.thePlayer.height, playerAABB.maxZ - 0.0001)
};
for (Vec3 corner : corners) {
if (mc.theWorld.rayTraceBlocks(corner, corner.addVector(0, distance, 0)) != null) {
return false;
}
}
return true;
}

public static BlockPos getBlockPosLookingAt() {
MovingObjectPosition mop = mc.thePlayer.rayTrace(5, 1);
if (mop == null)
Expand Down

0 comments on commit dcf9a37

Please sign in to comment.