-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Prismarine: Fixup Entity class #1341
base: master
Are you sure you want to change the base?
Conversation
It probably solves it #1331. |
Bundle ReportChanges will increase total bundle size by 281.64kB ⬆️
|
@@ -59,7 +57,7 @@ export class Vector2 { | |||
* await entity.setZ(10); | |||
* ``` | |||
*/ | |||
public setZ(z = 0): void { | |||
public setZ(z: number): void { |
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.
defaults here may lead to undefined behaviors.
@@ -191,6 +192,9 @@ export class Metadata extends MetadataWriter { | |||
* @TODO: Add missing functions. | |||
*/ | |||
protected setDefaults(): void { |
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.
As explained in the comments, this whole implementation is wrong.
import type ContainerEntry from '../../inventory/ContainerEntry'; | ||
import { AddItemActorPacket } from '../../network/Packets'; | ||
import { Position } from '../../world/Position'; | ||
import type { World } from '../../world/World'; | ||
import { Entity } from '../Entity'; | ||
|
||
export class Item extends Entity { |
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.
Well, an Item is an Entity, but its runtime ID isn't correlated to the Entity one, we will see about this one.
uuid is used by the level manager, well partially at least (but that's mostly due to not being completed). Similar to how JE does it. |
Well, for the umpteenth time the usual mistake was happening: a lot of logic and not very functional, many useless methods, some even without an actual purpose and also disconnected from the logic of the game. By analyzing the Entity class I was able to find a
uuid
, which only players have, resulting in useless logic and not even set up by the game. The Position class must be deterministic, an entity MUST be in a world and in a position, it makes no sense to make the parameters optional, and it only creates damage and UB. A console that acts as a player is something that adds complexity in the code for nothing, sure, they have things in common (a name and that we both send messages), but they are two different concepts... it makes more sense to use a interface. Furthermore, the Entity class must NOT contain netcode in any way, in fact it has been removed. Surely many things will need to be reviewed now, but we will gain stability later on.