Split Resources into shared read-only data and per-game pack state
Resources now holds only what is loaded once and never changes (blocks, items, recipes, biomes, mobs, collision, motion) and is Send + Sync behind an Arc, so an integrated server thread can share it with the client. What a resource pack reload replaces moves to PackResources (assets, meshing context, item renderer, names, panorama, clouds, forcefield), built by one loader used at startup and on reload. The client-only mutable state (the HUD atlas with its font cache and skin slots, fog state, screen effects) becomes the game's own fields. No behaviour change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -119,22 +119,6 @@ impl FogState {
|
||||
}
|
||||
}
|
||||
|
||||
/// The fog tables and evolving state kept by the game.
|
||||
pub struct FogRenderer {
|
||||
pub tables: FogTables,
|
||||
pub state: FogState,
|
||||
}
|
||||
impl FogRenderer {
|
||||
pub fn load(root: &Path, biomes: &Biomes) -> Self {
|
||||
Self {
|
||||
tables: FogTables::load(root, biomes),
|
||||
state: FogState::default(),
|
||||
}
|
||||
}
|
||||
pub fn setup(&self, input: &FogInputs) -> FogData {
|
||||
setup_fog(&self.tables, &self.state, input)
|
||||
}
|
||||
}
|
||||
/// `FluidState.getHeightForCamera`.
|
||||
fn camera_fluid_height(world: &World, facts: &BlockFacts, b: [i32; 3]) -> Option<(Fluid, f64)> {
|
||||
let s = facts.get(world.block(b[0], b[1], b[2]));
|
||||
|
||||
+188
-161
@@ -645,43 +645,91 @@ struct FallingBlock {
|
||||
/// The UUID and compound it was loaded with, kept while it moves.
|
||||
saved: Option<Box<([i32; 4], horizon_world::nbt::Tag)>>,
|
||||
}
|
||||
/// The data loaded once at startup and never changed: blocks, items,
|
||||
/// recipes, biomes, mobs, collision and motion. Read-only and `Send + Sync`,
|
||||
/// so the client and an integrated server thread can share one copy.
|
||||
pub struct Resources {
|
||||
assets: Arc<Assets>,
|
||||
facts: BlockFacts,
|
||||
items: Items,
|
||||
recipes: Recipes,
|
||||
transformers: horizon_client::block_transform::Transformers,
|
||||
biomes: Arc<Biomes>,
|
||||
environment: Environment,
|
||||
atlas: HudAtlas,
|
||||
panorama: horizon_client::gfx::panorama::Faces,
|
||||
layer_names: HashMap<u32, String>,
|
||||
mob_types: HashMap<String, Arc<MobType>>,
|
||||
mob_data: horizon_client::mobs::MobData,
|
||||
providers: Providers,
|
||||
block_entity_render: horizon_client::block_entity_render::BlockEntityRenderer,
|
||||
animate: horizon_client::animate_tick::AnimateTables,
|
||||
fog: horizon_client::fog::FogRenderer,
|
||||
fog: horizon_client::fog::FogTables,
|
||||
music: horizon_client::music::MusicTables,
|
||||
ambient: horizon_client::ambience::AmbientTables,
|
||||
screen_fx: horizon_client::screen_effects::ScreenEffects,
|
||||
nether_environment: Environment,
|
||||
end_environment: Environment,
|
||||
behaviours: Behaviours,
|
||||
names: Names,
|
||||
/// clouds.png: (width, height, filled cells).
|
||||
clouds: (u32, u32, Vec<bool>),
|
||||
/// misc/forcefield.png: (width, height, RGBA) for the world border wall.
|
||||
forcefield: (u32, u32, Vec<u8>),
|
||||
context: Arc<WorkerContext>,
|
||||
collision: BlockCollisionRegistry<'static>,
|
||||
motion: MotionResources,
|
||||
threads: usize,
|
||||
player_arm: Option<horizon_client::mobs::Part>,
|
||||
player_type: Option<Arc<horizon_client::mobs::MobType>>,
|
||||
/// Item definitions, baked item models and special renderers.
|
||||
item_renderer: Arc<horizon_client::item_render::ItemRenderer>,
|
||||
/// Enchantments, workstation recipes and brewing (game/stations.rs).
|
||||
stations: horizon_client::stations::StationData,
|
||||
}
|
||||
/// What a resource pack reload replaces (`Minecraft.reloadResourcePacks`):
|
||||
/// block models and sprites with their meshing tables, item models,
|
||||
/// translations and the textures read on the CPU. Each game holds its own;
|
||||
/// cloning shares the loaded data.
|
||||
#[derive(Clone)]
|
||||
pub struct PackResources {
|
||||
assets: Arc<Assets>,
|
||||
context: Arc<WorkerContext>,
|
||||
layer_names: Arc<HashMap<u32, String>>,
|
||||
panorama: Arc<horizon_client::gfx::panorama::Faces>,
|
||||
/// Item definitions, baked item models and special renderers.
|
||||
item_renderer: Arc<horizon_client::item_render::ItemRenderer>,
|
||||
names: Arc<Names>,
|
||||
/// clouds.png: (width, height, filled cells).
|
||||
clouds: Arc<(u32, u32, Vec<bool>)>,
|
||||
/// misc/forcefield.png: (width, height, RGBA) for the world border wall.
|
||||
forcefield: Arc<(u32, u32, Vec<u8>)>,
|
||||
}
|
||||
impl PackResources {
|
||||
/// Everything a pack overlay at `root` provides, over `assets` loaded from it.
|
||||
fn load(
|
||||
root: &std::path::Path,
|
||||
assets: Arc<Assets>,
|
||||
facts: &BlockFacts,
|
||||
biomes: Arc<Biomes>,
|
||||
light: Arc<LightTables>,
|
||||
) -> Result<Self> {
|
||||
let visibility = models::load_visibility(root, assets.registry)?;
|
||||
let tables = Arc::new(MeshTables::new(&assets, facts, visibility)?);
|
||||
let item_renderer = horizon_client::item_render::ItemRenderer::load_with_library(
|
||||
root,
|
||||
assets.model_library.clone(),
|
||||
)?;
|
||||
Ok(Self {
|
||||
layer_names: Arc::new(
|
||||
assets
|
||||
.sprite_layers
|
||||
.iter()
|
||||
.map(|(name, layer)| (*layer, name.trim_start_matches("minecraft:").to_owned()))
|
||||
.collect(),
|
||||
),
|
||||
context: Arc::new(WorkerContext {
|
||||
assets: assets.clone(),
|
||||
tables,
|
||||
biomes,
|
||||
light,
|
||||
}),
|
||||
assets,
|
||||
panorama: Arc::new(horizon_client::gfx::panorama::Faces::load(root)),
|
||||
item_renderer: Arc::new(item_renderer),
|
||||
names: Arc::new(Names::load(root)),
|
||||
clouds: Arc::new(load_clouds(root)),
|
||||
forcefield: Arc::new(load_forcefield(root)),
|
||||
})
|
||||
}
|
||||
}
|
||||
/// A quick craft drag as the screen draws it: each dragged slot's count and
|
||||
/// whether the slot caps it (None: hidden), and what stays in hand.
|
||||
struct DragView {
|
||||
@@ -705,9 +753,17 @@ fn select_creative_tab(
|
||||
}
|
||||
|
||||
struct Game<'a> {
|
||||
res: &'a mut Resources,
|
||||
/// Shared with an integrated server; `collision` and `motion` borrow from it.
|
||||
res: Arc<Resources>,
|
||||
collision: &'a BlockCollisionRegistry<'a>,
|
||||
motion: &'a MotionResources,
|
||||
/// This game's resource packs (`reload_packs` replaces them).
|
||||
pack: PackResources,
|
||||
/// The GUI, font, particle, map and skin atlas.
|
||||
atlas: HudAtlas,
|
||||
/// `FogRenderer`'s evolving state.
|
||||
fog: horizon_client::fog::FogState,
|
||||
screen_fx: horizon_client::screen_effects::ScreenEffects,
|
||||
world: World,
|
||||
streaming: Streaming,
|
||||
options: Options,
|
||||
@@ -1170,7 +1226,7 @@ impl Game<'_> {
|
||||
let state = self.world.block(pos[0], pos[1], pos[2]);
|
||||
let f = self.res.facts.get(state);
|
||||
let o = if f.outline_offset {
|
||||
self.res
|
||||
self.pack
|
||||
.context
|
||||
.tables
|
||||
.offset(state, pos[0], pos[2])
|
||||
@@ -1368,7 +1424,7 @@ impl Game<'_> {
|
||||
}
|
||||
fn particle_sprite(&self, state: BlockStateId) -> Option<(String, u32)> {
|
||||
let models = self
|
||||
.res
|
||||
.pack
|
||||
.assets
|
||||
.model_catalog
|
||||
.collect(state, horizon_core::position::BlockPos::new(0, 0, 0))
|
||||
@@ -1378,7 +1434,7 @@ impl Game<'_> {
|
||||
.flat_map(|(_, m)| m.faces.iter())
|
||||
.find(|f| f.quad.facing == horizon_assets::model::Direction::Up)
|
||||
.or_else(|| models.iter().flat_map(|(_, m)| m.faces.iter()).next())?;
|
||||
let name = self.res.layer_names.get(&face.layer)?.clone();
|
||||
let name = self.pack.layer_names.get(&face.layer)?.clone();
|
||||
let tint = if face.quad.tint_index >= 0 {
|
||||
let n = &self.res.facts.get(state).name;
|
||||
if n.contains("leaves") || n.contains("vine") {
|
||||
@@ -1394,7 +1450,7 @@ impl Game<'_> {
|
||||
fn particle_shape(&self, pos: [i32; 3], state: BlockStateId) -> Vec<[f64; 6]> {
|
||||
let f = self.res.facts.get(state);
|
||||
let offset = if f.outline_offset {
|
||||
self.res
|
||||
self.pack
|
||||
.context
|
||||
.tables
|
||||
.offset(state, pos[0], pos[2])
|
||||
@@ -1467,7 +1523,7 @@ impl Game<'_> {
|
||||
state: BlockStateId,
|
||||
held: Option<&ItemStack>,
|
||||
) -> Vec<ItemStack> {
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
let dynamic = self.pending.dynamic(pos);
|
||||
match self.res.items.block_loot_sequence(registry, state) {
|
||||
Some(sequence) => {
|
||||
@@ -1548,7 +1604,7 @@ impl Game<'_> {
|
||||
let environment = item.environment_tick(
|
||||
&self.world,
|
||||
&self.res.facts,
|
||||
self.res.assets.registry,
|
||||
self.pack.assets.registry,
|
||||
&self.res.items,
|
||||
);
|
||||
// shortcut: age is the fresh-drop clock; use entity ticks for saved/frozen-age phase parity.
|
||||
@@ -1684,7 +1740,7 @@ impl Game<'_> {
|
||||
behaviours: &self.res.behaviours,
|
||||
items: &self.res.items,
|
||||
loot: horizon_client::structure_blocks::loot_data(&self.options.resources),
|
||||
registry: self.res.assets.registry,
|
||||
registry: self.pack.assets.registry,
|
||||
rules,
|
||||
rand_sequences: &mut self.rand_sequences,
|
||||
pending: &mut self.pending,
|
||||
@@ -3179,7 +3235,7 @@ impl Game<'_> {
|
||||
entities: &ghast_collisions,
|
||||
player,
|
||||
scene: &mut self.world,
|
||||
assets: &self.res.assets,
|
||||
assets: &self.pack.assets,
|
||||
collision_binding: self.collision,
|
||||
resources: self.motion,
|
||||
}
|
||||
@@ -3626,7 +3682,7 @@ impl Game<'_> {
|
||||
let (stack, capped) = match drag.and_then(|d| d.slots.get(&slot)) {
|
||||
Some(None) => return,
|
||||
Some(Some((count, capped))) => {
|
||||
batch.fill(&self.res.atlas, x, y, 16.0, 16.0, rgba(255, 255, 255, 128));
|
||||
batch.fill(&self.atlas, x, y, 16.0, 16.0, rgba(255, 255, 255, 128));
|
||||
let carried = self
|
||||
.carried
|
||||
.clone()
|
||||
@@ -3721,10 +3777,10 @@ impl Game<'_> {
|
||||
0,
|
||||
0,
|
||||
&decorations,
|
||||
&self.res.atlas.font,
|
||||
&self.atlas.font,
|
||||
));
|
||||
draws.push(hud_layout::GuiDraw::Pop);
|
||||
hud_layout::paint(batch, &self.res.atlas, &draws);
|
||||
hud_layout::paint(batch, &self.atlas, &draws);
|
||||
}
|
||||
fn hud(&mut self, size: [u32; 2]) -> HudBatch {
|
||||
let mut batch = self.hud_layers(size);
|
||||
@@ -3732,7 +3788,7 @@ impl Game<'_> {
|
||||
// and the toasts, so it is over everything, menus included.
|
||||
self.draw_debug_overlay(&mut batch, size);
|
||||
self.frame_graph
|
||||
.draw(self.settings.horizon.overlay, &mut batch, &self.res.atlas);
|
||||
.draw(self.settings.horizon.overlay, &mut batch, &self.atlas);
|
||||
self.draw_pad_cursor(&mut batch);
|
||||
batch
|
||||
}
|
||||
@@ -3753,12 +3809,12 @@ impl Game<'_> {
|
||||
if horizon_client::ui_theme::horizon() {
|
||||
let fade = self.backdrop_fade();
|
||||
let mut ui =
|
||||
horizon_client::ui_theme::Ui::new(&self.res.atlas, &mut batch, self.cursor);
|
||||
horizon_client::ui_theme::Ui::new(&self.atlas, &mut batch, self.cursor);
|
||||
title.draw_horizon(&mut ui, fade);
|
||||
ui.finish();
|
||||
} else {
|
||||
title.draw(
|
||||
&self.res.atlas,
|
||||
&self.atlas,
|
||||
&mut batch,
|
||||
self.cursor,
|
||||
self.settings.file.bool("hideSplashTexts"),
|
||||
@@ -3766,7 +3822,7 @@ impl Game<'_> {
|
||||
}
|
||||
return batch;
|
||||
}
|
||||
let atlas_ptr: *const HudAtlas = &self.res.atlas;
|
||||
let atlas_ptr: *const HudAtlas = &self.atlas;
|
||||
let _ = atlas_ptr;
|
||||
if self.remote_overlay(&mut batch) {
|
||||
return batch;
|
||||
@@ -3795,7 +3851,7 @@ impl Game<'_> {
|
||||
hud_layout::full_attack_indicator(a, delay, self.crosshair_living())
|
||||
});
|
||||
let draws = hud_layout::crosshair(wi, hi, attack, full);
|
||||
hud_layout::paint(&mut batch, &self.res.atlas, &draws);
|
||||
hud_layout::paint(&mut batch, &self.atlas, &draws);
|
||||
}
|
||||
if !spectator {
|
||||
let inputs = hud_layout::HotbarInputs {
|
||||
@@ -3807,7 +3863,7 @@ impl Game<'_> {
|
||||
attack: (indicator == 2).then_some(strength),
|
||||
};
|
||||
let draws = hud_layout::hotbar(wi, hi, &inputs);
|
||||
hud_layout::paint(&mut batch, &self.res.atlas, &draws);
|
||||
hud_layout::paint(&mut batch, &self.atlas, &draws);
|
||||
for d in &draws {
|
||||
if let hud_layout::GuiDraw::Item { slot, x, y, .. } = *d {
|
||||
let stack = if slot == 40 {
|
||||
@@ -3829,7 +3885,7 @@ impl Game<'_> {
|
||||
// Hud.extractSleepOverlay, under the sidebar, titles and chat.
|
||||
if let Some((_, ticks)) = self.sleeping {
|
||||
let draws = hud_overlays::sleep_overlay(wi, hi, ticks as i32);
|
||||
hud_layout::paint(&mut batch, &self.res.atlas, &draws);
|
||||
hud_layout::paint(&mut batch, &self.atlas, &draws);
|
||||
}
|
||||
if !self.ui.hide_gui {
|
||||
self.draw_titles(&mut batch);
|
||||
@@ -3845,7 +3901,7 @@ impl Game<'_> {
|
||||
&& !spectator
|
||||
&& let Some(p) = &mut self.player
|
||||
{
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let width = |s: &str| HudBatch::text_width(atlas, s) as i32;
|
||||
let draws = hud_layout::experience(
|
||||
wi,
|
||||
@@ -3906,7 +3962,7 @@ impl Game<'_> {
|
||||
self.draw_selected_name(&mut batch, !self.creative);
|
||||
}
|
||||
}
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
if !self.ui.hide_gui
|
||||
&& let Some((text, at)) = &self.message
|
||||
&& at.elapsed() < Duration::from_secs(3)
|
||||
@@ -3921,9 +3977,9 @@ impl Game<'_> {
|
||||
// PauseScreen(false): only its title, at the top.
|
||||
Screen::Paused => {
|
||||
let title = self.translate("menu.paused", "Game Paused");
|
||||
let tw = HudBatch::text_width(&self.res.atlas, &title);
|
||||
let tw = HudBatch::text_width(&self.atlas, &title);
|
||||
batch.text(
|
||||
&self.res.atlas,
|
||||
&self.atlas,
|
||||
&title,
|
||||
((batch.width / 2.0).floor() - (tw / 2.0).floor()).floor(),
|
||||
10.0,
|
||||
@@ -4141,7 +4197,7 @@ impl Game<'_> {
|
||||
let (sx, sy) = self.slot_position(i);
|
||||
if i == 504 && self.offhand.is_none() {
|
||||
batch.sprite(
|
||||
&self.res.atlas,
|
||||
&self.atlas,
|
||||
"gui/sprites/container/slot/shield",
|
||||
ox + sx,
|
||||
oy + sy,
|
||||
@@ -4150,7 +4206,7 @@ impl Game<'_> {
|
||||
if (500..504).contains(&i) && self.armor[i - 500].is_none() {
|
||||
let icon = ["helmet", "chestplate", "leggings", "boots"][i - 500];
|
||||
batch.sprite(
|
||||
&self.res.atlas,
|
||||
&self.atlas,
|
||||
&format!("gui/sprites/container/slot/{icon}"),
|
||||
ox + sx,
|
||||
oy + sy,
|
||||
@@ -4166,7 +4222,7 @@ impl Game<'_> {
|
||||
}
|
||||
let (ox, oy) = self.inventory_origin(batch);
|
||||
{
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
batch.fill(
|
||||
atlas,
|
||||
0.0,
|
||||
@@ -4297,7 +4353,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.res.atlas,
|
||||
&self.atlas,
|
||||
ox + sx,
|
||||
oy + sy,
|
||||
16.0,
|
||||
@@ -4408,8 +4464,8 @@ impl Game<'_> {
|
||||
let search = &self.creative_screen.search;
|
||||
self.text_selection.select(("creative.search", 0), search);
|
||||
}
|
||||
let items = self.creative_screen.items(&self.res.names);
|
||||
let first = self.creative_screen.first_row(&self.res.names);
|
||||
let items = self.creative_screen.items(&self.pack.names);
|
||||
let first = self.creative_screen.first_row(&self.pack.names);
|
||||
let shown = items.get(first * 9 + slot - Creative::DISPLAY);
|
||||
let catalog = &self.res.items;
|
||||
let max = |s: &ItemStack| catalog.get(&s.item).map_or(64, |i| i.max_stack);
|
||||
@@ -5323,7 +5379,7 @@ impl Game<'_> {
|
||||
m.height(),
|
||||
camera,
|
||||
fire_yaw,
|
||||
&self.res.atlas.sprites,
|
||||
&self.atlas.sprites,
|
||||
self.world.light(
|
||||
at.x.floor() as i32,
|
||||
at.y.floor() as i32,
|
||||
@@ -5345,7 +5401,7 @@ impl Game<'_> {
|
||||
p.dimensions.height,
|
||||
camera,
|
||||
fire_yaw,
|
||||
&self.res.atlas.sprites,
|
||||
&self.atlas.sprites,
|
||||
self.world.light(
|
||||
feet.x.floor() as i32,
|
||||
feet.y.floor() as i32,
|
||||
@@ -5368,7 +5424,7 @@ impl Game<'_> {
|
||||
0.25,
|
||||
camera,
|
||||
fire_yaw,
|
||||
&self.res.atlas.sprites,
|
||||
&self.atlas.sprites,
|
||||
self.world.light(
|
||||
at.x.floor() as i32,
|
||||
at.y.floor() as i32,
|
||||
@@ -5387,7 +5443,7 @@ impl Game<'_> {
|
||||
1.975 * scale,
|
||||
camera,
|
||||
fire_yaw,
|
||||
&self.res.atlas.sprites,
|
||||
&self.atlas.sprites,
|
||||
self.world.light(
|
||||
stand.position.x.floor() as i32,
|
||||
stand.position.y.floor() as i32,
|
||||
@@ -5412,7 +5468,7 @@ impl Game<'_> {
|
||||
self.name_tag_geometry(camera, alpha, &mut out, &mut see_through);
|
||||
self.see_through_vertices = see_through;
|
||||
// Entity shadows (EntityRenderer.extractShadow).
|
||||
if let Some(sprite) = self.res.atlas.sprites.get("misc/shadow").copied() {
|
||||
if let Some(sprite) = self.atlas.sprites.get("misc/shadow").copied() {
|
||||
let ambient = if self.dim == Dim::Nether { 0.1 } else { 0.0 };
|
||||
let darken = self.sky_darken();
|
||||
let a = alpha;
|
||||
@@ -5467,7 +5523,7 @@ impl Game<'_> {
|
||||
game_time: self.world.game_time,
|
||||
max_y: self.dim.max_y(),
|
||||
world: &self.world,
|
||||
sprites: &self.res.atlas.sprites,
|
||||
sprites: &self.atlas.sprites,
|
||||
nether: self.dim == Dim::Nether,
|
||||
lid: &lid,
|
||||
sign: &|p| match self.world.block_entities.get(&(p[0], p[1], p[2])) {
|
||||
@@ -5475,7 +5531,7 @@ impl Game<'_> {
|
||||
_ => None,
|
||||
},
|
||||
banner: &|p| self.banner_layers_at(p),
|
||||
glyph: &|c| self.res.atlas.glyph_cell(c),
|
||||
glyph: &|c| self.atlas.glyph_cell(c),
|
||||
};
|
||||
// Block entities outside the view frustum are skipped (with a
|
||||
// block of margin for models larger than their block).
|
||||
@@ -5520,7 +5576,6 @@ impl Game<'_> {
|
||||
}
|
||||
// Experience orbs (ExperienceOrbRenderer): pulsing billboards from a 4x4 icon sheet.
|
||||
if let Some(r) = self
|
||||
.res
|
||||
.atlas
|
||||
.sprites
|
||||
.get("entity/experience/experience_orb")
|
||||
@@ -5632,7 +5687,7 @@ impl Game<'_> {
|
||||
&|b| world.light(b[0], b[1], b[2]),
|
||||
&mut out,
|
||||
);
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
// Breaking progress overlay (destroy_stage_0..9).
|
||||
if let Some(m) = &self.mining
|
||||
&& m.progress > 0.0
|
||||
@@ -5652,13 +5707,13 @@ impl Game<'_> {
|
||||
if self.res.facts.get(state).render_shape
|
||||
== horizon_client::blocks::RenderShape::Model
|
||||
&& let Ok(models) = self
|
||||
.res
|
||||
.pack
|
||||
.assets
|
||||
.model_catalog
|
||||
.collect(state, BlockPos::new(m.pos[0], m.pos[1], m.pos[2]))
|
||||
{
|
||||
let offset = self
|
||||
.res
|
||||
.pack
|
||||
.context
|
||||
.tables
|
||||
.offset(state, m.pos[0], m.pos[2])
|
||||
@@ -5931,11 +5986,11 @@ impl Game<'_> {
|
||||
}
|
||||
for ((x, y, z), lit) in lit_changes {
|
||||
let state = self.world.block(x, y, z);
|
||||
if let Some(mut s) = self.res.assets.registry.state(state).cloned()
|
||||
if let Some(mut s) = self.pack.assets.registry.state(state).cloned()
|
||||
&& s.properties.contains_key("lit")
|
||||
{
|
||||
s.properties.insert("lit".into(), lit.to_string());
|
||||
if let Ok(id) = self.res.assets.registry.resolve(&s) {
|
||||
if let Ok(id) = self.pack.assets.registry.resolve(&s) {
|
||||
self.world.set(x, y, z, id)?;
|
||||
}
|
||||
}
|
||||
@@ -5976,7 +6031,7 @@ impl Game<'_> {
|
||||
/// SkyRenderer.renderSunMoonAndStars: bodies on a frame rotated Y -90 then X by angle.
|
||||
fn celestial_geometry(&self, sky: &horizon_client::environment::Sky) -> Vec<Vertex> {
|
||||
let mut out = Vec::new();
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let frame = |angle: f32| {
|
||||
glam::Mat4::from_rotation_y((-90.0f32).to_radians())
|
||||
* glam::Mat4::from_rotation_x(angle.to_radians())
|
||||
@@ -6278,14 +6333,14 @@ impl Game<'_> {
|
||||
world_root,
|
||||
dim.id(),
|
||||
)));
|
||||
let res = &*self.res;
|
||||
let (res, pack) = (&*self.res, &self.pack);
|
||||
let flat = (dim == Dim::Overworld)
|
||||
.then(|| horizon_client::save::world_gen_settings(world_root))
|
||||
.flatten()
|
||||
.and_then(|s| {
|
||||
horizon_client::flatgen::FlatTerrain::from_settings(
|
||||
&s,
|
||||
res.assets.registry,
|
||||
pack.assets.registry,
|
||||
&res.biomes,
|
||||
)
|
||||
});
|
||||
@@ -6294,26 +6349,26 @@ impl Game<'_> {
|
||||
Arc::new(Persistent {
|
||||
inner: Arc::new(inner),
|
||||
save: save.clone(),
|
||||
registry: res.assets.clone(),
|
||||
registry: pack.assets.clone(),
|
||||
biomes: res.biomes.clone(),
|
||||
}),
|
||||
res.context.clone(),
|
||||
pack.context.clone(),
|
||||
res.threads,
|
||||
)
|
||||
} else if self.options.test_terrain && dim == Dim::Overworld {
|
||||
let inner = Arc::new(TestTerrain::new(res.assets.registry, &res.biomes)?);
|
||||
let inner = Arc::new(TestTerrain::new(pack.assets.registry, &res.biomes)?);
|
||||
Streaming::new(
|
||||
Arc::new(Persistent {
|
||||
inner,
|
||||
save: save.clone(),
|
||||
registry: res.assets.clone(),
|
||||
registry: pack.assets.clone(),
|
||||
biomes: res.biomes.clone(),
|
||||
}),
|
||||
res.context.clone(),
|
||||
pack.context.clone(),
|
||||
res.threads,
|
||||
)
|
||||
} else {
|
||||
let inner = Arc::new(VanillaTerrain::for_dimension(&self.options.resources.join("worldgen"), res.assets.registry, &res.biomes, seed, dim.id()).map_err(|e| {
|
||||
let inner = Arc::new(VanillaTerrain::for_dimension(&self.options.resources.join("worldgen"), pack.assets.registry, &res.biomes, seed, dim.id()).map_err(|e| {
|
||||
format!("{e}\nPrepare the worldgen bundle with the launcher, or: horizon-prepare --prepare")
|
||||
})?);
|
||||
self.end.set_locator(Some(inner.clone()));
|
||||
@@ -6321,10 +6376,10 @@ impl Game<'_> {
|
||||
Arc::new(Persistent {
|
||||
inner,
|
||||
save: save.clone(),
|
||||
registry: res.assets.clone(),
|
||||
registry: pack.assets.clone(),
|
||||
biomes: res.biomes.clone(),
|
||||
}),
|
||||
res.context.clone(),
|
||||
pack.context.clone(),
|
||||
res.threads,
|
||||
)
|
||||
};
|
||||
@@ -6349,7 +6404,7 @@ impl Game<'_> {
|
||||
let keys: Vec<_> = self.world.modified.drain().collect();
|
||||
let chunks = self.with_entities(keys.iter().filter_map(|k| self.world.chunks.get(k)));
|
||||
self.save
|
||||
.save(&chunks, self.res.assets.registry, &self.res.biomes)?;
|
||||
.save(&chunks, self.pack.assets.registry, &self.res.biomes)?;
|
||||
self.save_dimension_entities()?;
|
||||
// Coordinates scale by 8 between the Overworld and the Nether.
|
||||
let scale = match (self.dim, target) {
|
||||
@@ -6474,7 +6529,7 @@ impl Game<'_> {
|
||||
for x_axis in [true, false] {
|
||||
if let Some((origin, width, height)) = self.portal_shape(at, x_axis) {
|
||||
let d = if x_axis { [1, 0, 0] } else { [0, 0, 1] };
|
||||
let registry = &self.res.assets.registry;
|
||||
let registry = &self.pack.assets.registry;
|
||||
let Some(default) = registry.default_state("minecraft:nether_portal") else {
|
||||
return Ok(false);
|
||||
};
|
||||
@@ -6747,7 +6802,7 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
}
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
let id = self.world.block(pos[0], pos[1], pos[2]);
|
||||
let Some(state) = registry
|
||||
.state(id)
|
||||
@@ -6839,7 +6894,7 @@ impl Game<'_> {
|
||||
[-1, 0, 0] => "west",
|
||||
_ => "east",
|
||||
};
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
let (state, sound, loot, damage, particle) = {
|
||||
let around = Column {
|
||||
world: &self.world,
|
||||
@@ -6893,7 +6948,7 @@ impl Game<'_> {
|
||||
Ok(true)
|
||||
}
|
||||
fn set_state_named(&mut self, pos: [i32; 3], name: &str, keep: &[&str]) -> Result<bool> {
|
||||
let registry = &self.res.assets.registry;
|
||||
let registry = &self.pack.assets.registry;
|
||||
let old = self.world.block(pos[0], pos[1], pos[2]);
|
||||
let Some(default) = registry.default_state(name) else {
|
||||
return Ok(false);
|
||||
@@ -7073,7 +7128,7 @@ impl Game<'_> {
|
||||
return Ok(UseResult::Success { swing: true });
|
||||
}
|
||||
if item == "honeycomb" {
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
let old = registry.state(clicked).cloned();
|
||||
if let Some(waxed) = old.and_then(|old| self.res.transformers.waxed(registry, &old))
|
||||
&& let Ok(state) = registry.resolve(&waxed)
|
||||
@@ -7098,7 +7153,7 @@ impl Game<'_> {
|
||||
}
|
||||
let name = self.res.facts.get(clicked).name.clone();
|
||||
if self.can_light(clicked, &name) {
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
let mut state = registry
|
||||
.state(clicked)
|
||||
.cloned()
|
||||
@@ -7447,13 +7502,7 @@ impl Game<'_> {
|
||||
let Some(arm) = self.res.player_arm.clone() else {
|
||||
continue;
|
||||
};
|
||||
let Some(r) = self
|
||||
.res
|
||||
.atlas
|
||||
.sprites
|
||||
.get("entity/player/wide/steve")
|
||||
.copied()
|
||||
else {
|
||||
let Some(r) = self.atlas.sprites.get("entity/player/wide/steve").copied() else {
|
||||
continue;
|
||||
};
|
||||
// renderPlayerArm (right arm)
|
||||
@@ -7523,7 +7572,7 @@ impl Game<'_> {
|
||||
"minecraft:trident" if using => ItemPose::Trident { ticks_used },
|
||||
_ if using => {
|
||||
let components = self
|
||||
.res
|
||||
.pack
|
||||
.item_renderer
|
||||
.models
|
||||
.components(&horizon_client::item_render::stack_view(&stack));
|
||||
@@ -7580,7 +7629,7 @@ impl Game<'_> {
|
||||
/// The renderer for the window, with the current block sprites, shared
|
||||
/// atlas and world border texture.
|
||||
fn new_renderer(&self, window: Arc<Window>) -> Result<Renderer> {
|
||||
let assets = &self.res.assets;
|
||||
let assets = &self.pack.assets;
|
||||
let mut renderer = pollster::block_on(Renderer::new(
|
||||
window,
|
||||
self.options.offscreen,
|
||||
@@ -7590,16 +7639,11 @@ impl Game<'_> {
|
||||
assets.texture_layers,
|
||||
&assets.sprite_mips,
|
||||
&assets.animations,
|
||||
(
|
||||
&self.res.atlas.pixels,
|
||||
self.res.atlas.width,
|
||||
self.res.atlas.height,
|
||||
),
|
||||
(&self.res.forcefield.2, self.res.forcefield.0),
|
||||
&self.res.panorama,
|
||||
(&self.atlas.pixels, self.atlas.width, self.atlas.height),
|
||||
(&self.pack.forcefield.2, self.pack.forcefield.0),
|
||||
&self.pack.panorama,
|
||||
))?;
|
||||
renderer.hud.fire_animations = self
|
||||
.res
|
||||
.atlas
|
||||
.fire_animations
|
||||
.iter()
|
||||
@@ -7720,7 +7764,7 @@ impl Game<'_> {
|
||||
if intensity <= 0.0 {
|
||||
return;
|
||||
}
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let (Some(rain_tex), Some(snow_tex)) = (
|
||||
atlas.sprites.get("environment/rain").copied(),
|
||||
atlas.sprites.get("environment/snow").copied(),
|
||||
@@ -7808,7 +7852,7 @@ impl Game<'_> {
|
||||
let night = (12542..23460).contains(&time) || self.world.weather.thundering;
|
||||
let state = self.world.block(pos[0], pos[1], pos[2]);
|
||||
let props = self
|
||||
.res
|
||||
.pack
|
||||
.assets
|
||||
.registry
|
||||
.state(state)
|
||||
@@ -7909,7 +7953,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// Vanilla tooltip: dark box with a purple gradient border.
|
||||
fn tooltip(&self, batch: &mut HudBatch, text: &str, x: f32, y: f32) {
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let w = HudBatch::text_width(atlas, text);
|
||||
let (x, y) = (x + 12.0, y - 12.0);
|
||||
batch.fill(atlas, x - 3.0, y - 4.0, w + 6.0, 16.0, rgba(16, 0, 16, 240));
|
||||
@@ -7931,7 +7975,7 @@ impl Game<'_> {
|
||||
)
|
||||
};
|
||||
batch.fill(
|
||||
&self.res.atlas,
|
||||
&self.atlas,
|
||||
0.0,
|
||||
0.0,
|
||||
batch.width,
|
||||
@@ -7942,7 +7986,7 @@ impl Game<'_> {
|
||||
for (i, t) in tabs.iter().enumerate() {
|
||||
if i != selected {
|
||||
let (tx, ty) = Creative::tab_position(t);
|
||||
batch.sprite(&self.res.atlas, &tab_sprite(t, false), ox + tx, oy + ty);
|
||||
batch.sprite(&self.atlas, &tab_sprite(t, false), ox + tx, oy + ty);
|
||||
}
|
||||
}
|
||||
let background = if tab.search {
|
||||
@@ -7952,13 +7996,13 @@ impl Game<'_> {
|
||||
} else {
|
||||
"gui/container/creative_inventory/tab_items"
|
||||
};
|
||||
if let Some(mut r) = self.res.atlas.sprites.get(background).copied() {
|
||||
if let Some(mut r) = self.atlas.sprites.get(background).copied() {
|
||||
r.u1 = r.u0 + (r.u1 - r.u0) * Creative::WIDTH / r.w as f32;
|
||||
r.v1 = r.v0 + (r.v1 - r.v0) * Creative::HEIGHT / r.h as f32;
|
||||
batch.rect_uv(ox, oy, Creative::WIDTH, Creative::HEIGHT, r, u32::MAX);
|
||||
}
|
||||
let (tx, ty) = Creative::tab_position(&tab);
|
||||
batch.sprite(&self.res.atlas, &tab_sprite(&tab, true), ox + tx, oy + ty);
|
||||
batch.sprite(&self.atlas, &tab_sprite(&tab, true), ox + tx, oy + ty);
|
||||
for t in &tabs {
|
||||
let (tx, ty) = Creative::tab_position(t);
|
||||
let stack = ItemStack {
|
||||
@@ -7974,7 +8018,7 @@ impl Game<'_> {
|
||||
oy + ty + if t.top { 9.0 } else { 7.0 },
|
||||
);
|
||||
}
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
if !tab.inventory {
|
||||
batch.text(
|
||||
atlas,
|
||||
@@ -8016,7 +8060,7 @@ impl Game<'_> {
|
||||
if Self::creative_trash_hovered(batch, self.cursor) {
|
||||
let (x, y) = Creative::TRASH_POSITION;
|
||||
batch.fill(
|
||||
&self.res.atlas,
|
||||
&self.atlas,
|
||||
ox + x,
|
||||
oy + y,
|
||||
16.0,
|
||||
@@ -8027,7 +8071,7 @@ impl Game<'_> {
|
||||
if let Some(slot) = self.slot_at(batch, self.cursor.0, self.cursor.1) {
|
||||
let (x, y) = self.slot_position(slot);
|
||||
batch.fill(
|
||||
&self.res.atlas,
|
||||
&self.atlas,
|
||||
ox + x,
|
||||
oy + y,
|
||||
16.0,
|
||||
@@ -8036,8 +8080,8 @@ impl Game<'_> {
|
||||
);
|
||||
}
|
||||
} else {
|
||||
let items = self.creative_screen.items(&self.res.names);
|
||||
let first = self.creative_screen.first_row(&self.res.names);
|
||||
let items = self.creative_screen.items(&self.pack.names);
|
||||
let first = self.creative_screen.first_row(&self.pack.names);
|
||||
for r in 0..5 {
|
||||
for c in 0..9 {
|
||||
let Some(stack) = items.get((first + r) * 9 + c) else {
|
||||
@@ -8050,7 +8094,7 @@ impl Game<'_> {
|
||||
&& self.cursor.1 >= y
|
||||
&& self.cursor.1 < y + 16.0
|
||||
{
|
||||
batch.fill(&self.res.atlas, x, y, 16.0, 16.0, rgba(255, 255, 255, 128));
|
||||
batch.fill(&self.atlas, x, y, 16.0, 16.0, rgba(255, 255, 255, 128));
|
||||
hovered = Some(stack.item.to_string());
|
||||
}
|
||||
}
|
||||
@@ -8069,14 +8113,14 @@ impl Game<'_> {
|
||||
hovered = Some(stack.item.to_string());
|
||||
}
|
||||
}
|
||||
let scrollable = self.creative_screen.rows(&self.res.names) > 5;
|
||||
let scrollable = self.creative_screen.rows(&self.pack.names) > 5;
|
||||
let scroller = if scrollable {
|
||||
"gui/sprites/container/creative_inventory/scroller"
|
||||
} else {
|
||||
"gui/sprites/container/creative_inventory/scroller_disabled"
|
||||
};
|
||||
batch.sprite(
|
||||
&self.res.atlas,
|
||||
&self.atlas,
|
||||
scroller,
|
||||
ox + Creative::SCROLL_X,
|
||||
oy + Creative::SCROLL_Y + self.creative_screen.scroller_offset(),
|
||||
@@ -8102,7 +8146,7 @@ impl Game<'_> {
|
||||
} else if self.carried.is_none()
|
||||
&& let Some(item) = hovered
|
||||
{
|
||||
let name = self.res.names.item(&item);
|
||||
let name = self.pack.names.item(&item);
|
||||
self.tooltip(batch, &name, self.cursor.0, self.cursor.1);
|
||||
}
|
||||
self.draw_inventory_effects(batch, (ox, oy), Creative::WIDTH as i32);
|
||||
@@ -8158,7 +8202,7 @@ impl Game<'_> {
|
||||
if !right
|
||||
&& self
|
||||
.creative_screen
|
||||
.press_scrollbar(cx - ox, cy - oy, &self.res.names)
|
||||
.press_scrollbar(cx - ox, cy - oy, &self.pack.names)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -8277,7 +8321,7 @@ impl Game<'_> {
|
||||
let keys: Vec<_> = self.world.modified.drain().collect();
|
||||
let chunks = self.with_entities(keys.iter().filter_map(|k| self.world.chunks.get(k)));
|
||||
self.save
|
||||
.save_later(&chunks, self.res.assets.registry, &self.res.biomes)?;
|
||||
.save_later(&chunks, self.pack.assets.registry, &self.res.biomes)?;
|
||||
if wait {
|
||||
self.save.flush();
|
||||
}
|
||||
@@ -8385,7 +8429,7 @@ impl Game<'_> {
|
||||
let state = self.world.block(h.pos[0], h.pos[1], h.pos[2]);
|
||||
let f = self.res.facts.get(state);
|
||||
let o = if f.outline_offset {
|
||||
self.res
|
||||
self.pack
|
||||
.context
|
||||
.tables
|
||||
.offset(state, h.pos[0], h.pos[2])
|
||||
@@ -8540,10 +8584,10 @@ impl Game<'_> {
|
||||
clouds: ((!title || live)
|
||||
&& self.dim == Dim::Overworld
|
||||
&& horizon_client::clouds::visible(&self.settings.clouds, sky.cloud_color[3]))
|
||||
.then(|| self.res.atlas.sprites.get("horizon/white"))
|
||||
.then(|| self.atlas.sprites.get("horizon/white"))
|
||||
.flatten()
|
||||
.map(|white| horizon_client::clouds::Input {
|
||||
texture: &self.res.clouds,
|
||||
texture: &self.pack.clouds,
|
||||
uv: [(white.u0 + white.u1) / 2.0, (white.v0 + white.v1) / 2.0],
|
||||
camera,
|
||||
time: self.world.game_time,
|
||||
@@ -8570,15 +8614,14 @@ impl Game<'_> {
|
||||
.mining
|
||||
.as_ref()
|
||||
.and_then(|m| {
|
||||
self.res.atlas.sprites.get(&format!(
|
||||
self.atlas.sprites.get(&format!(
|
||||
"block/destroy_stage_{}",
|
||||
((m.progress * 10.0) as u32).min(9)
|
||||
))
|
||||
})
|
||||
.map_or([0.0; 4], |r| [r.u0, r.v0, r.u1 - r.u0, r.v1 - r.v0]),
|
||||
end_portal_sprites: ["environment/end_sky", "entity/end_portal/end_portal"].map(|n| {
|
||||
self.res
|
||||
.atlas
|
||||
self.atlas
|
||||
.sprites
|
||||
.get(n)
|
||||
.map_or([0.0; 4], |r| [r.u0, r.v0, r.u1 - r.u0, r.v1 - r.v0])
|
||||
@@ -8586,7 +8629,7 @@ impl Game<'_> {
|
||||
ticks: self.ticks,
|
||||
darkness: self.darkness_lighting(alpha as f32),
|
||||
night_vision: self.night_vision_intensity(),
|
||||
block_flicker: self.res.fog.state.block_light_flicker,
|
||||
block_flicker: self.fog.block_light_flicker,
|
||||
post: if live {
|
||||
Some(horizon_client::post::PostGrade::FROST)
|
||||
} else if self.horizon_pause() {
|
||||
@@ -8638,7 +8681,7 @@ impl Game<'_> {
|
||||
reason: horizon_client::level_loading::Reason,
|
||||
) {
|
||||
use horizon_client::level_loading::{self, Reason, STATUS_RADIUS};
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let (w, h) = (batch.width, batch.height);
|
||||
match reason {
|
||||
// The panorama and its blur are drawn by the renderer.
|
||||
@@ -8910,7 +8953,7 @@ impl Game<'_> {
|
||||
if !modified.is_empty()
|
||||
&& let Err(e) = horizon_client::spans::time("save_chunks", || {
|
||||
self.save
|
||||
.save_later(&modified, self.res.assets.registry, &self.res.biomes)
|
||||
.save_later(&modified, self.pack.assets.registry, &self.res.biomes)
|
||||
})
|
||||
{
|
||||
log::warn!("Horizon: failed to save unloaded chunks: {e}");
|
||||
@@ -9114,7 +9157,7 @@ impl ApplicationHandler for Game<'_> {
|
||||
&& !horizon_client::ui_theme::horizon()
|
||||
{
|
||||
title.drag(self.cursor, (b.width, b.height));
|
||||
title.drag_field(&self.res.atlas, self.cursor.0);
|
||||
title.drag_field(&self.atlas, self.cursor.0);
|
||||
}
|
||||
if self.dragging && self.screen == Screen::Options {
|
||||
let _ = b;
|
||||
@@ -9169,7 +9212,7 @@ impl ApplicationHandler for Game<'_> {
|
||||
self.options_scroll(d);
|
||||
}
|
||||
if self.screen == Screen::Creative && d != 0.0 {
|
||||
self.creative_screen.wheel(f64::from(d), &self.res.names);
|
||||
self.creative_screen.wheel(f64::from(d), &self.pack.names);
|
||||
}
|
||||
if self.screen == Screen::Inventory
|
||||
&& d != 0.0
|
||||
@@ -9218,7 +9261,7 @@ impl ApplicationHandler for Game<'_> {
|
||||
.map(|r| [r.config.width, r.config.height])
|
||||
.unwrap_or([1, 1]);
|
||||
let mut b = HudBatch::new(size);
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let shift = self.has_shift_down();
|
||||
let (action, sound) = self.title.as_mut().map_or((Action::None, false), |t| {
|
||||
if horizon_client::ui_theme::horizon() {
|
||||
@@ -9778,24 +9821,16 @@ pub fn run() -> Result<()> {
|
||||
let biomes = Arc::new(Biomes::load(&root)?);
|
||||
let environment = Environment::load(&root)?;
|
||||
log::info!("load biomes+env: {:.2}s", started.elapsed().as_secs_f32());
|
||||
let visibility = models::load_visibility(&root, assets.registry)?;
|
||||
log::info!("load visibility: {:.2}s", started.elapsed().as_secs_f32());
|
||||
let tables = Arc::new(MeshTables::new(&assets, &facts, visibility)?);
|
||||
let light = Arc::new(LightTables::load(&root, assets.registry, &facts)?);
|
||||
log::info!("load tables: {:.2}s", started.elapsed().as_secs_f32());
|
||||
let pack = PackResources::load(&root, assets.clone(), &facts, biomes.clone(), light)?;
|
||||
log::info!("load pack tables: {:.2}s", started.elapsed().as_secs_f32());
|
||||
let atlas = HudAtlas::build(&root)?;
|
||||
let panorama = horizon_client::gfx::panorama::Faces::load(&root);
|
||||
horizon_client::ui::load_metadata(&root);
|
||||
horizon_client::lang::set(horizon_client::lang::Language::load(
|
||||
&[&root],
|
||||
&early_settings.language,
|
||||
));
|
||||
log::info!("load atlas: {:.2}s", started.elapsed().as_secs_f32());
|
||||
let layer_names = assets
|
||||
.sprite_layers
|
||||
.iter()
|
||||
.map(|(name, layer)| (*layer, name.trim_start_matches("minecraft:").to_owned()))
|
||||
.collect();
|
||||
let registry_owner = assets.clone();
|
||||
let collision = collisions::load(&root, registry_owner.registry)?;
|
||||
let motion = MotionResources::load(&root, ®istry_owner)?;
|
||||
@@ -9803,12 +9838,6 @@ pub fn run() -> Result<()> {
|
||||
"load collision+motion: {:.2}s",
|
||||
started.elapsed().as_secs_f32()
|
||||
);
|
||||
let context = Arc::new(WorkerContext {
|
||||
assets: assets.clone(),
|
||||
tables,
|
||||
biomes: biomes.clone(),
|
||||
light,
|
||||
});
|
||||
let threads = early_settings.horizon.worker_threads();
|
||||
log::info!(
|
||||
"Horizon: resources loaded in {:.1}s; {} block states, {} items, {} biomes; {} worker threads",
|
||||
@@ -9821,7 +9850,7 @@ pub fn run() -> Result<()> {
|
||||
// Until a world is opened the streamer is idle.
|
||||
let mut streaming = Streaming::new(
|
||||
Arc::new(TestTerrain::new(assets.registry, &biomes)?),
|
||||
context.clone(),
|
||||
pack.context.clone(),
|
||||
1,
|
||||
);
|
||||
streaming.paused = true;
|
||||
@@ -9841,26 +9870,17 @@ pub fn run() -> Result<()> {
|
||||
let stations = horizon_client::stations::StationData::load(&root, &items);
|
||||
let animate =
|
||||
horizon_client::animate_tick::AnimateTables::load(&root, registry_owner.registry, &biomes)?;
|
||||
let fog = horizon_client::fog::FogRenderer::load(&root, &biomes);
|
||||
let item_renderer = Arc::new(
|
||||
horizon_client::item_render::ItemRenderer::load_with_library(
|
||||
&root,
|
||||
assets.model_library.clone(),
|
||||
)?,
|
||||
);
|
||||
let mut resources = Resources {
|
||||
let fog = horizon_client::fog::FogTables::load(&root, &biomes);
|
||||
let resources = Arc::new(Resources {
|
||||
stations,
|
||||
assets,
|
||||
facts,
|
||||
items,
|
||||
recipes,
|
||||
transformers,
|
||||
biomes,
|
||||
environment,
|
||||
atlas,
|
||||
panorama,
|
||||
item_renderer,
|
||||
layer_names,
|
||||
collision,
|
||||
motion,
|
||||
providers: Providers::load(&root),
|
||||
block_entity_render: horizon_client::block_entity_render::BlockEntityRenderer::load(
|
||||
&root,
|
||||
@@ -9870,25 +9890,20 @@ pub fn run() -> Result<()> {
|
||||
fog,
|
||||
music: horizon_client::music::MusicTables::load(&root),
|
||||
ambient: horizon_client::ambience::AmbientTables::load(&root),
|
||||
screen_fx: Default::default(),
|
||||
nether_environment: Environment::load_dimension(&root, "the_nether", false)?,
|
||||
end_environment: Environment::load_dimension(&root, "the_end", false)?,
|
||||
behaviours: Behaviours::load(registry_owner.registry, &root)?,
|
||||
names: Names::load(&root),
|
||||
clouds: load_clouds(&root),
|
||||
forcefield: load_forcefield(&root),
|
||||
mob_types: MobTypes::load(&root)?
|
||||
.types
|
||||
.into_iter()
|
||||
.map(|(k, v)| (k, Arc::new(v)))
|
||||
.collect(),
|
||||
mob_data,
|
||||
context,
|
||||
threads,
|
||||
player_type: perspective::player_type(&root),
|
||||
player_arm: horizon_client::mobs::load_model(&root, "minecraft:player#main")
|
||||
.and_then(|m| m.children.into_iter().find(|c| c.name == "right_arm")),
|
||||
};
|
||||
});
|
||||
// These batches share the exported document instead of reparsing it per layer.
|
||||
let (armor_stand_assets, boat_models, cart_models) = {
|
||||
let document = horizon_client::mobs::EntityModelDocument::load(&root).ok();
|
||||
@@ -9914,11 +9929,15 @@ pub fn run() -> Result<()> {
|
||||
settings.render_distance = d;
|
||||
}
|
||||
let look = options.look;
|
||||
let particles = horizon_client::particles::ParticleEngine::new(&root, &resources.atlas.sprites);
|
||||
let particles = horizon_client::particles::ParticleEngine::new(&root, &atlas.sprites);
|
||||
let mut game = Game {
|
||||
res: &mut resources,
|
||||
collision: &collision,
|
||||
motion: &motion,
|
||||
res: resources.clone(),
|
||||
collision: &resources.collision,
|
||||
motion: &resources.motion,
|
||||
pack,
|
||||
atlas,
|
||||
fog: Default::default(),
|
||||
screen_fx: Default::default(),
|
||||
world,
|
||||
streaming,
|
||||
options,
|
||||
@@ -10325,6 +10344,14 @@ mod tests {
|
||||
use horizon_client::container_screen::{Button, Clicks, Release, Target};
|
||||
use horizon_client::keymapping::{KeyAction, SPRINT, ToggleKeys};
|
||||
|
||||
/// An integrated server thread shares the loaded resources with the client.
|
||||
#[test]
|
||||
fn shared_resources_can_cross_threads() {
|
||||
fn shared<T: Send + Sync>() {}
|
||||
shared::<Resources>();
|
||||
shared::<PackResources>();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn selecting_creative_tabs_does_not_drop_the_carried_stack_on_release() {
|
||||
let mut creative = Creative::from_json(&serde_json::json!({
|
||||
|
||||
@@ -109,7 +109,7 @@ impl adv::World for View<'_, '_> {
|
||||
let name = self.0.res.facts.get(state).name.to_string();
|
||||
let props = self
|
||||
.0
|
||||
.res
|
||||
.pack
|
||||
.assets
|
||||
.registry
|
||||
.state(state)
|
||||
@@ -613,7 +613,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// `EnterBlockTrigger`: the block, its state properties and the player.
|
||||
pub(super) fn trigger_enter_block(&mut self, state: horizon_world::registry::BlockStateId) {
|
||||
let Some(definition) = self.res.assets.registry.state(state).cloned() else {
|
||||
let Some(definition) = self.pack.assets.registry.state(state).cloned() else {
|
||||
return;
|
||||
};
|
||||
let me = self.player_entity();
|
||||
@@ -746,11 +746,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.res.atlas;
|
||||
let atlas = &self.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.res.atlas;
|
||||
let atlas = &self.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();
|
||||
@@ -759,7 +759,7 @@ impl Game<'_> {
|
||||
self.draw_item_model(batch, &item, x + 8.0, 8.0);
|
||||
return;
|
||||
}
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
batch.sprite(atlas, "gui/sprites/toast/advancement", x, 0.0);
|
||||
let (key, color) = match frame {
|
||||
Frame::Task => ("advancements.toast.task", 0xFF00_FFFF),
|
||||
|
||||
@@ -257,7 +257,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.res.atlas.font;
|
||||
let font = &self.atlas.font;
|
||||
let a = &self.adv.tree.list[i];
|
||||
let Some(d) = &a.display else {
|
||||
return (Vec::new(), Vec::new(), 0.0);
|
||||
@@ -320,7 +320,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.res.atlas;
|
||||
let atlas = &self.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);
|
||||
@@ -432,7 +432,7 @@ impl Game<'_> {
|
||||
}
|
||||
let (x, y) = pos(i);
|
||||
let (x, y) = ((ox + x) as f32, (oy + y) as f32);
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
batch.sprite_scaled(
|
||||
atlas,
|
||||
frame_sprite(d.frame, done),
|
||||
@@ -449,7 +449,7 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
// The window, tabs and title.
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
batch.sprite_region(
|
||||
atlas,
|
||||
"gui/advancements/window",
|
||||
@@ -463,7 +463,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.res.atlas,
|
||||
&self.atlas,
|
||||
&sprite,
|
||||
left + x,
|
||||
top + y,
|
||||
@@ -482,7 +482,7 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
}
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.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),
|
||||
@@ -497,7 +497,7 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
// Done.
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.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(
|
||||
@@ -520,7 +520,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.res.atlas, &[text_of(&d.title)], self.cursor);
|
||||
ui::tooltip(batch, &self.atlas, &[text_of(&d.title)], self.cursor);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -604,7 +604,7 @@ impl Game<'_> {
|
||||
],
|
||||
)
|
||||
});
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.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 {
|
||||
|
||||
@@ -301,7 +301,7 @@ pub(super) enum Handled {
|
||||
|
||||
impl Game<'_> {
|
||||
pub(super) fn state_string(&self, state: BlockStateId) -> String {
|
||||
let Some(s) = self.res.assets.registry.state(state) else {
|
||||
let Some(s) = self.pack.assets.registry.state(state) else {
|
||||
return "?".into();
|
||||
};
|
||||
if s.properties.is_empty() {
|
||||
|
||||
@@ -124,7 +124,7 @@ impl Game<'_> {
|
||||
continue;
|
||||
};
|
||||
let (Some(r), Some(part)) = (
|
||||
self.res.atlas.sprites.get(texture.as_str()),
|
||||
self.atlas.sprites.get(texture.as_str()),
|
||||
assets.player.get(layer),
|
||||
) else {
|
||||
continue;
|
||||
@@ -379,7 +379,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.res.assets.registry) {
|
||||
if !a.environment_tick(&self.world, &self.res.facts, self.pack.assets.registry) {
|
||||
dead.push(i);
|
||||
}
|
||||
}
|
||||
@@ -403,7 +403,7 @@ impl Game<'_> {
|
||||
out: &mut Vec<Vertex>,
|
||||
) {
|
||||
let assets = &self.armor_stand_assets;
|
||||
let sprites = &self.res.atlas.sprites;
|
||||
let sprites = &self.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;
|
||||
@@ -668,12 +668,12 @@ impl Game<'_> {
|
||||
self.dim == super::Dim::Nether,
|
||||
)),
|
||||
};
|
||||
self.res.item_renderer.submit_special(
|
||||
self.pack.item_renderer.submit_special(
|
||||
&special,
|
||||
&serde_json::Value::Null,
|
||||
false,
|
||||
pose,
|
||||
&self.res.atlas.sprites,
|
||||
&self.atlas.sprites,
|
||||
&self.item_host(),
|
||||
&mut sink,
|
||||
);
|
||||
|
||||
@@ -150,11 +150,11 @@ impl Game<'_> {
|
||||
.join("backdrop");
|
||||
std::fs::create_dir_all(&root)?;
|
||||
let save = Arc::new(SaveDir::new(root.join(format!("{seed}"))));
|
||||
let res = &*self.res;
|
||||
let (res, pack) = (&*self.res, &self.pack);
|
||||
let inner = Arc::new(
|
||||
VanillaTerrain::new(
|
||||
&self.options.resources.join("worldgen"),
|
||||
res.assets.registry,
|
||||
pack.assets.registry,
|
||||
&res.biomes,
|
||||
seed,
|
||||
)
|
||||
@@ -164,10 +164,10 @@ impl Game<'_> {
|
||||
Arc::new(Persistent {
|
||||
inner: inner.clone(),
|
||||
save: save.clone(),
|
||||
registry: res.assets.clone(),
|
||||
registry: pack.assets.clone(),
|
||||
biomes: res.biomes.clone(),
|
||||
}),
|
||||
res.context.clone(),
|
||||
pack.context.clone(),
|
||||
res.threads.min(6),
|
||||
);
|
||||
streaming.radius = self.settings.render_distance.clamp(4, 10);
|
||||
|
||||
@@ -385,7 +385,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.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
batch.fill(
|
||||
atlas,
|
||||
0.0,
|
||||
@@ -406,7 +406,7 @@ impl Game<'_> {
|
||||
("block.minecraft.beacon.secondary", "Secondary Power", 169.0),
|
||||
] {
|
||||
let text = self.translate(key, fallback);
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let w = HudBatch::text_width(atlas, &text);
|
||||
batch.text(
|
||||
atlas,
|
||||
@@ -421,7 +421,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.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let mut tooltip = None;
|
||||
let button =
|
||||
|batch: &mut HudBatch, x: f32, y: f32, active: bool, selected: bool, icon: &str| {
|
||||
@@ -503,7 +503,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.res.atlas,
|
||||
&self.atlas,
|
||||
ox + sx,
|
||||
oy + sy,
|
||||
16.0,
|
||||
@@ -524,13 +524,7 @@ 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
|
||||
.res
|
||||
.atlas
|
||||
.sprites
|
||||
.get("entity/beacon/beacon_beam")
|
||||
.copied()
|
||||
else {
|
||||
let Some(s) = self.atlas.sprites.get("entity/beacon/beacon_beam").copied() else {
|
||||
return;
|
||||
};
|
||||
let time = (self.world.game_time.rem_euclid(40)) as f32 + alpha as f32;
|
||||
|
||||
@@ -63,7 +63,7 @@ impl HiveHost for GameHive<'_, '_> {
|
||||
|
||||
impl Game<'_> {
|
||||
fn hive_with_honey(&self, state: BlockStateId, level: i32) -> Option<BlockStateId> {
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
let mut s = registry.state(state)?.clone();
|
||||
s.properties
|
||||
.insert("honey_level".to_owned(), level.to_string());
|
||||
@@ -82,7 +82,7 @@ impl Game<'_> {
|
||||
{
|
||||
return None;
|
||||
}
|
||||
let props = &self.res.assets.registry.state(state)?.properties;
|
||||
let props = &self.pack.assets.registry.state(state)?.properties;
|
||||
let honey = props.get("honey_level").and_then(|v| v.parse().ok());
|
||||
let facing = beehive::facing_step(props.get("facing").map(String::as_str));
|
||||
Some((honey, facing))
|
||||
|
||||
@@ -280,7 +280,7 @@ impl Game<'_> {
|
||||
Ticker::Conduit => {
|
||||
let world = &self.world;
|
||||
let facts = &self.res.facts;
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
let is_water = |p: [i32; 3]| {
|
||||
facts.get(world.block(p[0], p[1], p[2])).fluid
|
||||
== horizon_client::blocks::Fluid::Water
|
||||
|
||||
@@ -46,7 +46,7 @@ impl Game<'_> {
|
||||
// BeehiveBlock.getCloneItemStack: the honey level as the item's block state.
|
||||
if include_data
|
||||
&& let Some(level) = self
|
||||
.res
|
||||
.pack
|
||||
.assets
|
||||
.registry
|
||||
.state(state)
|
||||
|
||||
@@ -33,7 +33,7 @@ fn parse_state(text: &str) -> Result<BlockState> {
|
||||
|
||||
impl Game<'_> {
|
||||
fn state_text(&self, state: BlockStateId) -> String {
|
||||
let Some(s) = self.res.assets.registry.state(state) else {
|
||||
let Some(s) = self.pack.assets.registry.state(state) else {
|
||||
return "?".into();
|
||||
};
|
||||
if s.properties.is_empty() {
|
||||
@@ -69,7 +69,7 @@ impl Game<'_> {
|
||||
"setblock" => {
|
||||
let pos = [int(1)?, int(2)?, int(3)?];
|
||||
let state = self
|
||||
.res
|
||||
.pack
|
||||
.assets
|
||||
.registry
|
||||
.resolve(&parse_state(words.get(4).ok_or("missing block")?)?)?;
|
||||
@@ -81,7 +81,7 @@ impl Game<'_> {
|
||||
"fill" => {
|
||||
let (a, b) = ([int(1)?, int(2)?, int(3)?], [int(4)?, int(5)?, int(6)?]);
|
||||
let state = self
|
||||
.res
|
||||
.pack
|
||||
.assets
|
||||
.registry
|
||||
.resolve(&parse_state(words.get(7).ok_or("missing block")?)?)?;
|
||||
|
||||
@@ -712,7 +712,6 @@ impl Game<'_> {
|
||||
};
|
||||
let folder = if b.chest { "chest_boat" } else { "boat" };
|
||||
let Some(uv) = self
|
||||
.res
|
||||
.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.res.atlas.font.split(&Text::literal(page), 114.0)
|
||||
self.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.res.atlas.font;
|
||||
let font = &self.atlas.font;
|
||||
match self.book.as_mut() {
|
||||
Some(BookScreen::Edit {
|
||||
signing: true,
|
||||
@@ -363,7 +363,7 @@ impl Game<'_> {
|
||||
}
|
||||
fn set_lectern_property(&mut self, key: (i32, i32, i32), name: &str, value: bool) {
|
||||
let state = self.world.block(key.0, key.1, key.2);
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
let Some(mut s) = registry.state(state).cloned() else {
|
||||
return;
|
||||
};
|
||||
@@ -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.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let (w, h) = (batch.width, batch.height);
|
||||
let (mx, my) = self.cursor;
|
||||
let hover =
|
||||
|
||||
@@ -89,17 +89,17 @@ impl Game<'_> {
|
||||
if is_locked {
|
||||
locked = true;
|
||||
if scaling || locking {
|
||||
batch.sprite(&self.res.atlas, error, ox + 35.0, oy + 31.0);
|
||||
batch.sprite(&self.atlas, error, ox + 35.0, oy + 31.0);
|
||||
}
|
||||
}
|
||||
if scaling && scale >= 4 {
|
||||
locked = true;
|
||||
batch.sprite(&self.res.atlas, error, ox + 35.0, oy + 31.0);
|
||||
batch.sprite(&self.atlas, error, ox + 35.0, oy + 31.0);
|
||||
}
|
||||
}
|
||||
let sprite = |batch: &mut HudBatch, game: &Self, name: &str, x: f32, y: f32| {
|
||||
batch.sprite(
|
||||
&game.res.atlas,
|
||||
&game.atlas,
|
||||
&format!("gui/sprites/container/cartography_table/{name}"),
|
||||
ox + x,
|
||||
oy + y,
|
||||
|
||||
@@ -226,7 +226,7 @@ impl Game<'_> {
|
||||
.map(|k| horizon_client::command::args::normalize(k))
|
||||
.collect();
|
||||
reg.block_tags.sort();
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
let mut blocks: BTreeMap<String, BTreeMap<String, Vec<String>>> = BTreeMap::new();
|
||||
for id in 0..registry.len() {
|
||||
let Some(state) = registry.state(horizon_world::registry::BlockStateId(id as u32))
|
||||
@@ -389,7 +389,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.res.atlas.font);
|
||||
let m = Measure(&self.atlas.font);
|
||||
let c = Commands {
|
||||
dispatcher: self.mods.dispatcher(),
|
||||
registries: &self.ui.registries,
|
||||
@@ -428,7 +428,7 @@ impl Game<'_> {
|
||||
let focused = self.screen == Screen::Chat;
|
||||
let heard = self.mods.mods.is_running().then(|| text.plain());
|
||||
self.ui.chat.add(
|
||||
&self.res.atlas,
|
||||
&self.atlas,
|
||||
text,
|
||||
Some(SYSTEM_INDICATOR),
|
||||
self.ticks,
|
||||
@@ -441,7 +441,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.res.atlas.font);
|
||||
let m = Measure(&self.atlas.font);
|
||||
let c = Commands {
|
||||
dispatcher: self.mods.dispatcher(),
|
||||
registries: &self.ui.registries,
|
||||
@@ -487,7 +487,7 @@ impl Game<'_> {
|
||||
let Some(mut screen) = self.ui.chat_screen.take() else {
|
||||
return;
|
||||
};
|
||||
let m = Measure(&self.res.atlas.font);
|
||||
let m = Measure(&self.atlas.font);
|
||||
let c = Commands {
|
||||
dispatcher: self.mods.dispatcher(),
|
||||
registries: &self.ui.registries,
|
||||
@@ -513,7 +513,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.res.atlas.font);
|
||||
let m = Measure(&self.atlas.font);
|
||||
let c = Commands {
|
||||
dispatcher: self.mods.dispatcher(),
|
||||
registries: &self.ui.registries,
|
||||
@@ -536,7 +536,7 @@ impl Game<'_> {
|
||||
let heard = self.mods.mods.is_running().then(|| line.plain());
|
||||
self.ui
|
||||
.chat
|
||||
.add(&self.res.atlas, line, None, self.ticks, focused);
|
||||
.add(&self.atlas, line, None, self.ticks, focused);
|
||||
if let Some(line) = heard {
|
||||
self.mods_chat(&line);
|
||||
}
|
||||
@@ -564,7 +564,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.res.atlas.font);
|
||||
let m = Measure(&self.atlas.font);
|
||||
let c = Commands {
|
||||
dispatcher: self.mods.dispatcher(),
|
||||
registries: &self.ui.registries,
|
||||
@@ -577,7 +577,7 @@ impl Game<'_> {
|
||||
return;
|
||||
}
|
||||
match self.ui.chat.click_at(
|
||||
&self.res.atlas.font,
|
||||
&self.atlas.font,
|
||||
height as i32,
|
||||
cursor.0 as f64,
|
||||
cursor.1 as f64,
|
||||
@@ -603,15 +603,13 @@ impl Game<'_> {
|
||||
if self.ui.hide_gui && !focused {
|
||||
return;
|
||||
}
|
||||
self.ui
|
||||
.chat
|
||||
.draw(batch, &self.res.atlas, self.ticks, focused);
|
||||
self.ui.chat.draw(batch, &self.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.res.atlas.font);
|
||||
let m = Measure(&self.atlas.font);
|
||||
let c = Commands {
|
||||
dispatcher: self.mods.dispatcher(),
|
||||
registries: &self.ui.registries,
|
||||
@@ -629,7 +627,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.res.atlas, &draws);
|
||||
horizon_client::screen_draw::paint(batch, &self.atlas, &draws);
|
||||
self.ui.chat_screen = Some(screen);
|
||||
}
|
||||
/// Advance the overworld clock (ServerClockManager.tick) when
|
||||
@@ -821,11 +819,11 @@ impl Game<'_> {
|
||||
let focused = self.screen == Screen::Chat;
|
||||
self.ui
|
||||
.chat
|
||||
.add(&self.res.atlas, message, None, self.ticks, focused);
|
||||
.add(&self.atlas, message, None, self.ticks, focused);
|
||||
}
|
||||
#[allow(dead_code)]
|
||||
fn chat_debug_fill(&self, batch: &mut HudBatch) {
|
||||
batch.fill(&self.res.atlas, 0.0, 0.0, 1.0, 1.0, rgba(0, 0, 0, 0));
|
||||
batch.fill(&self.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
|
||||
|
||||
@@ -193,7 +193,7 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
fn block_state_at(&self, pos: Pos) -> Option<&'static BlockState> {
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
state_of(registry, self.world.block(pos.0, pos.1, pos.2))
|
||||
}
|
||||
fn schedule_command_block(&mut self, pos: Pos) {
|
||||
@@ -202,7 +202,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// `CommandBlockEntity.scheduleTick`.
|
||||
fn schedule_command_block_tick(&mut self, pos: Pos) {
|
||||
mark_condition_met(&mut self.world, self.res.assets.registry, pos);
|
||||
mark_condition_met(&mut self.world, self.pack.assets.registry, pos);
|
||||
self.schedule_command_block(pos);
|
||||
}
|
||||
fn update_output_signal(&mut self, pos: Pos) {
|
||||
@@ -225,7 +225,7 @@ impl Game<'_> {
|
||||
}
|
||||
let at = BlockPos::new(pos.0, pos.1, pos.2);
|
||||
let signal = self.with_level(|b, level, ticks| b.has_neighbor_signal(level, ticks, at));
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
if let Some((was, auto)) = set_powered(&mut self.world, registry, pos, signal)
|
||||
&& signal
|
||||
&& !was
|
||||
@@ -249,7 +249,7 @@ impl Game<'_> {
|
||||
return;
|
||||
};
|
||||
if mode == Mode::Auto {
|
||||
mark_condition_met(&mut self.world, self.res.assets.registry, key);
|
||||
mark_condition_met(&mut self.world, self.pack.assets.registry, key);
|
||||
}
|
||||
match command_block::tick_action(mode, was_met, conditional(state)) {
|
||||
Some(true) => self.command_block_execute(key, state),
|
||||
@@ -283,7 +283,7 @@ impl Game<'_> {
|
||||
/// `CommandBlock.executeChain`: the chain command blocks in front, each
|
||||
/// facing on to the next, up to `max_command_sequence_length`.
|
||||
fn execute_chain(&mut self, start: Pos, mut step: [i32; 3]) {
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
let limit = self.ui.rules.int("max_command_sequence_length");
|
||||
let mut remaining = limit;
|
||||
let mut pos = start;
|
||||
@@ -458,7 +458,7 @@ impl Game<'_> {
|
||||
self.close_command_block();
|
||||
return;
|
||||
}
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.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);
|
||||
@@ -578,7 +578,7 @@ impl Game<'_> {
|
||||
return;
|
||||
}
|
||||
let pos = s.pos;
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
let Some(current) = self.block_state_at(pos) else {
|
||||
return;
|
||||
};
|
||||
|
||||
@@ -340,7 +340,7 @@ impl Game<'_> {
|
||||
.find(|i| i.id == id)
|
||||
.map(|i| i.stack.item.to_string())
|
||||
.unwrap_or_default();
|
||||
Text::literal(self.res.names.item(&item))
|
||||
Text::literal(self.pack.names.item(&item))
|
||||
}
|
||||
Target::Mob(id)
|
||||
if self
|
||||
@@ -783,7 +783,7 @@ impl Game<'_> {
|
||||
_ => text::WHITE,
|
||||
};
|
||||
Text::literal("[")
|
||||
.append(Text::literal(self.res.names.item(item)))
|
||||
.append(Text::literal(self.pack.names.item(item)))
|
||||
.append("]")
|
||||
.with_color(color)
|
||||
}
|
||||
@@ -816,7 +816,7 @@ impl Game<'_> {
|
||||
&[],
|
||||
)
|
||||
} else {
|
||||
Text::literal(self.res.names.item(item))
|
||||
Text::literal(self.pack.names.item(item))
|
||||
};
|
||||
let wrapped = Text::translate("chat.square_brackets", &[hover]);
|
||||
if empty {
|
||||
@@ -1456,7 +1456,7 @@ impl Game<'_> {
|
||||
name: b.id.clone(),
|
||||
properties: b.properties.iter().cloned().collect(),
|
||||
};
|
||||
self.res
|
||||
self.pack
|
||||
.assets
|
||||
.registry
|
||||
.resolve(&state)
|
||||
@@ -1464,7 +1464,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// BlockPredicateArgument test.
|
||||
fn block_matches(&self, b: &BlockInput, state: BlockStateId) -> bool {
|
||||
let Some(s) = self.res.assets.registry.state(state) else {
|
||||
let Some(s) = self.pack.assets.registry.state(state) else {
|
||||
return false;
|
||||
};
|
||||
let name_ok = if b.tag {
|
||||
@@ -1739,7 +1739,7 @@ impl Game<'_> {
|
||||
let strict = ctx.has("strict");
|
||||
// CloneCommands.clone sets every destination to a barrier first, so
|
||||
// each copied state but a barrier counts as placed.
|
||||
let barrier = self.res.assets.registry.default_state("minecraft:barrier");
|
||||
let barrier = self.pack.assets.registry.default_state("minecraft:barrier");
|
||||
let mut count = 0;
|
||||
for (_, to, s, entity) in copies {
|
||||
self.place_state(to, s, strict)?;
|
||||
@@ -2266,7 +2266,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// `PoiTypes`: the point of interest type of a block state.
|
||||
fn poi_type(&self, state: horizon_world::registry::BlockStateId) -> Option<&'static str> {
|
||||
let s = self.res.assets.registry.state(state)?;
|
||||
let s = self.pack.assets.registry.state(state)?;
|
||||
let name = s.name.strip_prefix("minecraft:")?;
|
||||
Some(match name {
|
||||
"blast_furnace" => "minecraft:armorer",
|
||||
@@ -2542,7 +2542,7 @@ impl Game<'_> {
|
||||
let focused = self.screen == Screen::Chat;
|
||||
self.ui
|
||||
.chat
|
||||
.add(&self.res.atlas, line, None, self.ticks, focused);
|
||||
.add(&self.atlas, line, None, self.ticks, focused);
|
||||
Ok(1)
|
||||
}
|
||||
/// MessageArgument: `@p`-style selectors in a message become names.
|
||||
|
||||
@@ -494,7 +494,7 @@ impl Game<'_> {
|
||||
return false;
|
||||
};
|
||||
let state = self.world.block(p[0], p[1], p[2]);
|
||||
let Some(s) = self.res.assets.registry.state(state) else {
|
||||
let Some(s) = self.pack.assets.registry.state(state) else {
|
||||
return false;
|
||||
};
|
||||
let name = s.name.to_string();
|
||||
|
||||
@@ -180,7 +180,7 @@ impl Game<'_> {
|
||||
}
|
||||
pub(in crate::game) fn data_block_name(&self, p: [i32; 3]) -> String {
|
||||
let state = self.world.block(p[0], p[1], p[2]);
|
||||
self.res
|
||||
self.pack
|
||||
.assets
|
||||
.registry
|
||||
.state(state)
|
||||
|
||||
@@ -227,7 +227,7 @@ impl Game<'_> {
|
||||
return Err(err(
|
||||
"commands.enchant.failed.incompatible",
|
||||
&[&stack.custom_name().map_or_else(
|
||||
|| self.res.names.item(&stack.item).to_string(),
|
||||
|| self.pack.names.item(&stack.item).to_string(),
|
||||
str::to_owned,
|
||||
)],
|
||||
));
|
||||
@@ -247,7 +247,7 @@ impl Game<'_> {
|
||||
),
|
||||
Some(item) => err(
|
||||
"commands.enchant.failed.incompatible",
|
||||
&[&self.res.names.item(&item)],
|
||||
&[&self.pack.names.item(&item)],
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -652,7 +652,7 @@ impl Game<'_> {
|
||||
let facts = self.res.facts.get(state);
|
||||
let blocks = facts.legacy_solid || facts.fluid != horizon_client::blocks::Fluid::None;
|
||||
let leaves = self
|
||||
.res
|
||||
.pack
|
||||
.assets
|
||||
.registry
|
||||
.state(state)
|
||||
|
||||
@@ -25,7 +25,7 @@ impl Game<'_> {
|
||||
.join("worldgen/blocks/structure-blocks.json"),
|
||||
)
|
||||
.ok()?;
|
||||
StateTransforms::from_json(&json, self.res.assets.registry.len()).ok()
|
||||
StateTransforms::from_json(&json, self.pack.assets.registry.len()).ok()
|
||||
})
|
||||
.as_ref()
|
||||
}
|
||||
@@ -64,7 +64,7 @@ impl Game<'_> {
|
||||
};
|
||||
return Some(Arc::new(StructureTemplate::from_nbt(
|
||||
&named.tag,
|
||||
self.res.assets.registry,
|
||||
self.pack.assets.registry,
|
||||
transforms,
|
||||
)));
|
||||
}
|
||||
|
||||
@@ -551,14 +551,14 @@ impl Game<'_> {
|
||||
Some(seq) => {
|
||||
let random = self.rand_sequences.get(&seq, self.level.seed);
|
||||
self.res.items.block_drops(
|
||||
self.res.assets.registry,
|
||||
self.pack.assets.registry,
|
||||
state,
|
||||
tool.as_ref(),
|
||||
random,
|
||||
)
|
||||
}
|
||||
None => self.res.items.block_drops(
|
||||
self.res.assets.registry,
|
||||
self.pack.assets.registry,
|
||||
state,
|
||||
tool.as_ref(),
|
||||
&mut self.world.random,
|
||||
|
||||
@@ -13,7 +13,7 @@ impl Game<'_> {
|
||||
/// The composter's `level` at `pos`, None when it isn't a composter.
|
||||
pub(super) fn composter_level(&self, pos: [i32; 3]) -> Option<i32> {
|
||||
let state = self.world.block(pos[0], pos[1], pos[2]);
|
||||
let s = self.res.assets.registry.state(state)?;
|
||||
let s = self.pack.assets.registry.state(state)?;
|
||||
if &*s.name != "minecraft:composter" {
|
||||
return None;
|
||||
}
|
||||
|
||||
@@ -427,7 +427,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.res.atlas, text),
|
||||
Screen::Options => self.ui.options.type_text(&self.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)),
|
||||
|
||||
@@ -168,7 +168,7 @@ impl Game<'_> {
|
||||
]
|
||||
.into(),
|
||||
};
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
let Some(id) = registry.id(&state) else {
|
||||
return;
|
||||
};
|
||||
|
||||
@@ -84,7 +84,7 @@ impl HeartHost for Host<'_> {
|
||||
|
||||
impl Game<'_> {
|
||||
fn heart_state_name(&self, state: BlockStateId) -> String {
|
||||
self.res
|
||||
self.pack
|
||||
.assets
|
||||
.registry
|
||||
.state(state)
|
||||
@@ -177,7 +177,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// `Creaking.tearDown`: the crumble particles.
|
||||
pub(super) fn creaking_tear_down(&mut self, center: [f64; 3], spread: [f64; 3]) {
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
let crumble = |this: &mut Self, name: &str, props: &[(&str, &str)], count: i32| {
|
||||
let Some(mut state) = registry
|
||||
.default_state(name)
|
||||
@@ -229,7 +229,7 @@ impl Game<'_> {
|
||||
});
|
||||
let state = self.world.block(key.0, key.1, key.2);
|
||||
let natural = self
|
||||
.res
|
||||
.pack
|
||||
.assets
|
||||
.registry
|
||||
.state(state)
|
||||
@@ -297,7 +297,7 @@ impl Game<'_> {
|
||||
/// entity (`newBlockEntity`) the first time their chunk is seen.
|
||||
fn scan_for_hearts(&mut self) {
|
||||
let Some(heart) = self
|
||||
.res
|
||||
.pack
|
||||
.assets
|
||||
.registry
|
||||
.default_state("minecraft:creaking_heart")
|
||||
|
||||
@@ -378,7 +378,7 @@ impl Game<'_> {
|
||||
let (rain, thunder) = self.world.weather.levels(1.0);
|
||||
MobWorld {
|
||||
world: &self.world,
|
||||
registry: self.res.assets.registry,
|
||||
registry: self.pack.assets.registry,
|
||||
facts: &self.res.facts,
|
||||
movement: &self.motion.blocks,
|
||||
collision: self.collision,
|
||||
@@ -995,7 +995,7 @@ impl Game<'_> {
|
||||
0.8,
|
||||
);
|
||||
}
|
||||
if let Some(state) = self.res.assets.registry.default_state(name) {
|
||||
if let Some(state) = self.pack.assets.registry.default_state(name) {
|
||||
self.world.set(pos[0], pos[1], pos[2], state)?;
|
||||
}
|
||||
}
|
||||
@@ -1004,7 +1004,7 @@ impl Game<'_> {
|
||||
self.destroy_particles(pos, old);
|
||||
if drop {
|
||||
let drops = self.res.items.block_drops_in(
|
||||
self.res.assets.registry,
|
||||
self.pack.assets.registry,
|
||||
old,
|
||||
None,
|
||||
&mut self.world.random,
|
||||
@@ -1752,7 +1752,7 @@ impl Game<'_> {
|
||||
) -> horizon_client::arrows::ArrowScene<'s, 's> {
|
||||
horizon_client::arrows::ArrowScene {
|
||||
world: &self.world,
|
||||
registry: self.res.assets.registry,
|
||||
registry: self.pack.assets.registry,
|
||||
facts: &self.res.facts,
|
||||
collision: self.collision,
|
||||
fluids: &self.motion.fluids,
|
||||
@@ -2008,7 +2008,7 @@ impl Game<'_> {
|
||||
.facts
|
||||
.is_air(self.world.block(fire[0], fire[1], fire[2]))
|
||||
&& let Some(state) =
|
||||
self.res.assets.registry.default_state("minecraft:fire")
|
||||
self.pack.assets.registry.default_state("minecraft:fire")
|
||||
{
|
||||
self.world.set(fire[0], fire[1], fire[2], state)?;
|
||||
}
|
||||
@@ -2767,7 +2767,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.res.atlas;
|
||||
let atlas = &self.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 {
|
||||
|
||||
@@ -423,7 +423,7 @@ impl Game<'_> {
|
||||
));
|
||||
}
|
||||
let (left, right) = d.columns(&self.debug_chart_lines());
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let mut draws = debug_overlay::draw(&atlas.font, [&left, &right], scale, width);
|
||||
let charts = self.debug_charts.draw(
|
||||
&atlas.font,
|
||||
|
||||
@@ -224,7 +224,7 @@ impl Game<'_> {
|
||||
for p in crafter_positions {
|
||||
let state = self.world.block(p.0, p.1, p.2);
|
||||
let triggered = self
|
||||
.res
|
||||
.pack
|
||||
.assets
|
||||
.registry
|
||||
.state(state)
|
||||
|
||||
@@ -308,7 +308,7 @@ pub(super) fn mob_set_slot(m: &mut Mob, slot: Slot, stack: ItemStack) {
|
||||
|
||||
impl Game<'_> {
|
||||
fn prop(&self, state: BlockStateId, key: &str) -> Option<String> {
|
||||
self.res
|
||||
self.pack
|
||||
.assets
|
||||
.registry
|
||||
.state(state)?
|
||||
@@ -318,11 +318,11 @@ impl Game<'_> {
|
||||
}
|
||||
/// The same block with other properties (`withProperty`).
|
||||
fn with_props(&self, state: BlockStateId, props: &[(&str, &str)]) -> Option<BlockStateId> {
|
||||
let mut s = self.res.assets.registry.state(state)?.clone();
|
||||
let mut s = self.pack.assets.registry.state(state)?.clone();
|
||||
for (k, v) in props {
|
||||
s.properties.insert((*k).to_owned(), (*v).to_owned());
|
||||
}
|
||||
self.res.assets.registry.resolve(&s).ok()
|
||||
self.pack.assets.registry.resolve(&s).ok()
|
||||
}
|
||||
fn block_at(&self, p: Pos) -> BlockStateId {
|
||||
self.world.block(p.0, p.1, p.2)
|
||||
@@ -1407,7 +1407,7 @@ impl Game<'_> {
|
||||
}
|
||||
};
|
||||
let skull = self
|
||||
.res
|
||||
.pack
|
||||
.assets
|
||||
.registry
|
||||
.default_state("minecraft:wither_skeleton_skull")
|
||||
@@ -1470,7 +1470,7 @@ impl Game<'_> {
|
||||
&& self.can_spawn_golem([target.0, target.1, target.2])
|
||||
{
|
||||
if let Some(pumpkin) = self
|
||||
.res
|
||||
.pack
|
||||
.assets
|
||||
.registry
|
||||
.default_state("minecraft:carved_pumpkin")
|
||||
@@ -2046,10 +2046,10 @@ impl Game<'_> {
|
||||
return None;
|
||||
}
|
||||
let twin = format!("minecraft:waxed_{n}");
|
||||
let mut s = self.res.assets.registry.state(state)?.clone();
|
||||
self.res.assets.registry.default_state(&twin)?;
|
||||
let mut s = self.pack.assets.registry.state(state)?.clone();
|
||||
self.pack.assets.registry.default_state(&twin)?;
|
||||
s.name = twin;
|
||||
self.res.assets.registry.resolve(&s).ok()
|
||||
self.pack.assets.registry.resolve(&s).ok()
|
||||
});
|
||||
let Some(waxed) =
|
||||
waxed.filter(|_| name.contains("copper") || name.contains("lightning_rod"))
|
||||
@@ -2108,7 +2108,7 @@ impl Game<'_> {
|
||||
1.0,
|
||||
);
|
||||
self.post_block_game_event("minecraft:fluid_place", [pos.0, pos.1, pos.2], None, None);
|
||||
if let Some(mud) = self.res.assets.registry.default_state("minecraft:mud") {
|
||||
if let Some(mud) = self.pack.assets.registry.default_state("minecraft:mud") {
|
||||
self.level_set([target.0, target.1, target.2], mud)?;
|
||||
}
|
||||
let bottle = ItemStack::new("minecraft:glass_bottle", 1);
|
||||
|
||||
@@ -582,7 +582,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// `EndCrystal.tick`: the time and the fire below it in the End.
|
||||
fn tick_crystals(&mut self) {
|
||||
let fire = self.res.assets.registry.default_state("minecraft:fire");
|
||||
let fire = self.pack.assets.registry.default_state("minecraft:fire");
|
||||
for i in 0..self.crystals.len() {
|
||||
self.crystals[i].time += 1;
|
||||
let p = self.crystals[i].position;
|
||||
@@ -1702,7 +1702,7 @@ impl Game<'_> {
|
||||
}
|
||||
if !self.fight.previously_killed
|
||||
&& let Some(egg) = self
|
||||
.res
|
||||
.pack
|
||||
.assets
|
||||
.registry
|
||||
.default_state("minecraft:dragon_egg")
|
||||
@@ -1866,9 +1866,9 @@ impl Game<'_> {
|
||||
batch.width as i32,
|
||||
batch.height as i32,
|
||||
&bars,
|
||||
&self.res.atlas.font,
|
||||
&self.atlas.font,
|
||||
);
|
||||
hud_layout::paint(batch, &self.res.atlas, &draws);
|
||||
hud_layout::paint(batch, &self.atlas, &draws);
|
||||
}
|
||||
/// The dragon fight's boss bar shows (`EnderDragonFight.dragonEvent`,
|
||||
/// with `setCreateWorldFog`).
|
||||
@@ -1906,13 +1906,7 @@ impl Game<'_> {
|
||||
return;
|
||||
};
|
||||
let a = alpha as f32;
|
||||
let sprite = |n: &str| {
|
||||
self.res
|
||||
.atlas
|
||||
.sprites
|
||||
.get(n)
|
||||
.map(|r| [r.u0, r.v0, r.u1, r.v1])
|
||||
};
|
||||
let sprite = |n: &str| self.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"),
|
||||
@@ -2078,7 +2072,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.res.atlas.font.white();
|
||||
let white = self.atlas.font.white();
|
||||
let uv = [white.u0, white.v0];
|
||||
let over = if t > 0.8 {
|
||||
((t - 0.8) / 0.2).min(1.0)
|
||||
@@ -2134,7 +2128,6 @@ impl Game<'_> {
|
||||
out: &mut Vec<Vertex>,
|
||||
) {
|
||||
let Some(s) = self
|
||||
.res
|
||||
.atlas
|
||||
.sprites
|
||||
.get("entity/end_crystal/end_crystal_beam")
|
||||
@@ -2196,7 +2189,6 @@ impl Game<'_> {
|
||||
out: &mut Vec<Vertex>,
|
||||
) {
|
||||
let Some(s) = self
|
||||
.res
|
||||
.atlas
|
||||
.sprites
|
||||
.get("entity/enderdragon/dragon_fireball")
|
||||
@@ -2610,7 +2602,7 @@ impl Game<'_> {
|
||||
/// and grown again with a guarded crystal.
|
||||
fn rebuild_spike(&mut self, spike: &horizon_world::worldgen::end_spike::EndSpike) {
|
||||
let (cx, cz, h) = (spike.center_x, spike.center_z, spike.height);
|
||||
let air = self.res.assets.registry.default_state("minecraft:air");
|
||||
let air = self.pack.assets.registry.default_state("minecraft:air");
|
||||
let Some(air) = air else {
|
||||
return;
|
||||
};
|
||||
@@ -2685,7 +2677,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// Iron bars connected north, south, west and east.
|
||||
fn set_bars(&mut self, pos: [i32; 3], sides: [bool; 4]) {
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
let Some(mut state) = registry
|
||||
.default_state("minecraft:iron_bars")
|
||||
.and_then(|d| registry.state(d).cloned())
|
||||
|
||||
@@ -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.res.atlas.sprites.get("environment/end_sky").copied() else {
|
||||
let Some(r) = self.atlas.sprites.get("environment/end_sky").copied() else {
|
||||
return out;
|
||||
};
|
||||
use std::f32::consts::FRAC_PI_2;
|
||||
@@ -184,7 +184,6 @@ impl Game<'_> {
|
||||
let intensity = self.end.flash.intensity(self.clock.fraction() as f32);
|
||||
if intensity > 1e-5
|
||||
&& let Some(r) = self
|
||||
.res
|
||||
.atlas
|
||||
.sprites
|
||||
.get("environment/celestial/end_flash")
|
||||
@@ -237,7 +236,7 @@ impl Game<'_> {
|
||||
if &*stack.item != "minecraft:ender_eye" {
|
||||
return Ok(false);
|
||||
}
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
let target = self.pick().and_then(|hit| {
|
||||
let state = registry.state(self.world.block(hit.pos[0], hit.pos[1], hit.pos[2]))?;
|
||||
(state.name == "minecraft:end_portal_frame").then(|| (hit, state.clone()))
|
||||
@@ -303,7 +302,7 @@ impl Game<'_> {
|
||||
/// ring (corners free) of filled frames, all facing the centre or all
|
||||
/// facing away from it. Returns the centre of the 3×3 opening.
|
||||
fn portal_ring_center(&self, frame: [i32; 3]) -> Option<[i32; 3]> {
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
// (offset from the centre, facing when the frames face the centre)
|
||||
let mut ring = Vec::with_capacity(12);
|
||||
for i in -1..=1 {
|
||||
@@ -630,7 +629,7 @@ impl Game<'_> {
|
||||
&[],
|
||||
)?;
|
||||
}
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
for (facing, d) in [
|
||||
("north", [0, -1]),
|
||||
("south", [0, 1]),
|
||||
@@ -898,8 +897,7 @@ 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.res
|
||||
.atlas
|
||||
self.atlas
|
||||
.sprites
|
||||
.get("entity/end_crystal/end_crystal")
|
||||
.copied(),
|
||||
@@ -1052,7 +1050,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.res.atlas.sprites.get("item/ender_eye").copied() else {
|
||||
let Some(r) = self.atlas.sprites.get("item/ender_eye").copied() else {
|
||||
return;
|
||||
};
|
||||
let alpha = self.clock.fraction();
|
||||
|
||||
@@ -511,7 +511,7 @@ impl Game<'_> {
|
||||
// random sequence.
|
||||
let decay = (interaction == BlockInteraction::DestroyWithDecay).then_some(radius);
|
||||
let drops = self.res.items.block_drops_exploded(
|
||||
self.res.assets.registry,
|
||||
self.pack.assets.registry,
|
||||
state,
|
||||
None,
|
||||
&dynamic,
|
||||
|
||||
@@ -193,10 +193,10 @@ impl Game<'_> {
|
||||
if !self.extras.minimap.compose(view) {
|
||||
return;
|
||||
}
|
||||
let Some(rect) = self.res.atlas.sprites.get(MINIMAP_SPRITE).copied() else {
|
||||
let Some(rect) = self.atlas.sprites.get(MINIMAP_SPRITE).copied() else {
|
||||
return;
|
||||
};
|
||||
let (w, h) = (self.res.atlas.width as f32, self.res.atlas.height as f32);
|
||||
let (w, h) = (self.atlas.width as f32, self.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,
|
||||
@@ -242,7 +242,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.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
if let Some(view) = self.minimap_view()
|
||||
&& visible(map_corner)
|
||||
&& !self.extras.minimap.image.is_empty()
|
||||
@@ -286,7 +286,7 @@ impl Game<'_> {
|
||||
use_: self.extras.mouse[1],
|
||||
cps,
|
||||
};
|
||||
extras_hud::draw_keystrokes(batch, &self.res.atlas, &mut corners, keys_corner, &k);
|
||||
extras_hud::draw_keystrokes(batch, &self.atlas, &mut corners, keys_corner, &k);
|
||||
}
|
||||
if mod_panels {
|
||||
self.draw_mod_panels(batch, &mut corners);
|
||||
|
||||
@@ -108,7 +108,6 @@ impl Game<'_> {
|
||||
return;
|
||||
};
|
||||
let Some(r) = self
|
||||
.res
|
||||
.atlas
|
||||
.sprites
|
||||
.get("entity/illager/evoker_fangs")
|
||||
|
||||
@@ -565,7 +565,6 @@ impl Game<'_> {
|
||||
return;
|
||||
};
|
||||
let Some(r) = self
|
||||
.res
|
||||
.atlas
|
||||
.sprites
|
||||
.get("entity/fishing/fishing_hook")
|
||||
|
||||
@@ -171,6 +171,6 @@ impl Game<'_> {
|
||||
}
|
||||
let draws =
|
||||
hud_overlays::spyglass(batch.width as i32, batch.height as i32, self.scope_scale);
|
||||
hud_layout::paint(batch, &self.res.atlas, &draws);
|
||||
hud_layout::paint(batch, &self.atlas, &draws);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.res.atlas.sprites;
|
||||
let sprites = &self.atlas.sprites;
|
||||
let mut maps: Vec<(i32, glam::Mat4, u32)> = Vec::new();
|
||||
let mut items: Vec<(ItemStack, u32, glam::Mat4, u8)> = Vec::new();
|
||||
for f in &self.item_frames {
|
||||
|
||||
@@ -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.res.atlas;
|
||||
let atlas = &self.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.res.atlas,
|
||||
&self.atlas,
|
||||
"gui/sprites/gamemode_switcher/slot",
|
||||
x as f32,
|
||||
y as f32,
|
||||
);
|
||||
if mode == selected {
|
||||
batch.sprite(
|
||||
&self.res.atlas,
|
||||
&self.atlas,
|
||||
"gui/sprites/gamemode_switcher/selection",
|
||||
x as f32,
|
||||
y as f32,
|
||||
|
||||
@@ -110,7 +110,7 @@ impl Game<'_> {
|
||||
f64::from(pos[2]) + 0.5,
|
||||
];
|
||||
let facing = self
|
||||
.res
|
||||
.pack
|
||||
.assets
|
||||
.registry
|
||||
.state(state)
|
||||
|
||||
@@ -146,7 +146,7 @@ impl Game<'_> {
|
||||
let below = [head[0], head[1] - 1, head[2]];
|
||||
let copper = self.world.block(below[0], below[1], below[2]);
|
||||
let pumpkin = self.world.block(head[0], head[1], head[2]);
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
let facing = registry
|
||||
.state(pumpkin)
|
||||
.and_then(|s| s.properties.get("facing").cloned())
|
||||
|
||||
@@ -15,7 +15,7 @@ impl Game<'_> {
|
||||
}
|
||||
let dir = self.options.resources.join("worldgen");
|
||||
let started = std::time::Instant::now();
|
||||
let features = vanillagen::shared_data(&dir, self.res.assets.registry)
|
||||
let features = vanillagen::shared_data(&dir, self.pack.assets.registry)
|
||||
.map_err(|e| e.to_string())
|
||||
.and_then(|data| LiveFeatures::new(&data).map_err(|e| e.to_string()));
|
||||
match features {
|
||||
|
||||
@@ -257,7 +257,7 @@ impl Game<'_> {
|
||||
.or_else(|| self.held());
|
||||
if let Some(stack) = active {
|
||||
let components = self
|
||||
.res
|
||||
.pack
|
||||
.item_renderer
|
||||
.models
|
||||
.components(&horizon_client::item_render::stack_view(stack));
|
||||
|
||||
@@ -72,7 +72,7 @@ impl Game<'_> {
|
||||
fn spawn_columns(&self) -> Columns<'_, '_> {
|
||||
Columns {
|
||||
world: &self.world,
|
||||
properties: &self.res.assets.properties,
|
||||
properties: &self.pack.assets.properties,
|
||||
binding: self.collision,
|
||||
}
|
||||
}
|
||||
@@ -82,7 +82,7 @@ impl Game<'_> {
|
||||
horizon_client::save::world_gen_settings(&self.world_root).and_then(|s| {
|
||||
horizon_client::flatgen::FlatTerrain::from_settings(
|
||||
&s,
|
||||
self.res.assets.registry,
|
||||
self.pack.assets.registry,
|
||||
&self.res.biomes,
|
||||
)
|
||||
})
|
||||
|
||||
@@ -31,7 +31,7 @@ impl ItemEnv for Env<'_, '_> {
|
||||
}
|
||||
fn grass_color(&self, temperature: f64, downfall: f64) -> i32 {
|
||||
self.game
|
||||
.res
|
||||
.pack
|
||||
.item_renderer
|
||||
.grass_color(temperature, downfall)
|
||||
}
|
||||
@@ -43,7 +43,7 @@ impl ItemEnv for Env<'_, '_> {
|
||||
else {
|
||||
return 0.0;
|
||||
};
|
||||
let prototypes = &self.game.res.item_renderer.models.prototypes;
|
||||
let prototypes = &self.game.pack.item_renderer.models.prototypes;
|
||||
let mut total = 0.0f64;
|
||||
for item in items {
|
||||
let id = item["id"].as_str().unwrap_or("");
|
||||
@@ -216,7 +216,7 @@ impl Game<'_> {
|
||||
&& self.inventory.get(slot).and_then(Option::as_ref) == Some(stack)
|
||||
{
|
||||
let view = item_render::stack_view(stack);
|
||||
let duration = use_duration(&self.res.item_renderer.models.components(&view));
|
||||
let duration = use_duration(&self.pack.item_renderer.models.components(&view));
|
||||
owner.using_this_item = true;
|
||||
owner.use_duration = duration;
|
||||
owner.use_item_remaining_ticks = duration - ticks as i32;
|
||||
@@ -239,7 +239,7 @@ impl Game<'_> {
|
||||
seed: i32,
|
||||
) -> ItemRenderState {
|
||||
let level = self.item_level();
|
||||
self.res.item_renderer.resolve(
|
||||
self.pack.item_renderer.resolve(
|
||||
&item_render::stack_view(stack),
|
||||
display,
|
||||
owner,
|
||||
@@ -254,8 +254,8 @@ impl Game<'_> {
|
||||
let state = self.resolve_item(stack, DisplayContext::Gui, Some(&owner), 0);
|
||||
item_render::gui::draw(
|
||||
&state,
|
||||
&self.res.item_renderer,
|
||||
&self.res.atlas.sprites,
|
||||
&self.pack.item_renderer,
|
||||
&self.atlas.sprites,
|
||||
&self.item_host(),
|
||||
batch,
|
||||
x,
|
||||
@@ -278,8 +278,8 @@ impl Game<'_> {
|
||||
lights: Some(diffuse_lights(self.dim == Dim::Nether)),
|
||||
};
|
||||
state.submit(
|
||||
&self.res.item_renderer,
|
||||
&self.res.atlas.sprites,
|
||||
&self.pack.item_renderer,
|
||||
&self.atlas.sprites,
|
||||
&self.item_host(),
|
||||
pose,
|
||||
&mut sink,
|
||||
@@ -299,8 +299,8 @@ impl Game<'_> {
|
||||
lights: None,
|
||||
};
|
||||
state.submit(
|
||||
&self.res.item_renderer,
|
||||
&self.res.atlas.sprites,
|
||||
&self.pack.item_renderer,
|
||||
&self.atlas.sprites,
|
||||
&self.item_host(),
|
||||
pose,
|
||||
&mut sink,
|
||||
@@ -360,7 +360,7 @@ impl Game<'_> {
|
||||
(q.y + 0.1).floor() as i32,
|
||||
q.z.floor() as i32,
|
||||
);
|
||||
let seed = i64::from(self.res.item_renderer.item_id(&item.stack.item))
|
||||
let seed = i64::from(self.pack.item_renderer.item_id(&item.stack.item))
|
||||
+ i64::from(item.stack.damage);
|
||||
for copy in item_render::cluster_poses(
|
||||
&state,
|
||||
|
||||
@@ -21,7 +21,7 @@ impl Game<'_> {
|
||||
}
|
||||
fn set_has_record(&mut self, pos: [i32; 3], has: bool) {
|
||||
let state = self.world.block(pos[0], pos[1], pos[2]);
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
let Some(mut s) = registry.state(state).cloned() else {
|
||||
return;
|
||||
};
|
||||
|
||||
@@ -440,7 +440,7 @@ impl Game<'_> {
|
||||
encoder.tables = Some(
|
||||
self.save
|
||||
.tables
|
||||
.get_or_init(|| Arc::new(horizon_client::save::SaveTables::new(&self.res.assets)))
|
||||
.get_or_init(|| Arc::new(horizon_client::save::SaveTables::new(&self.pack.assets)))
|
||||
.clone(),
|
||||
);
|
||||
let lan = Lan::start_with(sync.clone(), net)?;
|
||||
@@ -886,7 +886,7 @@ impl Game<'_> {
|
||||
let Some(host) = &self.lan else {
|
||||
return;
|
||||
};
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.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();
|
||||
|
||||
@@ -859,7 +859,7 @@ impl Game<'_> {
|
||||
entities: &[],
|
||||
player,
|
||||
scene: &mut game.world,
|
||||
assets: &game.res.assets,
|
||||
assets: &game.pack.assets,
|
||||
collision_binding: game.collision,
|
||||
resources: game.motion,
|
||||
};
|
||||
|
||||
@@ -502,7 +502,7 @@ impl Game<'_> {
|
||||
View::Restrictions => self.draw_restrictions(batch),
|
||||
View::GameRules => {
|
||||
if let Some(rules) = o.rules.as_mut() {
|
||||
rules.draw(batch, &self.res.atlas, self.cursor);
|
||||
rules.draw(batch, &self.atlas, self.cursor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -510,7 +510,7 @@ impl Game<'_> {
|
||||
}
|
||||
|
||||
fn draw_lock_question(&self, o: &WorldOptions, batch: &mut HudBatch) {
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let (w, h) = (batch.width, batch.height);
|
||||
// Screen.extractTransparentBackground.
|
||||
batch.fill_gradient(
|
||||
@@ -552,7 +552,7 @@ impl Game<'_> {
|
||||
}
|
||||
|
||||
fn draw_restrictions(&self, batch: &mut HudBatch) {
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.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", &[]);
|
||||
@@ -583,7 +583,7 @@ impl Game<'_> {
|
||||
}
|
||||
|
||||
fn draw_options_view(&self, o: &mut WorldOptions, batch: &mut HudBatch, cursor: (f32, f32)) {
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let (w, h) = (batch.width, batch.height);
|
||||
o.scroll = o.scroll.clamp(0.0, WorldOptions::max_scroll(h));
|
||||
// extractMenuBackground: the in-world background, the list
|
||||
@@ -701,7 +701,7 @@ impl Game<'_> {
|
||||
match o.view {
|
||||
View::Options => {}
|
||||
View::GameRules => {
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let exit = o.rules.as_mut().and_then(|rules| {
|
||||
if rules.clicks_button(atlas, self.cursor, (w, h)) {
|
||||
self.audio.play_button_click();
|
||||
@@ -715,7 +715,7 @@ impl Game<'_> {
|
||||
return;
|
||||
}
|
||||
View::LockQuestion => {
|
||||
let p = Popup::lock_question(&self.res.atlas.font, o.difficulty, (w, h));
|
||||
let p = Popup::lock_question(&self.atlas.font, o.difficulty, (w, h));
|
||||
let hit = p
|
||||
.buttons
|
||||
.iter()
|
||||
@@ -733,8 +733,7 @@ impl Game<'_> {
|
||||
return;
|
||||
}
|
||||
View::Restrictions => {
|
||||
let r =
|
||||
Restrictions::new(&self.res.atlas.font, self.settings.chat_visibility, (w, h));
|
||||
let r = Restrictions::new(&self.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)
|
||||
|
||||
@@ -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.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let white = atlas.font.white();
|
||||
let uv = [
|
||||
[white.u0, white.v1],
|
||||
|
||||
@@ -174,7 +174,7 @@ impl Game<'_> {
|
||||
if below.sturdy_full >> 1 & 1 == 0 {
|
||||
continue;
|
||||
}
|
||||
if let Some(fire) = self.res.assets.registry.default_state(name) {
|
||||
if let Some(fire) = self.pack.assets.registry.default_state(name) {
|
||||
let _ = self.level_set(p, fire);
|
||||
}
|
||||
}
|
||||
@@ -239,7 +239,7 @@ impl Game<'_> {
|
||||
if !self.res.facts.get(state).name.ends_with("lightning_rod") {
|
||||
return;
|
||||
}
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
if let Some(mut s) = registry.state(state).cloned() {
|
||||
s.properties.insert("powered".into(), "true".into());
|
||||
if let Some(powered) = registry.id(&s) {
|
||||
@@ -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.res.atlas.font.white();
|
||||
let white = self.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;
|
||||
|
||||
@@ -198,8 +198,8 @@ impl Game<'_> {
|
||||
.map(|l| (banners.banner_texture(&l.pattern), l.color.to_string()))
|
||||
.collect();
|
||||
horizon_client::item_render::gui::draw_banner_result(
|
||||
&self.res.item_renderer,
|
||||
&self.res.atlas.sprites,
|
||||
&self.pack.item_renderer,
|
||||
&self.atlas.sprites,
|
||||
batch,
|
||||
x,
|
||||
y,
|
||||
@@ -217,7 +217,7 @@ impl Game<'_> {
|
||||
draws: &[ScreenDraw],
|
||||
background: bool,
|
||||
) -> Option<Vec<(String, u32)>> {
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let mut tooltip = None;
|
||||
let mut sheet: Option<String> = None;
|
||||
for d in draws {
|
||||
|
||||
@@ -363,7 +363,7 @@ impl Game<'_> {
|
||||
world: &self.world,
|
||||
behaviours: &self.res.behaviours,
|
||||
items: &self.res.items,
|
||||
registry: self.res.assets.registry,
|
||||
registry: self.pack.assets.registry,
|
||||
brewing: Some(&self.res.stations.brewing),
|
||||
bone_meal: bone_meal(),
|
||||
}
|
||||
@@ -500,7 +500,7 @@ impl Game<'_> {
|
||||
/// Every hopper's `pushItemsTick`, in a stable position order.
|
||||
pub(super) fn tick_hoppers(&mut self) -> Result<()> {
|
||||
let hopper = self
|
||||
.res
|
||||
.pack
|
||||
.assets
|
||||
.registry
|
||||
.default_state("minecraft:hopper")
|
||||
@@ -833,7 +833,7 @@ impl Game<'_> {
|
||||
let Some(screen) = self.machine_screen() else {
|
||||
return false;
|
||||
};
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let key_is_cart = self
|
||||
.container
|
||||
.is_some_and(|k| k.1 == super::minecarts::CART_KEY_Y);
|
||||
|
||||
@@ -33,7 +33,7 @@ fn recipe_matches(condition: &Value, id: &str) -> bool {
|
||||
impl Game<'_> {
|
||||
/// `Level.setBlock` of one boolean property of the block at `pos`.
|
||||
fn set_bool_prop(&mut self, pos: Pos, key: &str, value: bool, flags: i32) {
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
let old = self.world.block(pos.0, pos.1, pos.2);
|
||||
let Some(mut state) = registry.state(old).cloned() else {
|
||||
return;
|
||||
@@ -254,7 +254,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.res.atlas;
|
||||
let atlas = &self.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);
|
||||
|
||||
@@ -789,7 +789,6 @@ impl Game<'_> {
|
||||
}
|
||||
let slot = self.maps.slots.last()?.1;
|
||||
let rect = self
|
||||
.res
|
||||
.atlas
|
||||
.sprites
|
||||
.get(&format!("horizon/map{slot}"))
|
||||
@@ -798,7 +797,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.res.atlas.width as f32, self.res.atlas.height as f32);
|
||||
let (w, h) = (self.atlas.width as f32, self.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,
|
||||
@@ -856,7 +855,7 @@ impl Game<'_> {
|
||||
.map(|m| m.decorations.clone())
|
||||
.unwrap_or_default();
|
||||
for (i, d) in decorations.iter().enumerate() {
|
||||
let Some(s) = self.res.atlas.sprites.get(d.sprite).copied() else {
|
||||
let Some(s) = self.atlas.sprites.get(d.sprite).copied() else {
|
||||
continue;
|
||||
};
|
||||
let dm = glam::Mat4::from_translation(glam::Vec3::new(
|
||||
@@ -932,7 +931,7 @@ impl Game<'_> {
|
||||
} else {
|
||||
"map/map_background"
|
||||
};
|
||||
if let Some(r) = self.res.atlas.sprites.get(background).copied() {
|
||||
if let Some(r) = self.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]),
|
||||
|
||||
@@ -221,7 +221,7 @@ impl Game<'_> {
|
||||
) {
|
||||
return None;
|
||||
}
|
||||
let s = self.res.assets.registry.state(state)?;
|
||||
let s = self.pack.assets.registry.state(state)?;
|
||||
let shape = Shape::parse(s.properties.get("shape").map_or("", String::as_str));
|
||||
let powered = s.properties.get("powered").is_some_and(|v| v == "true");
|
||||
Some(Rail {
|
||||
@@ -1148,16 +1148,16 @@ impl Game<'_> {
|
||||
light: u32,
|
||||
out: &mut Vec<Vertex>,
|
||||
) {
|
||||
let Ok(models) = self.res.assets.model_catalog.collect(state, seed_pos) else {
|
||||
let Ok(models) = self.pack.assets.model_catalog.collect(state, seed_pos) else {
|
||||
return;
|
||||
};
|
||||
for (_, model) in &models {
|
||||
for face in &model.faces {
|
||||
let Some(s) = self
|
||||
.res
|
||||
.pack
|
||||
.layer_names
|
||||
.get(&face.layer)
|
||||
.and_then(|n| self.res.atlas.sprites.get(n))
|
||||
.and_then(|n| self.atlas.sprites.get(n))
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
@@ -1185,7 +1185,7 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
fn display_state(&self, c: &Minecart) -> Option<BlockStateId> {
|
||||
let registry = &self.res.assets.registry;
|
||||
let registry = &self.pack.assets.registry;
|
||||
let with = |name: &str, props: &[(&str, &str)]| {
|
||||
let mut s = registry.state(registry.default_state(name)?)?.clone();
|
||||
for (k, v) in props {
|
||||
@@ -1218,7 +1218,6 @@ impl Game<'_> {
|
||||
continue;
|
||||
};
|
||||
let Some(uv) = self
|
||||
.res
|
||||
.atlas
|
||||
.sprites
|
||||
.get("entity/minecart/minecart")
|
||||
@@ -1325,12 +1324,12 @@ impl Game<'_> {
|
||||
game_time: self.world.game_time,
|
||||
max_y: self.dim.max_y(),
|
||||
world: &self.world,
|
||||
sprites: &self.res.atlas.sprites,
|
||||
sprites: &self.atlas.sprites,
|
||||
nether: self.dim == super::Dim::Nether,
|
||||
lid: &lid,
|
||||
sign: &|_| None,
|
||||
banner: &|_| Vec::new(),
|
||||
glyph: &|c| self.res.atlas.glyph_cell(c),
|
||||
glyph: &|c| self.atlas.glyph_cell(c),
|
||||
};
|
||||
self.res
|
||||
.block_entity_render
|
||||
|
||||
@@ -78,7 +78,7 @@ impl Game<'_> {
|
||||
let Some(kind) = self.res.mob_types.get("minecraft:elder_guardian") else {
|
||||
return;
|
||||
};
|
||||
let Some(r) = self.res.atlas.sprites.get("entity/guardian_elder").copied() else {
|
||||
let Some(r) = self.atlas.sprites.get("entity/guardian_elder").copied() else {
|
||||
return;
|
||||
};
|
||||
let age = (APPARITION_TICKS - left) as f32 + alpha as f32;
|
||||
@@ -147,7 +147,7 @@ impl Game<'_> {
|
||||
return;
|
||||
};
|
||||
let m = banner_matrix(head);
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.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.res.atlas.sprites.get(name).copied() else {
|
||||
let Some(r) = self.atlas.sprites.get(name).copied() else {
|
||||
continue;
|
||||
};
|
||||
let tint = if side == 0 { cube.tint } else { 0xFF_FFFF };
|
||||
|
||||
@@ -230,7 +230,7 @@ impl Game<'_> {
|
||||
let focused = self.screen == Screen::Chat;
|
||||
self.ui
|
||||
.chat
|
||||
.add(&self.res.atlas, line, None, self.ticks, focused);
|
||||
.add(&self.atlas, line, None, self.ticks, focused);
|
||||
}
|
||||
}
|
||||
/// The mods' HUD panels, stacked with the extras in their corners.
|
||||
@@ -251,7 +251,7 @@ impl Game<'_> {
|
||||
.iter()
|
||||
.map(|l| (l.text.as_str(), l.color))
|
||||
.collect();
|
||||
extras_hud::draw_lines(batch, &self.res.atlas, corners, corner, &lines);
|
||||
extras_hud::draw_lines(batch, &self.atlas, corners, corner, &lines);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ impl Game<'_> {
|
||||
let Some(open) = self.mount_menu.open.as_ref() else {
|
||||
return;
|
||||
};
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.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.res.atlas;
|
||||
let atlas = &self.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(
|
||||
|
||||
@@ -457,7 +457,7 @@ impl Game<'_> {
|
||||
return (0, false);
|
||||
};
|
||||
let m = &self.mobs[i];
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.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);
|
||||
|
||||
@@ -122,7 +122,7 @@ impl Game<'_> {
|
||||
f64::from(p.dimensions.width / 2.0),
|
||||
f64::from(p.dimensions.height),
|
||||
);
|
||||
let registry = &self.res.assets.registry;
|
||||
let registry = &self.pack.assets.registry;
|
||||
let facts = &self.res.facts;
|
||||
let bubble_column = horizon_client::ambience::bubble_column_in(
|
||||
[
|
||||
|
||||
@@ -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.res.atlas.font.white();
|
||||
let white = self.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.res.atlas.glyph(*c).map_or(6.0, |g| g.1))
|
||||
.map(|(c, _)| self.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.res.atlas.glyph(ch) else {
|
||||
let Some((g, advance)) = self.atlas.glyph(ch) else {
|
||||
x += 6.0;
|
||||
continue;
|
||||
};
|
||||
|
||||
@@ -161,7 +161,7 @@ impl Game<'_> {
|
||||
Some(c) => &**c,
|
||||
None => match self
|
||||
.save
|
||||
.load(x, z, self.res.assets.registry, &self.res.biomes)
|
||||
.load(x, z, self.pack.assets.registry, &self.res.biomes)
|
||||
{
|
||||
Some(c) => {
|
||||
saved = c;
|
||||
@@ -390,7 +390,7 @@ impl Game<'_> {
|
||||
self.capture(true);
|
||||
}
|
||||
}
|
||||
if self.res.screen_fx.portal == 0.0 {
|
||||
if self.screen_fx.portal == 0.0 {
|
||||
let pitch = self.world.random.next_float() * 0.4 + 0.8;
|
||||
self.audio
|
||||
.play("minecraft:block.portal.trigger", None, 0.25, pitch);
|
||||
|
||||
@@ -160,7 +160,7 @@ impl Game<'_> {
|
||||
* glam::Mat4::from_scale(glam::Vec3::splat(scale))
|
||||
* glam::Mat4::from_rotation_y(spin.to_radians());
|
||||
let seed =
|
||||
i64::from(self.res.item_renderer.item_id(&s.item.item)) + i64::from(s.item.damage);
|
||||
i64::from(self.pack.item_renderer.item_id(&s.item.item)) + i64::from(s.item.damage);
|
||||
for copy in item_render::cluster_poses(
|
||||
&state,
|
||||
pose,
|
||||
|
||||
@@ -100,7 +100,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.res.atlas, self.cursor);
|
||||
ui.draw(&self.settings, batch, &self.atlas, self.cursor);
|
||||
self.ui.options = ui;
|
||||
}
|
||||
pub(super) fn options_mouse(&mut self, pressed: bool, right: bool) -> Result<()> {
|
||||
@@ -122,7 +122,7 @@ impl Game<'_> {
|
||||
let mut ui = std::mem::take(&mut self.ui.options);
|
||||
let events = ui.click(
|
||||
&mut self.settings,
|
||||
&self.res.atlas,
|
||||
&self.atlas,
|
||||
self.cursor.0,
|
||||
self.cursor.1,
|
||||
size,
|
||||
@@ -141,7 +141,7 @@ impl Game<'_> {
|
||||
let mut ui = std::mem::take(&mut self.ui.options);
|
||||
let events = ui.click(
|
||||
&mut self.settings,
|
||||
&self.res.atlas,
|
||||
&self.atlas,
|
||||
self.cursor.0,
|
||||
self.cursor.1,
|
||||
size,
|
||||
@@ -154,7 +154,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.res.atlas, key, text);
|
||||
let events = ui.key(&mut self.settings, &self.atlas, key, text);
|
||||
self.ui.options = ui;
|
||||
self.handle_option_events(events)
|
||||
}
|
||||
@@ -165,7 +165,7 @@ impl Game<'_> {
|
||||
) -> bool {
|
||||
self.ui
|
||||
.options
|
||||
.shortcut(&self.res.atlas, shortcut, &mut self.clipboard)
|
||||
.shortcut(&self.atlas, shortcut, &mut self.clipboard)
|
||||
}
|
||||
pub(super) fn options_scroll(&mut self, amount: f32) {
|
||||
let size = self.gui_size();
|
||||
@@ -226,7 +226,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.res.atlas);
|
||||
self.ui.chat.rescale(&self.atlas);
|
||||
}
|
||||
/// Settings that Horizon applies beyond render distance, volume and GUI scale.
|
||||
pub(super) fn apply_ui_settings(&mut self) {
|
||||
@@ -256,14 +256,14 @@ impl Game<'_> {
|
||||
};
|
||||
self.ui.chat.options = chat;
|
||||
if rescale {
|
||||
self.ui.chat.rescale(&self.res.atlas);
|
||||
self.ui.chat.rescale(&self.atlas);
|
||||
}
|
||||
let font = &mut self.res.atlas.font;
|
||||
let font = &mut self.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.res.atlas);
|
||||
self.ui.chat.rescale(&self.atlas);
|
||||
}
|
||||
// A new renderer (resource reload, first window) takes the loaded pack.
|
||||
let stale = self
|
||||
|
||||
@@ -110,44 +110,30 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
fn reload_resources(&mut self, root: &Path) -> horizon_client::Result<()> {
|
||||
let assets = std::sync::Arc::new(self.res.assets.reload(root)?);
|
||||
let assets = std::sync::Arc::new(self.pack.assets.reload(root)?);
|
||||
let mut atlas = HudAtlas::build(root)?;
|
||||
let panorama = horizon_client::gfx::panorama::Faces::load(root);
|
||||
atlas.font.uniform = self.settings.force_unicode;
|
||||
atlas.font.japanese = self.settings.japanese_glyphs;
|
||||
let item_renderer = horizon_client::item_render::ItemRenderer::load_with_library(
|
||||
let pack = super::PackResources::load(
|
||||
root,
|
||||
assets.model_library.clone(),
|
||||
)?;
|
||||
let visibility = horizon_client::models::load_visibility(root, assets.registry)?;
|
||||
let tables = std::sync::Arc::new(horizon_client::mesher::MeshTables::new(
|
||||
&assets,
|
||||
assets,
|
||||
&self.res.facts,
|
||||
visibility,
|
||||
)?);
|
||||
self.pack.context.biomes.clone(),
|
||||
self.pack.context.light.clone(),
|
||||
)?;
|
||||
// Everything loaded: switch over.
|
||||
self.random_tick_sections.clear();
|
||||
self.options.resources = root.to_path_buf();
|
||||
let context = std::sync::Arc::new(horizon_client::streaming::WorkerContext {
|
||||
assets: assets.clone(),
|
||||
tables,
|
||||
biomes: self.res.context.biomes.clone(),
|
||||
light: self.res.context.light.clone(),
|
||||
});
|
||||
self.res.layer_names = assets
|
||||
.sprite_layers
|
||||
.iter()
|
||||
.map(|(name, layer)| (*layer, name.trim_start_matches("minecraft:").to_owned()))
|
||||
.collect();
|
||||
self.res.assets = assets;
|
||||
self.res.context = context.clone();
|
||||
self.res.atlas = atlas;
|
||||
self.res.panorama = panorama;
|
||||
self.res.item_renderer = std::sync::Arc::new(item_renderer);
|
||||
self.res.clouds = super::load_clouds(root);
|
||||
self.res.forcefield = super::load_forcefield(root);
|
||||
self.res.names = super::Names::load(root);
|
||||
self.res.mob_data.villager_hats =
|
||||
let context = pack.context.clone();
|
||||
self.pack = pack;
|
||||
self.atlas = atlas;
|
||||
// Villager hats come from the pack's texture metadata (shared data, swapped in place).
|
||||
*self
|
||||
.res
|
||||
.mob_data
|
||||
.villager_hats
|
||||
.write()
|
||||
.unwrap_or_else(std::sync::PoisonError::into_inner) =
|
||||
horizon_client::mobs::villager_hats::VillagerHats::load(root);
|
||||
horizon_client::ui::load_metadata(root);
|
||||
lang::set(lang::Language::load(&[&root.to_path_buf()], &lang::code()));
|
||||
@@ -161,7 +147,7 @@ impl Game<'_> {
|
||||
self.renderer = Some(self.new_renderer(window)?);
|
||||
self.apply_ui_settings();
|
||||
}
|
||||
self.ui.chat.rescale(&self.res.atlas);
|
||||
self.ui.chat.rescale(&self.atlas);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -942,7 +942,7 @@ impl Game<'_> {
|
||||
} else if self.screen == Screen::Options {
|
||||
let result = match text {
|
||||
Some(t) => {
|
||||
self.ui.options.type_text(&self.res.atlas, t);
|
||||
self.ui.options.type_text(&self.atlas, t);
|
||||
Ok(())
|
||||
}
|
||||
None => self.options_key(key.expect("a key"), None),
|
||||
@@ -987,7 +987,7 @@ impl Game<'_> {
|
||||
.is_some_and(|f| f.center().1 > batch.height / 2.0)
|
||||
|| self.screen == Screen::Chat
|
||||
|| self.remote_chat_open();
|
||||
let mut ui = horizon_client::ui_theme::Ui::new(&self.res.atlas, batch, self.cursor);
|
||||
let mut ui = horizon_client::ui_theme::Ui::new(&self.atlas, batch, self.cursor);
|
||||
keyboard.draw(&mut ui, at_top, self.ui.options.pad_style);
|
||||
ui.finish();
|
||||
return;
|
||||
@@ -1002,7 +1002,7 @@ impl Game<'_> {
|
||||
return;
|
||||
}
|
||||
// An arrow, outlined, pointing up-left at (x, y).
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let (x, y) = (x.floor(), y.floor());
|
||||
const ROWS: [u8; 10] = [1, 2, 3, 4, 5, 6, 7, 4, 2, 1];
|
||||
for (i, &w) in ROWS.iter().enumerate() {
|
||||
@@ -1047,7 +1047,7 @@ impl Game<'_> {
|
||||
};
|
||||
if horizon {
|
||||
use horizon_client::ui_theme::{self as theme, Ui, color};
|
||||
let mut ui = Ui::new(&self.res.atlas, batch, self.cursor);
|
||||
let mut ui = Ui::new(&self.atlas, batch, self.cursor);
|
||||
let k = ui.batch.scale / ui.density;
|
||||
let (x, y, w, h) = (x * k, y * k, w * k, h * k);
|
||||
let radius = match focus.kind {
|
||||
@@ -1070,7 +1070,7 @@ impl Game<'_> {
|
||||
return;
|
||||
}
|
||||
if matches!(focus.kind, Kind::Row | Kind::Field) {
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let white = rgba(255, 255, 255, 255);
|
||||
batch.fill(atlas, x, y, w, 1.0, white);
|
||||
batch.fill(atlas, x, y + h - 1.0, w, 1.0, white);
|
||||
|
||||
@@ -249,7 +249,7 @@ impl Game<'_> {
|
||||
/// PaintingRenderer: the variant on the front, the back texture behind and
|
||||
/// on the edges.
|
||||
pub(super) fn painting_geometry(&self, camera: glam::DVec3, out: &mut Vec<Vertex>) {
|
||||
let sprites = &self.res.atlas.sprites;
|
||||
let sprites = &self.atlas.sprites;
|
||||
let Some(back) = sprites.get("painting/back").copied() else {
|
||||
return;
|
||||
};
|
||||
|
||||
@@ -506,7 +506,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// `BlockState.CODEC`: a block name or `{id, properties}` (or legacy `{Name, Properties}`).
|
||||
fn state_from_nbt(&self, tag: &Tag) -> Option<BlockStateId> {
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
let state = match tag.get("Name") {
|
||||
Some(Tag::String(name)) => BlockState {
|
||||
name: name.to_string_lossy(),
|
||||
@@ -528,7 +528,7 @@ impl Game<'_> {
|
||||
.or_else(|| registry.default_state(&state.name))
|
||||
}
|
||||
pub(in crate::game) fn state_to_nbt(&self, state: BlockStateId) -> Tag {
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
match registry.state(state) {
|
||||
Some(s) if registry.default_state(&s.name) == Some(state) => {
|
||||
Tag::String(s.name.as_str().into())
|
||||
|
||||
@@ -203,7 +203,12 @@ impl Game<'_> {
|
||||
let p = self.player.as_ref()?;
|
||||
let sleeping = self.sleeping.map(|(head, _)| {
|
||||
let state = self.world.block(head[0], head[1], head[2]);
|
||||
let props = self.res.assets.registry.state(state).map(|s| &s.properties);
|
||||
let props = self
|
||||
.pack
|
||||
.assets
|
||||
.registry
|
||||
.state(state)
|
||||
.map(|s| &s.properties);
|
||||
// BedBlock.getBedOrientation as Direction.toYRot.
|
||||
props.and_then(|props| match props.get("facing").map(String::as_str) {
|
||||
Some("south") => Some(0.0),
|
||||
@@ -405,7 +410,7 @@ impl Game<'_> {
|
||||
m.position.z.floor() as i32,
|
||||
);
|
||||
let packed = (u32::from(light >> 4) * 16) | ((u32::from(light & 15) * 16) << 8);
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let lookup = |name: &str| atlas.sprites.get(name).map(|r| [r.u0, r.v0, r.u1, r.v1]);
|
||||
horizon_client::mobs::render::render_with(
|
||||
m,
|
||||
@@ -459,7 +464,7 @@ impl Game<'_> {
|
||||
m.position.y += 0.125 * f64::from(u8::from(m.extra.crouching));
|
||||
m.previous = m.position;
|
||||
let camera = glam::DVec3::new(m.position.x, m.position.y, m.position.z);
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.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(
|
||||
@@ -530,10 +535,9 @@ impl Game<'_> {
|
||||
let Some((texture, _)) = assets.equipment.get(asset).and_then(|k| k.get("wings")) else {
|
||||
return;
|
||||
};
|
||||
let (Some(model), Some(rect)) = (
|
||||
assets.player.get("elytra"),
|
||||
self.res.atlas.sprites.get(texture),
|
||||
) else {
|
||||
let (Some(model), Some(rect)) =
|
||||
(assets.player.get("elytra"), self.atlas.sprites.get(texture))
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let base = horizon_client::mobs::render::base_transform(m, partial, camera)
|
||||
|
||||
@@ -576,7 +576,7 @@ impl Game<'_> {
|
||||
.map(hud_overlays::EffectIcon::from)
|
||||
.collect();
|
||||
let draws = hud_overlays::effects(batch.width as i32, false, &icons);
|
||||
hud_layout::paint(batch, &self.res.atlas, &draws);
|
||||
hud_layout::paint(batch, &self.atlas, &draws);
|
||||
}
|
||||
/// `EffectsInInventory`: panels to the right of survival/creative inventory.
|
||||
pub(super) fn draw_inventory_effects(
|
||||
@@ -591,12 +591,12 @@ impl Game<'_> {
|
||||
image_width,
|
||||
&self.potions.effects.list,
|
||||
self.clock.rate(),
|
||||
&|key| self.res.names.get(key).map(str::to_owned),
|
||||
&|text| self.res.atlas.font.width(text).ceil() as i32,
|
||||
&|key| self.pack.names.get(key).map(str::to_owned),
|
||||
&|text| self.atlas.font.width(text).ceil() as i32,
|
||||
);
|
||||
if let Some(lines) = inventory_effects::paint(
|
||||
batch,
|
||||
&self.res.atlas,
|
||||
&self.atlas,
|
||||
&panels,
|
||||
[self.cursor.0 as i32, self.cursor.1 as i32],
|
||||
) {
|
||||
|
||||
@@ -976,7 +976,7 @@ impl Game<'_> {
|
||||
}
|
||||
let bed = *known.entry(state.0).or_insert_with(|| {
|
||||
self.res.facts.get(state).name.ends_with("_bed")
|
||||
&& self.res.assets.registry.state(state).is_some_and(|s| {
|
||||
&& self.pack.assets.registry.state(state).is_some_and(|s| {
|
||||
s.properties.get("part").map(String::as_str) == Some("head")
|
||||
})
|
||||
});
|
||||
|
||||
@@ -467,7 +467,7 @@ impl Game<'_> {
|
||||
horizon_client::item_tooltip::lines(
|
||||
stack,
|
||||
self.res.items.get(&stack.item),
|
||||
&|k| self.res.names.get(k).map(str::to_owned),
|
||||
&|k| self.pack.names.get(k).map(str::to_owned),
|
||||
)
|
||||
})
|
||||
{
|
||||
@@ -629,7 +629,7 @@ impl Game<'_> {
|
||||
search.focused = true;
|
||||
search.reset_blink();
|
||||
if !magnifier {
|
||||
let idx = search.index_at(&self.res.atlas, cursor.0);
|
||||
let idx = search.index_at(&self.atlas, cursor.0);
|
||||
search.set_cursor(idx, false);
|
||||
}
|
||||
return true;
|
||||
@@ -871,7 +871,7 @@ impl Game<'_> {
|
||||
let (bx, by) = self.book_button_pos(book_type, ox, batch);
|
||||
let hover = inside(cursor, bx, by, 20.0, 18.0);
|
||||
batch.sprite(
|
||||
&self.res.atlas,
|
||||
&self.atlas,
|
||||
&sprite(if hover {
|
||||
"button_highlighted"
|
||||
} else {
|
||||
@@ -919,7 +919,7 @@ impl Game<'_> {
|
||||
fn draw_book_panel(&mut self, batch: &mut HudBatch, book_type: BookType) {
|
||||
let (xo, yo) = self.book_origin(batch);
|
||||
let cursor = self.cursor;
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let search = match self.recipe_ui.search.as_mut() {
|
||||
Some(edit) => {
|
||||
// The box's place, for clicks and typing.
|
||||
@@ -1042,7 +1042,7 @@ impl Game<'_> {
|
||||
let mut tooltip: Option<Vec<(String, u32)>> = None;
|
||||
for d in calls {
|
||||
let start = batch.vertices.len();
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
match &d.call {
|
||||
Call::Blit {
|
||||
x, y, w, h, u, v, ..
|
||||
|
||||
@@ -169,7 +169,7 @@ impl Game<'_> {
|
||||
let player_type = super::perspective::player_type(&root);
|
||||
let mut streaming = Streaming::new(
|
||||
Arc::new(NoTerrain),
|
||||
self.res.context.clone(),
|
||||
self.pack.context.clone(),
|
||||
self.res.threads,
|
||||
);
|
||||
streaming.remote = true;
|
||||
@@ -278,7 +278,7 @@ impl Game<'_> {
|
||||
self.debug_charts.reset();
|
||||
self.tab_list.reset();
|
||||
self.score.board = Default::default();
|
||||
self.streaming = Streaming::new(Arc::new(NoTerrain), self.res.context.clone(), 1);
|
||||
self.streaming = Streaming::new(Arc::new(NoTerrain), self.pack.context.clone(), 1);
|
||||
self.streaming.paused = true;
|
||||
self.world = World::new(self.res.facts.air, 0);
|
||||
self.player = None;
|
||||
@@ -465,7 +465,7 @@ impl Game<'_> {
|
||||
if !same {
|
||||
let mut streaming = Streaming::new(
|
||||
Arc::new(NoTerrain),
|
||||
self.res.context.clone(),
|
||||
self.pack.context.clone(),
|
||||
self.res.threads,
|
||||
);
|
||||
streaming.remote = true;
|
||||
@@ -1545,11 +1545,10 @@ impl Game<'_> {
|
||||
self.skin_slots.len()
|
||||
} else {
|
||||
let (old, slot) = self.skin_slots.remove(0);
|
||||
self.res.atlas.sprites.remove(&old);
|
||||
self.atlas.sprites.remove(&old);
|
||||
slot
|
||||
};
|
||||
let Some(rect) = self
|
||||
.res
|
||||
.atlas
|
||||
.sprites
|
||||
.get(&format!("horizon/skin{slot}"))
|
||||
@@ -1557,7 +1556,7 @@ impl Game<'_> {
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let (w, h) = (self.res.atlas.width as f32, self.res.atlas.height as f32);
|
||||
let (w, h) = (self.atlas.width as f32, self.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,
|
||||
@@ -1565,7 +1564,7 @@ impl Game<'_> {
|
||||
height: 64,
|
||||
rgba,
|
||||
});
|
||||
self.res.atlas.sprites.insert(location.clone(), rect);
|
||||
self.atlas.sprites.insert(location.clone(), rect);
|
||||
self.skin_slots.push((location, slot));
|
||||
}
|
||||
/// Whether a downloaded skin is in the atlas, marking it recently shown.
|
||||
@@ -1807,7 +1806,7 @@ impl Game<'_> {
|
||||
entities: &ghast_collisions,
|
||||
player,
|
||||
scene: &mut self.world,
|
||||
assets: &self.res.assets,
|
||||
assets: &self.pack.assets,
|
||||
collision_binding: self.collision,
|
||||
resources: self.motion,
|
||||
}
|
||||
@@ -2742,7 +2741,7 @@ impl Game<'_> {
|
||||
if self.player.is_some() {
|
||||
return false;
|
||||
}
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let (w, h) = (batch.width, batch.height);
|
||||
batch.fill(atlas, 0.0, 0.0, w, h, rgba(20, 20, 20, 255));
|
||||
let shown = horizon_client::net::shown_address(&r.session.address);
|
||||
@@ -2767,7 +2766,7 @@ impl Game<'_> {
|
||||
/// Chat (ChatComponent), the chat input line and the action bar.
|
||||
pub(super) fn remote_hud(&self, batch: &mut HudBatch) {
|
||||
let Some(r) = &self.remote else { return };
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let (w, h) = (batch.width, batch.height);
|
||||
let open = r.chat_input.is_some();
|
||||
let now = Instant::now();
|
||||
|
||||
@@ -25,7 +25,7 @@ impl Game<'_> {
|
||||
} else {
|
||||
format!("minecraft:{name}")
|
||||
};
|
||||
let registry = &self.res.assets.registry;
|
||||
let registry = &self.pack.assets.registry;
|
||||
let default = registry
|
||||
.default_state(&name)
|
||||
.ok_or_else(|| format!("unknown block {name}"))?;
|
||||
|
||||
@@ -73,29 +73,33 @@ impl Game<'_> {
|
||||
} else {
|
||||
(0.0, 0.0)
|
||||
};
|
||||
self.res.fog.setup(&FogInputs {
|
||||
fog_type,
|
||||
sky,
|
||||
water_fog_color: [
|
||||
(water >> 16 & 255) as f32 / 255.0,
|
||||
(water >> 8 & 255) as f32 / 255.0,
|
||||
(water & 255) as f32 / 255.0,
|
||||
],
|
||||
biome,
|
||||
render_distance_chunks: self.streaming.radius,
|
||||
cloud_range_chunks: self.settings.cloud_range,
|
||||
camera_y: camera.y,
|
||||
// level.getMinY(): the Nether and the End start at y 0.
|
||||
min_y: if self.dim == Dim::Overworld { MIN_Y } else { 0 },
|
||||
flat: false,
|
||||
forward: forward.map(|c| c as f32),
|
||||
rain,
|
||||
thunder,
|
||||
skybox: self.dim == Dim::Overworld,
|
||||
blindness: None,
|
||||
darkness: self.darkness_fog(),
|
||||
boss_world_fog: self.dragon_bar_shown(),
|
||||
})
|
||||
horizon_client::fog::setup_fog(
|
||||
&self.res.fog,
|
||||
&self.fog,
|
||||
&FogInputs {
|
||||
fog_type,
|
||||
sky,
|
||||
water_fog_color: [
|
||||
(water >> 16 & 255) as f32 / 255.0,
|
||||
(water >> 8 & 255) as f32 / 255.0,
|
||||
(water & 255) as f32 / 255.0,
|
||||
],
|
||||
biome,
|
||||
render_distance_chunks: self.streaming.radius,
|
||||
cloud_range_chunks: self.settings.cloud_range,
|
||||
camera_y: camera.y,
|
||||
// level.getMinY(): the Nether and the End start at y 0.
|
||||
min_y: if self.dim == Dim::Overworld { MIN_Y } else { 0 },
|
||||
flat: false,
|
||||
forward: forward.map(|c| c as f32),
|
||||
rain,
|
||||
thunder,
|
||||
skybox: self.dim == Dim::Overworld,
|
||||
blindness: None,
|
||||
darkness: self.darkness_fog(),
|
||||
boss_world_fog: self.dragon_bar_shown(),
|
||||
},
|
||||
)
|
||||
}
|
||||
/// What a shader pack's `Frame` uniform reads of the game this frame.
|
||||
pub(super) fn shader_inputs(
|
||||
@@ -181,7 +185,7 @@ impl Game<'_> {
|
||||
(in_water && !spectator).then(|| (self.eye_brightness(eye), self.yaw, self.pitch));
|
||||
// Hud.extractCameraOverlays; the spyglass scope (and its easing) is
|
||||
// drawn on the HUD by draw_spyglass.
|
||||
let fx = &self.res.screen_fx;
|
||||
let fx = &self.screen_fx;
|
||||
let overlays = hud_overlays::CameraOverlays {
|
||||
vignette: self.settings.vignette.then_some((
|
||||
fx.vignette_brightness,
|
||||
@@ -206,8 +210,8 @@ impl Game<'_> {
|
||||
let mut scope = self.scope_scale;
|
||||
let gui_overlays =
|
||||
hud_overlays::camera_overlays(size[0] as i32, size[1] as i32, &overlays, &mut scope);
|
||||
self.res.screen_fx.build(&ScreenInputs {
|
||||
sprites: &self.res.atlas.sprites,
|
||||
self.screen_fx.build(&ScreenInputs {
|
||||
sprites: &self.atlas.sprites,
|
||||
aspect: size[0] as f32 / size[1].max(1) as f32,
|
||||
partial,
|
||||
block_overlay,
|
||||
@@ -231,16 +235,16 @@ impl Game<'_> {
|
||||
lightmap_brightness(if self.dim == Dim::Nether { 0.1 } else { 0.0 }, raw)
|
||||
}
|
||||
pub(super) fn tick_particles(&mut self) {
|
||||
self.res.fog.state.tick_flicker();
|
||||
self.fog.tick_flicker();
|
||||
let eye = self.eye_position();
|
||||
if let Some(e) = eye {
|
||||
let brightness = self.eye_brightness(e);
|
||||
let inside_portal = self.client_portal_effect();
|
||||
self.res.screen_fx.tick(brightness, inside_portal);
|
||||
self.screen_fx.tick(brightness, inside_portal);
|
||||
// LocalPlayer water vision and AtmosphericFogEnvironment rain fog.
|
||||
let in_water =
|
||||
fog_type(&self.world, &self.res.facts, e, self.forward()) == FogType::Water;
|
||||
self.res.fog.state.tick(in_water);
|
||||
self.fog.tick(in_water);
|
||||
let b = [
|
||||
e[0].floor() as i32,
|
||||
e[1].floor() as i32,
|
||||
@@ -258,7 +262,7 @@ impl Game<'_> {
|
||||
.map_or(0, |c| c.biome(b[0], b[1], b[2]));
|
||||
let rains = self.res.biomes.get(biome).precipitation;
|
||||
update_rain_fog(
|
||||
&mut self.res.fog.state,
|
||||
&mut self.fog,
|
||||
rain,
|
||||
self.world.light(b[0], b[1], b[2]) >> 4,
|
||||
rains,
|
||||
@@ -287,7 +291,7 @@ impl Game<'_> {
|
||||
facts,
|
||||
collision: self.collision,
|
||||
biomes,
|
||||
registry: self.res.assets.registry,
|
||||
registry: self.pack.assets.registry,
|
||||
raining_at: &raining_at,
|
||||
};
|
||||
if let Some(e) = eye {
|
||||
|
||||
@@ -66,7 +66,7 @@ impl Game<'_> {
|
||||
&*self.res.facts.get(state).name == "minecraft:respawn_anchor"
|
||||
}
|
||||
fn anchor_charges(&self, state: BlockStateId) -> i32 {
|
||||
self.res
|
||||
self.pack
|
||||
.assets
|
||||
.registry
|
||||
.state(state)
|
||||
@@ -75,9 +75,9 @@ impl Game<'_> {
|
||||
.unwrap_or(0)
|
||||
}
|
||||
fn anchor_with_charges(&self, state: BlockStateId, charges: i32) -> Option<BlockStateId> {
|
||||
let mut s = self.res.assets.registry.state(state)?.clone();
|
||||
let mut s = self.pack.assets.registry.state(state)?.clone();
|
||||
s.properties.insert("charges".into(), charges.to_string());
|
||||
self.res.assets.registry.resolve(&s).ok()
|
||||
self.pack.assets.registry.resolve(&s).ok()
|
||||
}
|
||||
/// `RespawnAnchorBlock.canSetSpawn`: the `respawn_anchor_works` attribute
|
||||
/// (only the Nether's dimension type sets it).
|
||||
@@ -243,7 +243,7 @@ impl Game<'_> {
|
||||
}
|
||||
// removeBlock(head), then the foot behind it if it is still this bed.
|
||||
let facing = self
|
||||
.res
|
||||
.pack
|
||||
.assets
|
||||
.registry
|
||||
.state(state)
|
||||
@@ -300,7 +300,7 @@ impl Game<'_> {
|
||||
let name = &self.res.facts.get(state).name;
|
||||
let open_trapdoor = name.ends_with("_trapdoor")
|
||||
&& self
|
||||
.res
|
||||
.pack
|
||||
.assets
|
||||
.registry
|
||||
.state(state)
|
||||
@@ -337,7 +337,7 @@ impl Game<'_> {
|
||||
let name = &*self.res.facts.get(state).name;
|
||||
let lit_campfire = (name == "minecraft:campfire" || name == "minecraft:soul_campfire")
|
||||
&& self
|
||||
.res
|
||||
.pack
|
||||
.assets
|
||||
.registry
|
||||
.state(state)
|
||||
|
||||
@@ -573,11 +573,11 @@ impl Game<'_> {
|
||||
batch.height as i32,
|
||||
board,
|
||||
objective,
|
||||
&self.res.atlas.font,
|
||||
&self.atlas.font,
|
||||
self.settings.text_background(0.3),
|
||||
self.settings.text_background(0.4),
|
||||
);
|
||||
hud_layout::paint(batch, &self.res.atlas, &draws);
|
||||
hud_layout::paint(batch, &self.atlas, &draws);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -639,8 +639,8 @@ impl Game<'_> {
|
||||
),
|
||||
upside_down: &up,
|
||||
};
|
||||
let draws = self.tab_list.layout(&inputs, &self.res.atlas.font);
|
||||
horizon_client::hud_layout::paint(batch, &self.res.atlas, &draws);
|
||||
let draws = self.tab_list.layout(&inputs, &self.atlas.font);
|
||||
horizon_client::hud_layout::paint(batch, &self.atlas, &draws);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,12 +78,12 @@ impl Game<'_> {
|
||||
let (world, quit) = self.pause_labels();
|
||||
self.tick_friends();
|
||||
let friends = self.friends_view();
|
||||
let mut ui = horizon_client::ui_theme::Ui::new(&self.res.atlas, batch, self.cursor);
|
||||
let mut ui = horizon_client::ui_theme::Ui::new(&self.atlas, batch, self.cursor);
|
||||
horizon_client::front::pause::draw(&mut ui, &world, quit, opened, &friends);
|
||||
ui.finish();
|
||||
return;
|
||||
}
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let (w, h) = (batch.width, batch.height);
|
||||
ui::menu_background(batch, atlas, 0.0, 0.0, w, h, true);
|
||||
let title = Text::translate("menu.game", &[]);
|
||||
@@ -135,7 +135,7 @@ impl Game<'_> {
|
||||
let mut b = HudBatch::new(size);
|
||||
let (world, quit) = self.pause_labels();
|
||||
horizon_client::front::pause::click(
|
||||
&self.res.atlas,
|
||||
&self.atlas,
|
||||
&mut b,
|
||||
self.cursor.0,
|
||||
self.cursor.1,
|
||||
@@ -175,7 +175,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// DeathScreen: gradient, the title at double size, the cause and score.
|
||||
pub(super) fn draw_death_screen(&mut self, batch: &mut HudBatch) {
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let (w, h) = (batch.width, batch.height);
|
||||
// fillGradient(0x60500000 -> 0xA0803030).
|
||||
let rows = h.ceil() as i32;
|
||||
|
||||
@@ -262,7 +262,7 @@ impl Game<'_> {
|
||||
if self.sculk.tables.built {
|
||||
return;
|
||||
}
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
let n = registry.len();
|
||||
let tag = |name: &str| {
|
||||
self.res
|
||||
@@ -640,7 +640,7 @@ impl Game<'_> {
|
||||
self.state_property(state, "shrieking") == Some("true")
|
||||
}
|
||||
fn state_property(&self, state: BlockStateId, key: &str) -> Option<&str> {
|
||||
self.res
|
||||
self.pack
|
||||
.assets
|
||||
.registry
|
||||
.state(state)
|
||||
@@ -1156,7 +1156,7 @@ impl Game<'_> {
|
||||
let in_water =
|
||||
horizon_client::fog::fog_type(&self.world, &self.res.facts, eye, self.forward())
|
||||
== FogType::Water;
|
||||
return self.res.fog.state.water_vision(in_water);
|
||||
return self.fog.water_vision(in_water);
|
||||
}
|
||||
0.0
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ impl Game<'_> {
|
||||
Some((n, rest)) => (n, rest.trim_end_matches(']')),
|
||||
None => (text, ""),
|
||||
};
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
let base = registry
|
||||
.default_state(name)
|
||||
.ok_or_else(|| format!("unknown block {name}"))?;
|
||||
@@ -197,7 +197,7 @@ impl Game<'_> {
|
||||
|
||||
/// `BlockStateParser.serialize`.
|
||||
fn fixture_state_text(&self, state: BlockStateId) -> String {
|
||||
let Some(s) = self.res.assets.registry.state(state) else {
|
||||
let Some(s) = self.pack.assets.registry.state(state) else {
|
||||
return "?".into();
|
||||
};
|
||||
if s.properties.is_empty() {
|
||||
|
||||
@@ -88,7 +88,7 @@ impl Game<'_> {
|
||||
return;
|
||||
};
|
||||
let line = edit.line;
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let width = |s: &str| HudBatch::text_width(atlas, s);
|
||||
let Some(key) = self.sign_edit.as_ref().map(|e| e.pos) else {
|
||||
return;
|
||||
@@ -130,7 +130,7 @@ impl Game<'_> {
|
||||
} else {
|
||||
&mut sign.back
|
||||
};
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
self.text_selection.apply(
|
||||
sign_line_id(front, line),
|
||||
&mut text.lines[line],
|
||||
@@ -163,7 +163,7 @@ impl Game<'_> {
|
||||
let Some(BlockEntity::Sign(sign)) = self.world.block_entities.get(&edit.pos) else {
|
||||
return;
|
||||
};
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let (w, h) = (batch.width, batch.height);
|
||||
batch.fill(atlas, 0.0, 0.0, w, h, rgba(16, 16, 16, 160));
|
||||
let title = if sign.hanging {
|
||||
|
||||
@@ -399,7 +399,7 @@ impl Game<'_> {
|
||||
alpha: f64,
|
||||
out: &mut Vec<horizon_client::mesher::Vertex>,
|
||||
) {
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let lookup = |name: &str| atlas.sprites.get(name).map(|r| [r.u0, r.v0, r.u1, r.v1]);
|
||||
for (key, (_, mob)) in &self.spawners.displays {
|
||||
let at = glam::DVec3::new(f64::from(key.0), f64::from(key.1), f64::from(key.2));
|
||||
|
||||
@@ -398,7 +398,7 @@ impl Game<'_> {
|
||||
fn anvil_item_name(&self, s: &Station) -> String {
|
||||
match &s.inputs[0] {
|
||||
Some(input)
|
||||
if input.custom_name().is_none() && s.name == self.res.names.item(&input.item) =>
|
||||
if input.custom_name().is_none() && s.name == self.pack.names.item(&input.item) =>
|
||||
{
|
||||
String::new()
|
||||
}
|
||||
@@ -429,7 +429,7 @@ impl Game<'_> {
|
||||
let name = self.anvil_item_name(&s);
|
||||
let hover = s.inputs[0]
|
||||
.as_ref()
|
||||
.map(|i| stations::hover_name(&|id| self.res.names.item(id), i))
|
||||
.map(|i| stations::hover_name(&|id| self.pack.names.item(id), i))
|
||||
.unwrap_or_default();
|
||||
s.anvil = stations::anvil_result(
|
||||
&data.enchantments,
|
||||
@@ -1157,7 +1157,7 @@ impl Game<'_> {
|
||||
s.anvil_last = s.inputs[0].clone();
|
||||
s.name = s.inputs[0]
|
||||
.as_ref()
|
||||
.map(|i| stations::hover_name(&|id| self.res.names.item(id), i))
|
||||
.map(|i| stations::hover_name(&|id| self.pack.names.item(id), i))
|
||||
.unwrap_or_default();
|
||||
}
|
||||
self.station_changed();
|
||||
@@ -1249,7 +1249,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// Text in the Standard Galactic alphabet (`minecraft:alt`), cut to `max` pixels.
|
||||
fn galactic(&self, batch: &mut HudBatch, text: &str, x: f32, y: f32, max: f32, color: u32) {
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let Some(sheet) = atlas.sprites.get("font/ascii_sga").copied() else {
|
||||
batch.text(atlas, text, x, y, color, false);
|
||||
return;
|
||||
@@ -1325,7 +1325,7 @@ impl Game<'_> {
|
||||
let local = (self.cursor.0 - ox, self.cursor.1 - oy);
|
||||
let mut tooltip: Option<Vec<(String, u32)>> = None;
|
||||
{
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
batch.fill(
|
||||
atlas,
|
||||
0.0,
|
||||
@@ -1342,7 +1342,7 @@ impl Game<'_> {
|
||||
};
|
||||
let (fuel, total_fuel, brew, total_brew) =
|
||||
(b.fuel, b.total_fuel, b.brew_time, b.total_brew_time);
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
Self::part(
|
||||
batch,
|
||||
atlas,
|
||||
@@ -1417,7 +1417,7 @@ impl Game<'_> {
|
||||
if self.slot_mut(i).is_none() {
|
||||
let (sx, sy) = self.station_slot_position(i).unwrap_or_default();
|
||||
batch.sprite(
|
||||
&self.res.atlas,
|
||||
&self.atlas,
|
||||
&format!("gui/sprites/container/slot/{icon}"),
|
||||
ox + sx,
|
||||
oy + sy,
|
||||
@@ -1427,7 +1427,7 @@ impl Game<'_> {
|
||||
} else if let Some(kind) = self.station.as_ref().map(|s| s.kind) {
|
||||
let title = self.translate(kind.title_key(), "");
|
||||
{
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
Self::part(
|
||||
batch,
|
||||
atlas,
|
||||
@@ -1446,7 +1446,7 @@ impl Game<'_> {
|
||||
if kind == Kind::Loom {
|
||||
tooltip = self.draw_loom(batch, ox, oy, local);
|
||||
}
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let s = self.station.as_ref().expect("open station");
|
||||
let has_input = s.inputs.iter().any(Option::is_some);
|
||||
match kind {
|
||||
@@ -1552,7 +1552,7 @@ impl Game<'_> {
|
||||
);
|
||||
-8323296
|
||||
};
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let cw = HudBatch::text_width(atlas, &cost_text);
|
||||
batch.text(
|
||||
atlas,
|
||||
@@ -1679,7 +1679,7 @@ impl Game<'_> {
|
||||
)
|
||||
};
|
||||
if let Some(line) = line {
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let tw = HudBatch::text_width(atlas, &line);
|
||||
let tx = 176.0 - 8.0 - tw - 2.0;
|
||||
batch.fill(
|
||||
@@ -1788,7 +1788,7 @@ impl Game<'_> {
|
||||
"recipe"
|
||||
};
|
||||
batch.sprite_scaled(
|
||||
&self.res.atlas,
|
||||
&self.atlas,
|
||||
&format!("gui/sprites/container/stonecutter/{sprite}"),
|
||||
ox + x,
|
||||
oy + y - 1.0,
|
||||
@@ -1816,7 +1816,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.res.atlas,
|
||||
&self.atlas,
|
||||
ox + sx,
|
||||
oy + sy,
|
||||
16.0,
|
||||
@@ -1889,16 +1889,16 @@ impl Game<'_> {
|
||||
{
|
||||
let key = brewing::potion_name_key(&stack.item, stack.potion());
|
||||
e.translate(&key)
|
||||
.map_or_else(|| self.res.names.item(&stack.item), str::to_owned)
|
||||
.map_or_else(|| self.pack.names.item(&stack.item), str::to_owned)
|
||||
} else {
|
||||
self.res.names.item(&stack.item)
|
||||
self.pack.names.item(&stack.item)
|
||||
};
|
||||
let mut lines = vec![(name, color)];
|
||||
let translate = |k: &str| e.translate(k).map(str::to_owned);
|
||||
// ItemContainerContents.addToTooltip.
|
||||
let hover_name = |s: &ItemStack| {
|
||||
s.custom_name()
|
||||
.map_or_else(|| self.res.names.item(&s.item), str::to_owned)
|
||||
.map_or_else(|| self.pack.names.item(&s.item), str::to_owned)
|
||||
};
|
||||
for line in horizon_client::item_tooltip::container_lines(stack, &hover_name, &translate) {
|
||||
lines.push((line, u32::MAX));
|
||||
@@ -2045,7 +2045,7 @@ impl Game<'_> {
|
||||
if lines.is_empty() {
|
||||
return;
|
||||
}
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let w = lines
|
||||
.iter()
|
||||
.map(|(t, _)| HudBatch::text_width(atlas, t))
|
||||
@@ -2149,14 +2149,14 @@ impl Game<'_> {
|
||||
}
|
||||
if let Some(bottles) = out.bottles {
|
||||
let state = self.world.block(x, y, z);
|
||||
if let Some(mut s) = self.res.assets.registry.state(state).cloned()
|
||||
if let Some(mut s) = self.pack.assets.registry.state(state).cloned()
|
||||
&& AsRef::<str>::as_ref(&s.name) == "minecraft:brewing_stand"
|
||||
{
|
||||
for (i, has) in bottles.iter().enumerate() {
|
||||
s.properties
|
||||
.insert(format!("has_bottle_{i}"), has.to_string());
|
||||
}
|
||||
if let Ok(id) = self.res.assets.registry.resolve(&s) {
|
||||
if let Ok(id) = self.pack.assets.registry.resolve(&s) {
|
||||
self.world.set(x, y, z, id)?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ impl Game<'_> {
|
||||
}
|
||||
pub(super) fn draw_stats(&mut self, batch: &mut HudBatch) {
|
||||
let (w, h) = (batch.width, batch.height);
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
ui::menu_background(batch, atlas, 0.0, 0.0, w, h, true);
|
||||
let (top, bottom) = (TAB_H, h - FOOTER);
|
||||
ui::separators(batch, atlas, top, bottom, true);
|
||||
@@ -327,13 +327,13 @@ impl Game<'_> {
|
||||
}
|
||||
let stack = ItemStack::new(item, 1);
|
||||
batch.sprite(
|
||||
&self.res.atlas,
|
||||
&self.atlas,
|
||||
"gui/sprites/container/slot",
|
||||
left + 1.0,
|
||||
y + 1.0,
|
||||
);
|
||||
self.draw_item(batch, &stack, left + 2.0, y + 2.0);
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let color = if (i + 1) % 2 == 0 {
|
||||
u32::MAX
|
||||
} else {
|
||||
@@ -394,7 +394,7 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
}
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
ui::scrollbar(
|
||||
batch,
|
||||
atlas,
|
||||
@@ -407,7 +407,7 @@ impl Game<'_> {
|
||||
self.draw_stats_footer(batch, w, h);
|
||||
}
|
||||
fn draw_stats_footer(&self, batch: &mut HudBatch, w: f32, h: f32) {
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.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(
|
||||
|
||||
@@ -76,7 +76,7 @@ impl Game<'_> {
|
||||
/// The other half of the open double chest and whether the open one is
|
||||
/// the right half (`ChestBlock.getConnectedDirection`).
|
||||
pub(super) fn chest_partner(&self, key: (i32, i32, i32)) -> Option<((i32, i32, i32), bool)> {
|
||||
let registry = self.res.assets.registry;
|
||||
let registry = self.pack.assets.registry;
|
||||
let state = registry.state(self.world.block(key.0, key.1, key.2))?;
|
||||
if !matches!(
|
||||
state.name.as_str(),
|
||||
@@ -211,7 +211,7 @@ impl Game<'_> {
|
||||
oy: f32,
|
||||
) {
|
||||
use horizon_client::hud::rgba;
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let grey = rgba(64, 64, 64, 255);
|
||||
if self
|
||||
.container_block()
|
||||
|
||||
@@ -47,7 +47,7 @@ impl Game<'_> {
|
||||
width: batch.width as i32,
|
||||
height: batch.height as i32,
|
||||
};
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let draws = self
|
||||
.subtitles
|
||||
.overlay
|
||||
|
||||
@@ -15,10 +15,10 @@ impl Game<'_> {
|
||||
let (w, h) = (batch.width as i32, batch.height as i32);
|
||||
let partial = self.clock.fraction() as f32;
|
||||
let background = self.settings.text_background(0.0);
|
||||
let font = &self.res.atlas.font;
|
||||
let font = &self.atlas.font;
|
||||
let mut draws = self.titles.overlay_message(w, h, partial, font, background);
|
||||
draws.extend(self.titles.title(w, h, partial, font, background));
|
||||
hud_layout::paint(batch, &self.res.atlas, &draws);
|
||||
hud_layout::paint(batch, &self.atlas, &draws);
|
||||
}
|
||||
/// The selected stack as `Hud.tick` compares it for the name highlight.
|
||||
fn held_name(&self) -> Option<HeldName> {
|
||||
@@ -37,7 +37,7 @@ impl Game<'_> {
|
||||
Some(HeldName {
|
||||
item: stack.item.to_string(),
|
||||
hover_name: Text::literal(
|
||||
custom.map_or_else(|| self.res.names.item(&stack.item), str::to_owned),
|
||||
custom.map_or_else(|| self.pack.names.item(&stack.item), str::to_owned),
|
||||
),
|
||||
rarity_color: match rarity.as_str() {
|
||||
"uncommon" => text::YELLOW,
|
||||
@@ -61,9 +61,9 @@ impl Game<'_> {
|
||||
batch.width as i32,
|
||||
batch.height as i32,
|
||||
can_hurt,
|
||||
&self.res.atlas.font,
|
||||
&self.atlas.font,
|
||||
self.settings.text_background(0.0),
|
||||
);
|
||||
hud_layout::paint(batch, &self.res.atlas, &draws);
|
||||
hud_layout::paint(batch, &self.atlas, &draws);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ impl Game<'_> {
|
||||
t.tick(
|
||||
&self.world,
|
||||
self.collision,
|
||||
&self.res.assets,
|
||||
&self.pack.assets,
|
||||
&self.res.facts,
|
||||
)?;
|
||||
if t.fuse <= 0 {
|
||||
@@ -210,12 +210,12 @@ impl Game<'_> {
|
||||
if self.tnts.is_empty() {
|
||||
return;
|
||||
}
|
||||
let Some(state) = self.res.assets.registry.default_state("minecraft:tnt") else {
|
||||
let Some(state) = self.pack.assets.registry.default_state("minecraft:tnt") else {
|
||||
return;
|
||||
};
|
||||
// Face sprites from the block model: up, down, north, south, west, east.
|
||||
let Ok(models) = self
|
||||
.res
|
||||
.pack
|
||||
.assets
|
||||
.model_catalog
|
||||
.collect(state, BlockPos::new(0, 0, 0))
|
||||
@@ -235,10 +235,10 @@ impl Game<'_> {
|
||||
};
|
||||
if sprites[index].is_none() {
|
||||
sprites[index] = self
|
||||
.res
|
||||
.pack
|
||||
.layer_names
|
||||
.get(&face.layer)
|
||||
.and_then(|name| self.res.atlas.sprites.get(name).copied());
|
||||
.and_then(|name| self.atlas.sprites.get(name).copied());
|
||||
}
|
||||
}
|
||||
for t in &self.tnts {
|
||||
|
||||
@@ -548,7 +548,7 @@ impl Game<'_> {
|
||||
);
|
||||
let offers = m.session.offers.clone();
|
||||
let costs: Vec<ItemStack> = offers.iter().map(|o| o.cost_a(&self.res.items)).collect();
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
batch.fill(
|
||||
atlas,
|
||||
0.0,
|
||||
@@ -687,7 +687,7 @@ impl Game<'_> {
|
||||
} else {
|
||||
"gui/sprites/widget/button"
|
||||
};
|
||||
batch.sprite_scaled(&self.res.atlas, sprite, bx, by, 88.0, 20.0, u32::MAX);
|
||||
batch.sprite_scaled(&self.atlas, sprite, bx, by, 88.0, 20.0, u32::MAX);
|
||||
let y = oy + 16.0 + 1.0 + 20.0 * row as f32 + 2.0;
|
||||
let base = offer.base_cost_a.stack.clone();
|
||||
let cost_a = costs[index].clone();
|
||||
@@ -705,7 +705,7 @@ impl Game<'_> {
|
||||
x,
|
||||
y,
|
||||
);
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
let t = base.count.to_string();
|
||||
batch.text(
|
||||
atlas,
|
||||
@@ -740,7 +740,7 @@ impl Game<'_> {
|
||||
"trade_arrow"
|
||||
};
|
||||
batch.sprite(
|
||||
&self.res.atlas,
|
||||
&self.atlas,
|
||||
&format!("gui/sprites/container/villager/{arrow}"),
|
||||
ox + SHIFT + 60.0,
|
||||
y + 3.0,
|
||||
@@ -770,7 +770,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.res.atlas,
|
||||
&self.atlas,
|
||||
ox + sx,
|
||||
oy + sy,
|
||||
16.0,
|
||||
|
||||
@@ -138,7 +138,7 @@ impl Game<'_> {
|
||||
/// The trial spawner block at `key`: its state and ominous flag.
|
||||
pub(super) fn trial_spawner_block(&self, key: Pos) -> Option<(TrialState, bool)> {
|
||||
let block = self
|
||||
.res
|
||||
.pack
|
||||
.assets
|
||||
.registry
|
||||
.state(self.world.block(key.0, key.1, key.2))?;
|
||||
@@ -292,7 +292,7 @@ impl Game<'_> {
|
||||
ominous: bool,
|
||||
) -> Result<()> {
|
||||
let current = self.world.block(key.0, key.1, key.2);
|
||||
let Some(mut block) = self.res.assets.registry.state(current).cloned() else {
|
||||
let Some(mut block) = self.pack.assets.registry.state(current).cloned() else {
|
||||
return Ok(());
|
||||
};
|
||||
block
|
||||
@@ -301,7 +301,7 @@ impl Game<'_> {
|
||||
block
|
||||
.properties
|
||||
.insert("ominous".into(), ominous.to_string());
|
||||
let id = self.res.assets.registry.resolve(&block)?;
|
||||
let id = self.pack.assets.registry.resolve(&block)?;
|
||||
self.level_set([key.0, key.1, key.2], id)
|
||||
}
|
||||
/// `transformBadOmenIntoTrialOmen`: Bad Omen becomes Trial Omen, 15
|
||||
|
||||
@@ -293,7 +293,7 @@ impl Game<'_> {
|
||||
p.position.z,
|
||||
];
|
||||
let facing = self
|
||||
.res
|
||||
.pack
|
||||
.assets
|
||||
.registry
|
||||
.state(self.world.block(pos[0], pos[1], pos[2]))
|
||||
|
||||
@@ -343,7 +343,6 @@ impl Game<'_> {
|
||||
return;
|
||||
};
|
||||
let Some(uv) = self
|
||||
.res
|
||||
.atlas
|
||||
.sprites
|
||||
.get("entity/trident/trident")
|
||||
|
||||
@@ -331,7 +331,7 @@ impl Game<'_> {
|
||||
/// The sort buttons: a bordered square with three bars, lighter under
|
||||
/// the cursor.
|
||||
pub(super) fn draw_sort_buttons(&self, batch: &mut HudBatch, ox: f32, oy: f32) {
|
||||
let atlas = &self.res.atlas;
|
||||
let atlas = &self.atlas;
|
||||
for ((x, y), _) in self.sort_buttons() {
|
||||
let (x, y) = (ox + x, oy + y);
|
||||
let (cx, cy) = self.cursor;
|
||||
@@ -401,7 +401,7 @@ impl Game<'_> {
|
||||
}
|
||||
let views: Vec<Option<ItemStack>> = slots.iter().map(|&s| self.slot_view(s)).collect();
|
||||
let clicks = {
|
||||
let names = |id: &str| self.res.names.item(id);
|
||||
let names = |id: &str| self.pack.names.item(id);
|
||||
let rank = |s: &ItemStack| {
|
||||
let order = self.creative_screen.order_of(s).unwrap_or(usize::MAX);
|
||||
(order, hover_name(&names, s))
|
||||
|
||||
@@ -51,7 +51,7 @@ impl Game<'_> {
|
||||
/// The vault at `key` with its block's state and ominous flag.
|
||||
pub(super) fn take_vault(&mut self, key: Pos) -> Option<(Box<Vault>, VaultState, bool)> {
|
||||
let state = self.world.block(key.0, key.1, key.2);
|
||||
let block = self.res.assets.registry.state(state)?;
|
||||
let block = self.pack.assets.registry.state(state)?;
|
||||
if block.name != "minecraft:vault" {
|
||||
return None;
|
||||
}
|
||||
@@ -200,13 +200,13 @@ impl Game<'_> {
|
||||
/// `setBlockAndUpdate` with the new `vault_state`.
|
||||
fn set_vault_state(&mut self, key: Pos, state: VaultState) -> Result<()> {
|
||||
let current = self.world.block(key.0, key.1, key.2);
|
||||
let Some(mut block) = self.res.assets.registry.state(current).cloned() else {
|
||||
let Some(mut block) = self.pack.assets.registry.state(current).cloned() else {
|
||||
return Ok(());
|
||||
};
|
||||
block
|
||||
.properties
|
||||
.insert("vault_state".into(), state.name().into());
|
||||
let id = self.res.assets.registry.resolve(&block)?;
|
||||
let id = self.pack.assets.registry.resolve(&block)?;
|
||||
self.level_set([key.0, key.1, key.2], id)
|
||||
}
|
||||
/// `VaultRenderer`: the display item of every vault near the camera that
|
||||
@@ -233,7 +233,7 @@ impl Game<'_> {
|
||||
) * glam::Mat4::from_rotation_y(vault.display_spin(alpha as f32).to_radians());
|
||||
let light = self.world.light(key.0, key.1, key.2);
|
||||
let seed =
|
||||
i64::from(self.res.item_renderer.item_id(&stack.item)) + i64::from(stack.damage);
|
||||
i64::from(self.pack.item_renderer.item_id(&stack.item)) + i64::from(stack.damage);
|
||||
for copy in item_render::cluster_poses(
|
||||
&state,
|
||||
pose,
|
||||
|
||||
@@ -404,7 +404,7 @@ impl Game<'_> {
|
||||
let state = self.world.block(pos[0], pos[1], pos[2]);
|
||||
let name = self.res.facts.get(state).name.clone();
|
||||
let prop = |game: &Self, key: &str| {
|
||||
game.res
|
||||
game.pack
|
||||
.assets
|
||||
.registry
|
||||
.state(state)
|
||||
@@ -478,7 +478,6 @@ impl Game<'_> {
|
||||
});
|
||||
let Some(model) = model else { return };
|
||||
let Some(r) = self
|
||||
.res
|
||||
.atlas
|
||||
.sprites
|
||||
.get("entity/projectiles/wind_charge")
|
||||
|
||||
@@ -46,7 +46,8 @@ pub struct MobData {
|
||||
/// Each entity type's `SpawnPlacements.getHeightmapType`.
|
||||
pub heightmaps: HashMap<String, String>,
|
||||
pub animations: HashMap<String, Animation>,
|
||||
pub villager_hats: super::villager_hats::VillagerHats,
|
||||
/// Replaced when the resource packs change (the rest of `MobData` never is).
|
||||
pub villager_hats: std::sync::RwLock<super::villager_hats::VillagerHats>,
|
||||
/// Biome tags (spawns_warm_variant_farm_animals, is_ocean...) by tag id.
|
||||
pub biome_tags: HashMap<String, std::collections::HashSet<String>>,
|
||||
/// Entity type tags (`data/*/tags/entity_type`).
|
||||
@@ -72,7 +73,7 @@ impl MobData {
|
||||
};
|
||||
data.biome_tags = crate::items::load_tags(root, "worldgen/biome").unwrap_or_default();
|
||||
data.entity_tags = crate::items::load_tags(root, "entity_type").unwrap_or_default();
|
||||
data.villager_hats = super::villager_hats::VillagerHats::load(root);
|
||||
data.villager_hats = std::sync::RwLock::new(super::villager_hats::VillagerHats::load(root));
|
||||
data
|
||||
}
|
||||
/// Only the keyframe animation definitions of `mob-data.json`.
|
||||
|
||||
@@ -1067,6 +1067,8 @@ fn render_visible(
|
||||
let variant = variant.strip_prefix("baby/").unwrap_or(variant);
|
||||
let profession = PROFESSIONS[m.extra.variant2 as usize % PROFESSIONS.len()];
|
||||
data.villager_hats
|
||||
.read()
|
||||
.unwrap_or_else(std::sync::PoisonError::into_inner)
|
||||
.apply(folder, variant, profession, &mut poses);
|
||||
}
|
||||
let light = if layer.full_bright {
|
||||
|
||||
Reference in New Issue
Block a user