Seed falling block models from their spawn cell
This commit is contained in:
@@ -543,6 +543,8 @@ impl LevelAccess for GameLevel<'_> {
|
||||
#[derive(Clone, Debug)]
|
||||
struct FallingBlock {
|
||||
state: BlockStateId,
|
||||
/// `DATA_START_POS`: spawn position used to select weighted block models.
|
||||
start_pos: BlockPos,
|
||||
position: Vec3,
|
||||
previous: Vec3,
|
||||
velocity: Vec3,
|
||||
@@ -1699,6 +1701,7 @@ impl Game<'_> {
|
||||
);
|
||||
self.falling.push(FallingBlock {
|
||||
state,
|
||||
start_pos: pos,
|
||||
position: p,
|
||||
previous: p,
|
||||
velocity: Vec3::ZERO,
|
||||
@@ -4952,7 +4955,13 @@ impl Game<'_> {
|
||||
);
|
||||
let packed = (u32::from(light >> 4) * 16) | ((u32::from(light & 15) * 16) << 8);
|
||||
let start = out.len();
|
||||
self.block_model_vertices(f.state, glam::Mat4::from_translation(o), packed, &mut out);
|
||||
self.block_model_vertices(
|
||||
f.state,
|
||||
f.start_pos,
|
||||
glam::Mat4::from_translation(o),
|
||||
packed,
|
||||
&mut out,
|
||||
);
|
||||
let tint = horizon_client::mobs::render::abgr(tint);
|
||||
for vertex in &mut out[start..] {
|
||||
vertex.color = horizon_client::hud_layout::multiply(vertex.color, tint);
|
||||
|
||||
@@ -16,6 +16,7 @@ use horizon_client::{
|
||||
};
|
||||
use horizon_core::{
|
||||
geometry::{Aabb, Vec3},
|
||||
position::BlockPos,
|
||||
random::RandomSource,
|
||||
};
|
||||
use horizon_world::registry::BlockStateId;
|
||||
@@ -1080,16 +1081,12 @@ impl Game<'_> {
|
||||
pub(super) fn block_model_vertices(
|
||||
&self,
|
||||
state: BlockStateId,
|
||||
seed_pos: BlockPos,
|
||||
m: glam::Mat4,
|
||||
light: u32,
|
||||
out: &mut Vec<Vertex>,
|
||||
) {
|
||||
let Ok(models) = self
|
||||
.res
|
||||
.assets
|
||||
.model_catalog
|
||||
.collect(state, horizon_core::position::BlockPos::new(0, 0, 0))
|
||||
else {
|
||||
let Ok(models) = self.res.assets.model_catalog.collect(state, seed_pos) else {
|
||||
return;
|
||||
};
|
||||
for (_, model) in &models {
|
||||
@@ -1238,7 +1235,7 @@ impl Game<'_> {
|
||||
* glam::Mat4::from_translation(glam::Vec3::splat(-0.5));
|
||||
let flash = c.kind == CartKind::Tnt && c.fuse > -1 && (c.fuse / 5) % 2 == 0;
|
||||
let start = out.len();
|
||||
self.block_model_vertices(state, m, packed, out);
|
||||
self.block_model_vertices(state, BlockPos::default(), m, packed, out);
|
||||
if flash {
|
||||
// submitWhiteSolidBlock: OverlayTexture.u(1.0) on the cart's own light.
|
||||
for v in &mut out[start..] {
|
||||
|
||||
@@ -198,6 +198,8 @@ impl Game<'_> {
|
||||
let (no_gravity, drop_item) = entity_nbt::falling_block_flags(&tag);
|
||||
self.falling.push(FallingBlock {
|
||||
state,
|
||||
// DATA_START_POS is not persisted by vanilla.
|
||||
start_pos: horizon_core::position::BlockPos::default(),
|
||||
position,
|
||||
previous: position,
|
||||
velocity,
|
||||
|
||||
Reference in New Issue
Block a user