Finally fix all registries
This commit is contained in:
1 parent
d444f68093
commit
2fd3585af7
12 files changed
+146
-252
No files matched your search
@@ -1,10 +1,26 @@
|
||||
use super::RegistryValue;
|
||||
use pumpkin_protocol::VarInt;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct BiomeCodec {
|
||||
name: String,
|
||||
id: i32,
|
||||
element: Biome,
|
||||
}
|
||||
|
||||
impl Default for BiomeCodec {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
name: "minecraft:plains".to_string(),
|
||||
id: 0,
|
||||
element: Biome::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct Biome {
|
||||
has_precipitation: bool,
|
||||
has_precipitation: i8,
|
||||
temperature: f32,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
temperature_modifier: Option<String>,
|
||||
@@ -67,40 +83,36 @@ struct Music {
|
||||
sound: String,
|
||||
min_delay: i32,
|
||||
max_delay: i32,
|
||||
replace_current_music: bool,
|
||||
replace_current_music: i8,
|
||||
}
|
||||
|
||||
// 1.20.6 default https://gist.github.com/WinX64/ab8c7a8df797c273b32d3a3b66522906
|
||||
pub(super) fn all() -> Vec<RegistryValue<Biome>> {
|
||||
let biome = Biome {
|
||||
has_precipitation: false,
|
||||
temperature: 1.0,
|
||||
temperature_modifier: None,
|
||||
downfall: 0.0,
|
||||
effects: BiomeEffects {
|
||||
fog_color: 0x7FA1FF,
|
||||
water_color: 0x7FA1FF,
|
||||
water_fog_color: 0x7FA1FF,
|
||||
sky_color: 0x7FA1FF,
|
||||
foliage_color: Some(0x7FA1FF),
|
||||
grass_color: Some(0x7FA1FF),
|
||||
grass_color_modifier: None,
|
||||
particle: None,
|
||||
ambient_sound: None,
|
||||
mood_sound: Some(MoodSound {
|
||||
block_search_extent: 8,
|
||||
offset: 2.0,
|
||||
sound: "minecraft:ambient.cave".into(),
|
||||
tick_delay: 6000,
|
||||
}),
|
||||
additions_sound: None,
|
||||
music: None,
|
||||
},
|
||||
};
|
||||
|
||||
vec![RegistryValue {
|
||||
name: "minecraft:plains".into(),
|
||||
id: 0,
|
||||
element: biome,
|
||||
}]
|
||||
impl Default for Biome {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
has_precipitation: 0,
|
||||
temperature: 1.0,
|
||||
temperature_modifier: None,
|
||||
downfall: 0.0,
|
||||
effects: BiomeEffects {
|
||||
fog_color: 12638463,
|
||||
water_color: 4159204,
|
||||
water_fog_color: 329011,
|
||||
sky_color: 7907327,
|
||||
foliage_color: None,
|
||||
grass_color: None,
|
||||
grass_color_modifier: None,
|
||||
particle: None,
|
||||
ambient_sound: None,
|
||||
mood_sound: Some(MoodSound {
|
||||
block_search_extent: 8,
|
||||
offset: 2.0,
|
||||
sound: "minecraft:ambient.cave".into(),
|
||||
tick_delay: 6000,
|
||||
}),
|
||||
additions_sound: None,
|
||||
music: None,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
use super::RegistryValue;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
@@ -13,19 +12,4 @@ struct Decoration {
|
||||
parameters: Vec<String>,
|
||||
}
|
||||
|
||||
pub(super) fn all() -> Vec<RegistryValue<ChatType>> {
|
||||
vec![RegistryValue {
|
||||
name: "minecraft:chat".into(),
|
||||
id: 0,
|
||||
element: ChatType {
|
||||
chat: Decoration {
|
||||
parameters: vec!["sender".into(), "content".into()],
|
||||
translation_key: "chat.type.text".into(),
|
||||
},
|
||||
narration: Decoration {
|
||||
parameters: vec!["sender".into(), "content".into()],
|
||||
translation_key: "chat.type.text.narrate".into(),
|
||||
},
|
||||
},
|
||||
}]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use serde::Serialize;
|
||||
|
||||
use super::RegistryValue;
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct DamageType {
|
||||
@@ -61,23 +60,4 @@ const NAMES: &[&str] = &[
|
||||
"wither_skull",
|
||||
];
|
||||
|
||||
pub(super) fn all() -> Vec<RegistryValue<DamageType>> {
|
||||
let mut items: Vec<_> = NAMES
|
||||
.iter()
|
||||
.map(|name| RegistryValue {
|
||||
name: (*name).into(),
|
||||
id: 0,
|
||||
element: DamageType {
|
||||
exhaustion: 0.1,
|
||||
message_id: "inFire".into(),
|
||||
scaling: "when_caused_by_living_non_player".into(),
|
||||
effects: None,
|
||||
death_message_type: Some("default".into()),
|
||||
},
|
||||
})
|
||||
.collect();
|
||||
|
||||
items[1].element.effects = Some("burning".into());
|
||||
|
||||
items
|
||||
}
|
||||
@@ -49,13 +49,8 @@ impl Default for Dimension {
|
||||
infiniburn: "#minecraft:infiniburn_overworld".into(),
|
||||
logical_height: 384,
|
||||
min_y: -64,
|
||||
monster_spawn_block_light_limit: 0,
|
||||
monster_spawn_light_level: MonsterSpawnLightLevel::Tagged(
|
||||
MonsterSpawnLightLevelTagged::Uniform {
|
||||
min_inclusive: 7,
|
||||
max_inclusive: 0,
|
||||
},
|
||||
),
|
||||
monster_spawn_block_light_limit: 15,
|
||||
monster_spawn_light_level: MonsterSpawnLightLevel::Int(7),
|
||||
natural: 1,
|
||||
piglin_safe: 0,
|
||||
respawn_anchor_works: 0,
|
||||
|
||||
+45
-110
@@ -1,121 +1,56 @@
|
||||
use biomes::Biome;
|
||||
use dimensions::Dimension;
|
||||
use fastnbt::SerOpts;
|
||||
use pumpkin_protocol::bytebuf::ByteBuffer;
|
||||
use serde::Serialize;
|
||||
use paint::Painting;
|
||||
use pumpkin_protocol::client::config::RegistryEntry;
|
||||
use wolf::WolfVariant;
|
||||
|
||||
mod biomes;
|
||||
mod biomes;
|
||||
mod chat_type;
|
||||
mod damage_type;
|
||||
mod dimensions;
|
||||
mod wolf;
|
||||
mod dimensions;
|
||||
mod paint;
|
||||
mod wolf;
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
struct LoginInfo {
|
||||
#[serde(rename = "minecraft:dimension_type")]
|
||||
dimensions: Codec<dimensions::Dimension>,
|
||||
// #[serde(rename = "minecraft:wolf_variant")]
|
||||
// wolf: Codec<wolf::WolfVariant>,
|
||||
/* #[serde(rename = "minecraft:worldgen/biome")]
|
||||
biomes: Codec<biomes::Biome>,
|
||||
#[serde(rename = "minecraft:chat_type")]
|
||||
chat: Codec<chat_type::ChatType>,
|
||||
#[serde(rename = "minecraft:damage_type")]
|
||||
damage: Codec<damage_type::DamageType>, */
|
||||
pub struct Registry {
|
||||
pub registry_id: String,
|
||||
pub registry_entries: Vec<RegistryEntry>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct DimensionCodec {
|
||||
#[serde(rename = "minecraft:dimension_type")]
|
||||
dimensions: Codec<dimensions::Dimension>,
|
||||
}
|
||||
|
||||
impl DimensionCodec {
|
||||
pub fn parse() -> Vec<u8> {
|
||||
let dimension = Dimension::default();
|
||||
let codec = DimensionCodec {
|
||||
dimensions: Codec {
|
||||
ty: "minecraft:dimension_type".into(),
|
||||
value: vec![RegistryValue {
|
||||
name: "minecraft:overworld".into(),
|
||||
id: 0,
|
||||
element: dimension,
|
||||
}],
|
||||
},
|
||||
};
|
||||
fastnbt::to_bytes_with_opts(&codec, SerOpts::network_nbt()).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct WolfCodec {
|
||||
#[serde(rename = "minecraft:wolf_variant")]
|
||||
wolf: Codec<wolf::WolfVariant>,
|
||||
}
|
||||
|
||||
impl WolfCodec {
|
||||
pub fn parse() -> Vec<u8> {
|
||||
let wolf = WolfVariant::default();
|
||||
let codec = WolfCodec {
|
||||
wolf: Codec {
|
||||
ty: "minecraft:wolf_variant".into(),
|
||||
value: vec![RegistryValue {
|
||||
name: "minecraft:wolf_variant".into(),
|
||||
id: 0,
|
||||
element: wolf,
|
||||
}],
|
||||
},
|
||||
};
|
||||
fastnbt::to_bytes_with_opts(&codec, SerOpts::network_nbt()).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
struct Codec<T> {
|
||||
#[serde(rename = "type")]
|
||||
ty: String,
|
||||
value: Vec<RegistryValue<T>>,
|
||||
}
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
struct RegistryValue<T> {
|
||||
name: String,
|
||||
id: i32,
|
||||
element: T,
|
||||
}
|
||||
|
||||
pub fn write_codec(out: &mut ByteBuffer, world_min_y: i32, world_height: u32) -> Vec<u8> {
|
||||
let dimension = Dimension::default();
|
||||
let wolf = WolfVariant::default();
|
||||
|
||||
let info = LoginInfo {
|
||||
dimensions: Codec {
|
||||
ty: "minecraft:dimension_type".into(),
|
||||
value: vec![RegistryValue {
|
||||
name: "minecraft:overworld".into(),
|
||||
id: 0,
|
||||
element: dimension,
|
||||
impl Registry {
|
||||
pub fn get_static() -> Vec<Self> {
|
||||
let dimensions = Registry {
|
||||
registry_id: "minecraft:dimension_type".to_string(),
|
||||
registry_entries: vec![RegistryEntry {
|
||||
entry_id: "minecraft:overworld".to_string(),
|
||||
data: fastnbt::to_bytes_with_opts(&Dimension::default(), SerOpts::network_nbt())
|
||||
.unwrap(),
|
||||
}],
|
||||
},
|
||||
/* wolf: Codec {
|
||||
ty: "minecraft:wolf_variant".into(),
|
||||
value: vec![RegistryValue {
|
||||
name: "minecraft:wolf_variant".into(),
|
||||
id: 0,
|
||||
element: wolf,
|
||||
}],
|
||||
}, */ /* biomes: Codec {
|
||||
ty: "minecraft:worldgen/biome".into(),
|
||||
value: biomes::all(),
|
||||
},
|
||||
chat: Codec {
|
||||
ty: "minecraft:chat_type".into(),
|
||||
value: chat_type::all(),
|
||||
},
|
||||
damage: Codec {
|
||||
ty: "minecraft:damage_type".into(),
|
||||
value: damage_type::all(),
|
||||
}, */
|
||||
};
|
||||
|
||||
fastnbt::to_bytes_with_opts(&info, SerOpts::network_nbt()).unwrap()
|
||||
};
|
||||
let biomes = Registry {
|
||||
registry_id: "minecraft:worldgen/biome".to_string(),
|
||||
registry_entries: vec![RegistryEntry {
|
||||
entry_id: "minecraft:snowy_taiga".to_string(),
|
||||
data: fastnbt::to_bytes_with_opts(&Biome::default(), SerOpts::network_nbt())
|
||||
.unwrap(),
|
||||
}],
|
||||
};
|
||||
let wolf_variants = Registry {
|
||||
registry_id: "minecraft:wolf_variant".to_string(),
|
||||
registry_entries: vec![RegistryEntry {
|
||||
entry_id: "minecraft:wolf_variant".to_string(),
|
||||
data: fastnbt::to_bytes_with_opts(&WolfVariant::default(), SerOpts::network_nbt())
|
||||
.unwrap(),
|
||||
}],
|
||||
};
|
||||
let paintings = Registry {
|
||||
registry_id: "minecraft:painting_variant".to_string(),
|
||||
registry_entries: vec![RegistryEntry {
|
||||
entry_id: "minecraft:painting_variant".to_string(),
|
||||
data: fastnbt::to_bytes_with_opts(&Painting::default(), SerOpts::network_nbt())
|
||||
.unwrap(),
|
||||
}],
|
||||
};
|
||||
vec![dimensions, biomes, wolf_variants, paintings]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Painting {
|
||||
asset_id: String,
|
||||
height: i32,
|
||||
width: i32,
|
||||
}
|
||||
|
||||
impl Default for Painting {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
asset_id: "minecraft:backyard".into(),
|
||||
height: 2,
|
||||
width: 2,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user