-
-
Notifications
You must be signed in to change notification settings - Fork 127
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 AddSectionGeometryEvent
#642
Conversation
|
I still think it would be cleaner to use a |
src/main/java/net/neoforged/neoforge/client/event/AddSectionGeometryEvent.java
Show resolved
Hide resolved
It would be nice to have a test mod as well :) |
There have been some previous attempts at systems for adding custom chunk geometry previously:
However, for various reasons they've all been held up and have eventually gone stale. It would be nice to see some of those changes included here too, such as the ability to add custom buffers to the SectionBufferBuilderPack, because as it stands, it appears that calling |
Adding buffers for chunk meshing is completely out of scope for this PR. |
I disagree entirely. This API is about adding custom geometry when meshing; it is only natural that we consider the buffers where that geometry is stored. |
Even disregarding the adding buffers issue, it is incredibly poor API design for users to be able to pass custom render types to the APIs proposed here and have them throw a NPE, when it clearly looks like it should be supported based on the name of |
Alternatively, we can call it |
Adding layers is a whole new level of complexity that should not be tackled in this PR. However I would indeed encourage a way to prevent errors where a user thinks that any buffer can be used. |
These commits should address all points raised so far. Additionally they fix the event for sections that are "far away" from sections containing blocks. |
This event can be used to implement features that add static geometry to the world based on things other than blocks. See here for an example usage for Immersive Engineering wires (which is my usecase for this event).
The performance impact is one event fired on the main thread for each chunk section for which a rebuild task is started, which should be acceptable, plus whatever overhead mods add in their event handlers and custom renderers.
Some points brought up by @Technici4n in an earlier discussion:
SectionRenderingContext::getQuadLighter
can be used to obtain both AO and non-AO lighters as requiredLevel
is required. I think this is reasonable sincea) it is possible with reasonable effort to create a fake
Level
instance andb) most usecases will need access to data beyond what the "easier" interfaces of
Level
can provide (e.g. data attachments).CC @embeddedt, since we had some discussions about implementing this in Embeddium: I know you do not have all the objects needed to construct a
SectionRenderingContext
directly. However I did not want to use aFunction
here when there is no direct motivation for doing so in vanilla/NeoForge. My suggestion would be a Mixin that adds whatever fields you need to the context (set tonull
in the constructor), and chooses between a custom implementation ofgetOrCreateBuffer
and the default one based on which fields are set.