Skip to content

Commit

Permalink
Merge pull request #93 from MCHPR/compiler-pass
Browse files Browse the repository at this point in the history
  • Loading branch information
StackDoubleFlow authored Dec 2, 2022
2 parents bb54f33 + 4cf93d6 commit f0df327
Show file tree
Hide file tree
Showing 19 changed files with 1,100 additions and 649 deletions.
17 changes: 17 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ itertools = "0.10"
impls = "1"
bincode = "1.3"
smallvec = "1.9.0"
petgraph = "0.6"
redpiler_graph = { path = "../redpiler_graph" }
mchprs_save_data = { path = "../save_data" }
mchprs_blocks = { path = "../blocks" }
Expand Down
26 changes: 20 additions & 6 deletions crates/core/src/blocks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,26 @@ impl Block {
Item::StainedGlass { color } => Block::StainedGlass { color },
Item::SmoothStoneSlab {} => Block::SmoothStoneSlab {},
Item::QuartzSlab {} => Block::QuartzSlab {},
Item::IronTrapdoor {} => {
match context.block_face {
BlockFace::Bottom => Block::IronTrapdoor { facing: context.player.get_direction().opposite(), half: TrapdoorHalf::Top, powered: false },
BlockFace::Top => Block::IronTrapdoor { facing: context.player.get_direction().opposite(), half: TrapdoorHalf::Bottom, powered: false },
_ => Block::IronTrapdoor { facing: context.block_face.to_direction(), half: if context.cursor_y > 0.5 {TrapdoorHalf::Top} else {TrapdoorHalf::Bottom} , powered: false }
}
Item::IronTrapdoor {} => match context.block_face {
BlockFace::Bottom => Block::IronTrapdoor {
facing: context.player.get_direction().opposite(),
half: TrapdoorHalf::Top,
powered: false,
},
BlockFace::Top => Block::IronTrapdoor {
facing: context.player.get_direction().opposite(),
half: TrapdoorHalf::Bottom,
powered: false,
},
_ => Block::IronTrapdoor {
facing: context.block_face.to_direction(),
half: if context.cursor_y > 0.5 {
TrapdoorHalf::Top
} else {
TrapdoorHalf::Bottom
},
powered: false,
},
},
_ => Block::Air {},
};
Expand Down
15 changes: 15 additions & 0 deletions crates/core/src/plot/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,21 @@ impl Plot {

debug!("Compile took {:?}", start_time.elapsed());
}
"inspect" | "i" => {
let player = &self.players[player];
let pos = worldedit::ray_trace_block(
&self.world,
player.pos,
player.pitch as f64,
player.yaw as f64,
10.0,
);
let Some(pos) = pos else {
player.send_error_message("Trace failed");
return;
};
self.redpiler.inspect(pos);
}
"reset" | "r" => {
self.reset_redpiler();
}
Expand Down
7 changes: 4 additions & 3 deletions crates/core/src/plot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,8 @@ impl Plot {
let batch_size = batch_size.min(match self.last_nspt {
Some(Duration::ZERO) | None => 5,
Some(last_nspt) => {
let ticks_fit = WORLD_SEND_RATE.as_nanos() / last_nspt.as_nanos();
let ticks_fit =
WORLD_SEND_RATE.as_nanos() / last_nspt.as_nanos();
if ticks_fit == 0 {
// A tick previously took longer than the world send rate.
// Run at least one just so we're not stuck doing nothing
Expand All @@ -846,7 +847,7 @@ impl Plot {
}
self.lag_time -= dur_per_tick * batch_size as u32;
self.last_nspt =
Some(self.last_update_time.elapsed() / (batch_size as u32));
Some(self.last_update_time.elapsed() / (batch_size as u32));
}
}
}
Expand All @@ -867,7 +868,7 @@ impl Plot {
} else {
ticks_fit
}
},
}
} as u64;
if batch_size != 0 {
let batch_size = batch_size.min(50000) as u32;
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/plot/worldedit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ impl WorldEditOperation {
}
}

fn ray_trace_block(
pub fn ray_trace_block(
world: &impl World,
mut pos: PlayerPos,
start_pitch: f64,
Expand Down
Loading

0 comments on commit f0df327

Please sign in to comment.