Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified crates/engine/assets/textures/entity/player.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified mods/base/assets/textures/entity/armor/diamond_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified mods/base/assets/textures/entity/armor/diamond_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified mods/base/assets/textures/entity/armor/gold_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified mods/base/assets/textures/entity/armor/gold_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified mods/base/assets/textures/entity/armor/iron_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified mods/base/assets/textures/entity/armor/iron_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified mods/base/assets/textures/entity/armor/leather_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified mods/base/assets/textures/entity/armor/leather_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified mods/base/assets/textures/entity/chicken.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified mods/base/assets/textures/entity/cow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified mods/base/assets/textures/entity/pig.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified mods/base/assets/textures/entity/sheep.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified mods/base/assets/textures/item/leather_chestplate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion mods/base/src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
153 changes: 141 additions & 12 deletions mods/base/src/mobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand All @@ -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]),
],
),
Expand All @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down
Loading