Skip to content

Features/pathfinding#16

Open
Tonguechaude wants to merge 14 commits intotemper-mc:masterfrom
Tonguechaude:features/pathfinding
Open

Features/pathfinding#16
Tonguechaude wants to merge 14 commits intotemper-mc:masterfrom
Tonguechaude:features/pathfinding

Conversation

@Tonguechaude
Copy link
Copy Markdown
Contributor

@Tonguechaude Tonguechaude commented Mar 5, 2026

#15

this one need to be merged first sry for this incomprehensible diff

@Tonguechaude Tonguechaude marked this pull request as draft March 5, 2026 18:08
@Tonguechaude Tonguechaude force-pushed the features/pathfinding branch from 47d8bc8 to 6165d49 Compare March 14, 2026 00:16
@Tonguechaude
Copy link
Copy Markdown
Contributor Author

Im currently working on some unit / E2E tests I have some but the structure is shit. I actually use the create test state from gravity system but I dont need everything

@Tonguechaude
Copy link
Copy Markdown
Contributor Author

Currently have an issue with step down limited to 1 block ...

@Tonguechaude Tonguechaude marked this pull request as ready for review March 14, 2026 00:42
@Tonguechaude Tonguechaude force-pushed the features/pathfinding branch from cea299a to 13eb519 Compare March 16, 2026 09:18
/// system and the pathfinding system.
#[inline]
pub fn is_solid(id: BlockStateId) -> bool {
SOLID_BLOCKS[id.raw() as usize]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blockstateids aren't checked to be valid, can we return false instead of panicking

pub fn register_mob_systems(schedule: &mut Schedule) {
schedule.add_systems(pig::tick_pig);
schedule.add_systems(pathfinding::tick_pathfinder);
schedule.add_systems(pig::tick_pig.after(pathfinding::tick_pathfinder));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we its weird, but this would actually run the pathfinder twice cos the .after() method also adds it's argument to the ecs. could we use ().chain() instead to make it clearer and more extendable?


fn get_block(world: &temper_world::World, x: i32, y: i32, z: i32) -> BlockStateId {
let pos = BlockPos::of(x, y, z);
// Only read from cache — never generate chunks during pathfinding
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not? Also chunks might not be cached but could be in the database. Use the world.load_chunk() method

/// - 8 : water, honey blocks, danger zones (near fire/cactus)
/// - 16 : fire, lava, magma, lit campfire
#[inline]
pub fn block_penalty(id: BlockStateId) -> i32 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the comments in src/core/src/block_properties, they apply to this, as well as the PATHFINDING_COSTS above.

IMPASSABLE
}

fn is_non_solid(name: &str) -> bool {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You already have this in src/core/src/block_properties

/// advances the A* search incrementally (budget_per_tick nodes/tick) and updates `path`.
/// The mob AI reads `current_waypoint()` and calls `advance_waypoint()` when it arrives.
#[derive(Component)]
pub struct Pathfinder {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put this in the components crate

// Steer horizontally toward the center of the next waypoint block.
let dx = (next.pos.x as f64 + 0.5 - pig_pos.x) as f32;
let dz = (next.pos.z as f64 + 0.5 - pig_pos.z) as f32;
let len = (dx * dx + dz * dz).sqrt();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants