-
-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Item Entities and make them interactable #103
base: master
Are you sure you want to change the base?
Conversation
4f4c723
to
cd61b4c
Compare
To clarify, collisions kinda work. They work fully with the ground, but they cancel out velocity, and don't act exactly as they should. Dropped Items also do not merge into one yet. |
Hey @Bryntet any updates on this? |
Currently stuck on getting collisions to work exactly like vanilla. Chunks saving to ram changes is also blocking the Block-breaking drops items. Edit: I'd love any help I can get with doing collisions, as I've never really worked with collisions before, and the decompiled Mojang code is a big mess :( |
935359f
to
b7b7da3
Compare
Block dropping now partially works. I'd be happy to receive an initial review now, as well as maybe discussing whether this should be polished more, or merged so that we can branch of and work on the more fine implementation details on this separately. |
pub struct CSetEntityMetadata<T: Serialize> { | ||
pub entity_id: VarInt, | ||
pub metadata: Metadata<T>, | ||
pub end: u8, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that you like to make the fields public, But its more of an "interal convention" in pumpkin to use the new function
pumpkin/src/entity/item.rs
Outdated
|
||
let entity = Arc::new(Entity { | ||
entity_id: server.new_entity_id(), | ||
uuid: Uuid::new_v4(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a check if the UUID is not matching any existing player UUID on the server, I also wonder what to do if a new player join which has the same UUID as an entity
fn toss_velocity(player: &Entity) -> Vector3<f64> { | ||
use std::f64::consts::PI; | ||
let pitch_sin = f64::sin(f64::from(player.pitch.load()) * (PI / 180.0)); | ||
let pitch_cos = f64::cos(f64::from(player.pitch.load()) * (PI / 180.0)); | ||
let yaw_sin = f64::sin(f64::from(player.yaw.load()) * (PI / 180.0)); | ||
let yaw_cos = f64::cos(f64::from(player.yaw.load()) * (PI / 180.0)); | ||
let random_angle = random_float() * (2.0 * PI); | ||
let random_offset = 0.02 * random_float(); | ||
|
||
Vector3 { | ||
x: (-yaw_sin * pitch_cos).mul_add(0.3, f64::cos(random_angle) * random_offset), | ||
y: (-pitch_sin).mul_add(0.3, (random_float() - random_float()).mul_add(0.1, 0.1)), | ||
z: (yaw_cos * pitch_cos).mul_add(0.3, f64::sin(random_angle) * random_offset), | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this from vanilla ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes these are the same mathematical functions as those run by vanilla when an item is dropped by a player
@@ -47,6 +55,9 @@ pub struct Entity { | |||
/// Indicates whether the entity is on the ground (may not always be accurate). | |||
pub on_ground: AtomicBool, | |||
|
|||
/// Indicates whether the entity is inside of ground, and needs to be pushed out. | |||
pub in_ground: AtomicBool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this generally checks if a Entity is in blocks not only ground, right?, Then a better name would be maybe inside_block
pumpkin/src/entity/to_packet.rs
Outdated
pub fn spawn_entity_with_data(entity: &Entity, data: Option<i32>) -> CSpawnEntity { | ||
let pos = entity.pos.load(); | ||
let velocity = entity.velocity.load(); | ||
CSpawnEntity::new( | ||
entity.entity_id.into(), | ||
entity.uuid, | ||
(entity.entity_type as i32).into(), | ||
pos.x, | ||
pos.y, | ||
pos.z, | ||
entity.pitch.load(), | ||
entity.yaw.load(), | ||
entity.head_yaw.load(), | ||
data.unwrap_or(0).into(), | ||
velocity.x, | ||
velocity.y, | ||
velocity.z, | ||
) | ||
} | ||
|
||
impl From<&Entity> for CSpawnEntity { | ||
fn from(entity: &Entity) -> Self { | ||
spawn_entity_with_data(entity, None) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't like this, First you have a whole new file for only wrapping around some values, Also i don't think its that hard to write this every time, If you think this is really necessary i would much more prefer this in the entity file
0313adb
to
0e43d63
Compare
# Conflicts: # pumpkin-core/src/math/boundingbox.rs # pumpkin-inventory/src/player.rs # pumpkin-protocol/src/client/play/c_entity_metadata.rs # pumpkin-protocol/src/client/play/c_entity_velocity.rs # pumpkin-protocol/src/client/play/mod.rs # pumpkin-world/src/block/block_registry.rs # pumpkin-world/src/item/item_registry.rs # pumpkin-world/src/item/mod.rs # pumpkin/src/client/container.rs # pumpkin/src/client/player_packet.rs # pumpkin/src/entity/mod.rs # pumpkin/src/entity/player.rs # pumpkin/src/world/mod.rs
0e43d63
to
d9096ce
Compare
# Conflicts: # pumpkin-world/src/item/item_registry.rs # pumpkin/src/client/player_packet.rs # pumpkin/src/world/mod.rs
This PR aims to add the following: