add damage type registries
This commit is contained in:
parent
661e196987
commit
f111c7881c
@ -274,6 +274,10 @@ impl ByteBuffer {
|
||||
self.buffer.put_f32(n)
|
||||
}
|
||||
|
||||
pub fn put_f64(&mut self, n: f64) {
|
||||
self.buffer.put_f64(n)
|
||||
}
|
||||
|
||||
pub fn copy_to_bytes(&mut self, len: usize) -> bytes::Bytes {
|
||||
self.buffer.copy_to_bytes(len)
|
||||
}
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
use fastnbt::SerOpts;
|
||||
use pumpkin_protocol::client::config::RegistryEntry;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
@ -16,6 +18,8 @@ const NAMES: &[&str] = &[
|
||||
"bad_respawn_point",
|
||||
"cactus",
|
||||
"cramming",
|
||||
"campfire",
|
||||
"cramming",
|
||||
"dragon_breath",
|
||||
"drown",
|
||||
"dry_out",
|
||||
@ -58,3 +62,21 @@ const NAMES: &[&str] = &[
|
||||
"wither",
|
||||
"wither_skull",
|
||||
];
|
||||
|
||||
pub(super) fn entires() -> Vec<RegistryEntry> {
|
||||
let items: Vec<_> = NAMES
|
||||
.iter()
|
||||
.map(|name| RegistryEntry {
|
||||
entry_id: (*name).into(),
|
||||
data: fastnbt::to_bytes_with_opts(&DamageType {
|
||||
exhaustion: 0.1,
|
||||
message_id: "inFire".into(),
|
||||
scaling: "when_caused_by_living_non_player".into(),
|
||||
death_message_type: None,
|
||||
effects: None,
|
||||
}, SerOpts::network_nbt()).unwrap(),
|
||||
})
|
||||
.collect();
|
||||
|
||||
items
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
use biomes::Biome;
|
||||
use damage_type::DamageType;
|
||||
use dimensions::Dimension;
|
||||
use fastnbt::SerOpts;
|
||||
use paint::Painting;
|
||||
@ -33,7 +34,11 @@ impl Registry {
|
||||
entry_id: "minecraft:snowy_taiga".to_string(),
|
||||
data: fastnbt::to_bytes_with_opts(&Biome::default(), SerOpts::network_nbt())
|
||||
.unwrap(),
|
||||
}],
|
||||
}, RegistryEntry {
|
||||
entry_id: "minecraft:plains".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(),
|
||||
@ -43,6 +48,10 @@ impl Registry {
|
||||
.unwrap(),
|
||||
}],
|
||||
};
|
||||
let damage_types = Registry {
|
||||
registry_id: "minecraft:damage_type".to_string(),
|
||||
registry_entries: damage_type::entires(),
|
||||
};
|
||||
let paintings = Registry {
|
||||
registry_id: "minecraft:painting_variant".to_string(),
|
||||
registry_entries: vec![RegistryEntry {
|
||||
@ -51,6 +60,6 @@ impl Registry {
|
||||
.unwrap(),
|
||||
}],
|
||||
};
|
||||
vec![dimensions, biomes, wolf_variants, paintings]
|
||||
vec![dimensions, damage_types, biomes, wolf_variants, paintings]
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ use mio::{event::Event, Poll};
|
||||
use pumpkin_protocol::{
|
||||
client::{
|
||||
config::CPluginMessage,
|
||||
play::{CGameEvent, CLogin},
|
||||
play::{CGameEvent, CLogin, CSyncPlayerPostion},
|
||||
},
|
||||
PacketError, Players, Sample, StatusResponse, VarInt, VarInt32, Version,
|
||||
};
|
||||
@ -95,6 +95,7 @@ impl Server {
|
||||
|
||||
// todo: do this in a world
|
||||
pub fn spawn_player(&mut self, client: &mut Client) {
|
||||
dbg!("spawning player");
|
||||
let player = Player {
|
||||
entity: Entity {
|
||||
entity_id: self.new_entity_id(),
|
||||
@ -126,12 +127,16 @@ impl Server {
|
||||
false,
|
||||
))
|
||||
.unwrap_or_else(|e| client.kick(&e.to_string()));
|
||||
// teleport
|
||||
client
|
||||
.send_packet(CSyncPlayerPostion::new(10.0, 10.0, 10.0, 10.0, 0.0, 0, 10))
|
||||
.unwrap_or_else(|e| client.kick(&e.to_string()));
|
||||
|
||||
// Start waiting for level chunks
|
||||
client
|
||||
.send_packet(CGameEvent::new(13, 0.0))
|
||||
.unwrap_or_else(|e| client.kick(&e.to_string()));
|
||||
dbg!("spawning player");
|
||||
|
||||
client.player = Some(player);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user