diff --git a/crates/engine/assets/textures/entity/player.png b/crates/engine/assets/textures/entity/player.png index 176b73a6..2b2fddfe 100644 Binary files a/crates/engine/assets/textures/entity/player.png and b/crates/engine/assets/textures/entity/player.png differ diff --git a/mods/base/assets/textures/entity/armor/diamond_1.png b/mods/base/assets/textures/entity/armor/diamond_1.png index 96a61828..b0e92a2b 100644 Binary files a/mods/base/assets/textures/entity/armor/diamond_1.png and b/mods/base/assets/textures/entity/armor/diamond_1.png differ diff --git a/mods/base/assets/textures/entity/armor/diamond_2.png b/mods/base/assets/textures/entity/armor/diamond_2.png index b8a592ac..4bb74cf0 100644 Binary files a/mods/base/assets/textures/entity/armor/diamond_2.png and b/mods/base/assets/textures/entity/armor/diamond_2.png differ diff --git a/mods/base/assets/textures/entity/armor/gold_1.png b/mods/base/assets/textures/entity/armor/gold_1.png index 69129fa9..f2c9dc00 100644 Binary files a/mods/base/assets/textures/entity/armor/gold_1.png and b/mods/base/assets/textures/entity/armor/gold_1.png differ diff --git a/mods/base/assets/textures/entity/armor/gold_2.png b/mods/base/assets/textures/entity/armor/gold_2.png index c17bc394..57915d31 100644 Binary files a/mods/base/assets/textures/entity/armor/gold_2.png and b/mods/base/assets/textures/entity/armor/gold_2.png differ diff --git a/mods/base/assets/textures/entity/armor/iron_1.png b/mods/base/assets/textures/entity/armor/iron_1.png index ab4672c5..328cd145 100644 Binary files a/mods/base/assets/textures/entity/armor/iron_1.png and b/mods/base/assets/textures/entity/armor/iron_1.png differ diff --git a/mods/base/assets/textures/entity/armor/iron_2.png b/mods/base/assets/textures/entity/armor/iron_2.png index e89bfebc..44871146 100644 Binary files a/mods/base/assets/textures/entity/armor/iron_2.png and b/mods/base/assets/textures/entity/armor/iron_2.png differ diff --git a/mods/base/assets/textures/entity/armor/leather_1.png b/mods/base/assets/textures/entity/armor/leather_1.png index 7248c13d..c22306ec 100644 Binary files a/mods/base/assets/textures/entity/armor/leather_1.png and b/mods/base/assets/textures/entity/armor/leather_1.png differ diff --git a/mods/base/assets/textures/entity/armor/leather_2.png b/mods/base/assets/textures/entity/armor/leather_2.png index d26233ee..73792663 100644 Binary files a/mods/base/assets/textures/entity/armor/leather_2.png and b/mods/base/assets/textures/entity/armor/leather_2.png differ diff --git a/mods/base/assets/textures/entity/chicken.png b/mods/base/assets/textures/entity/chicken.png index 9231f958..8fd7d2f0 100644 Binary files a/mods/base/assets/textures/entity/chicken.png and b/mods/base/assets/textures/entity/chicken.png differ diff --git a/mods/base/assets/textures/entity/cow.png b/mods/base/assets/textures/entity/cow.png index 82c30007..0338cf49 100644 Binary files a/mods/base/assets/textures/entity/cow.png and b/mods/base/assets/textures/entity/cow.png differ diff --git a/mods/base/assets/textures/entity/pig.png b/mods/base/assets/textures/entity/pig.png index dfd1c9f8..9b0a4338 100644 Binary files a/mods/base/assets/textures/entity/pig.png and b/mods/base/assets/textures/entity/pig.png differ diff --git a/mods/base/assets/textures/entity/sheep.png b/mods/base/assets/textures/entity/sheep.png index 555dc130..3dd18a70 100644 Binary files a/mods/base/assets/textures/entity/sheep.png and b/mods/base/assets/textures/entity/sheep.png differ diff --git a/mods/base/assets/textures/item/leather_chestplate.png b/mods/base/assets/textures/item/leather_chestplate.png index 200c2d14..8824efeb 100644 Binary files a/mods/base/assets/textures/item/leather_chestplate.png and b/mods/base/assets/textures/item/leather_chestplate.png differ diff --git a/mods/base/src/items.rs b/mods/base/src/items.rs index f8f65e95..a94b0f90 100644 --- a/mods/base/src/items.rs +++ b/mods/base/src/items.rs @@ -148,7 +148,8 @@ pub fn register(r: &mut Registry) { let points = points[slot]; let tag = ARMOR_SLOTS[slot]; // Leggings are the inner layer, drawn closer to the body. - let (inflate, layer) = if slot == 2 { (0.5, 2) } else { (1.0, 1) }; + let (inflate, layer) = + if mat == "leather" { if slot == 2 { (0.2, 2) } else { (0.4, 1) } } else { if slot == 2 { (0.5, 2) } else { (0.75, 1) } }; r.item(Item::generated(format!("{mat}_{piece}"))) .durability(durability * dur) .set(&ARMOR, Armor { points, toughness }) diff --git a/mods/base/src/mobs.rs b/mods/base/src/mobs.rs index f12187ef..82e46153 100644 --- a/mods/base/src/mobs.rs +++ b/mods/base/src/mobs.rs @@ -2,6 +2,7 @@ use weft_sdk::ai; use weft_sdk::*; +use weft_sdk::abi::MeshVertex; pub static ZOMBIE: EntityKind = EntityKind::named("zombie"); pub static SPIDER: EntityKind = EntityKind::named("spider"); @@ -31,6 +32,80 @@ fn vanilla_legs(x: f32, y: f32) -> [ModelPart; 4] { let leg = |name, px, pz| vanilla_part(name, [px, y, pz], &[([-2.0, 0.0, -2.0], [4.0, height, 4.0], [0.0, 16.0])]); [leg("leg0", -x, 7.0), leg("leg1", x, 7.0), leg("leg2", x, -5.0), leg("leg3", -x, -5.0)] } +fn polygon(part: ModelPart, size: [f32; 2], uv: [f32; 4], two_sided: bool) -> ModelPart { + let [x, y, z] = part.pivot; + let [width, height] = size; + let [u, v, uv_width, uv_height] = uv; + let a = MeshVertex { + pos: [x, y, z], + uv: [u, v], + }; + let b = MeshVertex { + pos: [x + width, y, z], + uv: [u + uv_width, v], + }; + let c = MeshVertex { + pos: [x + width, y + height, z], + uv: [u + uv_width, v + uv_height], + }; + let d = MeshVertex { + pos: [x, y + height, z], + uv: [u, v + uv_height], + }; + if two_sided { + part.mesh(vec![a, b, c, a, c, d]).mesh(vec![a, c, b, a, d, c]) + } else { + part.mesh(vec![a, b, c, a, c, d]) + } +} +fn rotate_vertex(v: MeshVertex, pivot: [f32; 3], degrees: [f32; 3]) -> MeshVertex { + let [rx, ry, rz] = degrees.map(f32::to_radians); + let (mut x, mut y, mut z) = ( + v.pos[0] - pivot[0], + v.pos[1] - pivot[1], + v.pos[2] - pivot[2], + ); + let (s, c) = rx.sin_cos(); + let (ny, nz) = (y * c - z * s, y * s + z * c); + y = ny; + z = nz; + let (s, c) = ry.sin_cos(); + let (nx, nz) = (x * c + z * s, -x * s + z * c); + x = nx; + z = nz; + let (s, c) = rz.sin_cos(); + let (nx, ny) = (x * c - y * s, x * s + y * c); + x = nx; + y = ny; + MeshVertex { + pos: [x + pivot[0], y + pivot[1], z + pivot[2]], + uv: v.uv, + } +} +fn polygon_at(part: ModelPart, offset: [f32; 3], size: [f32; 2], uv: [f32; 4], rotation: [f32; 3], two_sided: bool) -> ModelPart { + let anchor = [ + part.pivot[0] + offset[0], + part.pivot[1] + offset[1], + part.pivot[2] + offset[2], + ]; + let [x, y, z] = anchor; + let [width, height] = size; + let [u, v, uv_width, uv_height] = uv; + let make = |pos: [f32; 3], uv: [f32; 2]| rotate_vertex( + MeshVertex { pos, uv }, + anchor, + rotation, + ); + let a = make([x, y, z], [u, v]); + let b = make([x + width, y, z], [u + uv_width, v]); + let c = make([x + width, y + height, z], [u + uv_width, v + uv_height]); + let d = make([x, y + height, z], [u, v + uv_height]); + if two_sided { + part.mesh(vec![a, b, c, a, c, d]).mesh(vec![a, c, b, a, d, c]) + } else { + part.mesh(vec![a, b, c, a, c, d]) + } +} /// Vanilla's creeper (`CreeperModel`): 64 x 32. fn creeper_model() -> Model { @@ -62,18 +137,30 @@ fn skeleton_model() -> Model { .uv_size(64, 32) } -/// Vanilla's sheep (`SheepModel` and `SheepFurModel`) in one texture: the sheep in the upper half, -/// its wool in the lower, on boxes grown over it. +/// Vanilla's sheep fn sheep_model() -> Model { let wool = |p: [f32; 2]| [p[0], p[1] + 32.0]; - let head = vanilla_part("head", [0.0, 6.0, -8.0], &[([-3.0, -4.0, -6.0], [6.0, 6.0, 8.0], [0.0, 0.0])]) - .cuboid([-3.0, -2.0, -4.0], [6.0, 6.0, 6.0], wool([0.0, 0.0])) - .inflated(0.6); + let head = vanilla_part("head", [0.0, 6.0, -8.0], &[( + [-4.0, -4.0, -6.0], [8.0, 8.0, 8.0], [0.0, 32.0] + )]); let body = vanilla_part("body", [0.0, 5.0, 2.0], &[([-4.0, -10.0, -7.0], [8.0, 16.0, 6.0], [28.0, 8.0])]) - .cuboid([-4.0, -6.0, -7.0], [8.0, 16.0, 6.0], wool([28.0, 8.0])) + .cuboid([-4.5, -8.0, -9.0], [9.0, 18.0, 8.0], [16.0, 0.0]) .inflated(1.75) .rotation(-90.0, 0.0, 0.0); - let mut parts = vec![head, body]; + let left_ear = ModelPart::new("leftEar", [-4.0, 12.0, -9.0]) + .cuboid([0.0, 6.5, -3.0], [3.0, 2.0, 1.0], [0.0, 0.0]) + .rotation(0.0, 0.0, 15.0) + .mirrored() + .child_of(0); + let right_ear = ModelPart::new("rightEar", [4.0, 12.0, -9.0]) + .cuboid([-3.0, 6.5, -3.0], [3.0, 2.0, 1.0], [0.0, 0.0]) + .rotation(0.0, 0.0, -15.0) + .child_of(0); + let snout = ModelPart::new("snout", [4.0, 12.0, -9.0]) + .cuboid([-5.5, 5.0, -6.0], [3.0, 3.0, 4.0], [0.0, 3.0]) + .rotation(-15.0, 0.0, 0.0) + .child_of(0); + let mut parts = vec![head, body, left_ear, right_ear, snout]; parts.extend(vanilla_legs(3.0, 12.0).map(|l| { l.cuboid([-2.0, -6.0, -2.0], [4.0, 6.0, 4.0], wool([0.0, 16.0])) .inflated(0.5) @@ -83,14 +170,26 @@ fn sheep_model() -> Model { /// Vanilla's chicken: 64 x 32. fn chicken_model() -> Model { - let leg = |name, x| vanilla_part(name, [x, 19.0, 1.0], &[([-1.0, 0.0, -3.0], [3.0, 5.0, 3.0], [26.0, 0.0])]); + let leg = |name, x| polygon_at( + polygon( + ModelPart::new(name, [x, 5.0, 0.0]), + [1.0, -5.0], + [26.0, 3.0, 1.0, 5.0], + true, + ), + [-1.0, -4.9, -3.0], + [3.0, 3.0], + [27.0, 3.0, 3.0, 3.0], + [90.0, 0.0, 0.0], + true, + ); Model::from(vec![ vanilla_part( "head", [0.0, 15.0, -4.0], &[ ([-2.0, -6.0, -2.0], [4.0, 6.0, 3.0], [0.0, 0.0]), - ([-2.0, -4.0, -4.0], [4.0, 2.0, 2.0], [14.0, 0.0]), + ([-1.5, -4.0, -4.0], [3.0, 2.0, 2.0], [14.0, 0.0]), ([-1.0, -2.0, -3.0], [2.0, 2.0, 2.0], [14.0, 4.0]), ], ), @@ -99,6 +198,18 @@ fn chicken_model() -> Model { vanilla_part("wing1", [4.0, 13.0, 0.0], &[([-1.0, 0.0, -3.0], [1.0, 4.0, 6.0], [24.0, 13.0])]), leg("rightLeg", -2.0), leg("leftLeg", 1.0), + polygon( + ModelPart::new("comb", [0.0, 17.0, -7.0]), + [4.0, -3.0], + [31.0, 3.0, 4.0, 3.0], + true, + ).child_of(0).rotation(0.0, -90.0, 0.0), + polygon( + ModelPart::new("tail", [0.0, 13.0, 2.0]), + [6.0, -6.0], + [36.0, 3.0, 6.0, 6.0], + true, + ).rotation(0.0, -90.0, 0.0), ]) .uv_size(64, 32) } @@ -126,7 +237,16 @@ fn cow_model() -> Model { &[([-6.0, -10.0, -7.0], [12.0, 18.0, 10.0], [18.0, 4.0]), ([-2.0, 2.0, -8.0], [4.0, 6.0, 1.0], [52.0, 0.0])], ) .rotation(-90.0, 0.0, 0.0); - let mut parts = vec![head, body]; + let left_ear = ModelPart::new("leftEar", [-4.0, 12.0, -9.0]) + .cuboid([0.0, 8.0, -3.0], [3.0, 2.0, 1.0], [18.0, 32.0]) + .rotation(0.0, 0.0, 15.0) + .mirrored() + .child_of(0); + let right_ear = ModelPart::new("rightEar", [4.0, 12.0, -9.0]) + .cuboid([-3.0, 8.0, -3.0], [3.0, 2.0, 1.0], [18.0, 32.0]) + .rotation(0.0, 0.0, -15.0) + .child_of(0); + let mut parts = vec![head, body, left_ear, right_ear]; parts.extend(vanilla_legs(4.0, 12.0)); Model::from(parts).uv_size(64, 64) } @@ -138,8 +258,17 @@ fn pig_model() -> Model { [0.0, 12.0, -6.0], &[([-4.0, -4.0, -8.0], [8.0, 8.0, 8.0], [0.0, 0.0]), ([-2.0, 0.0, -9.0], [4.0, 3.0, 1.0], [16.0, 16.0])], ); - let body = vanilla_part("body", [0.0, 11.0, 2.0], &[([-5.0, -10.0, -7.0], [10.0, 16.0, 8.0], [28.0, 8.0])]).rotation(-90.0, 0.0, 0.0); - let mut parts = vec![head, body]; + let body = vanilla_part("body", [0.0, 11.0, 2.0], &[([-5.0, -10.0, -7.0], [10.0, 17.0, 8.0], [28.0, 8.0])]).rotation(-90.0, 0.0, 0.0); + let left_ear = ModelPart::new("leftEar", [-4.0, 12.0, -9.0]) + .cuboid([-1.0, -2.0, -4.0], [1.0, 5.0, 4.0], [0.0, 26.0]) + .rotation(0.0, 0.0, -15.0) + .mirrored() + .child_of(0); + let right_ear = ModelPart::new("rightEar", [4.0, 12.0, -9.0]) + .cuboid([0.0, -2.0, -4.0], [1.0, 5.0, 4.0], [0.0, 26.0]) + .rotation(0.0, 0.0, 15.0) + .child_of(0); + let mut parts = vec![head, body, left_ear, right_ear]; parts.extend(vanilla_legs(3.0, 18.0)); Model::from(parts).uv_size(64, 64) }