-
Notifications
You must be signed in to change notification settings - Fork 234
Custom Entities Guide #267
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
base: main
Are you sure you want to change the base?
Conversation
…entation and classes
✅ Deploy Preview for nimble-elf-d9d491 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Implementation of Client-Side Code needs suggestion , Server Side Code - needs review |
Add tutorial entity code
its-miroma
left a comment
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.
the article still needs work
...rence/1.21.4/src/main/generated/assets/fabric-docs-reference/items/mini_golem_spawn_egg.json
Outdated
Show resolved
Hide resolved
Co-authored-by: Miroma <its.miroma@proton.me>
Co-authored-by: Miroma <its.miroma@proton.me>
Co-authored-by: Miroma <its.miroma@proton.me>
|
can PR #320 be merged with this PR? |
|
|
||
| @[code transcludeWith=:::model_animation](@/reference/latest/src/client/java/com/example/docs/entity/model/MiniGolemEntityModel.java) | ||
|
|
||
| Most of the math is provided by Blockbench. |
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.
Huh? On the contrary, I believe I probably took this from one of vanilla's entities. It swings the legs based on a fairly simple transformation of a sine wave.
Does Blockbench commonly generate this? In which case I would change the wording to suggest that it can be generated by Blockbench, and instead describe the maths directly rather than a hand-wavy "Blockbench will do it for you" comment.
|
|
||
| ### Using Synched Entity Data {#using-synched-entity-data} | ||
|
|
||
| We can store data on the entity itself by defining an `EntityDataAccessor` for it. This data will be synchronized with the client, making it a good place to define our dancing state. |
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.
This feels a little brief to me, although maybe I'm tripping. I think my problem with it is the way it's framed. As a mod developer of course you would do this as a subtask of making a dancing animation, but in a tutorial the important part is introducing the reader to synched entity data and explaining what it's all about. The same goes for the next section as well.
So rather than "we need a place to store our data, ah that's convenient there's this thing we can use to synchronize with the client", it should be "one way to synchronize entity data with the client is to use synched entity data. [Insert a brief introduction of synched entity data]. We will be using this for storing whether the entity is dancing, and synchronizing that information with the client. [Insert how we use synched entity data in this specific case".
Another problem with how this is worded is it implies that the primary purpose for synched entity data is to store data in an entity, when in fact it is to synchronize to the client. If anything doesn't need to be synchronized (and sometimes even if it does), you should use a field or another mechanism.
I think part of the problem is that this is included as a subsection of "adding a dancing animation", rather than a section in its own right. Even though it's part of setting up the animation, the dancing is part of the narrative of the whole tutorial, and only the actual animation itself needs to be under an animation header.
|
|
||
| We can store data on the entity itself by defining an `EntityDataAccessor` for it. This data will be synchronized with the client, making it a good place to define our dancing state. | ||
|
|
||
| @[code transcludeWith=:::datatracker](@/reference/latest/src/main/java/com/example/docs/entity/MiniGolemEntity.java) |
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 is some animation state code interleaved in here. I think that should be left to the animation section later. (The field and the override of onSyncedDataUpdated.
|
|
||
| Looking into the game, you now have all you need to spawn the entity with `/summon example-mod:mini_golem`! | ||
|
|
||
|  |
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.
The alt text here is wrong
|
|
||
| Let's make this entity a bit more lively by giving it a dancing animation. We'll create a `MiniGolemAnimations` class with a simple animation that allows the Mini Golem to dance. | ||
|
|
||
| @[code transcludeWith=:::dancing_animation](@/reference/latest/src/client/java/com/example/docs/entity/animation/MiniGolemAnimations.java) |
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 big long comment, I think this part should go in its own section at the end (just before the spawn egg).
Co-authored-by: Joseph Burton <burtonjae@hotmail.co.uk>
closes #147
https://deploy-preview-267--nimble-elf-d9d491.netlify.app/develop/entities/first-entity
TODO by Earthcomputer
/summon.TrackedDatafor dancing, and explain how to use the data tracker for synchronizing values to the client.dancingTimeLeftwhich will be saved and loaded from NBT, explain saving and loading entities from NBT.