Merge pull request #878 from rdbtCVS/startup/combined-progressive-loading-20261018
🤖 Agent: Merged. Thanks rdbt for the consolidation and for merging main yourself! On de6f15e6: fmt, workspace clippy, horizon-client tests and the client build pass, and 19/19 covering harnesses pass (options, world_reopen, lan, dedicated_server, block_removal, section_mesh, resource_pack, menu_click, screen_layout, the pack, world-options, chat and container screens, and the consumable ones). We'll handle the two follow-ups noted in the comment above (the 120 s fatal timeout, and the backdrop terrain built on the event loop).
This commit is contained in:
@@ -58,11 +58,12 @@ fn main() -> Result<()> {
|
||||
let root = PathBuf::from(&args[0]);
|
||||
let dir = PathBuf::from(&args[1]);
|
||||
let assets = Assets::load(&root)?;
|
||||
let mut scene = World::test_scene(&assets, 1)?;
|
||||
let render = assets.reload(&root)?;
|
||||
let mut scene = World::test_scene(&assets, &render, 1)?;
|
||||
fs::write(
|
||||
dir.join("scene.json"),
|
||||
serde_json::to_vec(
|
||||
&serde_json::json!({"radius":1,"resident_chunks":scene.chunks.len(),"model_gallery":assets.model_gallery}),
|
||||
&serde_json::json!({"radius":1,"resident_chunks":scene.chunks.len(),"model_gallery":render.model_gallery}),
|
||||
)?,
|
||||
)?;
|
||||
if args[2] == "--describe" {
|
||||
|
||||
@@ -31,13 +31,14 @@ fn main() -> Result<()> {
|
||||
};
|
||||
let root = PathBuf::from(root);
|
||||
let assets = Assets::load(&root)?;
|
||||
let mut scene = World::test_scene(&assets, 1)?;
|
||||
let render = assets.reload(&root)?;
|
||||
let mut scene = World::test_scene(&assets, &render, 1)?;
|
||||
let binding = collisions::load(&root, assets.registry)?;
|
||||
let resources = MotionResources::load(&root, &assets)?;
|
||||
fs::write(
|
||||
scene_json,
|
||||
serde_json::to_vec(&serde_json::json!({
|
||||
"radius": 1, "resident_chunks": scene.chunks.len(), "model_gallery": assets.model_gallery,
|
||||
"radius": 1, "resident_chunks": scene.chunks.len(), "model_gallery": render.model_gallery,
|
||||
}))?,
|
||||
)?;
|
||||
let mut out = BufWriter::new(fs::File::create(output)?);
|
||||
|
||||
@@ -12,9 +12,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let args: Vec<_> = std::env::args().collect();
|
||||
let root = Path::new(&args[1]);
|
||||
let assets = Assets::load(root)?;
|
||||
let render = assets.reload(root)?;
|
||||
let facts = BlockFacts::load(root, assets.registry)?;
|
||||
let tables = MeshTables::new(
|
||||
&assets,
|
||||
&render,
|
||||
&facts,
|
||||
models::load_visibility(root, assets.registry)?,
|
||||
)?;
|
||||
|
||||
@@ -18,9 +18,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let args: Vec<_> = std::env::args().collect();
|
||||
let root = Path::new(&args[1]);
|
||||
let assets = Assets::load(root)?;
|
||||
let render = assets.reload(root)?;
|
||||
let facts = BlockFacts::load(root, assets.registry)?;
|
||||
let tables = MeshTables::new(
|
||||
&assets,
|
||||
&render,
|
||||
&facts,
|
||||
models::load_visibility(root, assets.registry)?,
|
||||
)?;
|
||||
@@ -33,7 +35,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut vertices = Vec::new();
|
||||
let mut translucent = false;
|
||||
if facts.get(state).render_shape == RenderShape::Model {
|
||||
let models = assets
|
||||
let models = render
|
||||
.model_catalog
|
||||
.collect(state, BlockPos::new(p[0], p[1], p[2]))?;
|
||||
let offset = tables.offset(state, p[0], p[2]).unwrap_or([0.0; 3]);
|
||||
|
||||
@@ -31,10 +31,12 @@ fn main() -> Result<()> {
|
||||
};
|
||||
let (seed, size) = (flag("--seed", 12345), flag("--size", 8) as i32);
|
||||
let assets = Assets::load(&root)?;
|
||||
let render = assets.reload(&root)?;
|
||||
let facts = BlockFacts::load(&root, assets.registry)?;
|
||||
let biomes = Biomes::load(&root)?;
|
||||
let tables = MeshTables::new(
|
||||
&assets,
|
||||
&render,
|
||||
&facts,
|
||||
models::load_visibility(&root, assets.registry)?,
|
||||
)?;
|
||||
@@ -132,6 +134,7 @@ fn main() -> Result<()> {
|
||||
let mut mesher = Mesher {
|
||||
nether_shading: false,
|
||||
assets: &assets,
|
||||
render: &render,
|
||||
tables: &tables,
|
||||
biomes: &biomes,
|
||||
visibility: tables.visibility.clone(),
|
||||
|
||||
@@ -56,10 +56,11 @@ fn main() -> horizon_client::Result<()> {
|
||||
let initial = LIVE.load(Relaxed);
|
||||
let start = Instant::now();
|
||||
let assets = Assets::load(root)?;
|
||||
let render = assets.reload(root)?;
|
||||
let block_ms = start.elapsed().as_secs_f64() * 1000.;
|
||||
let block_retained = LIVE.load(Relaxed) - initial;
|
||||
let start_items = Instant::now();
|
||||
let items = ItemRenderer::load_with_library(root, assets.model_library.clone())?;
|
||||
let items = ItemRenderer::load_with_library(root, render.model_library.clone())?;
|
||||
let item_ms = start_items.elapsed().as_secs_f64() * 1000.;
|
||||
let total_ms = start.elapsed().as_secs_f64() * 1000.;
|
||||
let retained = LIVE.load(Relaxed) - initial;
|
||||
@@ -74,7 +75,7 @@ fn main() -> horizon_client::Result<()> {
|
||||
horizon_core::position::BlockPos::new(0, 0, 0),
|
||||
horizon_core::position::BlockPos::new(-17, 65, 31),
|
||||
] {
|
||||
if let Ok(selected) = assets.model_catalog.collect(id, pos) {
|
||||
if let Ok(selected) = render.model_catalog.collect(id, pos) {
|
||||
for (variant, model) in selected {
|
||||
format!("{variant:?}").hash(&mut hash);
|
||||
model.ambient_occlusion.hash(&mut hash);
|
||||
|
||||
@@ -94,12 +94,13 @@ fn main() -> Result<()> {
|
||||
drop(registry);
|
||||
step("registry dropped");
|
||||
let assets = Assets::load(&root)?;
|
||||
let render = assets.reload(&root)?;
|
||||
step("assets");
|
||||
println!(
|
||||
" sprites: {} layers of {}px, {:.0} MB of pixels",
|
||||
assets.texture_layers,
|
||||
assets.sprite_size,
|
||||
assets.pixels.len() as f64 / MB
|
||||
render.texture_layers,
|
||||
render.sprite_size,
|
||||
render.pixels.len() as f64 / MB
|
||||
);
|
||||
// The game decodes gameplay facts once for both tables (BlockFacts::load_pair).
|
||||
let (facts, behaviours) = BlockFacts::load_pair(&root, assets.registry)?;
|
||||
@@ -114,6 +115,7 @@ fn main() -> Result<()> {
|
||||
step("light tables");
|
||||
let tables = MeshTables::new(
|
||||
&assets,
|
||||
&render,
|
||||
&facts,
|
||||
models::load_visibility(&root, assets.registry)?,
|
||||
)?;
|
||||
|
||||
@@ -40,7 +40,8 @@ fn main() -> Result<()> {
|
||||
return Err("radius must be 1..16".into());
|
||||
}
|
||||
let assets = assets::Assets::load(&resources)?;
|
||||
let world = world::World::test_scene(&assets, radius)?;
|
||||
let render = assets.reload(&resources)?;
|
||||
let world = world::World::test_scene(&assets, &render, radius)?;
|
||||
let binding = collisions::load(&resources, assets.registry)?;
|
||||
let mut scene = collisions::SceneCollisions {
|
||||
world: &world,
|
||||
@@ -50,7 +51,7 @@ fn main() -> Result<()> {
|
||||
fs::write(
|
||||
dir.join("scene.json"),
|
||||
serde_json::to_vec(&serde_json::json!({
|
||||
"radius":radius,"resident_chunks":world.chunks.len(),"model_gallery":assets.model_gallery,
|
||||
"radius":radius,"resident_chunks":world.chunks.len(),"model_gallery":render.model_gallery,
|
||||
}))?,
|
||||
)?;
|
||||
let mut output = std::io::BufWriter::new(fs::File::create(dir.join("rust.txt"))?);
|
||||
|
||||
@@ -243,13 +243,14 @@ fn main() -> Result<()> {
|
||||
let root = PathBuf::from(&args[0]);
|
||||
let dir = PathBuf::from(&args[1]);
|
||||
let assets = Assets::load(&root)?;
|
||||
let mut scene = World::test_scene(&assets, 1)?;
|
||||
let render = assets.reload(&root)?;
|
||||
let mut scene = World::test_scene(&assets, &render, 1)?;
|
||||
let binding = collisions::load(&root, assets.registry)?;
|
||||
let resources = MotionResources::load(&root, &assets)?;
|
||||
fs::write(
|
||||
dir.join("scene.json"),
|
||||
serde_json::to_vec(
|
||||
&serde_json::json!({"radius":1,"resident_chunks":scene.chunks.len(),"model_gallery":assets.model_gallery}),
|
||||
&serde_json::json!({"radius":1,"resident_chunks":scene.chunks.len(),"model_gallery":render.model_gallery}),
|
||||
)?,
|
||||
)?;
|
||||
if args[2] == "--describe" {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//! the oracle's canonical form (vanilla ARGB colours and packed light coords).
|
||||
#![forbid(unsafe_code)]
|
||||
use horizon_client::{
|
||||
assets::Assets,
|
||||
assets::{Assets, RenderAssets},
|
||||
biome::{BiomeInfo, Biomes, GrassModifier},
|
||||
blocks::BlockFacts,
|
||||
chunk::{Chunk, Light, MIN_Y, index},
|
||||
@@ -48,6 +48,7 @@ fn chunk_index(x: i32, z: i32) -> Result<usize> {
|
||||
fn scene(
|
||||
row: &Value,
|
||||
assets: &Assets,
|
||||
render: &RenderAssets,
|
||||
tables: &MeshTables,
|
||||
biomes: &mut Biomes,
|
||||
pristine: &[BiomeInfo],
|
||||
@@ -127,6 +128,7 @@ fn scene(
|
||||
let mut mesher = Mesher {
|
||||
nether_shading: row["nether"].as_bool().unwrap_or(false),
|
||||
assets,
|
||||
render,
|
||||
tables,
|
||||
biomes: &*biomes,
|
||||
visibility: tables.visibility.clone(),
|
||||
@@ -177,11 +179,12 @@ fn main() -> Result<()> {
|
||||
}
|
||||
let root = PathBuf::from(&args[0]);
|
||||
let assets = Assets::load(&root)?;
|
||||
let render = assets.reload(&root)?;
|
||||
let facts = BlockFacts::load(&root, assets.registry)?;
|
||||
let mut biomes = Biomes::load(&root)?;
|
||||
let visibility = models::load_visibility(&root, assets.registry)?;
|
||||
let tables = MeshTables::new(&assets, &facts, visibility)?;
|
||||
let names: BTreeMap<u32, &str> = assets
|
||||
let tables = MeshTables::new(&assets, &render, &facts, visibility)?;
|
||||
let names: BTreeMap<u32, &str> = render
|
||||
.sprite_layers
|
||||
.iter()
|
||||
.map(|(name, layer)| (*layer, name.as_str()))
|
||||
@@ -215,6 +218,7 @@ fn main() -> Result<()> {
|
||||
let result = scene(
|
||||
&row,
|
||||
&assets,
|
||||
&render,
|
||||
&tables,
|
||||
&mut biomes,
|
||||
&pristine,
|
||||
|
||||
@@ -144,10 +144,12 @@ fn main() -> Result<()> {
|
||||
let hz = flag("--hz", 240.0);
|
||||
|
||||
let assets = Arc::new(Assets::load(&root)?);
|
||||
let render = Arc::new(assets.reload(&root)?);
|
||||
let facts = BlockFacts::load(&root, assets.registry)?;
|
||||
let biomes = Arc::new(Biomes::load(&root)?);
|
||||
let tables = Arc::new(MeshTables::new(
|
||||
&assets,
|
||||
&render,
|
||||
&facts,
|
||||
models::load_visibility(&root, assets.registry)?,
|
||||
)?);
|
||||
@@ -160,6 +162,7 @@ fn main() -> Result<()> {
|
||||
)?);
|
||||
let context = Arc::new(WorkerContext {
|
||||
assets,
|
||||
render: render.clone(),
|
||||
tables,
|
||||
biomes,
|
||||
light,
|
||||
|
||||
@@ -48,11 +48,20 @@ impl TerrainBlockStates for Properties {
|
||||
self.0[id.0 as usize]
|
||||
}
|
||||
}
|
||||
/// The block registry and the facts read from `facts.json` and the block tags:
|
||||
/// everything world generation and collisions need, with none of the block
|
||||
/// models or baked sprites.
|
||||
pub struct Assets {
|
||||
/// Leaked once per process: shared by world generation threads.
|
||||
pub registry: &'static BlockRegistry,
|
||||
pub properties: Properties,
|
||||
pub material_states: [BlockStateId; 6],
|
||||
/// Block names in `#minecraft:blocks_fluid_flow` (fluid flow vectors).
|
||||
pub blocks_fluid_flow: BTreeSet<String>,
|
||||
}
|
||||
/// The block models and their baked sprites, read from the pack at `root` over
|
||||
/// an existing block registry: everything the mesher and renderer need.
|
||||
pub struct RenderAssets {
|
||||
pub sprite_size: u32,
|
||||
pub sprite_minimum_size: u32,
|
||||
pub pixels: Vec<u8>,
|
||||
@@ -67,8 +76,6 @@ pub struct Assets {
|
||||
pub translucent_layers: Vec<bool>,
|
||||
/// Each layer's `MipmapGenerator` settings.
|
||||
pub sprite_mips: Vec<crate::mipmap::Settings>,
|
||||
/// Block names in `#minecraft:blocks_fluid_flow` (fluid flow vectors).
|
||||
pub blocks_fluid_flow: BTreeSet<String>,
|
||||
}
|
||||
fn invalid(message: &str) -> io::Error {
|
||||
io::Error::new(io::ErrorKind::InvalidData, message)
|
||||
@@ -152,33 +159,23 @@ impl Assets {
|
||||
// past vanilla's 16-bit global palette.
|
||||
crate::chunk::set_block_states(registry.len());
|
||||
let registry: &'static BlockRegistry = Box::leak(Box::new(registry));
|
||||
Self::with_models(
|
||||
root,
|
||||
Ok(Self {
|
||||
registry,
|
||||
properties,
|
||||
material_states,
|
||||
blocks_fluid_flow,
|
||||
)
|
||||
})
|
||||
}
|
||||
/// The same blocks with the models and sprites of another resource root
|
||||
/// The models and sprites of another resource root over these blocks
|
||||
/// (resource packs changed): the registry and block facts come from the
|
||||
/// game data, which resource packs do not touch.
|
||||
pub fn reload(&self, root: &Path) -> Result<Self> {
|
||||
Self::with_models(
|
||||
root,
|
||||
self.registry,
|
||||
self.properties.clone(),
|
||||
self.material_states,
|
||||
self.blocks_fluid_flow.clone(),
|
||||
)
|
||||
pub fn reload(&self, root: &Path) -> Result<RenderAssets> {
|
||||
RenderAssets::load(root, self)
|
||||
}
|
||||
fn with_models(
|
||||
root: &Path,
|
||||
registry: &'static BlockRegistry,
|
||||
properties: Properties,
|
||||
material_states: [BlockStateId; 6],
|
||||
blocks_fluid_flow: BTreeSet<String>,
|
||||
) -> Result<Self> {
|
||||
}
|
||||
impl RenderAssets {
|
||||
pub fn load(root: &Path, assets: &Assets) -> Result<Self> {
|
||||
let registry = assets.registry;
|
||||
let mut sprites = crate::sprites::Sprites::default();
|
||||
for name in MATERIALS {
|
||||
sprites.insert(root, &format!("minecraft:block/{name}"))?;
|
||||
@@ -202,9 +199,6 @@ impl Assets {
|
||||
}
|
||||
sprites.finish();
|
||||
Ok(Self {
|
||||
registry,
|
||||
properties,
|
||||
material_states,
|
||||
sprite_size: sprites.size,
|
||||
sprite_minimum_size: sprites.minimum_size,
|
||||
texture_layers: u32::try_from(sprites.count())?,
|
||||
@@ -217,7 +211,6 @@ impl Assets {
|
||||
sprite_layers: sprites.layers,
|
||||
translucent_layers: sprites.translucent,
|
||||
sprite_mips: sprites.mips,
|
||||
blocks_fluid_flow,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -602,9 +602,10 @@ mod fire_environment_tests {
|
||||
return;
|
||||
}
|
||||
let assets = crate::assets::Assets::load(&root).unwrap();
|
||||
let render = assets.reload(&root).unwrap();
|
||||
let facts = BlockFacts::load(&root, assets.registry).unwrap();
|
||||
let items = crate::items::Items::load(&root, assets.registry, &facts).unwrap();
|
||||
let mut world = World::test_scene(&assets, 3).unwrap();
|
||||
let mut world = World::test_scene(&assets, &render, 3).unwrap();
|
||||
let at = Vec3::new(20.5, 4.0, 20.5);
|
||||
world
|
||||
.set(
|
||||
|
||||
@@ -32,6 +32,7 @@ pub struct FogData {
|
||||
}
|
||||
|
||||
/// Per-biome water fog end multipliers (`visual/water_fog_end_distance`).
|
||||
#[derive(Default)]
|
||||
pub struct FogTables {
|
||||
water_fog_end: Vec<f32>,
|
||||
}
|
||||
|
||||
+890
-353
File diff suppressed because it is too large
Load Diff
@@ -106,7 +106,7 @@ impl adv::World for View<'_, '_> {
|
||||
.map(|c| {
|
||||
self.0
|
||||
.res
|
||||
.biomes
|
||||
.biomes()
|
||||
.get(c.biome(p[0], p[1], p[2]))
|
||||
.name
|
||||
.clone()
|
||||
@@ -118,7 +118,7 @@ impl adv::World for View<'_, '_> {
|
||||
}
|
||||
fn block(&self, p: [i32; 3]) -> (String, BTreeMap<String, String>) {
|
||||
let state = self.0.world.block(p[0], p[1], p[2]);
|
||||
let name = self.0.res.facts.get(state).name.to_string();
|
||||
let name = self.0.res.facts().get(state).name.to_string();
|
||||
let props = self
|
||||
.0
|
||||
.pack
|
||||
@@ -138,7 +138,7 @@ impl adv::World for View<'_, '_> {
|
||||
match self
|
||||
.0
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.0.world.block(p[0], p[1], p[2]))
|
||||
.fluid
|
||||
{
|
||||
@@ -152,7 +152,7 @@ impl adv::World for View<'_, '_> {
|
||||
!self
|
||||
.0
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.0.world.block(p[0], y, p[2]))
|
||||
.full_collision
|
||||
})
|
||||
@@ -165,19 +165,19 @@ impl adv::World for View<'_, '_> {
|
||||
(1..=5).any(|d| {
|
||||
self.0
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.0.world.block(p[0], p[1] - d, p[2]))
|
||||
.name
|
||||
.ends_with("campfire")
|
||||
})
|
||||
}
|
||||
fn in_tag(&self, registry: &str, tag: &str, id: &str) -> bool {
|
||||
let items = &self.0.res.items;
|
||||
let items = &self.0.res.items();
|
||||
match registry {
|
||||
"item" => items.item_tags.get(tag).is_some_and(|t| t.contains(id)),
|
||||
"block" => items.block_tags.get(tag).is_some_and(|t| t.contains(id)),
|
||||
"entity_type" => self.0.res.mob_data.entity_has(tag, id),
|
||||
"worldgen/biome" => self.0.res.mob_data.biome_has(tag, id),
|
||||
"entity_type" => self.0.res.mob_data().entity_has(tag, id),
|
||||
"worldgen/biome" => self.0.res.mob_data().biome_has(tag, id),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@@ -454,17 +454,17 @@ impl Game<'_> {
|
||||
.rewards
|
||||
.recipes
|
||||
.iter()
|
||||
.filter(|r| self.res.stations.recipe_index.contains(r))
|
||||
.filter(|r| self.res.stations().recipe_index.contains(r))
|
||||
.cloned()
|
||||
.collect();
|
||||
let (_, unlocked) = self
|
||||
.level
|
||||
.recipe_book
|
||||
.add_recipes(&self.res.stations.recipe_index, &rewards);
|
||||
.add_recipes(&self.res.stations().recipe_index, &rewards);
|
||||
for table in &a.rewards.loot {
|
||||
let items = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.loot_table(table, false, None, &mut self.world.random);
|
||||
for s in items {
|
||||
if let Some(rest) = self.give(s)
|
||||
@@ -549,7 +549,7 @@ impl Game<'_> {
|
||||
.filter_map(|s| s.as_ref())
|
||||
.filter(|s| {
|
||||
self.res
|
||||
.items
|
||||
.items()
|
||||
.get(&s.item)
|
||||
.is_some_and(|i| s.count >= i.max_stack)
|
||||
})
|
||||
@@ -790,11 +790,11 @@ impl Game<'_> {
|
||||
if let Some((station, item)) = recipe {
|
||||
// RecipeToast: black description under a purple title, the
|
||||
// station at 0.6 scale in the corner over the cycling result.
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
batch.sprite(atlas, "gui/sprites/toast/recipe", x, 0.0);
|
||||
let title = self.translate("recipe.toast.title", "New Recipe(s) Unlocked!");
|
||||
let description = self.translate("recipe.toast.description", "Check your recipe book");
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
batch.text(atlas, &title, x + 30.0, 7.0, 0xFF50_0050, false);
|
||||
batch.text(atlas, &description, x + 30.0, 18.0, 0xFF00_0000, false);
|
||||
let start = batch.vertices.len();
|
||||
@@ -803,7 +803,7 @@ impl Game<'_> {
|
||||
self.draw_item_model(batch, &item, x + 8.0, 8.0);
|
||||
return;
|
||||
}
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
batch.sprite(atlas, "gui/sprites/toast/advancement", x, 0.0);
|
||||
let (key, color) = match frame {
|
||||
Frame::Task => ("advancements.toast.task", 0xFF00_FFFF),
|
||||
|
||||
@@ -269,7 +269,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// `AdvancementWidget`'s title lines, description lines and width.
|
||||
fn adv_widget_text(&self, i: usize) -> (Vec<Text>, Vec<Text>, f32) {
|
||||
let font = &self.atlas.font;
|
||||
let font = &self.gui.atlas.font;
|
||||
let a = &self.adv.tree.list[i];
|
||||
let Some(d) = &a.display else {
|
||||
return (Vec::new(), Vec::new(), 0.0);
|
||||
@@ -332,7 +332,7 @@ impl Game<'_> {
|
||||
let (sx, sy) = self.adv_ui.scroll.unwrap_or_default();
|
||||
let (sx, sy) = (sx.floor() as i32, sy.floor() as i32);
|
||||
self.adv_tick_hover(&view, sx, sy, left, top);
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
ui::menu_background(batch, atlas, 0.0, 0.0, w, h, true);
|
||||
let title = Text::translate("gui.advancements", &[]);
|
||||
let tw = atlas.font.width_text(&title);
|
||||
@@ -444,7 +444,7 @@ impl Game<'_> {
|
||||
}
|
||||
let (x, y) = pos(i);
|
||||
let (x, y) = ((ox + x) as f32, (oy + y) as f32);
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
batch.sprite_scaled(
|
||||
atlas,
|
||||
frame_sprite(d.frame, done),
|
||||
@@ -461,7 +461,7 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
// The window, tabs and title.
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
batch.sprite_region(
|
||||
atlas,
|
||||
"gui/advancements/window",
|
||||
@@ -475,7 +475,7 @@ impl Game<'_> {
|
||||
let (x, y) = tab_pos(ty, i);
|
||||
let sprite = tab_sprite(ty, i, ty.3, Some(t) == tab);
|
||||
batch.sprite_scaled(
|
||||
&self.atlas,
|
||||
&self.gui.atlas,
|
||||
&sprite,
|
||||
left + x,
|
||||
top + y,
|
||||
@@ -494,7 +494,7 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
}
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let title = tab.and_then(|t| tree.list[t].display.as_ref()).map_or_else(
|
||||
|| Text::translate("gui.advancements", &[]),
|
||||
|d| text_of(&d.title),
|
||||
@@ -509,7 +509,7 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
// Done.
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let (bx, by) = ((w / 2.0 - 100.0).floor(), h - FOOTER + 6.0);
|
||||
let hover = ui::hovered(self.cursor, bx, by, 200.0, 20.0);
|
||||
ui::button(
|
||||
@@ -532,7 +532,7 @@ impl Game<'_> {
|
||||
let (cx, cy) = self.cursor;
|
||||
if cx > x && cx < x + ty.1 && cy > y && cy < y + ty.2 {
|
||||
if let Some(d) = &tree.list[t].display {
|
||||
ui::tooltip(batch, &self.atlas, &[text_of(&d.title)], self.cursor);
|
||||
ui::tooltip(batch, &self.gui.atlas, &[text_of(&d.title)], self.cursor);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -616,7 +616,7 @@ impl Game<'_> {
|
||||
],
|
||||
)
|
||||
});
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let progress_w = progress.as_ref().map_or(0.0, |t| atlas.font.width_text(t)) as i32;
|
||||
let top_side = title_bottom + desc_h >= INSIDE_H;
|
||||
let amount = if a.criteria.is_empty() || total == 0 {
|
||||
|
||||
@@ -325,7 +325,7 @@ impl Game<'_> {
|
||||
let state = self.world.block(pos[0], pos[1], pos[2]);
|
||||
let mut v = json!({
|
||||
"pos": pos,
|
||||
"block": &*self.res.facts.get(state).name,
|
||||
"block": &*self.res.facts().get(state).name,
|
||||
"state": self.state_string(state),
|
||||
"loaded": self.world.chunks.contains_key(&(pos[0] >> 4, pos[2] >> 4)),
|
||||
});
|
||||
@@ -677,17 +677,25 @@ impl Game<'_> {
|
||||
|
||||
/// Whether a block stops movement, for the path finder.
|
||||
fn blocks_motion(&self, pos: [i32; 3]) -> bool {
|
||||
let f = self.res.facts.get(self.world.block(pos[0], pos[1], pos[2]));
|
||||
let f = self
|
||||
.res
|
||||
.facts()
|
||||
.get(self.world.block(pos[0], pos[1], pos[2]));
|
||||
f.full_collision || f.legacy_solid
|
||||
}
|
||||
fn walkable(&self, n: Node) -> bool {
|
||||
let below = self.world.block(n[0], n[1] - 1, n[2]);
|
||||
let lava = |p: [i32; 3]| {
|
||||
&*self.res.facts.get(self.world.block(p[0], p[1], p[2])).name == "minecraft:lava"
|
||||
&*self
|
||||
.res
|
||||
.facts()
|
||||
.get(self.world.block(p[0], p[1], p[2]))
|
||||
.name
|
||||
== "minecraft:lava"
|
||||
};
|
||||
self.world.chunks.contains_key(&(n[0] >> 4, n[2] >> 4))
|
||||
&& (self.blocks_motion([n[0], n[1] - 1, n[2]])
|
||||
|| self.res.facts.get(below).fluid != horizon_client::blocks::Fluid::None)
|
||||
|| self.res.facts().get(below).fluid != horizon_client::blocks::Fluid::None)
|
||||
&& !self.blocks_motion(n)
|
||||
&& !self.blocks_motion([n[0], n[1] + 1, n[2]])
|
||||
&& !lava(n)
|
||||
@@ -748,7 +756,11 @@ impl Game<'_> {
|
||||
if !clear || !self.walkable(m) {
|
||||
continue;
|
||||
}
|
||||
let water = self.res.facts.get(self.world.block(m[0], m[1], m[2])).fluid
|
||||
let water = self
|
||||
.res
|
||||
.facts()
|
||||
.get(self.world.block(m[0], m[1], m[2]))
|
||||
.fluid
|
||||
!= horizon_client::blocks::Fluid::None;
|
||||
let step = 10 + if dy != 0 { 5 } else { 0 } + if water { 30 } else { 0 };
|
||||
let c = base + step;
|
||||
@@ -958,10 +970,10 @@ impl Game<'_> {
|
||||
for z in lo[2]..=hi[2] {
|
||||
for x in lo[0]..=hi[0] {
|
||||
let state = self.world.block(x, y, z);
|
||||
if self.res.facts.is_air(state) {
|
||||
if self.res.facts().is_air(state) {
|
||||
continue;
|
||||
}
|
||||
let name = self.res.facts.get(state).name.to_string();
|
||||
let name = self.res.facts().get(state).name.to_string();
|
||||
*census.entry(name).or_insert(0) += 1;
|
||||
list.push(json!([x, y, z, self.state_string(state)]));
|
||||
}
|
||||
@@ -1013,7 +1025,7 @@ impl Game<'_> {
|
||||
for z in c[2] - radius..=c[2] + radius {
|
||||
for x in c[0] - radius..=c[0] + radius {
|
||||
let state = self.world.block(x, y, z);
|
||||
if *self.res.facts.get(state).name == *want {
|
||||
if *self.res.facts().get(state).name == *want {
|
||||
let d = dist(eye, [x, y, z].map(|v| f64::from(v) + 0.5));
|
||||
found.push((d, [x, y, z]));
|
||||
}
|
||||
@@ -1221,7 +1233,7 @@ impl Game<'_> {
|
||||
self.playing()?;
|
||||
let pos = a.block_pos(0)?;
|
||||
let before = self.world.block(pos[0], pos[1], pos[2]);
|
||||
if self.res.facts.is_air(before) {
|
||||
if self.res.facts().is_air(before) {
|
||||
return Err(format!("there is no block at {pos:?}").into());
|
||||
}
|
||||
self.aim_block(pos, None)?;
|
||||
@@ -1250,24 +1262,24 @@ impl Game<'_> {
|
||||
.ok_or("nothing in hand to place; select an item")?;
|
||||
let held = held.item.clone();
|
||||
let before = self.world.block(pos[0], pos[1], pos[2]);
|
||||
if !self.res.facts.get(before).replaceable && !self.res.facts.is_air(before) {
|
||||
if !self.res.facts().get(before).replaceable && !self.res.facts().is_air(before) {
|
||||
return Err(format!(
|
||||
"{pos:?} holds {}; break it first",
|
||||
self.res.facts.get(before).name
|
||||
self.res.facts().get(before).name
|
||||
)
|
||||
.into());
|
||||
}
|
||||
// A replaceable block there (grass, snow) is clicked itself, as
|
||||
// a player would; otherwise the face of a neighbour touching it.
|
||||
let mut aimed = !self.res.facts.is_air(before)
|
||||
&& !self.res.facts.get(before).outline.is_empty()
|
||||
let mut aimed = !self.res.facts().is_air(before)
|
||||
&& !self.res.facts().get(before).outline.is_empty()
|
||||
&& self.aim_block(pos, None).is_ok();
|
||||
for (_, d) in FACES.iter().filter(|_| !aimed) {
|
||||
let d = *d;
|
||||
let support = add(pos, d);
|
||||
let state = self.world.block(support[0], support[1], support[2]);
|
||||
let f = self.res.facts.get(state);
|
||||
if self.res.facts.is_air(state)
|
||||
let f = self.res.facts().get(state);
|
||||
if self.res.facts().is_air(state)
|
||||
|| f.replaceable
|
||||
|| f.fluid != horizon_client::blocks::Fluid::None && !f.waterlogged
|
||||
{
|
||||
@@ -1933,7 +1945,10 @@ impl Game<'_> {
|
||||
// Step up onto the next block, or out of water.
|
||||
let in_water = {
|
||||
let b = p.map(|v| v.floor() as i32);
|
||||
self.res.facts.get(self.world.block(b[0], b[1], b[2])).fluid
|
||||
self.res
|
||||
.facts()
|
||||
.get(self.world.block(b[0], b[1], b[2]))
|
||||
.fluid
|
||||
!= horizon_client::blocks::Fluid::None
|
||||
};
|
||||
if aim[1] > p[1] + 0.5 && horizontal(p, aim) < 1.6 && on_ground {
|
||||
|
||||
@@ -29,7 +29,11 @@ impl Game<'_> {
|
||||
continue;
|
||||
};
|
||||
let carried = self.mobs[i].extra.ints[1];
|
||||
let max = self.res.items.get(&held).map_or(64, |i| i.max_stack as i32);
|
||||
let max = self
|
||||
.res
|
||||
.items()
|
||||
.get(&held)
|
||||
.map_or(64, |i| i.max_stack as i32);
|
||||
// GoToWantedItem / wantsToPickUp: the same item within 32.
|
||||
let wanted = if griefing && carried < max && self.mobs[i].extra.ints[3] <= 0 {
|
||||
self.dropped
|
||||
|
||||
@@ -111,7 +111,12 @@ impl Game<'_> {
|
||||
let Some(item) = item else {
|
||||
continue;
|
||||
};
|
||||
let Some(asset) = self.res.items.get(item).and_then(|i| i.equip_asset.clone()) else {
|
||||
let Some(asset) = self
|
||||
.res
|
||||
.items()
|
||||
.get(item)
|
||||
.and_then(|i| i.equip_asset.clone())
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
let kind = if layer == "leggings" {
|
||||
@@ -124,7 +129,7 @@ impl Game<'_> {
|
||||
continue;
|
||||
};
|
||||
let (Some(r), Some(part)) = (
|
||||
self.atlas.sprites.get(texture.as_str()),
|
||||
self.gui.atlas.sprites.get(texture.as_str()),
|
||||
assets.player.get(layer),
|
||||
) else {
|
||||
continue;
|
||||
@@ -144,7 +149,7 @@ impl Game<'_> {
|
||||
// BlockPlaceContext: a replaceable clicked block is replaced.
|
||||
let clicked = self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(hit.pos[0], hit.pos[1], hit.pos[2]));
|
||||
let pos = if clicked.replaceable {
|
||||
hit.pos
|
||||
@@ -230,7 +235,7 @@ impl Game<'_> {
|
||||
fn equipment_slot(&self, stack: &ItemStack) -> usize {
|
||||
match self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.get(&stack.item)
|
||||
.and_then(|i| i.equip_slot.as_deref())
|
||||
{
|
||||
@@ -379,7 +384,7 @@ impl Game<'_> {
|
||||
let mut dead = Vec::new();
|
||||
for (i, a) in self.armor_stands.iter_mut().enumerate() {
|
||||
a.tick(&mut scene);
|
||||
if !a.environment_tick(&self.world, &self.res.facts, self.pack.assets.registry) {
|
||||
if !a.environment_tick(&self.world, self.res.facts(), self.pack.assets.registry) {
|
||||
dead.push(i);
|
||||
}
|
||||
}
|
||||
@@ -403,7 +408,7 @@ impl Game<'_> {
|
||||
out: &mut Vec<Vertex>,
|
||||
) {
|
||||
let assets = &self.armor_stand_assets;
|
||||
let sprites = &self.atlas.sprites;
|
||||
let sprites = &self.gui.atlas.sprites;
|
||||
let uv_of = |name: &str| sprites.get(name).map(|r| [r.u0, r.v0, r.u1, r.v1]);
|
||||
let Some(wood) = uv_of("entity/armorstand/armorstand") else {
|
||||
return;
|
||||
@@ -516,7 +521,7 @@ impl Game<'_> {
|
||||
};
|
||||
let Some(asset) = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.get(&stack.item)
|
||||
.and_then(|i| i.equip_asset.clone())
|
||||
else {
|
||||
@@ -568,7 +573,7 @@ impl Game<'_> {
|
||||
/// `Equippable.swapWithEquipmentSlot`: right-clicking armor swaps it into
|
||||
/// its slot (the worn piece comes back to the hand).
|
||||
pub(super) fn equip_from_hand(&mut self, stack: &ItemStack) -> bool {
|
||||
let Some(info) = self.res.items.get(&stack.item) else {
|
||||
let Some(info) = self.res.items().get(&stack.item) else {
|
||||
return false;
|
||||
};
|
||||
let index = match info.equip_slot.as_deref() {
|
||||
@@ -699,7 +704,7 @@ impl Game<'_> {
|
||||
&serde_json::Value::Null,
|
||||
false,
|
||||
pose,
|
||||
&self.atlas.sprites,
|
||||
&self.gui.atlas.sprites,
|
||||
&self.item_host(),
|
||||
&mut sink,
|
||||
);
|
||||
@@ -709,7 +714,7 @@ impl Game<'_> {
|
||||
if let Some(stack) = &a.equipment[5]
|
||||
&& self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.get(&stack.item)
|
||||
.is_none_or(|i| i.equip_asset.is_none())
|
||||
&& let Some(head) = part_matrix(model, base, poses, "head", 0.0)
|
||||
|
||||
@@ -71,8 +71,10 @@ impl Game<'_> {
|
||||
}
|
||||
/// Called every frame while the title is up.
|
||||
pub(super) fn update_backdrop(&mut self) -> Result<()> {
|
||||
let wanted = self.title.is_some()
|
||||
let wanted = self.pending_entry.is_none()
|
||||
&& self.title.is_some()
|
||||
&& horizon_client::ui_theme::horizon()
|
||||
&& self.world_renderer_ready
|
||||
&& self.renderer.is_some()
|
||||
&& self.options.frames.is_none();
|
||||
if !wanted {
|
||||
@@ -127,6 +129,10 @@ impl Game<'_> {
|
||||
.is_some_and(|r| r.section_count() > 40)
|
||||
{
|
||||
self.backdrop.ready = Some(Instant::now());
|
||||
log::info!(
|
||||
"Horizon: title backdrop ready; world rest ready: {}",
|
||||
self.res.rest.get().is_some()
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -139,10 +145,14 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
fn surface_y(&self, x: i32, z: i32) -> Option<i32> {
|
||||
let air = self.res.facts.air;
|
||||
let air = self.res.facts().air;
|
||||
(-60..320).rev().find(|&y| self.world.block(x, y, z) != air)
|
||||
}
|
||||
fn start_backdrop(&mut self) -> Result<()> {
|
||||
log::info!(
|
||||
"Horizon: starting title backdrop after {} ms",
|
||||
self.started.elapsed().as_millis()
|
||||
);
|
||||
let seed = seed();
|
||||
let root = std::env::current_dir()?
|
||||
.join("saves")
|
||||
@@ -155,7 +165,7 @@ impl Game<'_> {
|
||||
VanillaTerrain::new(
|
||||
&self.options.resources.join("worldgen"),
|
||||
pack.assets.registry,
|
||||
&res.biomes,
|
||||
res.biomes(),
|
||||
seed,
|
||||
)
|
||||
.map_err(|e| format!("title backdrop: {e}"))?,
|
||||
@@ -165,10 +175,10 @@ impl Game<'_> {
|
||||
inner: inner.clone(),
|
||||
save: save.clone(),
|
||||
registry: pack.assets.clone(),
|
||||
biomes: res.biomes.clone(),
|
||||
biomes: res.biomes().clone(),
|
||||
}),
|
||||
pack.context.clone(),
|
||||
res.threads.min(6),
|
||||
res.threads().min(6),
|
||||
);
|
||||
streaming.radius = self.settings.render_distance.clamp(4, 10);
|
||||
streaming.biome_blend = self.settings.biome_blend;
|
||||
@@ -179,7 +189,7 @@ impl Game<'_> {
|
||||
streaming.paused = true;
|
||||
self.streaming = streaming;
|
||||
self.save = save;
|
||||
let mut world = World::new(self.res.facts.air, seed);
|
||||
let mut world = World::new(self.res.facts().air, seed);
|
||||
world.day_time = DAY_TIME;
|
||||
world.game_time = 6000;
|
||||
// Light snow: the weather renders as snow in frozen biomes.
|
||||
@@ -237,7 +247,7 @@ impl Game<'_> {
|
||||
}
|
||||
fn stop_backdrop(&mut self) {
|
||||
self.streaming.paused = true;
|
||||
self.world = World::new(self.res.facts.air, 0);
|
||||
self.world = World::new(self.res.facts().air, 0);
|
||||
if let Some(r) = self.renderer.as_mut() {
|
||||
r.clear_sections();
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ impl Game<'_> {
|
||||
else {
|
||||
return Vec::new();
|
||||
};
|
||||
layer_textures(&self.res.stations.banners, &b.layers)
|
||||
layer_textures(&self.res.stations().banners, &b.layers)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ impl Game<'_> {
|
||||
/// `getHeight(WORLD_SURFACE)`: above the highest non-air block.
|
||||
pub(super) fn world_surface(&self, x: i32, z: i32) -> i32 {
|
||||
self.world
|
||||
.world_surface(x, z, |id| self.res.facts.is_air(id))
|
||||
.world_surface(x, z, |id| self.res.facts().is_air(id))
|
||||
}
|
||||
/// `BeaconBlockEntity.tick` of the beacon at `key`.
|
||||
pub(super) fn tick_beacon_at(&mut self, key: (i32, i32, i32)) {
|
||||
@@ -122,7 +122,7 @@ impl Game<'_> {
|
||||
let mut i = 0;
|
||||
while i < 10 && check <= surface {
|
||||
let state = self.world.block(x, check, z);
|
||||
let f = self.res.facts.get(state);
|
||||
let f = self.res.facts().get(state);
|
||||
if let Some(color) = self.beam_color(&f.name) {
|
||||
if b.checking.len() <= 1 {
|
||||
b.checking.push((color, 1));
|
||||
@@ -183,7 +183,7 @@ impl Game<'_> {
|
||||
fn beacon_base(&self, x: i32, y: i32, z: i32) -> i32 {
|
||||
let base = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.block_tags
|
||||
.get("minecraft:beacon_base_blocks");
|
||||
let mut levels = 0;
|
||||
@@ -194,7 +194,7 @@ impl Game<'_> {
|
||||
}
|
||||
let ok = (x - step..=x + step).all(|lx| {
|
||||
(z - step..=z + step).all(|lz| {
|
||||
let name = &self.res.facts.get(self.world.block(lx, ly, lz)).name;
|
||||
let name = &self.res.facts().get(self.world.block(lx, ly, lz)).name;
|
||||
base.is_some_and(|t| t.contains(&**name))
|
||||
})
|
||||
});
|
||||
@@ -375,7 +375,7 @@ impl Game<'_> {
|
||||
let levels = self.beacon_levels();
|
||||
let sel = self.station.as_ref().map_or([None; 2], |s| s.beacon);
|
||||
let paid = self.station.as_ref().is_some_and(|s| s.inputs[0].is_some());
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
batch.fill(
|
||||
atlas,
|
||||
0.0,
|
||||
@@ -396,7 +396,7 @@ impl Game<'_> {
|
||||
("block.minecraft.beacon.secondary", "Secondary Power", 169.0),
|
||||
] {
|
||||
let text = self.translate(key, fallback);
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let w = HudBatch::text_width(atlas, &text);
|
||||
batch.text(
|
||||
atlas,
|
||||
@@ -411,7 +411,7 @@ impl Game<'_> {
|
||||
let x = [20.0, 41.0, 63.0, 86.0, 108.0][i];
|
||||
self.draw_item(batch, &ItemStack::new(item, 1), bx + x, by + 109.0);
|
||||
}
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let mut tooltip = None;
|
||||
let button =
|
||||
|batch: &mut HudBatch, x: f32, y: f32, active: bool, selected: bool, icon: &str| {
|
||||
@@ -493,7 +493,7 @@ impl Game<'_> {
|
||||
if let Some(slot) = self.slot_at(batch, self.cursor.0, self.cursor.1) {
|
||||
let (sx, sy) = self.slot_position(slot);
|
||||
batch.fill(
|
||||
&self.atlas,
|
||||
&self.gui.atlas,
|
||||
ox + sx,
|
||||
oy + sy,
|
||||
16.0,
|
||||
@@ -514,7 +514,13 @@ impl Game<'_> {
|
||||
}
|
||||
/// `BeaconRenderer`: each section's rotating solid beam and its glow.
|
||||
pub(super) fn beacon_geometry(&self, camera: glam::DVec3, alpha: f64, out: &mut Vec<Vertex>) {
|
||||
let Some(s) = self.atlas.sprites.get("entity/beacon/beacon_beam").copied() else {
|
||||
let Some(s) = self
|
||||
.gui
|
||||
.atlas
|
||||
.sprites
|
||||
.get("entity/beacon/beacon_beam")
|
||||
.copied()
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let time = (self.world.game_time.rem_euclid(40)) as f32 + alpha as f32;
|
||||
|
||||
@@ -41,7 +41,7 @@ impl HiveHost for GameHive<'_, '_> {
|
||||
if !self
|
||||
.game
|
||||
.res
|
||||
.mob_data
|
||||
.mob_data()
|
||||
.entity_has("minecraft:beehive_inhabitors", &kind)
|
||||
{
|
||||
return None;
|
||||
@@ -72,10 +72,10 @@ impl Game<'_> {
|
||||
/// The hive's honey level and front, from its block state.
|
||||
pub(super) fn hive_state(&self, at: [i32; 3]) -> Option<(Option<i32>, [i32; 2])> {
|
||||
let state = self.world.block(at[0], at[1], at[2]);
|
||||
let name = &self.res.facts.get(state).name;
|
||||
let name = &self.res.facts().get(state).name;
|
||||
if !self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.block_tags
|
||||
.get("minecraft:beehives")
|
||||
.is_some_and(|t| t.contains(&**name))
|
||||
@@ -108,7 +108,7 @@ impl Game<'_> {
|
||||
.iter()
|
||||
.any(|d| {
|
||||
let state = self.world.block(at[0] + d[0], at[1] + d[1], at[2] + d[2]);
|
||||
&*self.res.facts.get(state).name == "minecraft:fire"
|
||||
&*self.res.facts().get(state).name == "minecraft:fire"
|
||||
});
|
||||
let mut host = GameHive { game: self };
|
||||
if fire && !hive.bees.is_empty() {
|
||||
|
||||
@@ -193,7 +193,7 @@ impl Game<'_> {
|
||||
};
|
||||
let raiders = self
|
||||
.res
|
||||
.stations
|
||||
.stations()
|
||||
.enchantments
|
||||
.entity_tags
|
||||
.get("minecraft:raiders")
|
||||
@@ -201,7 +201,7 @@ impl Game<'_> {
|
||||
.unwrap_or_default();
|
||||
let frames = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.block_tags
|
||||
.get("minecraft:conduit_effect_block")
|
||||
.cloned()
|
||||
@@ -285,7 +285,7 @@ impl Game<'_> {
|
||||
}
|
||||
Ticker::Conduit => {
|
||||
let world = &self.world;
|
||||
let facts = &self.res.facts;
|
||||
let facts = self.res.facts();
|
||||
let registry = self.pack.assets.registry;
|
||||
let is_water = |p: [i32; 3]| {
|
||||
facts.get(world.block(p[0], p[1], p[2])).fluid
|
||||
@@ -372,7 +372,7 @@ impl Game<'_> {
|
||||
/// pot's saved `sherds` (back, left, right, front).
|
||||
pub(super) fn block_anim(&self, pos: [i32; 3], partial: f32) -> BlockAnim {
|
||||
let state = self.world.block(pos[0], pos[1], pos[2]);
|
||||
let sherds = if &*self.res.facts.get(state).name == "minecraft:decorated_pot" {
|
||||
let sherds = if &*self.res.facts().get(state).name == "minecraft:decorated_pot" {
|
||||
let sherds = self.saved_tag(pos).and_then(|t| t.get("sherds"));
|
||||
["back", "left", "right", "front"].map(|side| match sherds.and_then(|s| s.get(side)) {
|
||||
// An item id, or the item stack the processed templates hold.
|
||||
|
||||
@@ -76,7 +76,7 @@ impl Game<'_> {
|
||||
(0..registry.len())
|
||||
.map(|i| {
|
||||
let state = BlockStateId(i as u32);
|
||||
let name: &str = &self.res.facts.get(state).name;
|
||||
let name: &str = &self.res.facts().get(state).name;
|
||||
match name {
|
||||
"minecraft:hopper"
|
||||
| "minecraft:crafter"
|
||||
@@ -129,7 +129,7 @@ impl Game<'_> {
|
||||
let Some(BlockEntity::Furnace(f)) = self.world.block_entities.get_mut(&pos) else {
|
||||
return Ok(());
|
||||
};
|
||||
let Some(lit) = f.tick(&self.res.recipes, &self.res.items, &self.res.providers) else {
|
||||
let Some(lit) = f.tick(self.res.recipes(), self.res.items(), self.res.providers()) else {
|
||||
return Ok(());
|
||||
};
|
||||
let state = self.world.block(pos.0, pos.1, pos.2);
|
||||
|
||||
@@ -22,7 +22,7 @@ impl Game<'_> {
|
||||
let entity = self.world.block_entities.get(&key)?;
|
||||
let block = &self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(key.0, key.1, key.2))
|
||||
.name;
|
||||
let mut tag = save::encode_block_entity(key, entity, block);
|
||||
@@ -37,7 +37,7 @@ impl Game<'_> {
|
||||
pub(super) fn picked_stack(&self, pos: [i32; 3], include_data: bool) -> Option<ItemStack> {
|
||||
let key = (pos[0], pos[1], pos[2]);
|
||||
let state = self.world.block(pos[0], pos[1], pos[2]);
|
||||
let facts = self.res.facts.get(state);
|
||||
let facts = self.res.facts().get(state);
|
||||
if &*facts.item == "minecraft:air" {
|
||||
return None;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ impl Game<'_> {
|
||||
format!("{}[{}]", s.name, props.join(","))
|
||||
}
|
||||
fn put_block(&mut self, pos: [i32; 3], state: BlockStateId) -> Result<()> {
|
||||
let name = self.res.facts.get(state).name.clone();
|
||||
let name = self.res.facts().get(state).name.clone();
|
||||
self.world.block_entities.remove(&(pos[0], pos[1], pos[2]));
|
||||
self.level_set(pos, state)?;
|
||||
if let Some(entity) = BlockEntity::for_block(&name) {
|
||||
|
||||
@@ -180,11 +180,11 @@ impl BoatModels {
|
||||
}
|
||||
impl Game<'_> {
|
||||
fn fluid_height(&self, x: i32, y: i32, z: i32) -> Option<(f32, bool)> {
|
||||
let f = self.res.facts.get(self.world.block(x, y, z));
|
||||
let f = self.res.facts().get(self.world.block(x, y, z));
|
||||
if f.fluid != Fluid::Water {
|
||||
return None;
|
||||
}
|
||||
let above = self.res.facts.get(self.world.block(x, y + 1, z));
|
||||
let above = self.res.facts().get(self.world.block(x, y + 1, z));
|
||||
// FluidState.getHeight: 1 under the same fluid, else amount / 9.
|
||||
let height = if above.fluid == Fluid::Water {
|
||||
1.0
|
||||
@@ -277,7 +277,7 @@ impl Game<'_> {
|
||||
&& f64::from(x + 1) > lo.x
|
||||
&& f64::from(z) < hi.z
|
||||
&& f64::from(z + 1) > lo.z;
|
||||
let f = self.res.facts.get(self.world.block(x, y0, z));
|
||||
let f = self.res.facts().get(self.world.block(x, y0, z));
|
||||
if inside && (f.full_collision || f.legacy_solid) && !f.has_class("LilyPadBlock") {
|
||||
friction += f.friction;
|
||||
count += 1;
|
||||
@@ -495,8 +495,8 @@ impl Game<'_> {
|
||||
);
|
||||
let top = b.bounds().max_position().y;
|
||||
let (bx, by, bz) = (x.floor() as i32, top.floor() as i32, z.floor() as i32);
|
||||
let below = self.res.facts.get(self.world.block(bx, by - 1, bz));
|
||||
let here = self.res.facts.get(self.world.block(bx, by, bz));
|
||||
let below = self.res.facts().get(self.world.block(bx, by - 1, bz));
|
||||
let here = self.res.facts().get(self.world.block(bx, by, bz));
|
||||
let target = if below.fluid != Fluid::Water
|
||||
&& !here.full_collision
|
||||
&& (below.full_collision || below.legacy_solid)
|
||||
@@ -723,6 +723,7 @@ impl Game<'_> {
|
||||
};
|
||||
let folder = if b.chest { "chest_boat" } else { "boat" };
|
||||
let Some(uv) = self
|
||||
.gui
|
||||
.atlas
|
||||
.sprites
|
||||
.get(&format!("entity/{folder}/{}", b.wood))
|
||||
|
||||
@@ -45,7 +45,7 @@ pub(super) enum BookScreen {
|
||||
}
|
||||
impl Game<'_> {
|
||||
fn book_lines(&self, page: &str) -> Vec<Text> {
|
||||
self.atlas.font.split(&Text::literal(page), 114.0)
|
||||
self.gui.atlas.font.split(&Text::literal(page), 114.0)
|
||||
}
|
||||
/// `WritableBookItem.use` / `WrittenBookItem.use`.
|
||||
pub(super) fn use_book(&mut self, stack: &ItemStack) -> bool {
|
||||
@@ -242,7 +242,7 @@ impl Game<'_> {
|
||||
/// the page (`MultilineTextField.insertText`: line breaks kept, cut to
|
||||
/// the 1024 characters left, rejected when it overflows the 14 lines).
|
||||
fn book_shortcut(&mut self, shortcut: horizon_client::clipboard::EditShortcut) {
|
||||
let font = &self.atlas.font;
|
||||
let font = &self.gui.atlas.font;
|
||||
match self.book.as_mut() {
|
||||
Some(BookScreen::Edit {
|
||||
signing: true,
|
||||
@@ -397,7 +397,7 @@ impl Game<'_> {
|
||||
let key = (pos[0], pos[1], pos[2]);
|
||||
if &*self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(pos[0], pos[1], pos[2]))
|
||||
.name
|
||||
!= "minecraft:lectern"
|
||||
@@ -549,7 +549,7 @@ impl Game<'_> {
|
||||
}
|
||||
pub(super) fn draw_book(&self, batch: &mut HudBatch) {
|
||||
let Some(book) = &self.book else { return };
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let (w, h) = (batch.width, batch.height);
|
||||
let (mx, my) = self.cursor;
|
||||
let hover =
|
||||
|
||||
@@ -40,7 +40,7 @@ impl Game<'_> {
|
||||
m.position.z.floor() as i32,
|
||||
);
|
||||
let mut state = self.world.block(x, y, z);
|
||||
if self.res.facts.is_air(state) {
|
||||
if self.res.facts().is_air(state) {
|
||||
state = self.world.block(x, (m.position.y - 0.2).floor() as i32, z);
|
||||
}
|
||||
let Some((sprite, tint)) = self.particle_sprite(state) else {
|
||||
|
||||
@@ -89,17 +89,17 @@ impl Game<'_> {
|
||||
if is_locked {
|
||||
locked = true;
|
||||
if scaling || locking {
|
||||
batch.sprite(&self.atlas, error, ox + 35.0, oy + 31.0);
|
||||
batch.sprite(&self.gui.atlas, error, ox + 35.0, oy + 31.0);
|
||||
}
|
||||
}
|
||||
if scaling && scale >= 4 {
|
||||
locked = true;
|
||||
batch.sprite(&self.atlas, error, ox + 35.0, oy + 31.0);
|
||||
batch.sprite(&self.gui.atlas, error, ox + 35.0, oy + 31.0);
|
||||
}
|
||||
}
|
||||
let sprite = |batch: &mut HudBatch, game: &Self, name: &str, x: f32, y: f32| {
|
||||
batch.sprite(
|
||||
&game.atlas,
|
||||
&game.gui.atlas,
|
||||
&format!("gui/sprites/container/cartography_table/{name}"),
|
||||
ox + x,
|
||||
oy + y,
|
||||
|
||||
@@ -219,12 +219,18 @@ impl Game<'_> {
|
||||
.map(|a| format!("minecraft:{a}"))
|
||||
.collect();
|
||||
let reg = &mut self.ui.registries;
|
||||
let mut items: Vec<String> = self.res.items.order.iter().map(|s| s.to_string()).collect();
|
||||
let mut items: Vec<String> = self
|
||||
.res
|
||||
.items()
|
||||
.order
|
||||
.iter()
|
||||
.map(|s| s.to_string())
|
||||
.collect();
|
||||
items.sort();
|
||||
reg.items = items;
|
||||
reg.item_tags = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.item_tags
|
||||
.keys()
|
||||
.map(|k| horizon_client::command::args::normalize(k))
|
||||
@@ -232,7 +238,7 @@ impl Game<'_> {
|
||||
reg.item_tags.sort();
|
||||
reg.block_tags = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.block_tags
|
||||
.keys()
|
||||
.map(|k| horizon_client::command::args::normalize(k))
|
||||
@@ -259,7 +265,7 @@ impl Game<'_> {
|
||||
.collect();
|
||||
let mut summonable: Vec<String> = self
|
||||
.res
|
||||
.mob_types
|
||||
.mob_types()
|
||||
.keys()
|
||||
.map(|k| horizon_client::command::args::normalize(k))
|
||||
.collect();
|
||||
@@ -405,7 +411,7 @@ impl Game<'_> {
|
||||
.as_ref()
|
||||
.map_or([1280, 720], |r| [r.config.width, r.config.height]);
|
||||
let b = HudBatch::new(size);
|
||||
let m = Measure(&self.atlas.font);
|
||||
let m = Measure(&self.gui.atlas.font);
|
||||
let c = Commands {
|
||||
dispatcher: chat_tree(&self.remote, &self.mods),
|
||||
registries: &self.ui.registries,
|
||||
@@ -450,7 +456,7 @@ impl Game<'_> {
|
||||
let focused = self.screen == Screen::Chat;
|
||||
let heard = self.mods.mods.is_running().then(|| text.plain());
|
||||
self.ui.chat.add(
|
||||
&self.atlas,
|
||||
&self.gui.atlas,
|
||||
text,
|
||||
Some(SYSTEM_INDICATOR),
|
||||
self.ticks,
|
||||
@@ -463,7 +469,7 @@ impl Game<'_> {
|
||||
/// Keys while the chat screen is open.
|
||||
pub(super) fn chat_key(&mut self, event: &KeyEvent) {
|
||||
if let Some(shortcut) = self.edit_shortcut(event) {
|
||||
let m = Measure(&self.atlas.font);
|
||||
let m = Measure(&self.gui.atlas.font);
|
||||
let c = Commands {
|
||||
dispatcher: chat_tree(&self.remote, &self.mods),
|
||||
registries: &self.ui.registries,
|
||||
@@ -509,7 +515,7 @@ impl Game<'_> {
|
||||
let Some(mut screen) = self.ui.chat_screen.take() else {
|
||||
return;
|
||||
};
|
||||
let m = Measure(&self.atlas.font);
|
||||
let m = Measure(&self.gui.atlas.font);
|
||||
let c = Commands {
|
||||
dispatcher: chat_tree(&self.remote, &self.mods),
|
||||
registries: &self.ui.registries,
|
||||
@@ -541,7 +547,7 @@ impl Game<'_> {
|
||||
range: (usize, usize),
|
||||
list: Vec<(String, Option<String>)>,
|
||||
) {
|
||||
let m = Measure(&self.atlas.font);
|
||||
let m = Measure(&self.gui.atlas.font);
|
||||
let c = Commands {
|
||||
dispatcher: chat_tree(&self.remote, &self.mods),
|
||||
registries: &self.ui.registries,
|
||||
@@ -552,7 +558,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// Text typed into the chat box (control socket `chat`).
|
||||
pub(super) fn chat_type(&mut self, text: &str) {
|
||||
let m = Measure(&self.atlas.font);
|
||||
let m = Measure(&self.gui.atlas.font);
|
||||
let c = Commands {
|
||||
dispatcher: chat_tree(&self.remote, &self.mods),
|
||||
registries: &self.ui.registries,
|
||||
@@ -580,7 +586,7 @@ impl Game<'_> {
|
||||
let heard = self.mods.mods.is_running().then(|| line.plain());
|
||||
self.ui
|
||||
.chat
|
||||
.add(&self.atlas, line, None, self.ticks, focused);
|
||||
.add(&self.gui.atlas, line, None, self.ticks, focused);
|
||||
if let Some(line) = heard {
|
||||
self.mods_chat(&line);
|
||||
}
|
||||
@@ -608,7 +614,7 @@ impl Game<'_> {
|
||||
let height = self.renderer.as_ref().map_or(720.0, |r| {
|
||||
HudBatch::new([r.config.width, r.config.height]).height
|
||||
});
|
||||
let m = Measure(&self.atlas.font);
|
||||
let m = Measure(&self.gui.atlas.font);
|
||||
let c = Commands {
|
||||
dispatcher: chat_tree(&self.remote, &self.mods),
|
||||
registries: &self.ui.registries,
|
||||
@@ -621,7 +627,7 @@ impl Game<'_> {
|
||||
return;
|
||||
}
|
||||
match self.ui.chat.click_at(
|
||||
&self.atlas.font,
|
||||
&self.gui.atlas.font,
|
||||
height as i32,
|
||||
cursor.0 as f64,
|
||||
cursor.1 as f64,
|
||||
@@ -647,13 +653,15 @@ impl Game<'_> {
|
||||
if self.ui.hide_gui && !focused {
|
||||
return;
|
||||
}
|
||||
self.ui.chat.draw(batch, &self.atlas, self.ticks, focused);
|
||||
self.ui
|
||||
.chat
|
||||
.draw(batch, &self.gui.atlas, self.ticks, focused);
|
||||
}
|
||||
pub(super) fn draw_chat_screen(&mut self, batch: &mut HudBatch) {
|
||||
let Some(mut screen) = self.ui.chat_screen.take() else {
|
||||
return;
|
||||
};
|
||||
let m = Measure(&self.atlas.font);
|
||||
let m = Measure(&self.gui.atlas.font);
|
||||
let c = Commands {
|
||||
dispatcher: chat_tree(&self.remote, &self.mods),
|
||||
registries: &self.ui.registries,
|
||||
@@ -671,7 +679,7 @@ impl Game<'_> {
|
||||
.chat_opened
|
||||
.map_or(0, |t| t.elapsed().as_millis() as u64);
|
||||
let draws = screen.draw(&m, mouse, blink, background);
|
||||
horizon_client::screen_draw::paint(batch, &self.atlas, &draws);
|
||||
horizon_client::screen_draw::paint(batch, &self.gui.atlas, &draws);
|
||||
self.ui.chat_screen = Some(screen);
|
||||
}
|
||||
/// Advance the overworld clock (ServerClockManager.tick) when
|
||||
@@ -863,11 +871,11 @@ impl Game<'_> {
|
||||
let focused = self.screen == Screen::Chat;
|
||||
self.ui
|
||||
.chat
|
||||
.add(&self.atlas, message, None, self.ticks, focused);
|
||||
.add(&self.gui.atlas, message, None, self.ticks, focused);
|
||||
}
|
||||
#[allow(dead_code)]
|
||||
fn chat_debug_fill(&self, batch: &mut HudBatch) {
|
||||
batch.fill(&self.atlas, 0.0, 0.0, 1.0, 1.0, rgba(0, 0, 0, 0));
|
||||
batch.fill(&self.gui.atlas, 0.0, 0.0, 1.0, 1.0, rgba(0, 0, 0, 0));
|
||||
}
|
||||
}
|
||||
/// `yyyy-MM-dd_HH.mm.ss[_n].png` (Util.getFilenameFormattedDateTime, local time
|
||||
|
||||
@@ -114,7 +114,7 @@ impl Game<'_> {
|
||||
let location = if let Some(c) = p.last_climbable {
|
||||
let name = self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(c.x, c.y, c.z))
|
||||
.name
|
||||
.clone();
|
||||
@@ -127,7 +127,7 @@ impl Game<'_> {
|
||||
_ => "other_climbable",
|
||||
})
|
||||
} else {
|
||||
let f = self.res.facts.get(self.world.block(
|
||||
let f = self.res.facts().get(self.world.block(
|
||||
p.position.x.floor() as i32,
|
||||
(p.position.y + 0.1).floor() as i32,
|
||||
p.position.z.floor() as i32,
|
||||
|
||||
@@ -459,7 +459,7 @@ impl Game<'_> {
|
||||
self.close_command_block();
|
||||
return;
|
||||
}
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let (w, h) = (batch.width, batch.height);
|
||||
let mid = (w / 2.0).floor();
|
||||
ui::menu_background(batch, atlas, 0.0, 0.0, w, h, true);
|
||||
|
||||
@@ -941,7 +941,7 @@ impl Game<'_> {
|
||||
};
|
||||
let count = Self::int(ctx, "count").unwrap_or(1);
|
||||
let targets = self.entities(ctx, "targets", true)?;
|
||||
let max_stack = self.res.items.get(&id).map_or(64, |i| i.max_stack) as i32;
|
||||
let max_stack = self.res.items().get(&id).map_or(64, |i| i.max_stack) as i32;
|
||||
if count > max_stack * 100 {
|
||||
return Err(CommandError::new(Text::translate(
|
||||
"commands.give.failed.toomanyitems",
|
||||
@@ -1468,7 +1468,7 @@ impl Game<'_> {
|
||||
if self.ui.difficulty == 0
|
||||
&& self
|
||||
.res
|
||||
.mob_types
|
||||
.mob_types()
|
||||
.get(&format!("minecraft:{short}"))
|
||||
.is_some_and(|t| t.category == "monster")
|
||||
{
|
||||
@@ -1485,7 +1485,7 @@ impl Game<'_> {
|
||||
let name;
|
||||
if let Some(t) = self
|
||||
.res
|
||||
.mob_types
|
||||
.mob_types()
|
||||
.get(&format!("minecraft:{short}"))
|
||||
.cloned()
|
||||
{
|
||||
@@ -1561,10 +1561,10 @@ impl Game<'_> {
|
||||
let name_ok = if b.tag {
|
||||
let tag = b.id.trim_start_matches("minecraft:");
|
||||
self.res
|
||||
.items
|
||||
.items()
|
||||
.block_tags
|
||||
.get(tag)
|
||||
.or_else(|| self.res.items.block_tags.get(&b.id))
|
||||
.or_else(|| self.res.items().block_tags.get(&b.id))
|
||||
.is_some_and(|set| {
|
||||
set.contains(&s.name) || set.contains(s.name.trim_start_matches("minecraft:"))
|
||||
})
|
||||
@@ -1589,8 +1589,8 @@ impl Game<'_> {
|
||||
}
|
||||
// A different block replaces the block entity (Level.setBlock).
|
||||
let (old, new) = (
|
||||
self.res.facts.get(previous).name.clone(),
|
||||
self.res.facts.get(state).name.clone(),
|
||||
self.res.facts().get(previous).name.clone(),
|
||||
self.res.facts().get(state).name.clone(),
|
||||
);
|
||||
// The command clears the old block entity without its side effects
|
||||
// (UPDATE_SKIP_BLOCK_ENTITY_SIDEEFFECTS); the new block gets a fresh one.
|
||||
@@ -2184,10 +2184,10 @@ impl Game<'_> {
|
||||
let tag = predicate.id.trim_start_matches("minecraft:");
|
||||
return self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.item_tags
|
||||
.get(tag)
|
||||
.or_else(|| self.res.items.item_tags.get(&predicate.id))
|
||||
.or_else(|| self.res.items().item_tags.get(&predicate.id))
|
||||
.is_some_and(|s| {
|
||||
s.contains(item) || s.contains(item.trim_start_matches("minecraft:"))
|
||||
});
|
||||
@@ -2633,7 +2633,7 @@ impl Game<'_> {
|
||||
let focused = self.screen == Screen::Chat;
|
||||
self.ui
|
||||
.chat
|
||||
.add(&self.atlas, line, None, self.ticks, focused);
|
||||
.add(&self.gui.atlas, line, None, self.ticks, focused);
|
||||
Ok(1)
|
||||
}
|
||||
/// MessageArgument: `@p`-style selectors in a message become names.
|
||||
|
||||
@@ -502,7 +502,7 @@ impl Game<'_> {
|
||||
Some(Value::String(b)) => match b.strip_prefix('#') {
|
||||
Some(tag) => self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.block_tags
|
||||
.get(tag.trim_start_matches("minecraft:"))
|
||||
.is_some_and(|set| {
|
||||
|
||||
@@ -142,7 +142,7 @@ impl Game<'_> {
|
||||
set_key(&mut tag, "id", Tag::String(k.as_str().into()));
|
||||
}
|
||||
let new =
|
||||
entity_nbt::mob_from_nbt(&tag, &self.res.mob_types, id).ok_or_else(stale)?;
|
||||
entity_nbt::mob_from_nbt(&tag, self.res.mob_types(), id).ok_or_else(stale)?;
|
||||
if let Some(slot) = self.mobs.iter_mut().find(|m| m.id == id) {
|
||||
// Runtime-only state (AI, animation) carries over.
|
||||
let old = std::mem::replace(slot, new);
|
||||
|
||||
@@ -187,7 +187,7 @@ impl Game<'_> {
|
||||
return Ok(0);
|
||||
};
|
||||
let level = Self::int(ctx, "level").unwrap_or(1);
|
||||
let enchantments = &self.res.stations.enchantments;
|
||||
let enchantments = &self.res.stations().enchantments;
|
||||
let Some(def) = enchantments.get(&id) else {
|
||||
return Err(err(
|
||||
"argument.resource.not_found",
|
||||
@@ -213,8 +213,8 @@ impl Game<'_> {
|
||||
}
|
||||
continue;
|
||||
};
|
||||
let e = &self.res.stations.enchantments;
|
||||
let compatible = e.can_enchant(&self.res.items, &id, &stack.item)
|
||||
let e = &self.res.stations().enchantments;
|
||||
let compatible = e.can_enchant(self.res.items(), &id, &stack.item)
|
||||
&& stack
|
||||
.crafting_enchantments()
|
||||
.iter()
|
||||
@@ -265,7 +265,7 @@ impl Game<'_> {
|
||||
}
|
||||
let (name, curse) = self
|
||||
.res
|
||||
.stations
|
||||
.stations()
|
||||
.enchantments
|
||||
.full_name(&id, level.max(0) as u32);
|
||||
let style = Style {
|
||||
|
||||
@@ -656,7 +656,7 @@ impl Game<'_> {
|
||||
if state == self.world.air {
|
||||
continue;
|
||||
}
|
||||
let facts = self.res.facts.get(state);
|
||||
let facts = self.res.facts().get(state);
|
||||
let blocks = facts.legacy_solid || facts.fluid != horizon_client::blocks::Fluid::None;
|
||||
let leaves = self
|
||||
.pack
|
||||
@@ -948,7 +948,7 @@ impl Game<'_> {
|
||||
let chunk = self.world.chunks.get(&(p[0] >> 4, p[2] >> 4))?;
|
||||
Some(
|
||||
self.res
|
||||
.biomes
|
||||
.biomes()
|
||||
.get(chunk.biome(p[0], p[1], p[2]))
|
||||
.name
|
||||
.clone(),
|
||||
@@ -971,7 +971,7 @@ impl Game<'_> {
|
||||
.resources
|
||||
.join(format!("data/{ns}/tags/worldgen/biome/{path}.json"));
|
||||
let Ok(bytes) = std::fs::read(file) else {
|
||||
return self.res.mob_data.biome_has(tag, biome);
|
||||
return self.res.mob_data().biome_has(tag, biome);
|
||||
};
|
||||
let v: serde_json::Value = serde_json::from_slice(&bytes).unwrap_or_default();
|
||||
v["values"].as_array().is_some_and(|a| {
|
||||
|
||||
@@ -586,7 +586,7 @@ impl Game<'_> {
|
||||
);
|
||||
let hit = traverse_blocks(eye, end, 256, |b: BlockPos| {
|
||||
let state = self.world.block(b.x, b.y, b.z);
|
||||
(!self.res.facts.is_air(state)).then_some([b.x, b.y, b.z])
|
||||
(!self.res.facts().is_air(state)).then_some([b.x, b.y, b.z])
|
||||
});
|
||||
hit.ok().flatten().unwrap_or([
|
||||
end.x.floor() as i32,
|
||||
|
||||
@@ -375,7 +375,11 @@ impl Game<'_> {
|
||||
} else {
|
||||
0
|
||||
};
|
||||
let max = self.res.items.get(&stack.item).map_or(64, |i| i.max_stack);
|
||||
let max = self
|
||||
.res
|
||||
.items()
|
||||
.get(&stack.item)
|
||||
.map_or(64, |i| i.max_stack);
|
||||
stack.count = (base + n).clamp(0, max as i32) as u32;
|
||||
}
|
||||
"minecraft:limit_count" => {
|
||||
@@ -389,7 +393,11 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
"minecraft:set_damage" => {
|
||||
let max = self.res.items.get(&stack.item).map_or(0, |i| i.max_damage);
|
||||
let max = self
|
||||
.res
|
||||
.items()
|
||||
.get(&stack.item)
|
||||
.map_or(0, |i| i.max_damage);
|
||||
if max > 0 {
|
||||
let f = match m["damage"].as_f64() {
|
||||
Some(f) => f as f32,
|
||||
@@ -587,7 +595,7 @@ impl Game<'_> {
|
||||
if let Some(Tag::Int(n)) = s.data().and_then(|d| d.other("minecraft:max_stack_size")) {
|
||||
return (*n).clamp(1, 99) as u32;
|
||||
}
|
||||
self.res.items.get(&s.item).map_or(64, |i| i.max_stack)
|
||||
self.res.items().get(&s.item).map_or(64, |i| i.max_stack)
|
||||
}
|
||||
/// `ResourceOrIdArgument.getItemModifier`: an inline modifier (SNBT) or
|
||||
/// a registered one.
|
||||
|
||||
@@ -174,7 +174,7 @@ impl Game<'_> {
|
||||
if volume > i64::from(limit) {
|
||||
return Err(err("commands.fillbiome.toobig", &[&limit, &volume]));
|
||||
}
|
||||
let Some(target) = self.res.biomes.list.iter().position(|b| b.name == biome) else {
|
||||
let Some(target) = self.res.biomes().list.iter().position(|b| b.name == biome) else {
|
||||
return Err(err(
|
||||
"argument.resource.not_found",
|
||||
&[&biome, &"minecraft:worldgen/biome"],
|
||||
@@ -201,7 +201,7 @@ impl Game<'_> {
|
||||
continue;
|
||||
};
|
||||
let current = chunk.biome(x, y, z);
|
||||
let current_name = &self.res.biomes.list[usize::from(current)].name;
|
||||
let current_name = &self.res.biomes().list[usize::from(current)].name;
|
||||
if let Some(f) = &filter
|
||||
&& !self.biome_matches(f, current_name)
|
||||
{
|
||||
@@ -474,11 +474,11 @@ impl Game<'_> {
|
||||
let json = horizon_client::scoreboard::tag_to_json(&tag);
|
||||
let drops = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.inline_loot_table(&json, &mut self.world.random);
|
||||
(drops, None)
|
||||
} else {
|
||||
if !self.res.items.has_loot_table(&table) {
|
||||
if !self.res.items().has_loot_table(&table) {
|
||||
return Err(err("argument.resource_or_id.failed_to_parse", &[&table]));
|
||||
}
|
||||
let held = if id == "loot.fish" {
|
||||
@@ -486,14 +486,14 @@ impl Game<'_> {
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let drops = match self.res.items.loot_sequence(&table) {
|
||||
let drops = match self.res.items().loot_sequence(&table) {
|
||||
Some(seq) => {
|
||||
let random = self.rand_sequences.get(&seq, self.level.seed);
|
||||
self.res
|
||||
.items
|
||||
.items()
|
||||
.loot_table(&table, false, held.as_ref(), random)
|
||||
}
|
||||
None => self.res.items.loot_table(
|
||||
None => self.res.items().loot_table(
|
||||
&table,
|
||||
false,
|
||||
held.as_ref(),
|
||||
@@ -510,7 +510,7 @@ impl Game<'_> {
|
||||
};
|
||||
let ty = self.target_type(t);
|
||||
let table = format!("minecraft:entities/{}", ty.trim_start_matches("minecraft:"));
|
||||
if t == Target::Player || !self.res.items.has_loot_table(&table) {
|
||||
if t == Target::Player || !self.res.items().has_loot_table(&table) {
|
||||
return Err(err(
|
||||
"commands.drop.no_loot_table.entity",
|
||||
&[&self.target_name(t).plain()],
|
||||
@@ -521,14 +521,14 @@ impl Game<'_> {
|
||||
None | Some(Some(Target::Player))
|
||||
);
|
||||
let held = self.slot_get(&super::items::Slot::Inv(self.selected));
|
||||
let drops = match self.res.items.loot_sequence(&table) {
|
||||
let drops = match self.res.items().loot_sequence(&table) {
|
||||
Some(seq) => {
|
||||
let random = self.rand_sequences.get(&seq, self.level.seed);
|
||||
self.res
|
||||
.items
|
||||
.items()
|
||||
.entity_drops(&ty, by_player, held.as_ref(), random)
|
||||
}
|
||||
None => self.res.items.entity_drops(
|
||||
None => self.res.items().entity_drops(
|
||||
&ty,
|
||||
by_player,
|
||||
held.as_ref(),
|
||||
@@ -543,21 +543,21 @@ impl Game<'_> {
|
||||
let state = self.world.block(p[0], p[1], p[2]);
|
||||
let name = self.data_block_name(p);
|
||||
let table = format!("minecraft:blocks/{}", name.trim_start_matches("minecraft:"));
|
||||
if !self.res.items.has_loot_table(&table) {
|
||||
if !self.res.items().has_loot_table(&table) {
|
||||
return Err(err("commands.drop.no_loot_table.block", &[&name]));
|
||||
}
|
||||
let tool = self.tool_stack(ctx)?;
|
||||
let drops = match self.res.items.loot_sequence(&table) {
|
||||
let drops = match self.res.items().loot_sequence(&table) {
|
||||
Some(seq) => {
|
||||
let random = self.rand_sequences.get(&seq, self.level.seed);
|
||||
self.res.items.block_drops(
|
||||
self.res.items().block_drops(
|
||||
self.pack.assets.registry,
|
||||
state,
|
||||
tool.as_ref(),
|
||||
random,
|
||||
)
|
||||
}
|
||||
None => self.res.items.block_drops(
|
||||
None => self.res.items().block_drops(
|
||||
self.pack.assets.registry,
|
||||
state,
|
||||
tool.as_ref(),
|
||||
@@ -624,7 +624,7 @@ impl Game<'_> {
|
||||
&& cur.damage == left.damage
|
||||
&& cur.extra == left.extra =>
|
||||
{
|
||||
let max = self.res.items.get(&cur.item).map_or(64, |i| i.max_stack);
|
||||
let max = self.res.items().get(&cur.item).map_or(64, |i| i.max_stack);
|
||||
let take = left.count.min(max.saturating_sub(cur.count));
|
||||
if take > 0 {
|
||||
cur.count += take;
|
||||
|
||||
@@ -31,7 +31,7 @@ impl Game<'_> {
|
||||
|
||||
/// Every recipe id of the recipe manager (what `/recipe` resolves and suggests).
|
||||
pub(super) fn learnable_recipes(&self) -> Vec<String> {
|
||||
self.res.stations.recipe_index.ids().cloned().collect()
|
||||
self.res.stations().recipe_index.ids().cloned().collect()
|
||||
}
|
||||
pub(super) fn cmd_recipe(&mut self, id: &str, ctx: &Context) -> R<i32> {
|
||||
let targets = self.entities(ctx, "targets", true)?;
|
||||
@@ -52,7 +52,7 @@ impl Game<'_> {
|
||||
// displays (a transmute recipe has one per material count).
|
||||
let mut n = 0;
|
||||
// ServerPlayer.awardRecipes / resetRecipes: the displays changed.
|
||||
let index = &self.res.stations.recipe_index;
|
||||
let index = &self.res.stations().recipe_index;
|
||||
n += if give {
|
||||
let (count, unlocked) = self.level.recipe_book.add_recipes(index, &recipes);
|
||||
self.recipe_unlocked(&unlocked);
|
||||
@@ -1267,7 +1267,7 @@ impl Game<'_> {
|
||||
fn spread_spawn_y(&self, p: [f64; 2], max_y: i32) -> i32 {
|
||||
let (x, z) = (p[0].floor() as i32, p[1].floor() as i32);
|
||||
let air = |y: i32| {
|
||||
let name: &str = &self.res.facts.get(self.world.block(x, y, z)).name;
|
||||
let name: &str = &self.res.facts().get(self.world.block(x, y, z)).name;
|
||||
matches!(
|
||||
name,
|
||||
"minecraft:air" | "minecraft:cave_air" | "minecraft:void_air"
|
||||
@@ -1292,16 +1292,16 @@ impl Game<'_> {
|
||||
fn spread_safe(&self, p: [f64; 2], max_y: i32) -> bool {
|
||||
let y = self.spread_spawn_y(p, max_y) - 1;
|
||||
let (x, z) = (p[0].floor() as i32, p[1].floor() as i32);
|
||||
let name = self.res.facts.get(self.world.block(x, y, z)).name.clone();
|
||||
let name = self.res.facts().get(self.world.block(x, y, z)).name.clone();
|
||||
let liquid = matches!(&*name, "minecraft:water" | "minecraft:lava");
|
||||
let teleportable = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.block_tags
|
||||
.get("entities_can_teleport_to")
|
||||
.or_else(|| {
|
||||
self.res
|
||||
.items
|
||||
.items()
|
||||
.block_tags
|
||||
.get("minecraft:entities_can_teleport_to")
|
||||
})
|
||||
|
||||
@@ -21,7 +21,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// The item's `compostable` layers provider.
|
||||
fn compostable(&self, stack: &ItemStack) -> Option<serde_json::Value> {
|
||||
self.res.items.get(&stack.item)?.compostable.clone()
|
||||
self.res.items().get(&stack.item)?.compostable.clone()
|
||||
}
|
||||
/// `ComposterBlock.addLayer` and level event 1500: the provider is
|
||||
/// evaluated in the composter's block-interaction loot context (its
|
||||
|
||||
@@ -154,7 +154,7 @@ impl Game<'_> {
|
||||
let states: Vec<_> = blocks.map(|(x, y, z)| self.world.block(x, y, z)).collect();
|
||||
let liquid = states
|
||||
.iter()
|
||||
.any(|&s| self.res.facts.get(s).fluid != horizon_client::blocks::Fluid::None);
|
||||
.any(|&s| self.res.facts().get(s).fluid != horizon_client::blocks::Fluid::None);
|
||||
if !free || liquid || states.iter().any(|&s| self.state_in_tag(avoid, s)) {
|
||||
return false;
|
||||
}
|
||||
@@ -167,9 +167,9 @@ impl Game<'_> {
|
||||
true
|
||||
}
|
||||
fn state_in_tag(&self, tag: &str, state: horizon_world::registry::BlockStateId) -> bool {
|
||||
let name = &self.res.facts.get(state).name;
|
||||
let name = &self.res.facts().get(state).name;
|
||||
self.res
|
||||
.items
|
||||
.items()
|
||||
.block_tags
|
||||
.get(tag)
|
||||
.is_some_and(|s| s.contains(&**name))
|
||||
|
||||
@@ -345,7 +345,7 @@ impl Game<'_> {
|
||||
};
|
||||
let info = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.get(&item)
|
||||
.ok_or_else(|| format!("unknown item {item}"))?;
|
||||
let count: u32 = words.get(2).map_or(Ok(1), |c| c.parse())?;
|
||||
@@ -437,7 +437,7 @@ impl Game<'_> {
|
||||
match self.screen {
|
||||
Screen::Chat => self.chat_type(text),
|
||||
Screen::CommandBlock => self.command_block_type(text),
|
||||
Screen::Options => self.ui.options.type_text(&self.atlas, text),
|
||||
Screen::Options => self.ui.options.type_text(&self.gui.atlas, text),
|
||||
// The port, or the game rules' search and number boxes.
|
||||
Screen::WorldOptions if text == "\\b" => self.world_options_text(None),
|
||||
Screen::WorldOptions => self.world_options_text(Some(text)),
|
||||
@@ -661,7 +661,7 @@ impl Game<'_> {
|
||||
});
|
||||
let target = self.pick().map(|hit| {
|
||||
let state = self.world.block(hit.pos[0], hit.pos[1], hit.pos[2]);
|
||||
json!({ "pos": hit.pos, "block": &*self.res.facts.get(state).name })
|
||||
json!({ "pos": hit.pos, "block": &*self.res.facts().get(state).name })
|
||||
});
|
||||
let renderer = self.renderer.as_ref().map(|r| {
|
||||
let [arena_bytes, section_vertex_bytes] = r.section_vertex_bytes();
|
||||
|
||||
@@ -106,7 +106,7 @@ impl Game<'_> {
|
||||
fn golem_chest_sound(&mut self, p: [i32; 3], open: bool) {
|
||||
let name = self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(p[0], p[1], p[2]))
|
||||
.name
|
||||
.clone();
|
||||
@@ -292,7 +292,7 @@ impl Game<'_> {
|
||||
pub(super) fn golem_shearable(&self, index: usize) -> bool {
|
||||
self.mobs[index].saddle_item().is_some_and(|a| {
|
||||
self.res
|
||||
.items
|
||||
.items()
|
||||
.item_tags
|
||||
.get("minecraft:shearable_from_copper_golem")
|
||||
.is_some_and(|t| t.contains(&*a.item))
|
||||
|
||||
@@ -110,7 +110,7 @@ impl Game<'_> {
|
||||
let mut next_entity = self.next_entity;
|
||||
let mut random = self.world.random.clone();
|
||||
let spawning = self.spawning_monsters();
|
||||
let creaking = self.res.mob_types.get("minecraft:creaking").cloned();
|
||||
let creaking = self.res.mob_types().get("minecraft:creaking").cloned();
|
||||
let player_uuid = self.level.player_uuid;
|
||||
let snapshot: Vec<_> = mobs.iter().map(|m| seen(m, player_uuid)).collect();
|
||||
let mut events = Vec::new();
|
||||
@@ -265,7 +265,7 @@ impl Game<'_> {
|
||||
return Ok(());
|
||||
};
|
||||
let state = self.world.block(key.0, key.1, key.2);
|
||||
if &*self.res.facts.get(state).name != "minecraft:creaking_heart" {
|
||||
if &*self.res.facts().get(state).name != "minecraft:creaking_heart" {
|
||||
// The block is gone: preRemoveSideEffects.
|
||||
self.world.block_entities.forget(&key);
|
||||
self.with_heart(key, &mut heart, |h, _, _, host, out| {
|
||||
@@ -317,7 +317,7 @@ impl Game<'_> {
|
||||
if self.creaking.hearts.is_empty() {
|
||||
self.creaking.hearts = self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.states
|
||||
.iter()
|
||||
.map(|f| &*f.name == "minecraft:creaking_heart")
|
||||
|
||||
@@ -204,8 +204,8 @@ impl Game<'_> {
|
||||
let Some(chunk) = self.world.chunks.get(&(x >> 4, z >> 4)) else {
|
||||
return BiomeFacts::default();
|
||||
};
|
||||
let b = self.res.biomes.get(chunk.biome(x, y, z));
|
||||
let tags = &self.res.mob_data;
|
||||
let b = self.res.biomes().get(chunk.biome(x, y, z));
|
||||
let tags = self.res.mob_data();
|
||||
let has = |t: &str| tags.biome_has(t, &b.name);
|
||||
let climate = if has("minecraft:spawns_warm_variant_farm_animals") {
|
||||
Climate::Warm
|
||||
@@ -255,7 +255,7 @@ impl Game<'_> {
|
||||
} else {
|
||||
format!("minecraft:{kind}")
|
||||
};
|
||||
let t = self.res.mob_types.get(&kind).cloned()?;
|
||||
let t = self.res.mob_types().get(&kind).cloned()?;
|
||||
self.next_entity += 1;
|
||||
let yaw = self.world.random.next_float() * 360.0;
|
||||
let mut mob = Mob::new(self.next_entity, t, Vec3::new(at[0], at[1], at[2]), yaw);
|
||||
@@ -368,7 +368,7 @@ impl Game<'_> {
|
||||
pub(super) fn motion_top(&self, x: i32, z: i32) -> i32 {
|
||||
let top = if self.dim == Dim::Nether { 127 } else { 319 };
|
||||
for y in (horizon_client::chunk::MIN_Y..=top).rev() {
|
||||
let f = self.res.facts.get(self.world.block(x, y, z));
|
||||
let f = self.res.facts().get(self.world.block(x, y, z));
|
||||
if (f.full_collision || f.fluid != Fluid::None) && !f.name.ends_with("leaves") {
|
||||
return y + 1;
|
||||
}
|
||||
@@ -380,10 +380,10 @@ impl Game<'_> {
|
||||
MobWorld {
|
||||
world: &self.world,
|
||||
registry: self.pack.assets.registry,
|
||||
facts: &self.res.facts,
|
||||
facts: self.res.facts(),
|
||||
movement: &self.motion.blocks,
|
||||
collision: self.collision,
|
||||
data: &self.res.mob_data,
|
||||
data: self.res.mob_data(),
|
||||
player: self.player_view(),
|
||||
others,
|
||||
others_grid: None,
|
||||
@@ -393,14 +393,14 @@ impl Game<'_> {
|
||||
raining: rain > 0.2,
|
||||
thundering: thunder > 0.9,
|
||||
nether: self.dim == Dim::Nether,
|
||||
block_tags: &self.res.items.block_tags,
|
||||
biomes: &self.res.biomes,
|
||||
block_tags: &self.res.items().block_tags,
|
||||
biomes: self.res.biomes(),
|
||||
mob_griefing: self.ui.rules.bool("mob_griefing"),
|
||||
end: self.dim == Dim::End,
|
||||
world_seed: self.level.seed,
|
||||
sea_level: if self.dim == Dim::Nether { 32 } else { 63 },
|
||||
teams: self.mob_teams(),
|
||||
items: Some(&self.res.items),
|
||||
items: Some(self.res.items()),
|
||||
difficulty: self.local_difficulty(
|
||||
self.player
|
||||
.as_ref()
|
||||
@@ -984,7 +984,7 @@ impl Game<'_> {
|
||||
if effect {
|
||||
let old = self.world.block(pos[0], pos[1], pos[2]);
|
||||
self.destroy_particles(pos, old);
|
||||
let s = self.res.facts.get(old).sounds.break_sound.clone();
|
||||
let s = self.res.facts().get(old).sounds.break_sound.clone();
|
||||
self.audio.play(
|
||||
&s,
|
||||
Some([
|
||||
@@ -1004,7 +1004,7 @@ impl Game<'_> {
|
||||
let old = self.world.block(pos[0], pos[1], pos[2]);
|
||||
self.destroy_particles(pos, old);
|
||||
if drop {
|
||||
let drops = self.res.items.block_drops_in(
|
||||
let drops = self.res.items().block_drops_in(
|
||||
self.pack.assets.registry,
|
||||
old,
|
||||
None,
|
||||
@@ -1158,7 +1158,7 @@ impl Game<'_> {
|
||||
MobEvent::GiftLoot { table, at } => {
|
||||
let drops =
|
||||
self.res
|
||||
.items
|
||||
.items()
|
||||
.loot_table(table, false, None, &mut self.world.random);
|
||||
for d in drops {
|
||||
self.spawn_item(d, at, [0.0, 0.2, 0.0], 10);
|
||||
@@ -1421,7 +1421,7 @@ impl Game<'_> {
|
||||
}
|
||||
let projectile = self
|
||||
.res
|
||||
.stations
|
||||
.stations()
|
||||
.enchantments
|
||||
.damage_tags
|
||||
.get("minecraft:is_projectile")
|
||||
@@ -1781,7 +1781,7 @@ impl Game<'_> {
|
||||
horizon_client::arrows::ArrowScene {
|
||||
world: &self.world,
|
||||
registry: self.pack.assets.registry,
|
||||
facts: &self.res.facts,
|
||||
facts: self.res.facts(),
|
||||
collision: self.collision,
|
||||
fluids: &self.motion.fluids,
|
||||
raining: rain,
|
||||
@@ -2033,7 +2033,7 @@ impl Game<'_> {
|
||||
let fire = [pos[0] + face[0], pos[1] + face[1], pos[2] + face[2]];
|
||||
if self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.is_air(self.world.block(fire[0], fire[1], fire[2]))
|
||||
&& let Some(state) =
|
||||
self.pack.assets.registry.default_state("minecraft:fire")
|
||||
@@ -2359,7 +2359,7 @@ impl Game<'_> {
|
||||
Species::Sheep if item == "minecraft:shears" && !m.extra.sheared && !m.is_baby() => {
|
||||
m.extra.sheared = true;
|
||||
let color = horizon_client::mobs::render::DYE_NAMES[m.extra.color as usize & 15];
|
||||
let stacks = self.res.items.loot_table(
|
||||
let stacks = self.res.items().loot_table(
|
||||
&format!("minecraft:shearing/sheep/{color}"),
|
||||
false,
|
||||
None,
|
||||
@@ -2391,7 +2391,7 @@ impl Game<'_> {
|
||||
Species::Wolf if m.extra.tame && is_food && m.health < m.attrs.max_health => {
|
||||
let heal = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.get(&item)
|
||||
.and_then(|i| i.food.as_ref())
|
||||
.map_or(2.0, |f| f.0 as f32);
|
||||
@@ -2495,7 +2495,7 @@ impl Game<'_> {
|
||||
Species::Cat if m.extra.tame && is_food && m.health < m.attrs.max_health => {
|
||||
let heal = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.get(&item)
|
||||
.and_then(|i| i.food.as_ref())
|
||||
.map_or(1.0, |f| f.0 as f32);
|
||||
@@ -2662,7 +2662,7 @@ impl Game<'_> {
|
||||
return;
|
||||
}
|
||||
if let Some(stack) = self.inventory[self.selected].as_mut()
|
||||
&& let Some(info) = self.res.items.get(&stack.item)
|
||||
&& let Some(info) = self.res.items().get(&stack.item)
|
||||
&& info.max_damage > 0
|
||||
{
|
||||
stack.damage += 1;
|
||||
@@ -2735,7 +2735,7 @@ impl Game<'_> {
|
||||
// EntityType.canSpawn: no monsters in peaceful (FAIL ends the click).
|
||||
let id = format!("minecraft:{}", kind.trim_start_matches("minecraft:"));
|
||||
if self.ui.difficulty == 0
|
||||
&& let Some(t) = self.res.mob_types.get(&id)
|
||||
&& let Some(t) = self.res.mob_types().get(&id)
|
||||
&& !horizon_client::mobs::spawn_rules::allowed_in_peaceful(t.species)
|
||||
{
|
||||
return Ok(true);
|
||||
@@ -2799,7 +2799,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// Mob models and projectiles for the entity pass.
|
||||
pub(super) fn mob_geometry(&self, camera: glam::DVec3, alpha: f64, out: &mut Vec<Vertex>) {
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let lookup = |name: &str| atlas.sprites.get(name).map(|r| [r.u0, r.v0, r.u1, r.v1]);
|
||||
let scale = f64::from(self.settings.entity_distance);
|
||||
for mob in &self.mobs {
|
||||
@@ -2857,7 +2857,7 @@ impl Game<'_> {
|
||||
camera,
|
||||
&lookup,
|
||||
packed,
|
||||
&self.res.mob_data,
|
||||
self.res.mob_data(),
|
||||
&armor,
|
||||
out,
|
||||
);
|
||||
@@ -3101,13 +3101,17 @@ impl Game<'_> {
|
||||
return;
|
||||
}
|
||||
let mut y = pos[1];
|
||||
while &*self.res.facts.get(self.world.block(pos[0], y, pos[2])).name
|
||||
while &*self
|
||||
.res
|
||||
.facts()
|
||||
.get(self.world.block(pos[0], y, pos[2]))
|
||||
.name
|
||||
== "minecraft:nether_portal"
|
||||
{
|
||||
y -= 1;
|
||||
}
|
||||
// isValidSpawn: a sturdy top face (portal frames emit no light).
|
||||
let below = self.res.facts.get(self.world.block(pos[0], y, pos[2]));
|
||||
let below = self.res.facts().get(self.world.block(pos[0], y, pos[2]));
|
||||
if below.sturdy_full & (1 << 1) == 0 {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -440,7 +440,7 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
let (left, right) = d.columns(&self.debug_chart_lines());
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let mut draws = debug_overlay::draw(&atlas.font, [&left, &right], scale, width);
|
||||
let charts = self.debug_charts.draw(
|
||||
&atlas.font,
|
||||
|
||||
@@ -63,7 +63,7 @@ impl Game<'_> {
|
||||
/// pot without), or None when no pot is there.
|
||||
fn pot_tag(&mut self, pos: [i32; 3]) -> Option<Tag> {
|
||||
let state = self.world.block(pos[0], pos[1], pos[2]);
|
||||
if &*self.res.facts.get(state).name != "minecraft:decorated_pot" {
|
||||
if &*self.res.facts().get(state).name != "minecraft:decorated_pot" {
|
||||
return None;
|
||||
}
|
||||
let mut tag = spill::saved_entity(&self.world, pos).unwrap_or_else(|| {
|
||||
|
||||
@@ -340,7 +340,7 @@ impl Game<'_> {
|
||||
);
|
||||
}
|
||||
let settings = if flat {
|
||||
let biomes = &self.res.biomes;
|
||||
let biomes = self.res.biomes();
|
||||
let (settings, errors) = horizon_client::flatgen::settings_from_json(
|
||||
&props.generator_settings,
|
||||
|b| self.pack.assets.registry.default_state(b).is_some(),
|
||||
@@ -431,6 +431,7 @@ const BROADCAST: &[&str] = &[
|
||||
impl Game<'_> {
|
||||
/// DedicatedServer.initServer and MinecraftServer.runServer.
|
||||
pub(super) fn run_dedicated(&mut self) -> Result<()> {
|
||||
self.join_world_rest()?;
|
||||
let Setup {
|
||||
props,
|
||||
universe,
|
||||
|
||||
@@ -114,9 +114,9 @@ impl Game<'_> {
|
||||
}
|
||||
|
||||
fn fixture_reset(&mut self, seed: i64) {
|
||||
self.world = World::new(self.res.facts.air, seed);
|
||||
self.world = World::new(self.res.facts().air, seed);
|
||||
// The oracle level is plains everywhere (bone meal's flowers, freezing).
|
||||
let plains = u32::from(self.res.biomes.id("minecraft:plains"));
|
||||
let plains = u32::from(self.res.biomes().id("minecraft:plains"));
|
||||
for cx in -2..=2 {
|
||||
for cz in -2..=2 {
|
||||
let mut chunk = Chunk::empty(cx, cz);
|
||||
@@ -198,7 +198,7 @@ impl Game<'_> {
|
||||
let state = BlockStateId(cell[3].as_u64().unwrap_or(0) as u32);
|
||||
self.world.set(p.0, p.1, p.2, state)?;
|
||||
before.insert(p, state.0);
|
||||
if let Some(entity) = BlockEntity::for_block(&self.res.facts.get(state).name) {
|
||||
if let Some(entity) = BlockEntity::for_block(&self.res.facts().get(state).name) {
|
||||
self.world.block_entities.insert(p, entity);
|
||||
}
|
||||
}
|
||||
@@ -339,7 +339,7 @@ impl Game<'_> {
|
||||
changed.dedup();
|
||||
for p in changed {
|
||||
let now = self.world.block(p.0, p.1, p.2).0;
|
||||
if before.get(&p).copied().unwrap_or(self.res.facts.air.0) != now {
|
||||
if before.get(&p).copied().unwrap_or(self.res.facts().air.0) != now {
|
||||
out.push(format!("set {},{},{} {now}", p.0, p.1, p.2));
|
||||
}
|
||||
}
|
||||
@@ -706,7 +706,7 @@ impl Game<'_> {
|
||||
/// lectern's book, or the items of a block entity Horizon keeps as saved.
|
||||
fn fixture_fill(&mut self, p: (i32, i32, i32), slot: usize, stack: Option<ItemStack>) {
|
||||
let jukebox =
|
||||
&*self.res.facts.get(self.world.block(p.0, p.1, p.2)).name == "minecraft:jukebox";
|
||||
&*self.res.facts().get(self.world.block(p.0, p.1, p.2)).name == "minecraft:jukebox";
|
||||
match self.world.block_entities.get_mut(&p) {
|
||||
Some(BlockEntity::Jukebox(j)) => j.record = stack,
|
||||
Some(BlockEntity::Lectern(l)) => l.book = stack,
|
||||
@@ -735,7 +735,7 @@ impl Game<'_> {
|
||||
use horizon_world::nbt::Tag;
|
||||
let name = self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(p.0, p.1, p.2))
|
||||
.name
|
||||
.clone();
|
||||
@@ -833,7 +833,7 @@ impl Game<'_> {
|
||||
self.inventory[self.selected] = stack.clone();
|
||||
self.offhand = None;
|
||||
let state = self.world.block(pos.x, pos.y, pos.z);
|
||||
let block = self.res.facts.get(state).name.clone();
|
||||
let block = self.res.facts().get(state).name.clone();
|
||||
let item = stack.as_ref().map(|s| s.item.clone());
|
||||
let before = |game: &Self| {
|
||||
let used = item.as_ref().map_or(0, |i| game.stats.get("used", i));
|
||||
@@ -882,7 +882,7 @@ impl Game<'_> {
|
||||
}
|
||||
let t = self
|
||||
.res
|
||||
.mob_types
|
||||
.mob_types()
|
||||
.get(kind)
|
||||
.cloned()
|
||||
.ok_or_else(|| format!("no mob type {kind}"))?;
|
||||
|
||||
@@ -328,18 +328,18 @@ impl Game<'_> {
|
||||
self.world.block(p.0, p.1, p.2)
|
||||
}
|
||||
fn dispenser_block_name(&self, p: Pos) -> std::sync::Arc<str> {
|
||||
self.res.facts.get(self.block_at(p)).name.clone()
|
||||
self.res.facts().get(self.block_at(p)).name.clone()
|
||||
}
|
||||
fn in_block_tag(&self, tag: &str, block: &str) -> bool {
|
||||
self.res
|
||||
.items
|
||||
.items()
|
||||
.block_tags
|
||||
.get(tag)
|
||||
.is_some_and(|s| s.contains(block))
|
||||
}
|
||||
fn water_at(&self, p: Pos) -> bool {
|
||||
matches!(
|
||||
self.res.behaviours.fluid_kind(self.block_at(p)),
|
||||
self.res.behaviours().fluid_kind(self.block_at(p)),
|
||||
FluidKind::Water | FluidKind::FlowingWater
|
||||
)
|
||||
}
|
||||
@@ -520,7 +520,7 @@ impl Game<'_> {
|
||||
if let Some(entity) = self.world.block_entities.get_mut(&pos) {
|
||||
let max = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.get(&rest.item)
|
||||
.map_or(64, |i| i.max_stack)
|
||||
.max(1);
|
||||
@@ -555,7 +555,11 @@ impl Game<'_> {
|
||||
}
|
||||
/// `ItemStack.hurtAndBreak(amount)` without an entity.
|
||||
fn hurt_and_break(&mut self, mut stack: ItemStack, amount: u32) -> Option<ItemStack> {
|
||||
let max = self.res.items.get(&stack.item).map_or(0, |i| i.max_damage);
|
||||
let max = self
|
||||
.res
|
||||
.items()
|
||||
.get(&stack.item)
|
||||
.map_or(0, |i| i.max_damage);
|
||||
if max == 0 {
|
||||
return Some(stack);
|
||||
}
|
||||
@@ -637,7 +641,7 @@ impl Game<'_> {
|
||||
) -> Result<Dispensed> {
|
||||
let equippable = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.get(&stack.item)
|
||||
.is_some_and(|i| i.equip_slot.is_some());
|
||||
if equippable {
|
||||
@@ -649,7 +653,7 @@ impl Game<'_> {
|
||||
}
|
||||
let swallowable = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.item_tags
|
||||
.get("minecraft:sulfur_cube_swallowable")
|
||||
.is_some_and(|t| t.contains(&*stack.item));
|
||||
@@ -748,7 +752,7 @@ impl Game<'_> {
|
||||
} else {
|
||||
format!("minecraft:{kind}")
|
||||
};
|
||||
let t = self.res.mob_types.get(&name)?.clone();
|
||||
let t = self.res.mob_types().get(&name)?.clone();
|
||||
let y_off = if try_move_down {
|
||||
self.drop_offset(t.width, t.height, p)
|
||||
} else {
|
||||
@@ -768,7 +772,7 @@ impl Game<'_> {
|
||||
/// `EquipmentDispenseItemBehavior.dispenseEquipment`: the first living
|
||||
/// entity in front that `canEquipWithDispenser` gets one of the item.
|
||||
fn dispense_equipment(&mut self, pos: Pos, facing: Direction, stack: &mut ItemStack) -> bool {
|
||||
let Some(info) = self.res.items.get(&stack.item) else {
|
||||
let Some(info) = self.res.items().get(&stack.item) else {
|
||||
return false;
|
||||
};
|
||||
let (Some(slot), true) = (
|
||||
@@ -1078,7 +1082,7 @@ impl Game<'_> {
|
||||
let below = (front.0, front.1 - 1, front.2);
|
||||
let y_offset = if self.water_at(front) {
|
||||
1.0
|
||||
} else if self.res.facts.is_air(self.block_at(front)) && self.water_at(below) {
|
||||
} else if self.res.facts().is_air(self.block_at(front)) && self.water_at(below) {
|
||||
0.0
|
||||
} else {
|
||||
return (self.dispense_default(pos, facing, stack), CLICK);
|
||||
@@ -1116,7 +1120,7 @@ impl Game<'_> {
|
||||
let y_offset = if let Some(rail) = self.rail(front.0, front.1, front.2) {
|
||||
if rail.shape.is_slope() { 0.6 } else { 0.1 }
|
||||
} else {
|
||||
if !self.res.facts.is_air(self.block_at(front)) {
|
||||
if !self.res.facts().is_air(self.block_at(front)) {
|
||||
return (self.dispense_default(pos, facing, stack), CLICK);
|
||||
}
|
||||
let below = (front.0, front.1 - 1, front.2);
|
||||
@@ -1389,7 +1393,7 @@ impl Game<'_> {
|
||||
stack: ItemStack,
|
||||
) -> Result<Dispensed> {
|
||||
let target = offset(pos, facing);
|
||||
let free = self.res.facts.is_air(self.block_at(target))
|
||||
let free = self.res.facts().is_air(self.block_at(target))
|
||||
&& target.1 >= horizon_client::chunk::MIN_Y + 2
|
||||
&& self.ui.difficulty != 0
|
||||
&& self.can_build_wither(target);
|
||||
@@ -1443,7 +1447,7 @@ impl Game<'_> {
|
||||
"minecraft:soul_sand" | "minecraft:soul_soil"
|
||||
)
|
||||
};
|
||||
let air = |p: Pos| self.res.facts.is_air(self.block_at(p));
|
||||
let air = |p: Pos| self.res.facts().is_air(self.block_at(p));
|
||||
for (ax, az) in [(1, 0), (0, 1)] {
|
||||
for col in 0..3 {
|
||||
let left = (head.0 - ax * col, head.1, head.2 - az * col);
|
||||
@@ -1466,7 +1470,7 @@ impl Game<'_> {
|
||||
stack: ItemStack,
|
||||
) -> Result<Dispensed> {
|
||||
let target = offset(pos, facing);
|
||||
if self.res.facts.is_air(self.block_at(target))
|
||||
if self.res.facts().is_air(self.block_at(target))
|
||||
&& self.can_spawn_golem([target.0, target.1, target.2])
|
||||
{
|
||||
if let Some(pumpkin) = self
|
||||
@@ -1511,7 +1515,7 @@ impl Game<'_> {
|
||||
let front = offset(pos, facing);
|
||||
let below_empty = self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.is_air(self.block_at((front.0, front.1 - 1, front.2)));
|
||||
let clicked_face = if below_empty { facing } else { Direction::Up };
|
||||
let ctx = PlaceContext {
|
||||
@@ -1539,7 +1543,7 @@ impl Game<'_> {
|
||||
return Ok((Some(stack), FAIL));
|
||||
};
|
||||
let target = (placed.x, placed.y, placed.z);
|
||||
if let Some(entity) = BlockEntity::for_block(&self.res.facts.get(state).name) {
|
||||
if let Some(entity) = BlockEntity::for_block(&self.res.facts().get(state).name) {
|
||||
self.world.block_entities.insert(target, entity);
|
||||
self.apply_placed_item([target.0, target.1, target.2], &stack, false);
|
||||
}
|
||||
@@ -1689,14 +1693,14 @@ impl Game<'_> {
|
||||
table: &str,
|
||||
held: Option<&ItemStack>,
|
||||
) -> Vec<ItemStack> {
|
||||
match self.res.items.loot_sequence(parent) {
|
||||
match self.res.items().loot_sequence(parent) {
|
||||
Some(sequence) => {
|
||||
let random = self.rand_sequences.get(&sequence, self.level.seed);
|
||||
self.res.items.loot_table_from(table, false, held, random)
|
||||
self.res.items().loot_table_from(table, false, held, random)
|
||||
}
|
||||
None => self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.loot_table(table, false, held, &mut self.world.random),
|
||||
}
|
||||
}
|
||||
@@ -1717,7 +1721,7 @@ impl Game<'_> {
|
||||
/// random draws) keeps the name, flags, persistence and age; the old one
|
||||
/// is discarded.
|
||||
pub(super) fn convert_mob(&mut self, index: usize, kind: &str) -> Option<u32> {
|
||||
let t = self.res.mob_types.get(kind).cloned()?;
|
||||
let t = self.res.mob_types().get(kind).cloned()?;
|
||||
let old = &self.mobs[index];
|
||||
self.next_entity += 1;
|
||||
let mut mob = Mob::new(self.next_entity, t, old.position, old.yaw);
|
||||
|
||||
@@ -447,9 +447,9 @@ impl Game<'_> {
|
||||
}
|
||||
fn end_portal_active(&self) -> bool {
|
||||
(0..256).any(|y| {
|
||||
&*self.res.facts.get(self.world.block(0, y, 0)).name == "minecraft:bedrock"
|
||||
&*self.res.facts().get(self.world.block(0, y, 0)).name == "minecraft:bedrock"
|
||||
&& (-3..=3).any(|d| {
|
||||
&*self.res.facts.get(self.world.block(d, y, 0)).name == "minecraft:end_portal"
|
||||
&*self.res.facts().get(self.world.block(d, y, 0)).name == "minecraft:end_portal"
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -591,7 +591,7 @@ impl Game<'_> {
|
||||
let p = self.crystals[i].position;
|
||||
let b = [p.x.floor() as i32, p.y.floor() as i32, p.z.floor() as i32];
|
||||
if let Some(fire) = fire
|
||||
&& self.res.facts.is_air(self.world.block(b[0], b[1], b[2]))
|
||||
&& self.res.facts().is_air(self.world.block(b[0], b[1], b[2]))
|
||||
&& self.world.loaded(b[0], b[2])
|
||||
{
|
||||
let _ = self.level_set(b, fire);
|
||||
@@ -764,7 +764,7 @@ impl Game<'_> {
|
||||
let held = self.held().cloned();
|
||||
let modifiers = held
|
||||
.as_ref()
|
||||
.and_then(|h| self.res.items.get(&h.item))
|
||||
.and_then(|h| self.res.items().get(&h.item))
|
||||
.map(|i| (i.attack_damage, i.attack_speed))
|
||||
.unwrap_or((0.0, 0.0));
|
||||
let speed = (4.0 + modifiers.1).max(0.1);
|
||||
@@ -813,7 +813,7 @@ impl Game<'_> {
|
||||
(0..256)
|
||||
.rev()
|
||||
.find(|&y| {
|
||||
let f = self.res.facts.get(self.world.block(x, y, z));
|
||||
let f = self.res.facts().get(self.world.block(x, y, z));
|
||||
(f.full_collision
|
||||
|| f.legacy_solid
|
||||
|| f.fluid != horizon_client::blocks::Fluid::None)
|
||||
@@ -1257,7 +1257,7 @@ impl Game<'_> {
|
||||
let (x, z) = (head.x + look.x * 2.5, head.z + look.y * 2.5);
|
||||
let mut y = head.y + 0.5;
|
||||
while y > 0.0
|
||||
&& self.res.facts.is_air(self.world.block(
|
||||
&& self.res.facts().is_air(self.world.block(
|
||||
x.floor() as i32,
|
||||
y.floor() as i32,
|
||||
z.floor() as i32,
|
||||
@@ -1594,7 +1594,7 @@ impl Game<'_> {
|
||||
return;
|
||||
};
|
||||
let boxes = [d.part_box(0), d.part_box(1), d.part_box(2)];
|
||||
let tags = &self.res.items.block_tags;
|
||||
let tags = &self.res.items().block_tags;
|
||||
let transparent = tags
|
||||
.get("minecraft:dragon_transparent")
|
||||
.cloned()
|
||||
@@ -1610,8 +1610,8 @@ impl Game<'_> {
|
||||
for y in lo.y.floor() as i32..=hi.y.floor() as i32 {
|
||||
for z in lo.z.floor() as i32..=hi.z.floor() as i32 {
|
||||
let state = self.world.block(x, y, z);
|
||||
let name = &self.res.facts.get(state).name;
|
||||
if self.res.facts.is_air(state) || transparent.contains(&**name) {
|
||||
let name = &self.res.facts().get(state).name;
|
||||
if self.res.facts().is_air(state) || transparent.contains(&**name) {
|
||||
continue;
|
||||
}
|
||||
if griefing && !immune.contains(&**name) {
|
||||
@@ -1713,7 +1713,7 @@ impl Game<'_> {
|
||||
let y = (0..256)
|
||||
.rev()
|
||||
.find(|&y| {
|
||||
let f = self.res.facts.get(self.world.block(0, y, 0));
|
||||
let f = self.res.facts().get(self.world.block(0, y, 0));
|
||||
f.full_collision || f.legacy_solid
|
||||
})
|
||||
.map_or(64, |y| y + 1);
|
||||
@@ -1767,7 +1767,7 @@ impl Game<'_> {
|
||||
next.y.floor() as i32,
|
||||
next.z.floor() as i32,
|
||||
];
|
||||
let f = self.res.facts.get(self.world.block(p[0], p[1], p[2]));
|
||||
let f = self.res.facts().get(self.world.block(p[0], p[1], p[2]));
|
||||
f.full_collision || f.legacy_solid
|
||||
};
|
||||
let hit_player = player.is_some_and(|pb| {
|
||||
@@ -1869,9 +1869,9 @@ impl Game<'_> {
|
||||
batch.width as i32,
|
||||
batch.height as i32,
|
||||
&bars,
|
||||
&self.atlas.font,
|
||||
&self.gui.atlas.font,
|
||||
);
|
||||
hud_layout::paint(batch, &self.atlas, &draws);
|
||||
hud_layout::paint(batch, &self.gui.atlas, &draws);
|
||||
}
|
||||
/// The dragon fight's boss bar shows (`EnderDragonFight.dragonEvent`,
|
||||
/// with `setCreateWorldFog`).
|
||||
@@ -1909,7 +1909,13 @@ impl Game<'_> {
|
||||
return;
|
||||
};
|
||||
let a = alpha as f32;
|
||||
let sprite = |n: &str| self.atlas.sprites.get(n).map(|r| [r.u0, r.v0, r.u1, r.v1]);
|
||||
let sprite = |n: &str| {
|
||||
self.gui
|
||||
.atlas
|
||||
.sprites
|
||||
.get(n)
|
||||
.map(|r| [r.u0, r.v0, r.u1, r.v1])
|
||||
};
|
||||
let (Some(skin), Some(eyes)) = (
|
||||
sprite("entity/enderdragon/dragon"),
|
||||
sprite("entity/enderdragon/dragon_eyes"),
|
||||
@@ -2075,7 +2081,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// `submitRays`: the death rays from a fixed seed, fading in white to magenta.
|
||||
fn dragon_rays(&self, base: glam::Mat4, t: f32, out: &mut Vec<Vertex>) {
|
||||
let white = self.atlas.font.white();
|
||||
let white = self.gui.atlas.font.white();
|
||||
let uv = [white.u0, white.v0];
|
||||
let over = if t > 0.8 {
|
||||
((t - 0.8) / 0.2).min(1.0)
|
||||
@@ -2131,6 +2137,7 @@ impl Game<'_> {
|
||||
out: &mut Vec<Vertex>,
|
||||
) {
|
||||
let Some(s) = self
|
||||
.gui
|
||||
.atlas
|
||||
.sprites
|
||||
.get("entity/end_crystal/end_crystal_beam")
|
||||
@@ -2192,6 +2199,7 @@ impl Game<'_> {
|
||||
out: &mut Vec<Vertex>,
|
||||
) {
|
||||
let Some(s) = self
|
||||
.gui
|
||||
.atlas
|
||||
.sprites
|
||||
.get("entity/enderdragon/dragon_fireball")
|
||||
@@ -2381,7 +2389,7 @@ impl Game<'_> {
|
||||
}
|
||||
let name = self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(hit.pos[0], hit.pos[1], hit.pos[2]))
|
||||
.name
|
||||
.clone();
|
||||
@@ -2391,7 +2399,7 @@ impl Game<'_> {
|
||||
let above = [hit.pos[0], hit.pos[1] + 1, hit.pos[2]];
|
||||
if !self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.is_air(self.world.block(above[0], above[1], above[2]))
|
||||
{
|
||||
return false;
|
||||
@@ -2512,7 +2520,7 @@ impl Game<'_> {
|
||||
}
|
||||
fn block_name_at(&self, p: [i32; 3]) -> std::sync::Arc<str> {
|
||||
self.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(p[0], p[1], p[2]))
|
||||
.name
|
||||
.clone()
|
||||
@@ -2614,7 +2622,7 @@ impl Game<'_> {
|
||||
for y in h - 10..=h + 10 {
|
||||
for z in cz - 10..=cz + 10 {
|
||||
for x in cx - 10..=cx + 10 {
|
||||
if !self.res.facts.is_air(self.world.block(x, y, z)) {
|
||||
if !self.res.facts().is_air(self.world.block(x, y, z)) {
|
||||
let _ = self.level_set([x, y, z], air);
|
||||
}
|
||||
}
|
||||
@@ -2636,7 +2644,7 @@ impl Game<'_> {
|
||||
if &*self.block_name_at([x, y, z]) != "minecraft:obsidian" {
|
||||
let _ = self.set_state_named([x, y, z], "minecraft:obsidian", &[]);
|
||||
}
|
||||
} else if y > 65 && !self.res.facts.is_air(self.world.block(x, y, z)) {
|
||||
} else if y > 65 && !self.res.facts().is_air(self.world.block(x, y, z)) {
|
||||
let _ = self.level_set([x, y, z], air);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ impl Game<'_> {
|
||||
let held = self.inventory[self.selected].as_ref();
|
||||
speed += self
|
||||
.res
|
||||
.stations
|
||||
.stations()
|
||||
.enchantments
|
||||
.attribute_add(held, "minecraft:mining_efficiency") as f32;
|
||||
}
|
||||
@@ -26,7 +26,7 @@ impl Game<'_> {
|
||||
pub(super) fn submerged_mining_speed(&self) -> f32 {
|
||||
let mut total = 0.0;
|
||||
for stack in self.armor.iter().flatten() {
|
||||
for (attr, _, amount, op) in self.res.stations.enchantments.attributes(stack) {
|
||||
for (attr, _, amount, op) in self.res.stations().enchantments.attributes(stack) {
|
||||
if attr == "minecraft:submerged_mining_speed" && op == "add_multiplied_total" {
|
||||
total += amount;
|
||||
}
|
||||
@@ -36,13 +36,13 @@ impl Game<'_> {
|
||||
}
|
||||
/// `EnchantmentHelper.processDurabilityChange` (unbreaking) for `amount` points.
|
||||
pub(super) fn durability_loss(&mut self, stack: &ItemStack, amount: u32) -> u32 {
|
||||
let e = &self.res.stations.enchantments;
|
||||
let e = &self.res.stations().enchantments;
|
||||
if !e.has_component(stack, "minecraft:item_damage") {
|
||||
return amount;
|
||||
}
|
||||
let ctx = EffectContext {
|
||||
tool: Some(&stack.item),
|
||||
items: Some(&self.res.items),
|
||||
items: Some(self.res.items()),
|
||||
..Default::default()
|
||||
};
|
||||
e.modify_value(
|
||||
@@ -65,10 +65,10 @@ impl Game<'_> {
|
||||
direct_attacker: Some("minecraft:player"),
|
||||
is_direct: true,
|
||||
damage_type: Some("minecraft:player_attack"),
|
||||
items: Some(&self.res.items),
|
||||
items: Some(self.res.items()),
|
||||
..Default::default()
|
||||
};
|
||||
self.res.stations.enchantments.modify_value(
|
||||
self.res.stations().enchantments.modify_value(
|
||||
Some(&held),
|
||||
"minecraft:damage",
|
||||
&ctx,
|
||||
@@ -96,10 +96,10 @@ impl Game<'_> {
|
||||
attacker: Some("minecraft:player"),
|
||||
direct_attacker: Some("minecraft:player"),
|
||||
is_direct: true,
|
||||
items: Some(&self.res.items),
|
||||
items: Some(self.res.items()),
|
||||
..Default::default()
|
||||
};
|
||||
let knockback = self.res.stations.enchantments.modify_value(
|
||||
let knockback = self.res.stations().enchantments.modify_value(
|
||||
Some(&held),
|
||||
"minecraft:knockback",
|
||||
&ctx,
|
||||
@@ -130,7 +130,7 @@ impl Game<'_> {
|
||||
// minecraft:post_attack ignite effects of the attacker's weapon (fire aspect).
|
||||
let mut ignite = 0.0f32;
|
||||
for (id, level) in held.enchantments() {
|
||||
let Some(def) = self.res.stations.enchantments.get(id) else {
|
||||
let Some(def) = self.res.stations().enchantments.get(id) else {
|
||||
continue;
|
||||
};
|
||||
for effect in def.effects["minecraft:post_attack"]
|
||||
@@ -145,7 +145,7 @@ impl Game<'_> {
|
||||
let mut random = self.world.random.clone();
|
||||
let ok = effect.get("requirements").is_none_or(|r| {
|
||||
self.res
|
||||
.stations
|
||||
.stations()
|
||||
.enchantments
|
||||
.condition(r, *level, &ctx, &mut random)
|
||||
});
|
||||
@@ -182,13 +182,13 @@ impl Game<'_> {
|
||||
attacker: Some("minecraft:player"),
|
||||
direct_attacker: Some("minecraft:player"),
|
||||
is_direct: true,
|
||||
items: Some(&self.res.items),
|
||||
items: Some(self.res.items()),
|
||||
direct_motion: Some(motion),
|
||||
..Default::default()
|
||||
};
|
||||
let mut bursts = Vec::new();
|
||||
for (id, level) in held.enchantments() {
|
||||
let Some(def) = self.res.stations.enchantments.get(id) else {
|
||||
let Some(def) = self.res.stations().enchantments.get(id) else {
|
||||
continue;
|
||||
};
|
||||
for effect in def.effects["minecraft:post_attack"]
|
||||
@@ -205,7 +205,7 @@ impl Game<'_> {
|
||||
continue;
|
||||
}
|
||||
let ok = effect.get("requirements").is_none_or(|r| {
|
||||
self.res.stations.enchantments.condition(
|
||||
self.res.stations().enchantments.condition(
|
||||
r,
|
||||
*level,
|
||||
&ctx,
|
||||
@@ -254,16 +254,16 @@ impl Game<'_> {
|
||||
if level == 0 {
|
||||
continue;
|
||||
}
|
||||
let Some(def) = self.res.stations.enchantments.get("minecraft:thorns") else {
|
||||
let Some(def) = self.res.stations().enchantments.get("minecraft:thorns") else {
|
||||
continue;
|
||||
};
|
||||
let effect = def.effects["minecraft:post_attack"][0].clone();
|
||||
let ctx = EffectContext {
|
||||
items: Some(&self.res.items),
|
||||
items: Some(self.res.items()),
|
||||
..Default::default()
|
||||
};
|
||||
let mut random = self.world.random.clone();
|
||||
let ok = self.res.stations.enchantments.condition(
|
||||
let ok = self.res.stations().enchantments.condition(
|
||||
&effect["requirements"],
|
||||
level,
|
||||
&ctx,
|
||||
@@ -286,7 +286,7 @@ impl Game<'_> {
|
||||
s.damage += 2;
|
||||
if self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.get(&s.item)
|
||||
.is_some_and(|i| s.damage >= i.max_damage)
|
||||
{
|
||||
@@ -330,10 +330,10 @@ impl Game<'_> {
|
||||
};
|
||||
let Some(stack) = stack else { return amount };
|
||||
let ctx = EffectContext {
|
||||
items: Some(&self.res.items),
|
||||
items: Some(self.res.items()),
|
||||
..Default::default()
|
||||
};
|
||||
let to_repair_xp = self.res.stations.enchantments.modify_value(
|
||||
let to_repair_xp = self.res.stations().enchantments.modify_value(
|
||||
Some(&stack),
|
||||
"minecraft:repair_with_xp",
|
||||
&ctx,
|
||||
@@ -364,11 +364,11 @@ impl Game<'_> {
|
||||
let Some(bow) = self.inventory[self.selected].clone() else {
|
||||
return (0.0, false);
|
||||
};
|
||||
let e = &self.res.stations.enchantments;
|
||||
let e = &self.res.stations().enchantments;
|
||||
let ctx = EffectContext {
|
||||
direct_attacker: Some("minecraft:arrow"),
|
||||
attacker: Some("minecraft:player"),
|
||||
items: Some(&self.res.items),
|
||||
items: Some(self.res.items()),
|
||||
..Default::default()
|
||||
};
|
||||
let power = e.modify_value(
|
||||
@@ -380,7 +380,7 @@ impl Game<'_> {
|
||||
);
|
||||
let ammo_ctx = EffectContext {
|
||||
tool: Some("minecraft:arrow"),
|
||||
items: Some(&self.res.items),
|
||||
items: Some(self.res.items()),
|
||||
..Default::default()
|
||||
};
|
||||
let infinity = e.has_component(&bow, "minecraft:ammo_use")
|
||||
@@ -399,12 +399,12 @@ impl Game<'_> {
|
||||
let bow = self.inventory[self.selected].clone()?;
|
||||
let ctx = EffectContext {
|
||||
this: Some("minecraft:arrow"),
|
||||
items: Some(&self.res.items),
|
||||
items: Some(self.res.items()),
|
||||
..Default::default()
|
||||
};
|
||||
let mut ignite: Option<f32> = None;
|
||||
for (id, level) in bow.enchantments() {
|
||||
let Some(def) = self.res.stations.enchantments.get(id) else {
|
||||
let Some(def) = self.res.stations().enchantments.get(id) else {
|
||||
continue;
|
||||
};
|
||||
for effect in def.effects["minecraft:projectile_spawned"]
|
||||
@@ -416,7 +416,7 @@ impl Game<'_> {
|
||||
continue;
|
||||
}
|
||||
let ok = effect.get("requirements").is_none_or(|r| {
|
||||
self.res.stations.enchantments.condition(
|
||||
self.res.stations().enchantments.condition(
|
||||
r,
|
||||
*level,
|
||||
&ctx,
|
||||
@@ -436,7 +436,7 @@ impl Game<'_> {
|
||||
pub(super) fn apply_enchantment_attributes(&mut self) {
|
||||
let mut wanted: Vec<(String, String, f64, String)> = Vec::new();
|
||||
for stack in self.armor.iter().flatten() {
|
||||
wanted.extend(self.res.stations.enchantments.attributes(stack));
|
||||
wanted.extend(self.res.stations().enchantments.attributes(stack));
|
||||
}
|
||||
let Some(p) = self.player.as_mut() else {
|
||||
return;
|
||||
|
||||
@@ -132,9 +132,9 @@ impl Game<'_> {
|
||||
/// The environment attributes of the current dimension.
|
||||
pub(super) fn dim_environment(&self) -> &Environment {
|
||||
match self.dim {
|
||||
Dim::Overworld => &self.res.environment,
|
||||
Dim::Nether => &self.res.nether_environment,
|
||||
Dim::End => &self.res.end_environment,
|
||||
Dim::Overworld => self.res.environment(),
|
||||
Dim::Nether => self.res.nether_environment(),
|
||||
Dim::End => self.res.end_environment(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ impl Game<'_> {
|
||||
/// tinted 0x282828. The atlas does not wrap, so each face is 16×16 quads.
|
||||
pub(super) fn end_sky_geometry(&self) -> Vec<Vertex> {
|
||||
let mut out = Vec::with_capacity(6 * 256 * 4);
|
||||
let Some(r) = self.atlas.sprites.get("environment/end_sky").copied() else {
|
||||
let Some(r) = self.gui.atlas.sprites.get("environment/end_sky").copied() else {
|
||||
return out;
|
||||
};
|
||||
use std::f32::consts::FRAC_PI_2;
|
||||
@@ -184,6 +184,7 @@ impl Game<'_> {
|
||||
let intensity = self.end.flash.intensity(self.clock.fraction() as f32);
|
||||
if intensity > 1e-5
|
||||
&& let Some(r) = self
|
||||
.gui
|
||||
.atlas
|
||||
.sprites
|
||||
.get("environment/celestial/end_flash")
|
||||
@@ -224,7 +225,7 @@ impl Game<'_> {
|
||||
|
||||
pub(super) fn block_name(&self, p: [i32; 3]) -> std::sync::Arc<str> {
|
||||
self.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(p[0], p[1], p[2]))
|
||||
.name
|
||||
.clone()
|
||||
@@ -561,7 +562,7 @@ impl Game<'_> {
|
||||
let mut y = (0..256)
|
||||
.rev()
|
||||
.find(|&y| {
|
||||
let f = self.res.facts.get(self.world.block(0, y, 0));
|
||||
let f = self.res.facts().get(self.world.block(0, y, 0));
|
||||
(f.full_collision || f.fluid != horizon_client::blocks::Fluid::None)
|
||||
&& !f.name.ends_with("_leaves")
|
||||
})
|
||||
@@ -783,7 +784,7 @@ impl Game<'_> {
|
||||
let mut y = 255;
|
||||
while y > floor {
|
||||
let p = [around[0] + xd, y, around[2] + zd];
|
||||
let f = self.res.facts.get(self.world.block(p[0], p[1], p[2]));
|
||||
let f = self.res.facts().get(self.world.block(p[0], p[1], p[2]));
|
||||
if f.full_collision && (allow_bedrock || &*f.name != "minecraft:bedrock") {
|
||||
tallest = Some(p);
|
||||
break;
|
||||
@@ -839,12 +840,12 @@ impl Game<'_> {
|
||||
if &*self.block_name([x, y, z]) != "minecraft:end_stone"
|
||||
|| self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(x, y + 1, z))
|
||||
.full_collision
|
||||
|| self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(x, y + 2, z))
|
||||
.full_collision
|
||||
{
|
||||
@@ -920,7 +921,8 @@ impl Game<'_> {
|
||||
fn end_crystal_geometry(&self, camera: glam::DVec3, out: &mut Vec<Vertex>) {
|
||||
let (Some(model), Some(r)) = (
|
||||
self.crystal_model.as_ref(),
|
||||
self.atlas
|
||||
self.gui
|
||||
.atlas
|
||||
.sprites
|
||||
.get("entity/end_crystal/end_crystal")
|
||||
.copied(),
|
||||
@@ -1073,7 +1075,7 @@ impl Game<'_> {
|
||||
|
||||
/// ThrownItemRenderer: the ender eye item facing the camera.
|
||||
fn eye_geometry(&self, camera: glam::DVec3, out: &mut Vec<Vertex>) {
|
||||
let Some(r) = self.atlas.sprites.get("item/ender_eye").copied() else {
|
||||
let Some(r) = self.gui.atlas.sprites.get("item/ender_eye").copied() else {
|
||||
return;
|
||||
};
|
||||
let alpha = self.clock.fraction();
|
||||
|
||||
@@ -21,7 +21,7 @@ impl Game<'_> {
|
||||
&& self.settings.resource_packs.iter().all(|id| id == "vanilla")
|
||||
&& self.player.is_some()
|
||||
&& !self.spectator()
|
||||
&& !opaque(self.res.facts.get(self.world.block(at[0], at[1], at[2]))))
|
||||
&& !opaque(self.res.facts().get(self.world.block(at[0], at[1], at[2]))))
|
||||
.then(|| Culler::new(camera.to_array(), 8_192));
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ impl Game<'_> {
|
||||
if let Some(culler) = &self.entity_culler {
|
||||
culler.cull_vertices(vertices, start, |pos| {
|
||||
let state = self.world.block(pos[0], pos[1], pos[2]);
|
||||
if !opaque(self.res.facts.get(state)) {
|
||||
if !opaque(self.res.facts().get(state)) {
|
||||
return false;
|
||||
}
|
||||
let Some(y) = pos[1].checked_sub(MIN_Y) else {
|
||||
|
||||
@@ -196,7 +196,7 @@ impl Game<'_> {
|
||||
break;
|
||||
}
|
||||
let state = self.world.block(pos[0], pos[1], pos[2]);
|
||||
let f = self.res.facts.get(state);
|
||||
let f = self.res.facts().get(state);
|
||||
let fluid = if f.fluid != Fluid::None {
|
||||
100.0f32
|
||||
} else {
|
||||
@@ -206,7 +206,7 @@ impl Game<'_> {
|
||||
Some((at, resistance)) if at == pos => {
|
||||
power -= (resistance + 0.3) * 0.3;
|
||||
}
|
||||
_ if !self.res.facts.is_air(state) || f.fluid != Fluid::None => {
|
||||
_ if !self.res.facts().is_air(state) || f.fluid != Fluid::None => {
|
||||
power -= (f.explosion_resistance.max(fluid) + 0.3) * 0.3;
|
||||
}
|
||||
_ => {}
|
||||
@@ -450,11 +450,11 @@ impl Game<'_> {
|
||||
if self.world.random.next_int_bound(3).unwrap_or(1) == 0
|
||||
&& self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.is_air(self.world.block(pos[0], pos[1], pos[2]))
|
||||
&& self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(pos[0], pos[1] - 1, pos[2]))
|
||||
.solid_render
|
||||
{
|
||||
@@ -475,7 +475,7 @@ impl Game<'_> {
|
||||
} else {
|
||||
targets.len()
|
||||
};
|
||||
let (world, facts) = (&self.world, &self.res.facts);
|
||||
let (world, facts) = (&self.world, self.res.facts());
|
||||
self.particles.explosion(center, radius, block_count, &|b| {
|
||||
facts.is_air(world.block(b[0], b[1], b[2]))
|
||||
});
|
||||
@@ -490,10 +490,10 @@ impl Game<'_> {
|
||||
stacks: &mut Vec<([i32; 3], ItemStack)>,
|
||||
) -> Result<()> {
|
||||
let state = self.world.block(pos[0], pos[1], pos[2]);
|
||||
if self.res.facts.is_air(state) {
|
||||
if self.res.facts().is_air(state) {
|
||||
return Ok(());
|
||||
}
|
||||
let name = self.res.facts.get(state).name.clone();
|
||||
let name = self.res.facts().get(state).name.clone();
|
||||
let is_tnt = &*name == "minecraft:tnt";
|
||||
// Block.onExplosionHit: the drops copy from the block entity, which
|
||||
// then spills its contents as the block turns to air.
|
||||
@@ -510,7 +510,7 @@ impl Game<'_> {
|
||||
// tables' survives_explosion and explosion_decay draw from their
|
||||
// random sequence.
|
||||
let decay = (interaction == BlockInteraction::DestroyWithDecay).then_some(radius);
|
||||
let drops = self.res.items.block_drops_exploded(
|
||||
let drops = self.res.items().block_drops_exploded(
|
||||
self.pack.assets.registry,
|
||||
state,
|
||||
None,
|
||||
|
||||
@@ -188,7 +188,7 @@ impl Game<'_> {
|
||||
let radius = ((reach / 16.0).ceil() as i32 + 1).min(self.settings.render_distance.max(2));
|
||||
self.extras.minimap.update(
|
||||
&self.world,
|
||||
&self.res.facts,
|
||||
self.res.facts(),
|
||||
(bx >> 4, bz >> 4),
|
||||
radius,
|
||||
layer,
|
||||
@@ -197,10 +197,10 @@ impl Game<'_> {
|
||||
if !self.extras.minimap.compose(view) {
|
||||
return;
|
||||
}
|
||||
let Some(rect) = self.atlas.sprites.get(MINIMAP_SPRITE).copied() else {
|
||||
let Some(rect) = self.gui.atlas.sprites.get(MINIMAP_SPRITE).copied() else {
|
||||
return;
|
||||
};
|
||||
let (w, h) = (self.atlas.width as f32, self.atlas.height as f32);
|
||||
let (w, h) = (self.gui.atlas.width as f32, self.gui.atlas.height as f32);
|
||||
self.map_patches.push(horizon_client::font::Patch {
|
||||
x: (rect.u0 * w).round() as u32,
|
||||
y: (rect.v0 * h).round() as u32,
|
||||
@@ -246,7 +246,7 @@ impl Game<'_> {
|
||||
let (map_corner, map_size) = (e.minimap_corner, f32::from(e.minimap_size));
|
||||
let visible = |corner| !(self.debug && corner == Corner::TopLeft);
|
||||
let mut corners = Corners::new(batch.width, batch.height, self.effect_rows_height());
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
if let Some(view) = self.minimap_view()
|
||||
&& visible(map_corner)
|
||||
&& !self.extras.minimap.image.is_empty()
|
||||
@@ -290,7 +290,7 @@ impl Game<'_> {
|
||||
use_: self.extras.mouse[1],
|
||||
cps,
|
||||
};
|
||||
extras_hud::draw_keystrokes(batch, &self.atlas, &mut corners, keys_corner, &k);
|
||||
extras_hud::draw_keystrokes(batch, &self.gui.atlas, &mut corners, keys_corner, &k);
|
||||
}
|
||||
if mod_panels {
|
||||
self.draw_mod_panels(batch, &mut corners);
|
||||
|
||||
@@ -6,7 +6,7 @@ use horizon_world::level::LevelEvent;
|
||||
|
||||
impl Game<'_> {
|
||||
pub(super) fn finish_falling_block(&mut self, mut block: FallingBlock, pos: [i32; 3]) {
|
||||
let anvil = self.res.facts.get(block.state).name.ends_with("anvil");
|
||||
let anvil = self.res.facts().get(block.state).name.ends_with("anvil");
|
||||
if let Some(impact) = block.damage.impact(block.fall_distance) {
|
||||
if impact.amount > 0.0 {
|
||||
falling_block::hurt_mobs(&mut self.mobs, block.position, impact.amount);
|
||||
@@ -80,7 +80,7 @@ impl Game<'_> {
|
||||
&& block.drop_item
|
||||
&& self.ui.rules.bool("entity_drops")
|
||||
{
|
||||
let item = self.res.facts.get(block.state).item.clone();
|
||||
let item = self.res.facts().get(block.state).item.clone();
|
||||
if &*item != "minecraft:air" {
|
||||
self.pop_resource(
|
||||
pos,
|
||||
|
||||
@@ -108,6 +108,7 @@ impl Game<'_> {
|
||||
return;
|
||||
};
|
||||
let Some(r) = self
|
||||
.gui
|
||||
.atlas
|
||||
.sprites
|
||||
.get("entity/illager/evoker_fangs")
|
||||
|
||||
@@ -226,14 +226,18 @@ impl Game<'_> {
|
||||
fn biome_name_at(&self, p: Vec3) -> Option<String> {
|
||||
let (x, y, z) = (p.x.floor() as i32, p.y.floor() as i32, p.z.floor() as i32);
|
||||
let c = self.world.chunks.get(&(x >> 4, z >> 4))?;
|
||||
Some(self.res.biomes.list[c.biome(x, y, z) as usize].name.clone())
|
||||
Some(
|
||||
self.res.biomes().list[c.biome(x, y, z) as usize]
|
||||
.name
|
||||
.clone(),
|
||||
)
|
||||
}
|
||||
fn water_height(&self, x: i32, y: i32, z: i32) -> Option<(f32, bool)> {
|
||||
let f = self.res.facts.get(self.world.block(x, y, z));
|
||||
let f = self.res.facts().get(self.world.block(x, y, z));
|
||||
if f.fluid != Fluid::Water {
|
||||
return None;
|
||||
}
|
||||
let above = self.res.facts.get(self.world.block(x, y + 1, z));
|
||||
let above = self.res.facts().get(self.world.block(x, y + 1, z));
|
||||
let h = if above.fluid == Fluid::Water {
|
||||
1.0
|
||||
} else {
|
||||
@@ -243,7 +247,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// getOpenWaterTypeForBlock: 0 above water, 1 inside water, 2 invalid.
|
||||
fn open_water_type(&self, x: i32, y: i32, z: i32) -> u8 {
|
||||
let f = self.res.facts.get(self.world.block(x, y, z));
|
||||
let f = self.res.facts().get(self.world.block(x, y, z));
|
||||
if self.world.is_air(self.world.block(x, y, z)) || &*f.name == "minecraft:lily_pad" {
|
||||
return 0;
|
||||
}
|
||||
@@ -390,7 +394,7 @@ impl Game<'_> {
|
||||
(fish[1] - 1.0).floor() as i32,
|
||||
fish[2].floor() as i32,
|
||||
);
|
||||
&*self.res.facts.get(state).name == "minecraft:water"
|
||||
&*self.res.facts().get(state).name == "minecraft:water"
|
||||
}
|
||||
/// `ServerLevel.sendParticles` of a simple particle.
|
||||
fn send_particles(
|
||||
@@ -565,6 +569,7 @@ impl Game<'_> {
|
||||
return;
|
||||
};
|
||||
let Some(r) = self
|
||||
.gui
|
||||
.atlas
|
||||
.sprites
|
||||
.get("entity/fishing/fishing_hook")
|
||||
|
||||
@@ -75,7 +75,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// The fluid at the camera, as `Camera.getFluidInCamera` reports it.
|
||||
fn camera_fluid(&self, camera: [f64; 3]) -> CameraFluid {
|
||||
match fog_type(&self.world, &self.res.facts, camera, self.forward()) {
|
||||
match fog_type(&self.world, self.res.facts(), camera, self.forward()) {
|
||||
FogType::Water => CameraFluid::Water,
|
||||
FogType::Lava => CameraFluid::Lava,
|
||||
FogType::PowderSnow => CameraFluid::PowderSnow,
|
||||
@@ -177,6 +177,6 @@ impl Game<'_> {
|
||||
}
|
||||
let draws =
|
||||
hud_overlays::spyglass(batch.width as i32, batch.height as i32, self.scope_scale);
|
||||
hud_layout::paint(batch, &self.atlas, &draws);
|
||||
hud_layout::paint(batch, &self.gui.atlas, &draws);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ impl Game<'_> {
|
||||
return false;
|
||||
}
|
||||
let s = f.step();
|
||||
let behind = self.res.facts.get(self.world.block(
|
||||
let behind = self.res.facts().get(self.world.block(
|
||||
f.pos[0] - s[0],
|
||||
f.pos[1] - s[1],
|
||||
f.pos[2] - s[2],
|
||||
@@ -301,7 +301,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// ItemFrameRenderer: the frame model, then the item half size on its face.
|
||||
pub(super) fn frame_geometry(&mut self, camera: glam::DVec3, out: &mut Vec<Vertex>) {
|
||||
let sprites = &self.atlas.sprites;
|
||||
let sprites = &self.gui.atlas.sprites;
|
||||
let mut maps: Vec<(i32, glam::Mat4, u32)> = Vec::new();
|
||||
let mut items: Vec<(ItemStack, u32, glam::Mat4, u8)> = Vec::new();
|
||||
// ItemFrame.shouldRenderAtSqrDistance: 1024 blocks at 100%.
|
||||
|
||||
@@ -39,7 +39,7 @@ impl Game<'_> {
|
||||
};
|
||||
switcher.hover(w, h, (self.cursor.0 as i32, self.cursor.1 as i32));
|
||||
let selected = switcher.selected;
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
batch.sprite_region(
|
||||
atlas,
|
||||
"gui/container/gamemode_switcher",
|
||||
@@ -62,14 +62,14 @@ impl Game<'_> {
|
||||
for (index, mode) in MODES.into_iter().enumerate() {
|
||||
let (x, y) = slot_origin(w, h, index);
|
||||
batch.sprite(
|
||||
&self.atlas,
|
||||
&self.gui.atlas,
|
||||
"gui/sprites/gamemode_switcher/slot",
|
||||
x as f32,
|
||||
y as f32,
|
||||
);
|
||||
if mode == selected {
|
||||
batch.sprite(
|
||||
&self.atlas,
|
||||
&self.gui.atlas,
|
||||
"gui/sprites/gamemode_switcher/selection",
|
||||
x as f32,
|
||||
y as f32,
|
||||
|
||||
@@ -8,7 +8,7 @@ use horizon_client::Result;
|
||||
impl Game<'_> {
|
||||
fn golem_block(&self, p: [i32; 3]) -> &str {
|
||||
let state = self.world.block(p[0], p[1], p[2]);
|
||||
&self.res.facts.get(state).name
|
||||
&self.res.facts().get(state).name
|
||||
}
|
||||
fn is_golem_head(&self, p: [i32; 3]) -> bool {
|
||||
matches!(
|
||||
@@ -33,7 +33,7 @@ impl Game<'_> {
|
||||
for (ax, az) in [(1, 0), (0, 1)] {
|
||||
let side = |s: i32, row: i32| [head[0] + ax * s, head[1] - row, head[2] + az * s];
|
||||
let arms = (-1..=1).all(|s| self.golem_block(side(s, 1)) == "minecraft:iron_block");
|
||||
let air = |p: [i32; 3]| self.res.facts.is_air(self.world.block(p[0], p[1], p[2]));
|
||||
let air = |p: [i32; 3]| self.res.facts().is_air(self.world.block(p[0], p[1], p[2]));
|
||||
if arms
|
||||
&& self.golem_block(side(0, 2)) == "minecraft:iron_block"
|
||||
&& [-1, 1].iter().all(|&s| air(side(s, 0)) && air(side(s, 2)))
|
||||
@@ -58,7 +58,7 @@ impl Game<'_> {
|
||||
let below = [head[0], head[1] - 1, head[2]];
|
||||
let name = self.golem_block(below);
|
||||
self.res
|
||||
.items
|
||||
.items()
|
||||
.block_tags
|
||||
.get("minecraft:copper")
|
||||
.is_some_and(|t| t.contains(name))
|
||||
@@ -88,7 +88,7 @@ impl Game<'_> {
|
||||
/// `EntityType.create(level, TRIGGERED)` and `snapTo`: a built golem or
|
||||
/// wither has no spawn finalization and draws nothing from the level.
|
||||
pub(super) fn create_triggered(&mut self, kind: &str, at: [f64; 3], yaw: f32) -> Option<u32> {
|
||||
let t = self.res.mob_types.get(kind).cloned()?;
|
||||
let t = self.res.mob_types().get(kind).cloned()?;
|
||||
self.next_entity += 1;
|
||||
let mut mob = horizon_client::mobs::Mob::new(
|
||||
self.next_entity,
|
||||
@@ -181,9 +181,9 @@ impl Game<'_> {
|
||||
});
|
||||
if let Some(chest) = chest {
|
||||
self.with_level(|b, level, ticks| b.set_block(level, ticks, pos, chest, 2));
|
||||
if let Some(entity) =
|
||||
horizon_client::containers::BlockEntity::for_block(&self.res.facts.get(chest).name)
|
||||
{
|
||||
if let Some(entity) = horizon_client::containers::BlockEntity::for_block(
|
||||
&self.res.facts().get(chest).name,
|
||||
) {
|
||||
self.world
|
||||
.block_entities
|
||||
.insert((below[0], below[1], below[2]), entity);
|
||||
|
||||
@@ -10,7 +10,7 @@ impl Game<'_> {
|
||||
/// Load the configured/placed feature registry used by saplings, fungi
|
||||
/// and bone meal (once per process; shares the generator's bundle).
|
||||
pub(super) fn install_live_features(&self) {
|
||||
if self.res.behaviours.live_features().is_some() {
|
||||
if self.res.behaviours().live_features().is_some() {
|
||||
return;
|
||||
}
|
||||
let dir = self.options.resources.join("worldgen");
|
||||
@@ -20,7 +20,7 @@ impl Game<'_> {
|
||||
.and_then(|data| LiveFeatures::new(&data).map_err(|e| e.to_string()));
|
||||
match features {
|
||||
Ok(Some(features)) => {
|
||||
self.res.behaviours.set_live_features(Arc::new(features));
|
||||
self.res.behaviours().set_live_features(Arc::new(features));
|
||||
log::info!("Horizon: live features ready in {:?}", started.elapsed());
|
||||
}
|
||||
Ok(None) => {
|
||||
|
||||
@@ -90,7 +90,7 @@ impl Game<'_> {
|
||||
let (pos, first) = (d.pos, (d.ticks as u32 - 1).is_multiple_of(4));
|
||||
let state = self.world.block(pos[0], pos[1], pos[2]);
|
||||
if first {
|
||||
let sounds = self.res.facts.get(state).sounds.clone();
|
||||
let sounds = self.res.facts().get(state).sounds.clone();
|
||||
self.audio.play(
|
||||
&sounds.hit,
|
||||
Some(pos.map(|v| f64::from(v) + 0.5)),
|
||||
@@ -117,17 +117,17 @@ impl Game<'_> {
|
||||
/// `BlockBehaviour.getDestroyProgress` with `Player.getDestroySpeed`.
|
||||
pub(super) fn destroy_progress(&self, pos: [i32; 3]) -> f32 {
|
||||
let state = self.world.block(pos[0], pos[1], pos[2]);
|
||||
let facts = self.res.facts.get(state);
|
||||
let facts = self.res.facts().get(state);
|
||||
if facts.hardness == -1.0 {
|
||||
return 0.0;
|
||||
}
|
||||
let held = self.held();
|
||||
let mut speed = self.res.items.mining_speed(held, &facts.name);
|
||||
let mut speed = self.res.items().mining_speed(held, &facts.name);
|
||||
speed = self.modify_destroy_speed(speed);
|
||||
if let Some(eye) = self.eye_position()
|
||||
&& self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(
|
||||
eye[0].floor() as i32,
|
||||
eye[1].floor() as i32,
|
||||
@@ -141,7 +141,7 @@ impl Game<'_> {
|
||||
if self.player.as_ref().is_some_and(|p| !p.ground.on_ground) {
|
||||
speed /= 5.0;
|
||||
}
|
||||
let harvest = !facts.requires_tool || self.res.items.correct_for_drops(held, &facts.name);
|
||||
let harvest = !facts.requires_tool || self.res.items().correct_for_drops(held, &facts.name);
|
||||
speed / facts.hardness / if harvest { 30.0 } else { 100.0 }
|
||||
}
|
||||
/// Whether an attack would hit an entity rather than the block behind
|
||||
@@ -287,7 +287,7 @@ impl Game<'_> {
|
||||
horizon_client::attack_strength::BASE_ATTACK_SPEED
|
||||
+ self
|
||||
.held()
|
||||
.and_then(|h| self.res.items.get(&h.item))
|
||||
.and_then(|h| self.res.items().get(&h.item))
|
||||
.map_or(0.0, |i| f64::from(i.attack_speed))
|
||||
}
|
||||
/// `evaluateWhichHandsToRender`: which of the main and off hand show.
|
||||
@@ -351,7 +351,7 @@ impl HandWorld for GameHands<'_, '_> {
|
||||
}
|
||||
fn is_air(&mut self, pos: [i32; 3]) -> bool {
|
||||
let state = self.game.world.block(pos[0], pos[1], pos[2]);
|
||||
self.game.res.facts.get(state).name.ends_with("air")
|
||||
self.game.res.facts().get(state).name.ends_with("air")
|
||||
}
|
||||
fn creative(&self) -> bool {
|
||||
self.game.creative
|
||||
|
||||
@@ -83,7 +83,7 @@ impl Game<'_> {
|
||||
horizon_client::flatgen::FlatTerrain::from_settings(
|
||||
&s,
|
||||
self.pack.assets.registry,
|
||||
&self.res.biomes,
|
||||
self.res.biomes(),
|
||||
)
|
||||
})
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
//! player joins as a network player, and the server side of a network player
|
||||
//! does not do everything single player does yet.
|
||||
use super::{
|
||||
Game, Options, PackResources, Resources,
|
||||
Game, Options, PackResources, Resources, UiResources,
|
||||
lan::{LanSettings, Owner},
|
||||
};
|
||||
use horizon_client::{
|
||||
@@ -201,6 +201,7 @@ impl Game<'_> {
|
||||
options.server = None;
|
||||
options.world = None;
|
||||
options.dev_mods.clear();
|
||||
self.join_world_rest()?;
|
||||
let (res, pack, settings) = (self.res.clone(), self.pack.clone(), self.settings.clone());
|
||||
let flags = Arc::new(Flags::default());
|
||||
flags
|
||||
@@ -595,7 +596,14 @@ fn serve(
|
||||
) -> Result<()> {
|
||||
// It draws nothing: only the font, which books and chat measure with.
|
||||
let atlas = HudAtlas::fonts(&options.resources)?;
|
||||
let gui = UiResources {
|
||||
atlas,
|
||||
panorama: Arc::new(horizon_client::gfx::panorama::Faces {
|
||||
size: 1,
|
||||
pixels: [0u8; 4].repeat(6),
|
||||
}),
|
||||
};
|
||||
let audio = Audio::silent(&options.resources);
|
||||
let mut server = Game::new(res, pack, atlas, options, settings, audio)?;
|
||||
let mut server = Game::new(res, pack, gui, options, settings, audio)?;
|
||||
server.run_integrated(launch, flags, tasks, ready)
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ impl Game<'_> {
|
||||
}
|
||||
pub(super) fn item_host(&self) -> Host<'_> {
|
||||
Host {
|
||||
banners: &self.res.stations.banners,
|
||||
banners: &self.res.stations().banners,
|
||||
}
|
||||
}
|
||||
/// The client level as item models read it.
|
||||
@@ -255,7 +255,7 @@ impl Game<'_> {
|
||||
item_render::gui::draw(
|
||||
&state,
|
||||
&self.pack.item_renderer,
|
||||
&self.atlas.sprites,
|
||||
&self.gui.atlas.sprites,
|
||||
&self.item_host(),
|
||||
batch,
|
||||
x,
|
||||
@@ -279,7 +279,7 @@ impl Game<'_> {
|
||||
};
|
||||
state.submit(
|
||||
&self.pack.item_renderer,
|
||||
&self.atlas.sprites,
|
||||
&self.gui.atlas.sprites,
|
||||
&self.item_host(),
|
||||
pose,
|
||||
&mut sink,
|
||||
@@ -300,7 +300,7 @@ impl Game<'_> {
|
||||
};
|
||||
state.submit(
|
||||
&self.pack.item_renderer,
|
||||
&self.atlas.sprites,
|
||||
&self.gui.atlas.sprites,
|
||||
&self.item_host(),
|
||||
pose,
|
||||
&mut sink,
|
||||
|
||||
@@ -51,7 +51,7 @@ impl Game<'_> {
|
||||
pub(super) fn use_jukebox(&mut self, pos: [i32; 3], held: Option<&ItemStack>) -> bool {
|
||||
if &*self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(pos[0], pos[1], pos[2]))
|
||||
.name
|
||||
!= "minecraft:jukebox"
|
||||
@@ -65,7 +65,7 @@ impl Game<'_> {
|
||||
let Some(stack) = held else { return false };
|
||||
let Some(song) = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.get(&stack.item)
|
||||
.and_then(|i| i.jukebox_song.clone())
|
||||
else {
|
||||
@@ -95,7 +95,7 @@ impl Game<'_> {
|
||||
/// Level event 1010: the song from the jukebox, and the "Now Playing" overlay.
|
||||
fn start_song(&mut self, pos: [i32; 3], song: &str) {
|
||||
self.stop_song(pos);
|
||||
let Some(s) = self.res.items.songs.get(song).cloned() else {
|
||||
let Some(s) = self.res.items().songs.get(song).cloned() else {
|
||||
return;
|
||||
};
|
||||
// LevelRenderer.playJukeboxSong: SimpleSoundInstance.forJukeboxSong.
|
||||
@@ -144,7 +144,7 @@ impl Game<'_> {
|
||||
pub(super) fn tick_jukebox(&mut self, key: (i32, i32, i32)) {
|
||||
let playing = match self.world.block_entities.get(&key) {
|
||||
Some(BlockEntity::Jukebox(j)) if j.playing => j.record.as_ref().and_then(|r| {
|
||||
let song = self.res.items.get(&r.item)?.jukebox_song.clone()?;
|
||||
let song = self.res.items().get(&r.item)?.jukebox_song.clone()?;
|
||||
Some((song, j.ticks))
|
||||
}),
|
||||
_ => None,
|
||||
@@ -153,7 +153,7 @@ impl Game<'_> {
|
||||
return;
|
||||
};
|
||||
let pos = [key.0, key.1, key.2];
|
||||
let Some(s) = self.res.items.songs.get(&song).cloned() else {
|
||||
let Some(s) = self.res.items().songs.get(&song).cloned() else {
|
||||
return;
|
||||
};
|
||||
if s.finished(ticks) {
|
||||
|
||||
@@ -467,7 +467,7 @@ impl Game<'_> {
|
||||
.clone()?;
|
||||
let biome_names: Vec<String> = self
|
||||
.res
|
||||
.biomes
|
||||
.biomes()
|
||||
.list
|
||||
.iter()
|
||||
.map(|b| b.name.clone())
|
||||
@@ -480,7 +480,7 @@ impl Game<'_> {
|
||||
.unwrap_or_default();
|
||||
let mut encoder = ChunkEncoder::new(
|
||||
self.res
|
||||
.facts
|
||||
.facts()
|
||||
.states
|
||||
.iter()
|
||||
.map(|s| (s.name.clone(), s.fluid_level > 0 || s.waterlogged)),
|
||||
@@ -1100,7 +1100,7 @@ impl Game<'_> {
|
||||
|
||||
/// The guests' models, for the host to see them.
|
||||
fn lan_update_models(&mut self, host: &mut LanHost) {
|
||||
let Some(kind) = self.res.player_type.clone() else {
|
||||
let Some(kind) = self.res.player_type().clone() else {
|
||||
return;
|
||||
};
|
||||
host.models
|
||||
@@ -1171,7 +1171,7 @@ impl Game<'_> {
|
||||
let Some(host) = &self.lan else {
|
||||
return;
|
||||
};
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let lookup = |name: &str| atlas.sprites.get(name).map(|r| [r.u0, r.v0, r.u1, r.v1]);
|
||||
for m in host.models.values() {
|
||||
let entity_start = out.len();
|
||||
@@ -1187,7 +1187,7 @@ impl Game<'_> {
|
||||
camera,
|
||||
&lookup,
|
||||
packed,
|
||||
&self.res.mob_data,
|
||||
self.res.mob_data(),
|
||||
&self.worn_armor_layers(m),
|
||||
out,
|
||||
);
|
||||
|
||||
@@ -377,7 +377,7 @@ impl Game<'_> {
|
||||
fn lan_open_container(&mut self, host: &mut LanHost, conn: u32, pos: (i32, i32, i32)) -> bool {
|
||||
let name = &self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(pos.0, pos.1, pos.2))
|
||||
.name;
|
||||
let (menu, title, slots) = if &**name == "minecraft:ender_chest" {
|
||||
@@ -621,7 +621,7 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
S::ContainerClick(p) => {
|
||||
let rules = ItemRules(&self.res.items);
|
||||
let rules = ItemRules(self.res.items());
|
||||
let drops = host.hub.container_click(conn, &p, &mut self.world, &rules);
|
||||
self.drop_guest_items(host, gi, drops);
|
||||
}
|
||||
@@ -750,7 +750,7 @@ impl Game<'_> {
|
||||
}
|
||||
S::PickItemFromBlock(p) => {
|
||||
let state = self.world.block(p.pos[0], p.pos[1], p.pos[2]);
|
||||
let item = self.res.facts.get(state).item.clone();
|
||||
let item = self.res.facts().get(state).item.clone();
|
||||
let g = &mut host.hub.guests[gi];
|
||||
if g.creative() && &*item != "minecraft:air" {
|
||||
let slot = g.selected;
|
||||
@@ -1184,7 +1184,7 @@ impl Game<'_> {
|
||||
g.sleep_timer = super::tick_sleep_timer(g.sleep_timer, g.bed.is_some());
|
||||
if let Some(head) = g.bed {
|
||||
let block = self.world.block(head[0], head[1], head[2]);
|
||||
let bed = self.res.facts.get(block).name.ends_with("_bed");
|
||||
let bed = self.res.facts().get(block).name.ends_with("_bed");
|
||||
if g.dead || g.health <= 0.0 || !bed {
|
||||
host.hub.wake(gi);
|
||||
}
|
||||
@@ -1352,7 +1352,7 @@ impl Game<'_> {
|
||||
let range = |v: f64| (v - half).floor() as i32..=(v + half).floor() as i32;
|
||||
range(at[0]).any(|x| {
|
||||
range(at[2]).any(|z| {
|
||||
let f = self.res.facts.get(self.world.block(x, y, z));
|
||||
let f = self.res.facts().get(self.world.block(x, y, z));
|
||||
f.full_collision && f.solid_render
|
||||
})
|
||||
})
|
||||
@@ -1370,7 +1370,7 @@ impl Game<'_> {
|
||||
play.mining = None;
|
||||
let start = play.dig_start;
|
||||
let state = self.world.block(pos[0], pos[1], pos[2]);
|
||||
if !dug || self.res.facts.is_air(state) {
|
||||
if !dug || self.res.facts().is_air(state) {
|
||||
return;
|
||||
}
|
||||
let progress = self
|
||||
@@ -1394,7 +1394,7 @@ impl Game<'_> {
|
||||
};
|
||||
let ticks = host.hub.ticks;
|
||||
let state = self.world.block(pos[0], pos[1], pos[2]);
|
||||
let progress = if self.res.facts.is_air(state) {
|
||||
let progress = if self.res.facts().is_air(state) {
|
||||
None
|
||||
} else {
|
||||
self.as_guest(host, conn, |g| g.destroy_progress(pos))
|
||||
|
||||
@@ -84,10 +84,10 @@ fn place_back(menu: &mut Menu, env: &Env, stacks: Vec<ItemStack>) {
|
||||
impl Game<'_> {
|
||||
fn menu_env(&self) -> Env<'_> {
|
||||
Env {
|
||||
items: &self.res.items,
|
||||
recipes: &self.res.recipes,
|
||||
brewing: &self.res.stations.brewing,
|
||||
banners: &self.res.stations.banners,
|
||||
items: self.res.items(),
|
||||
recipes: self.res.recipes(),
|
||||
brewing: &self.res.stations().brewing,
|
||||
banners: &self.res.stations().banners,
|
||||
trade: None,
|
||||
}
|
||||
}
|
||||
@@ -218,7 +218,7 @@ impl Game<'_> {
|
||||
f.items[k] = menu.slot(k).cloned();
|
||||
}
|
||||
// AbstractFurnaceBlockEntity.setItem: only a new input restarts cooking.
|
||||
f.input_clicked(&self.res.recipes, items[0].clone());
|
||||
f.input_clicked(self.res.recipes(), items[0].clone());
|
||||
}
|
||||
host.play.entry(conn).or_default().crafting.furnace = Some((p.container, menu));
|
||||
host.hub.inventory_clicked(conn, p, &self.world, &changed);
|
||||
@@ -245,7 +245,7 @@ impl Game<'_> {
|
||||
}
|
||||
let Some(id) = self
|
||||
.res
|
||||
.stations
|
||||
.stations()
|
||||
.recipe_index
|
||||
.recipe_of_display(p.recipe)
|
||||
.map(str::to_owned)
|
||||
@@ -256,7 +256,7 @@ impl Game<'_> {
|
||||
if !g.recipe_book.knows(&id)
|
||||
|| self
|
||||
.res
|
||||
.recipes
|
||||
.recipes()
|
||||
.placement(&id)
|
||||
.is_none_or(|placement| placement.impossible())
|
||||
{
|
||||
|
||||
@@ -596,11 +596,11 @@ impl Game<'_> {
|
||||
View::Restrictions => self.draw_restrictions(batch),
|
||||
View::GameRules => {
|
||||
if let Some(rules) = o.rules.as_mut() {
|
||||
rules.draw(batch, &self.atlas, self.cursor);
|
||||
rules.draw(batch, &self.gui.atlas, self.cursor);
|
||||
} else {
|
||||
ui::menu_background(
|
||||
batch,
|
||||
&self.atlas,
|
||||
&self.gui.atlas,
|
||||
0.0,
|
||||
0.0,
|
||||
batch.width,
|
||||
@@ -614,7 +614,7 @@ impl Game<'_> {
|
||||
}
|
||||
|
||||
fn draw_lock_question(&self, o: &WorldOptions, batch: &mut HudBatch) {
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let (w, h) = (batch.width, batch.height);
|
||||
// Screen.extractTransparentBackground.
|
||||
batch.fill_gradient(
|
||||
@@ -656,7 +656,7 @@ impl Game<'_> {
|
||||
}
|
||||
|
||||
fn draw_restrictions(&self, batch: &mut HudBatch) {
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let (w, h) = (batch.width, batch.height);
|
||||
ui::menu_background(batch, atlas, 0.0, 0.0, w, h, true);
|
||||
let title = Text::translate("restrictions_screen.title", &[]);
|
||||
@@ -687,7 +687,7 @@ impl Game<'_> {
|
||||
}
|
||||
|
||||
fn draw_options_view(&self, o: &mut WorldOptions, batch: &mut HudBatch, cursor: (f32, f32)) {
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let (w, h) = (batch.width, batch.height);
|
||||
o.scroll = o.scroll.clamp(0.0, o.scroll_limit(h));
|
||||
// extractMenuBackground: the in-world background, the list
|
||||
@@ -810,7 +810,7 @@ impl Game<'_> {
|
||||
match o.view {
|
||||
View::Options => {}
|
||||
View::GameRules => {
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let exit = o.rules.as_mut().and_then(|rules| {
|
||||
if rules.clicks_button(atlas, self.cursor, (w, h)) {
|
||||
self.audio.play_button_click();
|
||||
@@ -824,7 +824,7 @@ impl Game<'_> {
|
||||
return;
|
||||
}
|
||||
View::LockQuestion => {
|
||||
let p = Popup::lock_question(&self.atlas.font, o.difficulty, (w, h));
|
||||
let p = Popup::lock_question(&self.gui.atlas.font, o.difficulty, (w, h));
|
||||
let hit = p
|
||||
.buttons
|
||||
.iter()
|
||||
@@ -842,7 +842,8 @@ impl Game<'_> {
|
||||
return;
|
||||
}
|
||||
View::Restrictions => {
|
||||
let r = Restrictions::new(&self.atlas.font, self.settings.chat_visibility, (w, h));
|
||||
let r =
|
||||
Restrictions::new(&self.gui.atlas.font, self.settings.chat_visibility, (w, h));
|
||||
let in_body = self.cursor.1 >= r.area.0 && self.cursor.1 < r.area.1;
|
||||
let action = r.action.is_some_and(|(ax, ay)| {
|
||||
in_body && ui::hovered(self.cursor, ax, ay, 200.0, 20.0)
|
||||
|
||||
@@ -133,7 +133,7 @@ impl Game<'_> {
|
||||
if let Some(name) = &state.name {
|
||||
return name.clone();
|
||||
}
|
||||
let e = &self.res.stations.enchantments;
|
||||
let e = &self.res.stations().enchantments;
|
||||
let profession = state.session.profession.trim_start_matches("minecraft:");
|
||||
if state.session.villager {
|
||||
e.translate(&format!("entity.minecraft.villager.{profession}"))
|
||||
@@ -245,15 +245,15 @@ impl Game<'_> {
|
||||
next_id: std::cell::Cell::new(next_map),
|
||||
};
|
||||
let trade_env = merchant::TradeEnv {
|
||||
trades: &self.res.stations.trades,
|
||||
enchantments: &self.res.stations.enchantments,
|
||||
trades: &self.res.stations().trades,
|
||||
enchantments: &self.res.stations().enchantments,
|
||||
maps: Some(&maps),
|
||||
};
|
||||
let env = Env {
|
||||
items: &self.res.items,
|
||||
recipes: &self.res.recipes,
|
||||
brewing: &self.res.stations.brewing,
|
||||
banners: &self.res.stations.banners,
|
||||
items: self.res.items(),
|
||||
recipes: self.res.recipes(),
|
||||
brewing: &self.res.stations().brewing,
|
||||
banners: &self.res.stations().banners,
|
||||
trade: Some(&trade_env),
|
||||
};
|
||||
let mut menu = Menu::new(Kind::Merchant);
|
||||
|
||||
@@ -220,11 +220,11 @@ impl Game<'_> {
|
||||
};
|
||||
let name = self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(hit.pos[0], hit.pos[1], hit.pos[2]));
|
||||
if !self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.block_tags
|
||||
.get("minecraft:fences")
|
||||
.is_some_and(|s| s.contains(&*name.name))
|
||||
@@ -283,7 +283,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// `LeashFeatureRenderer` for every lead and `LeashKnotRenderer` for the knots.
|
||||
pub(super) fn leash_geometry(&self, camera: glam::DVec3, alpha: f64, out: &mut Vec<Vertex>) {
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let white = atlas.font.white();
|
||||
let uv = [
|
||||
[white.u0, white.v1],
|
||||
|
||||
@@ -105,7 +105,7 @@ impl Game<'_> {
|
||||
fn open_level(&self, dim: Dim) -> Result<Parked> {
|
||||
let (streaming, save) =
|
||||
self.make_streaming(&self.world_root.clone(), dim, self.level.seed)?;
|
||||
let mut world = World::new(self.res.facts.air, self.level.seed);
|
||||
let mut world = World::new(self.res.facts().air, self.level.seed);
|
||||
world.fast_lava = dim == Dim::Nether;
|
||||
Ok(Parked {
|
||||
world,
|
||||
|
||||
@@ -50,7 +50,7 @@ impl Game<'_> {
|
||||
let difficulty = f64::from(self.ui.difficulty) * 0.75;
|
||||
let below = &self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(pos[0], pos[1] - 1, pos[2]))
|
||||
.name;
|
||||
let trap = self.ui.rules.bool("spawn_mobs")
|
||||
@@ -160,11 +160,11 @@ impl Game<'_> {
|
||||
}
|
||||
for p in spots {
|
||||
let state = self.world.block(p[0], p[1], p[2]);
|
||||
if !self.res.facts.is_air(state) {
|
||||
if !self.res.facts().is_air(state) {
|
||||
continue;
|
||||
}
|
||||
// BaseFireBlock.getState: soul fire on soul soil and sand.
|
||||
let below = self.res.facts.get(self.world.block(p[0], p[1] - 1, p[2]));
|
||||
let below = self.res.facts().get(self.world.block(p[0], p[1] - 1, p[2]));
|
||||
let name = if matches!(&*below.name, "minecraft:soul_soil" | "minecraft:soul_sand") {
|
||||
"minecraft:soul_fire"
|
||||
} else {
|
||||
@@ -236,7 +236,7 @@ impl Game<'_> {
|
||||
at[2].floor() as i32,
|
||||
];
|
||||
let state = self.world.block(p[0], p[1], p[2]);
|
||||
if !self.res.facts.get(state).name.ends_with("lightning_rod") {
|
||||
if !self.res.facts().get(state).name.ends_with("lightning_rod") {
|
||||
return;
|
||||
}
|
||||
let registry = self.pack.assets.registry;
|
||||
@@ -348,7 +348,7 @@ impl Game<'_> {
|
||||
/// `LightningBoltRenderer`: 4 layers of a trunk and two branches, 8
|
||||
/// segments of 16 blocks, from the bolt's seed.
|
||||
pub(super) fn bolt_geometry(&self, camera: glam::DVec3, out: &mut Vec<Vertex>) {
|
||||
let white = self.atlas.font.white();
|
||||
let white = self.gui.atlas.font.white();
|
||||
let uv = [white.u0, white.v0];
|
||||
// ARGB 0.45, 0.45, 0.5 at 0.3 alpha, packed RGBA.
|
||||
let color = (76u32 << 24) | (127 << 16) | (114 << 8) | 114;
|
||||
|
||||
@@ -192,14 +192,14 @@ impl Game<'_> {
|
||||
base: &str,
|
||||
layers: &[BannerLayer],
|
||||
) {
|
||||
let banners = &self.res.stations.banners;
|
||||
let banners = &self.res.stations().banners;
|
||||
let layers: Vec<(String, String)> = layers
|
||||
.iter()
|
||||
.map(|l| (banners.banner_texture(&l.pattern), l.color.to_string()))
|
||||
.collect();
|
||||
horizon_client::item_render::gui::draw_banner_result(
|
||||
&self.pack.item_renderer,
|
||||
&self.atlas.sprites,
|
||||
&self.gui.atlas.sprites,
|
||||
batch,
|
||||
x,
|
||||
y,
|
||||
@@ -217,7 +217,7 @@ impl Game<'_> {
|
||||
draws: &[ScreenDraw],
|
||||
background: bool,
|
||||
) -> Option<Vec<(String, u32)>> {
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let mut tooltip = None;
|
||||
let mut sheet: Option<String> = None;
|
||||
for d in draws {
|
||||
@@ -317,7 +317,7 @@ impl Game<'_> {
|
||||
let l = &s.loom;
|
||||
let dye = s.inputs[1]
|
||||
.as_ref()
|
||||
.and_then(|d| self.res.items.get(&d.item))
|
||||
.and_then(|d| self.res.items().get(&d.item))
|
||||
.and_then(|i| i.dye.clone())
|
||||
.unwrap_or_else(|| "white".to_owned());
|
||||
let result = s
|
||||
@@ -342,7 +342,7 @@ impl Game<'_> {
|
||||
dye: &dye,
|
||||
mouse: local,
|
||||
};
|
||||
let draws = screen_layout::loom(&view, &self.res.stations.banners);
|
||||
let draws = screen_layout::loom(&view, &self.res.stations().banners);
|
||||
self.paint_screen(batch, ox, oy, &draws, false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,11 +84,11 @@ impl Game<'_> {
|
||||
direct_attacker: Some("minecraft:player"),
|
||||
is_direct: true,
|
||||
damage_type: Some("minecraft:mace_smash"),
|
||||
items: Some(&self.res.items),
|
||||
items: Some(self.res.items()),
|
||||
..Default::default()
|
||||
};
|
||||
// EnchantmentHelper.modifyFallBasedDamage(..., 0)
|
||||
let per_block = self.res.stations.enchantments.modify_value(
|
||||
let per_block = self.res.stations().enchantments.modify_value(
|
||||
held.as_ref(),
|
||||
"minecraft:smash_damage_per_fallen_block",
|
||||
&ctx,
|
||||
@@ -111,10 +111,10 @@ impl Game<'_> {
|
||||
horizon_client::mobs::DamageKind::MaceSmash => "minecraft:mace_smash",
|
||||
_ => "minecraft:player_attack",
|
||||
}),
|
||||
items: Some(&self.res.items),
|
||||
items: Some(self.res.items()),
|
||||
..Default::default()
|
||||
};
|
||||
let enchantments = &self.res.stations.enchantments;
|
||||
let enchantments = &self.res.stations().enchantments;
|
||||
let random = &mut self.world.random;
|
||||
// CombatRules.getDamageAfterAbsorb: EnchantmentHelper.modifyArmorEffectiveness.
|
||||
let mut breach = |fraction: f32| {
|
||||
@@ -143,7 +143,7 @@ impl Game<'_> {
|
||||
};
|
||||
let weapon = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.get(&stack.item)
|
||||
.and_then(|i| i.weapon_damage.map(|d| (d, i.max_damage)));
|
||||
let smash = self.smash_attack();
|
||||
|
||||
@@ -361,10 +361,10 @@ impl Game<'_> {
|
||||
fn containers(&self) -> Containers<'_> {
|
||||
Containers {
|
||||
world: &self.world,
|
||||
behaviours: &self.res.behaviours,
|
||||
items: &self.res.items,
|
||||
behaviours: self.res.behaviours(),
|
||||
items: self.res.items(),
|
||||
registry: self.pack.assets.registry,
|
||||
brewing: Some(&self.res.stations.brewing),
|
||||
brewing: Some(&self.res.stations().brewing),
|
||||
bone_meal: bone_meal(),
|
||||
}
|
||||
}
|
||||
@@ -502,7 +502,7 @@ impl Game<'_> {
|
||||
pub(super) fn tick_hopper(&mut self, pos: Pos) {
|
||||
let hopper = self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(pos.0, pos.1, pos.2))
|
||||
.name
|
||||
.as_ref()
|
||||
@@ -626,12 +626,12 @@ impl Game<'_> {
|
||||
return false;
|
||||
}
|
||||
let above_state = self.world.block(above.0, above.1, above.2);
|
||||
let blocked = self.res.facts.get(above_state).full_collision
|
||||
let blocked = self.res.facts().get(above_state).full_collision
|
||||
&& !self
|
||||
.res
|
||||
.behaviours
|
||||
.behaviours()
|
||||
.tag("minecraft:does_not_block_hoppers")
|
||||
.is_some_and(|t| t.contains(self.res.behaviours.block(above_state)));
|
||||
.is_some_and(|t| t.contains(self.res.behaviours().block(above_state)));
|
||||
if blocked {
|
||||
return false;
|
||||
}
|
||||
@@ -678,7 +678,7 @@ impl Game<'_> {
|
||||
/// `DispenserBlock.dispenseFrom` / `DropperBlock.dispenseFrom`.
|
||||
pub(super) fn dispense_from(&mut self, pos: BlockPos, state: BlockStateId) -> Result<()> {
|
||||
let key = (pos.x, pos.y, pos.z);
|
||||
let name = self.res.facts.get(state).name.clone();
|
||||
let name = self.res.facts().get(state).name.clone();
|
||||
if &*name == "minecraft:crafter" {
|
||||
return self.crafter_dispense(pos, state);
|
||||
}
|
||||
@@ -775,7 +775,7 @@ impl Game<'_> {
|
||||
.then_some(Screen::Hopper);
|
||||
}
|
||||
let state = self.world.block(key.0, key.1, key.2);
|
||||
match &*self.res.facts.get(state).name {
|
||||
match &*self.res.facts().get(state).name {
|
||||
"minecraft:hopper" => Some(Screen::Hopper),
|
||||
"minecraft:dispenser" => Some(Screen::Dispenser),
|
||||
"minecraft:dropper" => Some(Screen::Dropper),
|
||||
@@ -832,7 +832,7 @@ impl Game<'_> {
|
||||
let Some(screen) = self.machine_screen() else {
|
||||
return false;
|
||||
};
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let key_is_cart = self
|
||||
.container
|
||||
.is_some_and(|k| k.1 == super::minecarts::CART_KEY_Y);
|
||||
|
||||
@@ -94,7 +94,7 @@ impl Game<'_> {
|
||||
// RecipeCache.get: the first crafting recipe that matches, assembled.
|
||||
let found = self
|
||||
.res
|
||||
.recipes
|
||||
.recipes()
|
||||
.find(&grid, 3)
|
||||
.map(|(name, result)| (name.to_owned(), result))
|
||||
.filter(|(_, result)| result.count > 0);
|
||||
@@ -120,7 +120,7 @@ impl Game<'_> {
|
||||
horizon_world::level::flags::UPDATE_CLIENTS,
|
||||
);
|
||||
// The remainders come from the grid as it was before anything moved.
|
||||
let remainders = self.res.recipes.remainders(&recipe, &grid, 3);
|
||||
let remainders = self.res.recipes().remainders(&recipe, &grid, 3);
|
||||
self.crafter_eject(key, facing, result, &recipe);
|
||||
for rest in remainders.into_iter().flatten() {
|
||||
self.crafter_eject(key, facing, rest, &recipe);
|
||||
@@ -202,7 +202,7 @@ impl Game<'_> {
|
||||
pub(in crate::game) fn crafter_result(&self) -> Option<ItemStack> {
|
||||
let key = self.container?;
|
||||
let c = self.crafter_at(key)?;
|
||||
self.res.recipes.craft(&c.items, 3)
|
||||
self.res.recipes().craft(&c.items, 3)
|
||||
}
|
||||
fn crafter_open(&self) -> bool {
|
||||
matches!(self.container_kind(), Some(BlockEntity::Crafter(_)))
|
||||
@@ -243,7 +243,7 @@ impl Game<'_> {
|
||||
// The background goes first, then the labels, then the slot decorations.
|
||||
let (background, rest) = draws.split_at(2.min(draws.len()));
|
||||
self.paint_screen(batch, ox, oy, background, true);
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let grey = rgba(64, 64, 64, 255);
|
||||
let title = self.container_title(self.translate("container.crafter", "Crafter"));
|
||||
let tw = HudBatch::text_width(atlas, &title);
|
||||
|
||||
@@ -673,17 +673,18 @@ impl Game<'_> {
|
||||
} else {
|
||||
loop {
|
||||
y -= 1;
|
||||
color = self.res.facts.get(self.world.block(x, y, z)).map_color;
|
||||
color =
|
||||
self.res.facts().get(self.world.block(x, y, z)).map_color;
|
||||
if color != 0 || y <= min_y {
|
||||
break;
|
||||
}
|
||||
}
|
||||
let f = self.res.facts.get(self.world.block(x, y, z));
|
||||
let f = self.res.facts().get(self.world.block(x, y, z));
|
||||
if y > min_y && f.fluid != Fluid::None {
|
||||
let mut solid = y - 1;
|
||||
loop {
|
||||
let below =
|
||||
self.res.facts.get(self.world.block(x, solid, z));
|
||||
self.res.facts().get(self.world.block(x, solid, z));
|
||||
solid -= 1;
|
||||
water_depth += 1;
|
||||
if solid <= min_y || below.fluid == Fluid::None {
|
||||
@@ -789,6 +790,7 @@ impl Game<'_> {
|
||||
}
|
||||
let slot = self.maps.slots.last()?.1;
|
||||
let rect = self
|
||||
.gui
|
||||
.atlas
|
||||
.sprites
|
||||
.get(&format!("horizon/map{slot}"))
|
||||
@@ -797,7 +799,7 @@ impl Game<'_> {
|
||||
if m.texture_dirty {
|
||||
m.texture_dirty = false;
|
||||
let rgba: Vec<u8> = m.colors.iter().flat_map(|&c| packed_rgba(c)).collect();
|
||||
let (w, h) = (self.atlas.width as f32, self.atlas.height as f32);
|
||||
let (w, h) = (self.gui.atlas.width as f32, self.gui.atlas.height as f32);
|
||||
self.map_patches.push(horizon_client::font::Patch {
|
||||
x: (rect.u0 * w).round() as u32,
|
||||
y: (rect.v0 * h).round() as u32,
|
||||
@@ -855,7 +857,7 @@ impl Game<'_> {
|
||||
.map(|m| m.decorations.clone())
|
||||
.unwrap_or_default();
|
||||
for (i, d) in decorations.iter().enumerate() {
|
||||
let Some(s) = self.atlas.sprites.get(d.sprite).copied() else {
|
||||
let Some(s) = self.gui.atlas.sprites.get(d.sprite).copied() else {
|
||||
continue;
|
||||
};
|
||||
let dm = glam::Mat4::from_translation(glam::Vec3::new(
|
||||
@@ -931,7 +933,7 @@ impl Game<'_> {
|
||||
} else {
|
||||
"map/map_background"
|
||||
};
|
||||
if let Some(r) = self.atlas.sprites.get(background).copied() {
|
||||
if let Some(r) = self.gui.atlas.sprites.get(background).copied() {
|
||||
for (c, uv) in [
|
||||
([-7.0, 135.0, 0.0], [r.u0, r.v1]),
|
||||
([135.0, 135.0, 0.0], [r.u1, r.v1]),
|
||||
|
||||
@@ -218,7 +218,7 @@ impl CartModels {
|
||||
impl Game<'_> {
|
||||
pub(super) fn rail(&self, x: i32, y: i32, z: i32) -> Option<Rail> {
|
||||
let state = self.world.block(x, y, z);
|
||||
let name = self.res.facts.get(state).name.clone();
|
||||
let name = self.res.facts().get(state).name.clone();
|
||||
if !matches!(
|
||||
&*name,
|
||||
"minecraft:rail"
|
||||
@@ -247,11 +247,14 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
fn conductor(&self, x: i32, y: i32, z: i32) -> bool {
|
||||
self.res.facts.get(self.world.block(x, y, z)).full_collision
|
||||
self.res
|
||||
.facts()
|
||||
.get(self.world.block(x, y, z))
|
||||
.full_collision
|
||||
}
|
||||
fn cart_in_water(&self, c: &Minecart) -> bool {
|
||||
let p = c.position;
|
||||
let f = self.res.facts.get(self.world.block(
|
||||
let f = self.res.facts().get(self.world.block(
|
||||
p.x.floor() as i32,
|
||||
(p.y + 0.1).floor() as i32,
|
||||
p.z.floor() as i32,
|
||||
@@ -661,7 +664,7 @@ impl Game<'_> {
|
||||
stack.count = 0;
|
||||
}
|
||||
Some(s) if s.same_item_same_components(&stack) => {
|
||||
let max = self.res.items.get(&s.item).map_or(64, |i| i.max_stack);
|
||||
let max = self.res.items().get(&s.item).map_or(64, |i| i.max_stack);
|
||||
let moved = stack.count.min(max.saturating_sub(s.count));
|
||||
s.count += moved;
|
||||
stack.count -= moved;
|
||||
@@ -889,9 +892,9 @@ impl Game<'_> {
|
||||
(-1, 1),
|
||||
] {
|
||||
let (x, y, z) = (bx + dx, by + dy, bz + dz);
|
||||
let below = self.res.facts.get(self.world.block(x, y - 1, z));
|
||||
let here = self.res.facts.get(self.world.block(x, y, z));
|
||||
let head = self.res.facts.get(self.world.block(x, y + 1, z));
|
||||
let below = self.res.facts().get(self.world.block(x, y - 1, z));
|
||||
let here = self.res.facts().get(self.world.block(x, y, z));
|
||||
let head = self.res.facts().get(self.world.block(x, y + 1, z));
|
||||
if (below.full_collision || below.legacy_solid)
|
||||
&& !here.full_collision
|
||||
&& !head.full_collision
|
||||
@@ -1156,7 +1159,7 @@ impl Game<'_> {
|
||||
diffuse: bool,
|
||||
out: &mut Vec<Vertex>,
|
||||
) {
|
||||
let Ok(models) = self.pack.assets.model_catalog.collect_seeded(state, seed) else {
|
||||
let Ok(models) = self.pack.render.model_catalog.collect_seeded(state, seed) else {
|
||||
return;
|
||||
};
|
||||
for (_, model) in &models {
|
||||
@@ -1165,7 +1168,7 @@ impl Game<'_> {
|
||||
.pack
|
||||
.layer_names
|
||||
.get(&face.layer)
|
||||
.and_then(|n| self.atlas.sprites.get(n))
|
||||
.and_then(|n| self.gui.atlas.sprites.get(n))
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
@@ -1239,6 +1242,7 @@ impl Game<'_> {
|
||||
pub(super) fn cart_geometry(&self, camera: glam::DVec3, alpha: f64, out: &mut Vec<Vertex>) {
|
||||
let a = alpha as f32;
|
||||
let Some(uv) = self
|
||||
.gui
|
||||
.atlas
|
||||
.sprites
|
||||
.get("entity/minecart/minecart")
|
||||
@@ -1382,15 +1386,15 @@ impl Game<'_> {
|
||||
game_time: self.world.game_time,
|
||||
max_y: self.dim.max_y(),
|
||||
world: &self.world,
|
||||
sprites: &self.atlas.sprites,
|
||||
sprites: &self.gui.atlas.sprites,
|
||||
nether: self.dim == super::Dim::Nether,
|
||||
lid: &lid,
|
||||
sign: &|_| None,
|
||||
banner: &|_| Vec::new(),
|
||||
glyph: &|c| self.atlas.glyph_cell(c),
|
||||
glyph: &|c| self.gui.atlas.glyph_cell(c),
|
||||
};
|
||||
self.res
|
||||
.block_entity_render
|
||||
.block_entity_render()
|
||||
.render_state(&scene, state.0, m, light, out);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,10 +75,10 @@ impl Game<'_> {
|
||||
if left <= 0 {
|
||||
return;
|
||||
}
|
||||
let Some(kind) = self.res.mob_types.get("minecraft:elder_guardian") else {
|
||||
let Some(kind) = self.res.mob_types().get("minecraft:elder_guardian") else {
|
||||
return;
|
||||
};
|
||||
let Some(r) = self.atlas.sprites.get("entity/guardian_elder").copied() else {
|
||||
let Some(r) = self.gui.atlas.sprites.get("entity/guardian_elder").copied() else {
|
||||
return;
|
||||
};
|
||||
let age = (APPARITION_TICKS - left) as f32 + alpha as f32;
|
||||
@@ -142,12 +142,12 @@ impl Game<'_> {
|
||||
return;
|
||||
};
|
||||
let Some(head) =
|
||||
render::part_transform(mob, alpha as f32, camera, &self.res.mob_data, "head")
|
||||
render::part_transform(mob, alpha as f32, camera, self.res.mob_data(), "head")
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let m = banner_matrix(head);
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let uv = |name: &str| atlas.sprites.get(name).map(|r| [r.u0, r.v0, r.u1, r.v1]);
|
||||
// BannerRenderer: the flag sways with a per-banner phase.
|
||||
let phase =
|
||||
@@ -187,7 +187,7 @@ impl Game<'_> {
|
||||
) {
|
||||
for (corners, shade, side) in FACES {
|
||||
let name = cube.sprites[usize::from(side)];
|
||||
let Some(r) = self.atlas.sprites.get(name).copied() else {
|
||||
let Some(r) = self.gui.atlas.sprites.get(name).copied() else {
|
||||
continue;
|
||||
};
|
||||
let tint = if side == 0 { cube.tint } else { 0xFF_FFFF };
|
||||
@@ -261,7 +261,7 @@ impl Game<'_> {
|
||||
let Some(item) = item else { continue };
|
||||
let left = off_hand != mob.extra.main_hand_left;
|
||||
let Some(t) =
|
||||
render::held_item_transform(mob, alpha as f32, camera, &self.res.mob_data, left)
|
||||
render::held_item_transform(mob, alpha as f32, camera, self.res.mob_data(), left)
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
|
||||
@@ -91,9 +91,9 @@ impl Game<'_> {
|
||||
let cost = random
|
||||
.next_int_between_inclusive(MIN_COST, top)
|
||||
.unwrap_or(MIN_COST);
|
||||
let e = &self.res.stations.enchantments;
|
||||
let e = &self.res.stations().enchantments;
|
||||
let pool = e.tag("minecraft:on_mob_spawn_equipment");
|
||||
let picked = e.select(&self.res.items, random, item, cost, pool);
|
||||
let picked = e.select(self.res.items(), random, item, cost, pool);
|
||||
if let Some(m) = self.mobs.iter_mut().find(|m| m.id == id) {
|
||||
for (enchantment, level) in picked {
|
||||
gear::upgrade(m, slot, &enchantment, level);
|
||||
|
||||
@@ -284,7 +284,7 @@ impl Game<'_> {
|
||||
let focused = self.screen == Screen::Chat;
|
||||
self.ui
|
||||
.chat
|
||||
.add(&self.atlas, line, None, self.ticks, focused);
|
||||
.add(&self.gui.atlas, line, None, self.ticks, focused);
|
||||
}
|
||||
}
|
||||
/// The mods' HUD panels, stacked with the extras in their corners.
|
||||
@@ -305,7 +305,7 @@ impl Game<'_> {
|
||||
.iter()
|
||||
.map(|l| (l.text.as_str(), l.color))
|
||||
.collect();
|
||||
extras_hud::draw_lines(batch, &self.atlas, corners, corner, &lines);
|
||||
extras_hud::draw_lines(batch, &self.gui.atlas, corners, corner, &lines);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ impl Game<'_> {
|
||||
let Some(open) = self.mount_menu.open.as_ref() else {
|
||||
return;
|
||||
};
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
batch.sprite_region(
|
||||
atlas,
|
||||
"gui/container/horse",
|
||||
@@ -376,7 +376,7 @@ impl Game<'_> {
|
||||
m.hurt_time = 0;
|
||||
m.death_time = 0;
|
||||
let camera = glam::DVec3::new(m.position.x, m.position.y, m.position.z);
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let lookup = |name: &str| atlas.sprites.get(name).map(|r| [r.u0, r.v0, r.u1, r.v1]);
|
||||
let mut verts = Vec::new();
|
||||
horizon_client::mobs::render::render_with(
|
||||
@@ -385,7 +385,7 @@ impl Game<'_> {
|
||||
camera,
|
||||
&lookup,
|
||||
240 | 240 << 8,
|
||||
&self.res.mob_data,
|
||||
self.res.mob_data(),
|
||||
&[],
|
||||
&mut verts,
|
||||
);
|
||||
|
||||
@@ -90,7 +90,11 @@ impl Game<'_> {
|
||||
&& let Some(stack) = self.inventory[self.selected].as_mut()
|
||||
{
|
||||
stack.damage += wear;
|
||||
let max = self.res.items.get(&stack.item).map_or(25, |i| i.max_damage);
|
||||
let max = self
|
||||
.res
|
||||
.items()
|
||||
.get(&stack.item)
|
||||
.map_or(25, |i| i.max_damage);
|
||||
if stack.damage >= max {
|
||||
self.inventory[self.selected] = Some(ItemStack::new("minecraft:fishing_rod", 1));
|
||||
}
|
||||
@@ -406,7 +410,7 @@ impl Game<'_> {
|
||||
.find(|c| {
|
||||
let f = |dy: i32| {
|
||||
self.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(
|
||||
c.x.floor() as i32,
|
||||
c.y.floor() as i32 + dy,
|
||||
@@ -457,7 +461,7 @@ impl Game<'_> {
|
||||
return (0, false);
|
||||
};
|
||||
let m = &self.mobs[i];
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let hearts = horizon_client::hud_layout::vehicle_max_hearts(m.attrs.max_health);
|
||||
let draws = horizon_client::hud_layout::vehicle_health(w, h, hearts, m.health);
|
||||
horizon_client::hud_layout::paint(batch, atlas, &draws);
|
||||
|
||||
@@ -50,7 +50,7 @@ impl Game<'_> {
|
||||
let (background, probe_volume) = match eye {
|
||||
Some(eye) => {
|
||||
let (dimension, biome) = (self.dim.id(), self.biome_at(eye));
|
||||
let tables = &self.res.music;
|
||||
let tables = self.res.music();
|
||||
(
|
||||
tables.background(dimension, biome),
|
||||
tables.volume(dimension, biome),
|
||||
@@ -81,7 +81,7 @@ impl Game<'_> {
|
||||
.chunks
|
||||
.get(&(x >> 4, z >> 4))
|
||||
.map_or("minecraft:plains", |c| {
|
||||
self.res.biomes.list[c.biome(x, y, z) as usize]
|
||||
self.res.biomes().list[c.biome(x, y, z) as usize]
|
||||
.name
|
||||
.as_str()
|
||||
})
|
||||
@@ -89,11 +89,11 @@ impl Game<'_> {
|
||||
/// `isEyeInFluid(WATER)`: the eye inside the water of its block column.
|
||||
fn eye_in_water(&self, x: f64, eye_y: f64, z: f64) -> bool {
|
||||
let (bx, by, bz) = (x.floor() as i32, eye_y.floor() as i32, z.floor() as i32);
|
||||
let f = self.res.facts.get(self.world.block(bx, by, bz));
|
||||
let f = self.res.facts().get(self.world.block(bx, by, bz));
|
||||
if f.fluid != Fluid::Water {
|
||||
return false;
|
||||
}
|
||||
let above = self.res.facts.get(self.world.block(bx, by + 1, bz));
|
||||
let above = self.res.facts().get(self.world.block(bx, by + 1, bz));
|
||||
let height = if above.fluid == Fluid::Water {
|
||||
1.0
|
||||
} else {
|
||||
@@ -111,7 +111,7 @@ impl Game<'_> {
|
||||
};
|
||||
let feet = [p.position.x, p.position.y, p.position.z];
|
||||
let eye_y = feet[1] + f64::from(p.dimensions.eye_height);
|
||||
let sounds = self.res.ambient.get(self.dim.id(), self.biome_at(feet));
|
||||
let sounds = self.res.ambient().get(self.dim.id(), self.biome_at(feet));
|
||||
let underwater = self.eye_in_water(feet[0], eye_y, feet[2]);
|
||||
let world = &self.world;
|
||||
let light = |b: [i32; 3]| {
|
||||
@@ -123,7 +123,7 @@ impl Game<'_> {
|
||||
f64::from(p.dimensions.height),
|
||||
);
|
||||
let registry = &self.pack.assets.registry;
|
||||
let facts = &self.res.facts;
|
||||
let facts = self.res.facts();
|
||||
let bubble_column = horizon_client::ambience::bubble_column_in(
|
||||
[
|
||||
feet[0] - half,
|
||||
|
||||
@@ -218,7 +218,7 @@ impl Game<'_> {
|
||||
let forward = glam::DVec3::from_array(view_vector(self.yaw, self.pitch));
|
||||
let right = forward.cross(glam::DVec3::Y).normalize_or_zero();
|
||||
let up = right.cross(forward).normalize_or_zero();
|
||||
let white = self.atlas.font.white();
|
||||
let white = self.gui.atlas.font.white();
|
||||
let away = forward.as_vec3() * 0.002;
|
||||
for (text, lift) in lines {
|
||||
let o = (o + glam::DVec3::new(0.0, *lift, 0.0)).as_vec3();
|
||||
@@ -240,7 +240,7 @@ impl Game<'_> {
|
||||
.collect();
|
||||
let width: f32 = chars
|
||||
.iter()
|
||||
.map(|(c, _)| self.atlas.glyph(*c).map_or(6.0, |g| g.1))
|
||||
.map(|(c, _)| self.gui.atlas.glyph(*c).map_or(6.0, |g| g.1))
|
||||
.sum();
|
||||
let x0 = -(width / 2.0).trunc();
|
||||
let y0 = if text.plain() == "deadmau5" {
|
||||
@@ -278,7 +278,7 @@ impl Game<'_> {
|
||||
}
|
||||
let mut x = x0;
|
||||
for (ch, color) in chars {
|
||||
let Some((g, advance)) = self.atlas.glyph(ch) else {
|
||||
let Some((g, advance)) = self.gui.atlas.glyph(ch) else {
|
||||
x += 6.0;
|
||||
continue;
|
||||
};
|
||||
|
||||
@@ -35,7 +35,7 @@ pub(super) struct GameLevel<'g, 'a> {
|
||||
impl GameLevel<'_, '_> {
|
||||
fn biome(&self, x: i32, y: i32, z: i32) -> Option<&BiomeInfo> {
|
||||
let chunk = self.game.world.chunks.get(&(x >> 4, z >> 4))?;
|
||||
Some(self.game.res.biomes.get(chunk.biome(x, y, z)))
|
||||
Some(self.game.res.biomes().get(chunk.biome(x, y, z)))
|
||||
}
|
||||
}
|
||||
impl SpawnLevel for GameLevel<'_, '_> {
|
||||
@@ -106,7 +106,7 @@ impl NaturalLevel for GameLevel<'_, '_> {
|
||||
self.game.dim == Dim::Nether
|
||||
}
|
||||
fn mob_type(&self, entity: &str) -> Option<(Species, f32, f32, Category)> {
|
||||
let t = self.game.res.mob_types.get(entity)?;
|
||||
let t = self.game.res.mob_types().get(entity)?;
|
||||
Some((
|
||||
t.species,
|
||||
t.width as f32,
|
||||
@@ -238,7 +238,7 @@ impl horizon_client::mobs::spawner::SpawnerLevel for GameLevel<'_, '_> {
|
||||
self.game.ui.rules.bool("spawner_blocks_work")
|
||||
}
|
||||
fn entity_exists(&self, id: &str) -> bool {
|
||||
self.game.res.mob_types.contains_key(id) || self.game.entity_type_exists(id)
|
||||
self.game.res.mob_types().contains_key(id) || self.game.entity_type_exists(id)
|
||||
}
|
||||
fn count_entities(&self, id: &str, bounds: Aabb) -> usize {
|
||||
let mobs = self
|
||||
@@ -268,7 +268,7 @@ impl<'a> Game<'a> {
|
||||
/// Creates a mob the spawner accepted, finalized the game's way; the
|
||||
/// caller adds it with [`Game::add_spawned`].
|
||||
fn finalize_spawned(&self, r: &SpawnRequest, pending: &mut Vec<Mob>) -> Option<Spawned> {
|
||||
let kind = self.res.mob_types.get(r.entity)?.clone();
|
||||
let kind = self.res.mob_types().get(r.entity)?.clone();
|
||||
let [x, y, z] = r.position;
|
||||
let mut mob = Mob::new(0, kind, Vec3::new(x, y, z), r.yaw);
|
||||
let facts = self.biome_facts(x.floor() as i32, y.floor() as i32, z.floor() as i32);
|
||||
|
||||
@@ -11,7 +11,7 @@ use horizon_core::random::RandomSource;
|
||||
impl Game<'_> {
|
||||
fn item_tagged(&self, tag: &str, item: &str) -> bool {
|
||||
self.res
|
||||
.items
|
||||
.items()
|
||||
.item_tags
|
||||
.get(tag)
|
||||
.is_some_and(|t| t.contains(item))
|
||||
@@ -43,7 +43,7 @@ impl Game<'_> {
|
||||
}
|
||||
let taming: Vec<String> = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.item_tags
|
||||
.get("minecraft:nautilus_taming_items")
|
||||
.map(|t| t.iter().cloned().collect())
|
||||
|
||||
@@ -114,7 +114,7 @@ impl Game<'_> {
|
||||
Dim::Nether
|
||||
};
|
||||
let state = self.world.block(entry.x, entry.y, entry.z);
|
||||
let b = &self.res.behaviours;
|
||||
let b = self.res.behaviours();
|
||||
let (entry_x_axis, offset) = match b.portal_axis(state) {
|
||||
Some(x_axis) => {
|
||||
let area = largest_rectangle_around(
|
||||
@@ -152,7 +152,7 @@ impl Game<'_> {
|
||||
/// (the points of interest `PortalForcer` searches): loaded chunks as
|
||||
/// they are, the others as saved; chunks never generated have none.
|
||||
fn portal_blocks(&self, center: BlockPos, radius: i32) -> Vec<BlockPos> {
|
||||
let b = &self.res.behaviours;
|
||||
let b = self.res.behaviours();
|
||||
let chunk_radius = radius.div_euclid(16) + 1;
|
||||
let (cx, cz) = (center.x >> 4, center.z >> 4);
|
||||
let mut out = Vec::new();
|
||||
@@ -163,7 +163,7 @@ impl Game<'_> {
|
||||
Some(c) => &**c,
|
||||
None => match self
|
||||
.save
|
||||
.load(x, z, self.pack.assets.registry, &self.res.biomes)
|
||||
.load(x, z, self.pack.assets.registry, self.res.biomes())
|
||||
{
|
||||
Some(c) => {
|
||||
saved = c;
|
||||
@@ -213,7 +213,7 @@ impl Game<'_> {
|
||||
);
|
||||
if let Some(found) = found {
|
||||
let state = self.world.block(found.x, found.y, found.z);
|
||||
let x_axis = self.res.behaviours.portal_axis(state).unwrap_or(true);
|
||||
let x_axis = self.res.behaviours().portal_axis(state).unwrap_or(true);
|
||||
return Some(largest_rectangle_around(
|
||||
found,
|
||||
if x_axis { Axis::X } else { Axis::Z },
|
||||
@@ -234,7 +234,7 @@ impl Game<'_> {
|
||||
/// `NetherPortalBlock.createDimensionTransition`: the arrival position
|
||||
/// and the yaw turned by.
|
||||
pub(super) fn arrival(&self, plan: &Plan, exit: FoundRectangle) -> (Vec3, f32) {
|
||||
let b = &self.res.behaviours;
|
||||
let b = self.res.behaviours();
|
||||
let corner = exit.min_corner;
|
||||
let exit_x_axis = b
|
||||
.portal_axis(self.world.block(corner.x, corner.y, corner.z))
|
||||
@@ -540,7 +540,7 @@ impl Game<'_> {
|
||||
|p, _| {
|
||||
if self
|
||||
.res
|
||||
.behaviours
|
||||
.behaviours()
|
||||
.portal_axis(self.world.block(p.x, p.y, p.z))
|
||||
.is_some()
|
||||
{
|
||||
@@ -584,7 +584,7 @@ impl Game<'_> {
|
||||
for sy in y0..=y1 {
|
||||
y_mask |= 1 << sy;
|
||||
}
|
||||
let behaviours = &self.res.behaviours;
|
||||
let behaviours = self.res.behaviours();
|
||||
let chunks = &self.world.chunks;
|
||||
(x0..=x1).any(|cx| {
|
||||
(z0..=z1).any(|cz| {
|
||||
|
||||
@@ -111,7 +111,7 @@ impl Game<'_> {
|
||||
}
|
||||
pub(super) fn draw_options(&mut self, batch: &mut HudBatch) {
|
||||
let mut ui = std::mem::take(&mut self.ui.options);
|
||||
ui.draw(&self.settings, batch, &self.atlas, self.cursor);
|
||||
ui.draw(&self.settings, batch, &self.gui.atlas, self.cursor);
|
||||
self.ui.options = ui;
|
||||
}
|
||||
pub(super) fn options_mouse(&mut self, pressed: bool, right: bool) -> Result<()> {
|
||||
@@ -133,7 +133,7 @@ impl Game<'_> {
|
||||
let mut ui = std::mem::take(&mut self.ui.options);
|
||||
let events = ui.click(
|
||||
&mut self.settings,
|
||||
&self.atlas,
|
||||
&self.gui.atlas,
|
||||
self.cursor.0,
|
||||
self.cursor.1,
|
||||
size,
|
||||
@@ -152,7 +152,7 @@ impl Game<'_> {
|
||||
let mut ui = std::mem::take(&mut self.ui.options);
|
||||
let events = ui.click(
|
||||
&mut self.settings,
|
||||
&self.atlas,
|
||||
&self.gui.atlas,
|
||||
self.cursor.0,
|
||||
self.cursor.1,
|
||||
size,
|
||||
@@ -165,7 +165,7 @@ impl Game<'_> {
|
||||
}
|
||||
pub(super) fn options_key(&mut self, key: KeyCode, text: Option<&str>) -> Result<()> {
|
||||
let mut ui = std::mem::take(&mut self.ui.options);
|
||||
let events = ui.key(&mut self.settings, &self.atlas, key, text);
|
||||
let events = ui.key(&mut self.settings, &self.gui.atlas, key, text);
|
||||
self.ui.options = ui;
|
||||
self.handle_option_events(events)
|
||||
}
|
||||
@@ -176,7 +176,7 @@ impl Game<'_> {
|
||||
) -> bool {
|
||||
self.ui
|
||||
.options
|
||||
.shortcut(&self.atlas, shortcut, &mut self.clipboard)
|
||||
.shortcut(&self.gui.atlas, shortcut, &mut self.clipboard)
|
||||
}
|
||||
pub(super) fn options_scroll(&mut self, amount: f32) {
|
||||
let size = self.gui_size();
|
||||
@@ -238,7 +238,7 @@ impl Game<'_> {
|
||||
pub(super) fn load_language(&mut self, code: &str) {
|
||||
let root = self.options.resources.clone();
|
||||
lang::set(lang::Language::load(&[&root], code));
|
||||
self.ui.chat.rescale(&self.atlas);
|
||||
self.ui.chat.rescale(&self.gui.atlas);
|
||||
}
|
||||
/// Settings that Horizon applies beyond render distance, volume and GUI scale.
|
||||
pub(super) fn apply_ui_settings(&mut self) {
|
||||
@@ -269,14 +269,14 @@ impl Game<'_> {
|
||||
};
|
||||
self.ui.chat.options = chat;
|
||||
if rescale {
|
||||
self.ui.chat.rescale(&self.atlas);
|
||||
self.ui.chat.rescale(&self.gui.atlas);
|
||||
}
|
||||
let font = &mut self.atlas.font;
|
||||
let font = &mut self.gui.atlas.font;
|
||||
if font.uniform != s.force_unicode || font.japanese != s.japanese_glyphs {
|
||||
font.uniform = s.force_unicode;
|
||||
font.japanese = s.japanese_glyphs;
|
||||
font.reset_cache();
|
||||
self.ui.chat.rescale(&self.atlas);
|
||||
self.ui.chat.rescale(&self.gui.atlas);
|
||||
}
|
||||
// A new renderer (resource reload, first window) takes the loaded pack.
|
||||
let stale = self
|
||||
|
||||
@@ -74,6 +74,15 @@ fn vanilla_info() -> PackInfo {
|
||||
fixed: false,
|
||||
}
|
||||
}
|
||||
/// Shared by the startup menu, which has no world resources yet.
|
||||
pub(super) fn pack_infos(vanilla: &Path) -> Vec<PackInfo> {
|
||||
let mut infos: Vec<PackInfo> = packs::discover(vanilla, &packs_dir())
|
||||
.iter()
|
||||
.map(info)
|
||||
.collect();
|
||||
infos.push(vanilla_info());
|
||||
infos
|
||||
}
|
||||
impl Game<'_> {
|
||||
fn vanilla_root(&self) -> PathBuf {
|
||||
if self.ui.vanilla_root.as_os_str().is_empty() {
|
||||
@@ -85,9 +94,7 @@ impl Game<'_> {
|
||||
/// The packs the pack screen offers and the current selection
|
||||
/// (`PackSelectionScreen` makes its `PackSelectionModel` from them).
|
||||
pub(super) fn refresh_pack_lists(&mut self) {
|
||||
let all = packs::discover(&self.vanilla_root(), &packs_dir());
|
||||
let mut infos: Vec<PackInfo> = all.iter().map(info).collect();
|
||||
infos.push(vanilla_info());
|
||||
let infos = pack_infos(&self.vanilla_root());
|
||||
let o = &mut self.ui.options;
|
||||
o.pack_infos = infos;
|
||||
o.pack_selection = self.settings.resource_packs.clone();
|
||||
@@ -100,6 +107,12 @@ impl Game<'_> {
|
||||
/// particle and font textures), item models, sounds, languages, GUI
|
||||
/// metadata and the cloud and world border textures.
|
||||
pub(super) fn reload_packs(&mut self) {
|
||||
// Pack reload updates tail-owned mob metadata. Keep menus responsive
|
||||
// until those resources exist, then apply the latest selection once.
|
||||
if self.rest_loader.is_some() {
|
||||
self.pending_pack_reload = true;
|
||||
return;
|
||||
}
|
||||
let vanilla = self.vanilla_root();
|
||||
if self.ui.vanilla_root.as_os_str().is_empty() {
|
||||
self.ui.vanilla_root = vanilla.clone();
|
||||
@@ -119,14 +132,19 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
fn reload_resources(&mut self, root: &Path) -> horizon_client::Result<()> {
|
||||
let assets = std::sync::Arc::new(self.pack.assets.reload(root)?);
|
||||
let render = std::sync::Arc::new(self.pack.assets.reload(root)?);
|
||||
let mut atlas = HudAtlas::build(root)?;
|
||||
atlas.font.uniform = self.settings.force_unicode;
|
||||
atlas.font.japanese = self.settings.japanese_glyphs;
|
||||
let gui = super::UiResources {
|
||||
atlas,
|
||||
panorama: std::sync::Arc::new(horizon_client::gfx::panorama::Faces::load(root)),
|
||||
};
|
||||
let pack = super::PackResources::load(
|
||||
root,
|
||||
assets,
|
||||
&self.res.facts,
|
||||
self.pack.assets.clone(),
|
||||
render,
|
||||
self.res.facts(),
|
||||
self.pack.context.biomes.clone(),
|
||||
self.pack.context.light.clone(),
|
||||
)?;
|
||||
@@ -137,7 +155,7 @@ impl Game<'_> {
|
||||
let renderer = match self
|
||||
.window
|
||||
.clone()
|
||||
.map(|window| self.renderer_for(window, &pack, &atlas))
|
||||
.map(|window| self.renderer_for(window, &pack, &gui))
|
||||
.transpose()
|
||||
{
|
||||
Ok(renderer) => renderer,
|
||||
@@ -158,12 +176,12 @@ impl Game<'_> {
|
||||
self.options.resources = root.to_path_buf();
|
||||
let context = pack.context.clone();
|
||||
self.pack = pack;
|
||||
self.atlas = atlas;
|
||||
self.gui = gui;
|
||||
horizon_client::ui_theme::reset_atlas();
|
||||
// Villager hats come from the pack's texture metadata (shared data, swapped in place).
|
||||
*self
|
||||
.res
|
||||
.mob_data
|
||||
.mob_data()
|
||||
.villager_hats
|
||||
.write()
|
||||
.unwrap_or_else(std::sync::PoisonError::into_inner) =
|
||||
@@ -179,7 +197,7 @@ impl Game<'_> {
|
||||
self.renderer = Some(renderer);
|
||||
self.apply_ui_settings();
|
||||
}
|
||||
self.ui.chat.rescale(&self.atlas);
|
||||
self.ui.chat.rescale(&self.gui.atlas);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user