-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
Entity docs #171
base: main
Are you sure you want to change the base?
Entity docs #171
Conversation
Co-authored-by: Dennis C <[email protected]>
Co-authored-by: Dennis C <[email protected]>
Co-authored-by: ChampionAsh5357 <[email protected]>
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.
First pass over the changes, still have to do the 4 largest files.
EntityRenderer-->ArrowRenderer; | ||
EntityRenderer-->LivingEntityRenderer; |
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.
EntityRenderer-->ArrowRenderer; | |
EntityRenderer-->LivingEntityRenderer; | |
EntityRenderer-->LivingEntityRenderer; | |
EntityRenderer-->ArrowRenderer; |
These should be switched around to avoid the arrow from LivingEntityRenderer
to ArmorStandRenderer
going through the ArrowRenderer
node
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.
Changing this makes the arrow go through the AbstractMinecartRenderer
instead. I'm afraid there is no easy way of solving this.
} | ||
``` | ||
|
||
That's literally it. Extend the class, add your field, and off you go. The only thing left to do now is to update that `stackInHand` field in `EntityRenderer#extractRenderState`, as explained above. |
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 section should include an overview over the render state modification system introduced in neoforged/NeoForge#1650.
if (renderer != null) { | ||
// Add the layer to the renderer. Reuses the ModelLayerLocation from above. | ||
renderer.addLayer(MY_LAYER); | ||
} |
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 is wrong in two ways:
- This event has nothing to do with
LayerDefinition
s, it's related toRenderLayer
s. ARenderLayer
however can indeed render anEntityModel
created from aLayerDefinition
after the latter is baked - Only renderers which implement
RenderLayerParent
can haveRenderLayer
s added to them. In vanilla this only applies toLivingEntityRenderer
and its subclasses
RenderLayer
s should be dealt with in a separate section. This section should instead explain how to go from a LayerDefinition
to the custom EntityModel
in the renderer's constructor.
// Get the associated PlayerRenderer. | ||
if (event.getSkin(skin) instanceof PlayerRenderer playerRenderer) { | ||
// Add the layer to the renderer. | ||
playerRenderer.addLayer(MY_LAYER); |
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.
Same issue as above
docs/entities/index.md
Outdated
// Build the entity type. The parameter is a string used for datafixing; mods generally | ||
// do not utilize this and can safely pass null here instead. | ||
.build(null) |
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 accurate? I copied around this code and it complains about
java.lang.NullPointerException: Cannot invoke "String.indexOf(int)" because "location" is null
Going through neo discord, Commoble says that this string cannot be null. https://discord.com/channels/313125603924639766/983834532904042537/1109539085560856656
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 needs to be set as it now attempts to resolve the location of the resource key. A patch needs to be added back in to safely supply null
``` | ||
|
||
:::danger | ||
While the compiler will allow you to use a class other than the owning class as the first parameter in `SynchedEntityData#defineId()`, this can and will lead to hard-to-debug issues and as such should be avoided. |
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 personally prefer the wording used in the old entity networking page. This is not a case of "avoid if possible", it's a case of "seriously, don't do it, it WILL break".
I would also add a note that this includes adding data accessors via mixin to the technically correct class.
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.
Here's the requested feedback. Still a few WIP sections, so I'm wondering why it was brought out of draft early.
@@ -120,6 +120,7 @@ graph TD; | |||
PlayerEvent-->CanPlayerSleepEvent; | |||
|
|||
class Event,BlockEvent,EntityEvent,LivingEvent,PlayerEvent red; | |||
class BlockDropsEvent,CanPlayerSleepEvent blue; |
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 there a reason for this in an entity docs PR?
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.
Mainly because this is the first PR that really makes use of Mermaid diagrams. I adopted the style guide of red -> abstract, blue -> non-abstract, and applied it to the only other diagram we had while I was at it.
Natural spawning is performed every tick for entities where `MobCategory#isFriendly()` is true, and every 400 ticks (\= 20 seconds) for entities where `MobCategory#isFriendly()` is false. If `MobCategory#isPersistent()` returns true, this process additionally also happens on chunk generation. | ||
|
||
For each chunk and mob category, it is checked whether there are less than `MobCategory#getMaxInstancesPerChunk() * loadedChunks / 289` in the world. Additionally, for each chunk, it is required that there are less than `MobCategory#getMaxInstancesPerChunk()` entities of that `MobCategory` near at least one player (near means that the distance between mob and player \<\= 128) for spawning of that `MobCategory` to occur. |
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.
It might be best to frame this with an example to get the actual numbers for each.
:::info | ||
This section is a work in progress. | ||
::: | ||
|
||
### Brains | ||
|
||
:::info | ||
This section is a work in progress. | ||
::: | ||
|
||
### Navigation | ||
|
||
:::info | ||
This section is a work in progress. | ||
::: |
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.
Work in progress?
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, and these sections will not be covered by the PR due to out-of-scope (and also because I do not have the energy to read into these systems at present).
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 would just remove the sections for now and stick them in an issue if they're not already.
} | ||
``` | ||
|
||
### Adding a Layer Definition to an 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.
As Xfact mentions, layer definitions are not 'added' to an entity. Instead, the registered ModelLayerLocation
is provided to the EntityModelSet
to construct the ModelPart
used to render the entity model. The below methods are for entity layers such as armor.
@IchHabeHunger54, this pull request has conflicts, please resolve them for this PR to move forward. |
# Conflicts: # docs/resources/client/models/bakedmodel.md # docs/resources/server/conditions.md
Adds some long-needed entity documentation. Supersedes #15 and #95 . Closes #90 . This PR:
Preview URL: https://pr-171.neoforged-docs-previews.pages.dev