mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'christof/fix_orichalcum_drop' into 'master'
introduce optional model indices for drop items as well (fixing orichalcum armor drops) See merge request veloren/veloren!3884
This commit is contained in:
commit
025713e2c0
@ -70,6 +70,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Intert entities like arrows no longer obstruct interacting with nearby entities/blocks.
|
- Intert entities like arrows no longer obstruct interacting with nearby entities/blocks.
|
||||||
- Underwater fall damage
|
- Underwater fall damage
|
||||||
- The scale component now behaves properly
|
- The scale component now behaves properly
|
||||||
|
- Multiple model support for dropped items (orichalcum armor)
|
||||||
|
|
||||||
## [0.14.0] - 2023-01-07
|
## [0.14.0] - 2023-01-07
|
||||||
|
|
||||||
|
@ -699,13 +699,13 @@
|
|||||||
Simple("common.items.armor.mail.bloodsteel.shoulder"): "voxel.armor.mail.bloodsteel.shoulder",
|
Simple("common.items.armor.mail.bloodsteel.shoulder"): "voxel.armor.mail.bloodsteel.shoulder",
|
||||||
Simple("common.items.armor.mail.bloodsteel.back"): "voxel.armor.mail.bloodsteel.back",
|
Simple("common.items.armor.mail.bloodsteel.back"): "voxel.armor.mail.bloodsteel.back",
|
||||||
//Orichalcum Set
|
//Orichalcum Set
|
||||||
Simple("common.items.armor.mail.orichalcum.chest"): "voxel.armor.mail.orichalcum.chest",
|
Simple("common.items.armor.mail.orichalcum.chest"): ("voxel.armor.mail.orichalcum", 0),
|
||||||
Simple("common.items.armor.mail.orichalcum.pants"): "voxel.armor.mail.orichalcum.pants",
|
Simple("common.items.armor.mail.orichalcum.pants"): ("voxel.armor.mail.orichalcum", 1),
|
||||||
Simple("common.items.armor.mail.orichalcum.belt"): "voxel.armor.mail.orichalcum.belt",
|
Simple("common.items.armor.mail.orichalcum.belt"): ("voxel.armor.mail.orichalcum", 2),
|
||||||
Simple("common.items.armor.mail.orichalcum.foot"): "voxel.armor.mail.orichalcum.foot",
|
Simple("common.items.armor.mail.orichalcum.foot"): ("voxel.armor.mail.orichalcum", 3),
|
||||||
Simple("common.items.armor.mail.orichalcum.hand"): "voxel.armor.mail.orichalcum.hand",
|
Simple("common.items.armor.mail.orichalcum.hand"): ("voxel.armor.mail.orichalcum", 4),
|
||||||
Simple("common.items.armor.mail.orichalcum.shoulder"): "voxel.armor.mail.orichalcum.shoulder",
|
Simple("common.items.armor.mail.orichalcum.shoulder"): ("voxel.armor.mail.orichalcum", 5),
|
||||||
Simple("common.items.armor.mail.orichalcum.back"): "voxel.armor.mail.orichalcum.back",
|
Simple("common.items.armor.mail.orichalcum.back"): ("voxel.armor.mail.orichalcum", 6),
|
||||||
//misc
|
//misc
|
||||||
Simple("common.items.armor.misc.pants.hunting"): "voxel.armor.misc.pants.grayscale",
|
Simple("common.items.armor.misc.pants.hunting"): "voxel.armor.misc.pants.grayscale",
|
||||||
// Backs
|
// Backs
|
||||||
|
@ -27,7 +27,7 @@ use common::{
|
|||||||
vol::{IntoFullPosIterator, ReadVol, Vox},
|
vol::{IntoFullPosIterator, ReadVol, Vox},
|
||||||
};
|
};
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use serde::Deserialize;
|
use serde::{Deserialize, Deserializer};
|
||||||
use std::{fmt, hash::Hash};
|
use std::{fmt, hash::Hash};
|
||||||
use tracing::{error, warn};
|
use tracing::{error, warn};
|
||||||
use vek::*;
|
use vek::*;
|
||||||
@ -5116,8 +5116,42 @@ impl ObjectCentralSpec {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ModelWithOptionalIndex(String, u32);
|
||||||
|
|
||||||
|
impl<'de> Deserialize<'de> for ModelWithOptionalIndex {
|
||||||
|
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
|
||||||
|
struct StringWithOptionalIndex;
|
||||||
|
use serde::de;
|
||||||
|
|
||||||
|
impl<'de> de::Visitor<'de> for StringWithOptionalIndex {
|
||||||
|
type Value = ModelWithOptionalIndex;
|
||||||
|
|
||||||
|
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
formatter.write_str("model_spec or (spec, index)")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_str<E: de::Error>(self, model: &str) -> Result<Self::Value, E> {
|
||||||
|
Ok(ModelWithOptionalIndex(model.into(), DEFAULT_INDEX))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_seq<A: de::SeqAccess<'de>>(self, mut seq: A) -> Result<Self::Value, A::Error> {
|
||||||
|
if let Some(spec) = seq.next_element::<String>()? {
|
||||||
|
if let Some(num) = seq.next_element::<u32>()? {
|
||||||
|
Ok(ModelWithOptionalIndex(spec, num))
|
||||||
|
} else {
|
||||||
|
Err(de::Error::missing_field("index"))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Err(de::Error::missing_field("spec"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
deserializer.deserialize_any(StringWithOptionalIndex {})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct ItemDropCentralSpec(HashMap<ItemKey, String>);
|
struct ItemDropCentralSpec(HashMap<ItemKey, ModelWithOptionalIndex>);
|
||||||
|
|
||||||
make_vox_spec!(
|
make_vox_spec!(
|
||||||
item_drop::Body,
|
item_drop::Body,
|
||||||
@ -5148,17 +5182,17 @@ make_vox_spec!(
|
|||||||
|
|
||||||
impl ItemDropCentralSpec {
|
impl ItemDropCentralSpec {
|
||||||
fn mesh_bone0(&self, item_drop: &item_drop::Body, item_key: &ItemKey) -> BoneMeshes {
|
fn mesh_bone0(&self, item_drop: &item_drop::Body, item_key: &ItemKey) -> BoneMeshes {
|
||||||
let coin_pouch = "voxel.object.pouch".to_string();
|
let coin_pouch = ModelWithOptionalIndex("voxel.object.pouch".to_string(), DEFAULT_INDEX);
|
||||||
|
|
||||||
if let Some(spec) = match item_drop {
|
if let Some(spec) = match item_drop {
|
||||||
item_drop::Body::CoinPouch => Some(&coin_pouch),
|
item_drop::Body::CoinPouch => Some(&coin_pouch),
|
||||||
_ => self.0.get(item_key),
|
_ => self.0.get(item_key),
|
||||||
} {
|
} {
|
||||||
let full_spec: String = ["voxygen.", spec.as_str()].concat();
|
let full_spec: String = ["voxygen.", spec.0.as_str()].concat();
|
||||||
let segment = match item_drop {
|
let segment = match item_drop {
|
||||||
item_drop::Body::Armor(_) => MatSegment::from_vox_model_index(
|
item_drop::Body::Armor(_) => MatSegment::from_vox_model_index(
|
||||||
&graceful_load_vox_fullspec(&full_spec).read().0,
|
&graceful_load_vox_fullspec(&full_spec).read().0,
|
||||||
0,
|
spec.1 as usize,
|
||||||
)
|
)
|
||||||
.map(|mat_cell| match mat_cell {
|
.map(|mat_cell| match mat_cell {
|
||||||
MatCell::None => None,
|
MatCell::None => None,
|
||||||
@ -5166,7 +5200,7 @@ impl ItemDropCentralSpec {
|
|||||||
MatCell::Normal(data) => data.is_hollow().then_some(MatCell::None),
|
MatCell::Normal(data) => data.is_hollow().then_some(MatCell::None),
|
||||||
})
|
})
|
||||||
.to_segment(|_| Default::default()),
|
.to_segment(|_| Default::default()),
|
||||||
_ => graceful_load_segment_fullspec(&full_spec, DEFAULT_INDEX),
|
_ => graceful_load_segment_fullspec(&full_spec, spec.1),
|
||||||
};
|
};
|
||||||
let offset = segment_center(&segment).unwrap_or_default();
|
let offset = segment_center(&segment).unwrap_or_default();
|
||||||
(segment, match item_drop {
|
(segment, match item_drop {
|
||||||
|
Loading…
Reference in New Issue
Block a user