Skip to content

Commit

Permalink
Apply trim logic for all armor
Browse files Browse the repository at this point in the history
  • Loading branch information
NickAcPT committed Nov 6, 2024
1 parent e621000 commit e621000
Showing 1 changed file with 28 additions and 24 deletions.
52 changes: 28 additions & 24 deletions nmsr-aas/src/model/armor/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,14 @@ impl<'a> VanillaArmorApplicable<'a> {
}

fn apply_modifications_if_needed(&self, image: &mut RgbaImage) {
if let Self::Armor(VanillaMinecraftArmorMaterial::Leather(LeatherArmorColor(color)))
| Self::Trim(VanillaMinecraftArmorMaterial::Leather(LeatherArmorColor(color)), _) = self
{
for pixel in image.pixels_mut() {
if pixel[3] == 0 {
continue;
}
for pixel in image.pixels_mut() {
if pixel[3] == 0 {
continue;
}

let do_leather_logic = if let Self::Trim(
armor_material,
VanillaMinecraftArmorTrimData { material, .. },
) = self
let do_leather_logic =
if let Self::Trim(armor_material, VanillaMinecraftArmorTrimData { material, .. }) =
self
{
let palette = material
.get_palette_for_trim_armor_material(*armor_material)
Expand All @@ -81,19 +77,27 @@ impl<'a> VanillaArmorApplicable<'a> {
true
};

if do_leather_logic {
let vec_color = Vec3::from([color[0] as f32, color[1] as f32, color[2] as f32]);
let skin_pixel =
(Vec3::from([pixel[0] as f32, pixel[1] as f32, pixel[2] as f32]) / 255.0)
* vec_color;

pixel.0 = [
skin_pixel.x as u8,
skin_pixel.y as u8,
skin_pixel.z as u8,
pixel[3],
];
}
if do_leather_logic {
let (Self::Armor(VanillaMinecraftArmorMaterial::Leather(LeatherArmorColor(color)))
| Self::Trim(
VanillaMinecraftArmorMaterial::Leather(LeatherArmorColor(color)),
_,
)) = self
else {
return;
};

let vec_color = Vec3::from([color[0] as f32, color[1] as f32, color[2] as f32]);
let skin_pixel = (Vec3::from([pixel[0] as f32, pixel[1] as f32, pixel[2] as f32])
/ 255.0)
* vec_color;

pixel.0 = [
skin_pixel.x as u8,
skin_pixel.y as u8,
skin_pixel.z as u8,
pixel[3],
];
}
}
}
Expand Down

0 comments on commit e621000

Please sign in to comment.