-
Notifications
You must be signed in to change notification settings - Fork 535
Add Sky Rendering Events #5328
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
Open
lowercasebtw
wants to merge
20
commits into
FabricMC:26.1.2
Choose a base branch
from
lowercasebtw:26.1.2
base: 26.1.2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add Sky Rendering Events #5328
Changes from 10 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b797d63
W.I.P: Add sky rendering events for each part of the sky
lowercasebtw b87ed55
Refactor events
lowercasebtw 7af7c63
Fix event ancestry
lowercasebtw 429df8a
Add pre/post events
lowercasebtw f02f2b4
Remove AbstractSkyInjectionContext
lowercasebtw d060467
Add SkyRenderContextImpl
lowercasebtw be794fd
Add Pre/Post Custom Element events
lowercasebtw cf6ac67
Add identifier key field to custom element events to allow determinin…
lowercasebtw 11209ec
Add mixins & Refactor classes
lowercasebtw 70ee75b
Move shadow field
lowercasebtw 3c8e2ad
Fix javadoc mistake
lowercasebtw 8605aae
Merge branch '26.1.2' into 26.1.2
lowercasebtw b2136dc
Add pre/post sky render events
lowercasebtw 7c95451
Merge branch '26.1.2' into 26.1.2
lowercasebtw bbd8849
Merge branch '26.1.2' into 26.1.2
lowercasebtw ed7d537
Add cameraRenderState & END_EXTRACTION event
lowercasebtw 79f2a88
Only invoke POST events if the PRE was not cancelled
lowercasebtw 50306fe
Apply requested changes
lowercasebtw 909da98
Refactors
lowercasebtw 5796f86
Pass down cancelled status
lowercasebtw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
...nt/java/net/fabricmc/fabric/api/client/rendering/v1/level/sky/CelestialRenderContext.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /* | ||
| * Copyright (c) 2016, 2017, 2018, 2019 FabricMC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package net.fabricmc.fabric.api.client.rendering.v1.level.sky; | ||
|
|
||
| import org.jetbrains.annotations.ApiStatus; | ||
|
|
||
| @ApiStatus.NonExtendable | ||
| public interface CelestialRenderContext extends SkyRenderContext { | ||
| Type type(); | ||
|
|
||
| enum Type { | ||
| SUN, | ||
| MOON, | ||
| STARS | ||
| } | ||
| } | ||
29 changes: 29 additions & 0 deletions
29
...c/client/java/net/fabricmc/fabric/api/client/rendering/v1/level/sky/SkyRenderContext.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /* | ||
| * Copyright (c) 2016, 2017, 2018, 2019 FabricMC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package net.fabricmc.fabric.api.client.rendering.v1.level.sky; | ||
|
|
||
| import org.jetbrains.annotations.ApiStatus; | ||
|
|
||
| import net.minecraft.client.renderer.SkyRenderer; | ||
| import net.minecraft.client.renderer.state.level.SkyRenderState; | ||
|
|
||
| @ApiStatus.NonExtendable | ||
| public interface SkyRenderContext { | ||
| SkyRenderer skyRenderer(); | ||
|
|
||
| SkyRenderState skyRenderState(); | ||
| } |
236 changes: 236 additions & 0 deletions
236
...rc/client/java/net/fabricmc/fabric/api/client/rendering/v1/level/sky/SkyRenderEvents.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,236 @@ | ||
| /* | ||
| * Copyright (c) 2016, 2017, 2018, 2019 FabricMC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package net.fabricmc.fabric.api.client.rendering.v1.level.sky; | ||
|
|
||
| import net.minecraft.resources.Identifier; | ||
|
|
||
| import net.fabricmc.fabric.api.event.Event; | ||
| import net.fabricmc.fabric.api.event.EventFactory; | ||
|
|
||
| /** | ||
| * To be used when adding custom skies or to modify existing aspects of the skys rendering. | ||
| */ | ||
| public final class SkyRenderEvents { | ||
| private SkyRenderEvents() { | ||
| } | ||
|
|
||
| /** | ||
| * Called before "renderEndSky" is invoked, determines if the end sky should render or not. | ||
| */ | ||
| public static final Event<PreEndSky> PRE_END_SKY = EventFactory.createArrayBacked(PreEndSky.class, callbacks -> context -> { | ||
| for (final PreEndSky callback : callbacks) { | ||
| if (callback.execute(context)) { | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| return false; | ||
| }); | ||
|
|
||
| /** | ||
| * Called after "renderEndSky" is invoked. | ||
| */ | ||
| public static final Event<PostEndSky> POST_END_SKY = EventFactory.createArrayBacked(PostEndSky.class, callbacks -> context -> { | ||
| for (final PostEndSky callback : callbacks) { | ||
| callback.execute(context); | ||
| } | ||
| }); | ||
|
|
||
| /** | ||
| * Called before "renderEndSky" is invoked, determines if the end sky should render or not. | ||
|
lowercasebtw marked this conversation as resolved.
|
||
| */ | ||
| public static final Event<PreEndFlash> PRE_END_FLASH = EventFactory.createArrayBacked(PreEndFlash.class, callbacks -> context -> { | ||
| for (final PreEndFlash callback : callbacks) { | ||
| if (callback.execute(context)) { | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| return false; | ||
| }); | ||
|
|
||
| /** | ||
| * Called after "renderEndSky" is invoked. | ||
|
lowercasebtw marked this conversation as resolved.
|
||
| */ | ||
| public static final Event<PostEndFlash> POST_END_FLASH = EventFactory.createArrayBacked(PostEndFlash.class, callbacks -> context -> { | ||
| for (final PostEndFlash callback : callbacks) { | ||
| callback.execute(context); | ||
| } | ||
| }); | ||
|
|
||
| /** | ||
| * Called before the top/bottom sky disc is rendered, determines if it should render or not. | ||
| */ | ||
| public static final Event<PreSkyDisc> PRE_SKY_DISC = EventFactory.createArrayBacked(PreSkyDisc.class, callbacks -> context -> { | ||
| for (final PreSkyDisc callback : callbacks) { | ||
| if (callback.execute(context)) { | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| return false; | ||
| }); | ||
|
|
||
| /** | ||
| * Called after the top/bottom sky disc is rendered. | ||
| */ | ||
| public static final Event<PostSkyDisc> POST_SKY_DISC = EventFactory.createArrayBacked(PostSkyDisc.class, callbacks -> context -> { | ||
| for (final PostSkyDisc callback : callbacks) { | ||
| callback.execute(context); | ||
| } | ||
| }); | ||
|
|
||
| /** | ||
| * Called when sunrise/sunset in the Overworld is rendered. | ||
| */ | ||
| public static final Event<PreSunriseSunset> PRE_SUNRISE_SUNSET = EventFactory.createArrayBacked(PreSunriseSunset.class, callbacks -> context -> { | ||
| for (final PreSunriseSunset callback : callbacks) { | ||
| if (callback.execute(context)) { | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| return false; | ||
| }); | ||
|
|
||
| /** | ||
| * Called when sunrise/sunset in the Overworld is rendered. | ||
| */ | ||
| public static final Event<PostSunriseSunset> POST_SUNRISE_SUNSET = EventFactory.createArrayBacked(PostSunriseSunset.class, callbacks -> context -> { | ||
| for (final PostSunriseSunset callback : callbacks) { | ||
| callback.execute(context); | ||
| } | ||
| }); | ||
|
|
||
| /** | ||
| * Called after the rendering of the sun/moon/stars. | ||
| */ | ||
| public static final Event<PostSunMoonStars> POST_SUN_MOON_STARS = EventFactory.createArrayBacked(PostSunMoonStars.class, callbacks -> context -> { | ||
| for (final PostSunMoonStars callback : callbacks) { | ||
| callback.execute(context); | ||
| } | ||
| }); | ||
|
|
||
| /** | ||
| * Called before the sun, moon, or stars are rendered. | ||
| */ | ||
| public static final Event<PreCelestial> PRE_CELESTIAL = EventFactory.createArrayBacked(PreCelestial.class, callbacks -> context -> { | ||
| for (final PreCelestial callback : callbacks) { | ||
| if (callback.execute(context)) { | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| return false; | ||
| }); | ||
|
|
||
| /** | ||
| * Called after the sun, moon, or stars are rendered. | ||
| */ | ||
| public static final Event<PostCelestial> POST_CELESTIAL = EventFactory.createArrayBacked(PostCelestial.class, callbacks -> context -> { | ||
| for (final PostCelestial callback : callbacks) { | ||
| callback.execute(context); | ||
| } | ||
| }); | ||
|
|
||
| /** | ||
| * Unused by FAPI, intended for mod developers to invoke when adding custom elements to the sky when rendering allowing other mods to intercept them and do as please. | ||
| */ | ||
| public static final Event<PreCustomElement> PRE_CUSTOM_ELEMENT = EventFactory.createArrayBacked(PreCustomElement.class, callbacks -> (key, context) -> { | ||
| for (final PreCustomElement callback : callbacks) { | ||
| if (callback.execute(key, context)) { | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| return false; | ||
| }); | ||
|
|
||
| /** | ||
| * Unused by FAPI, intended for mod developers to invoke when adding custom elements to the sky when rendering allowing other mods to intercept them and do as please. | ||
| */ | ||
| public static final Event<PostCustomElement> POST_CUSTOM_ELEMENT = EventFactory.createArrayBacked(PostCustomElement.class, callbacks -> (key, context) -> { | ||
| for (final PostCustomElement callback : callbacks) { | ||
| callback.execute(key, context); | ||
| } | ||
| }); | ||
|
|
||
| @FunctionalInterface | ||
| public interface PreEndSky { | ||
| boolean execute(SkyRenderContext context); | ||
| } | ||
|
|
||
| @FunctionalInterface | ||
| public interface PostEndSky { | ||
| void execute(SkyRenderContext context); | ||
| } | ||
|
|
||
| @FunctionalInterface | ||
| public interface PreEndFlash { | ||
| boolean execute(SkyRenderContext context); | ||
| } | ||
|
|
||
| @FunctionalInterface | ||
| public interface PostEndFlash { | ||
| void execute(SkyRenderContext context); | ||
| } | ||
|
|
||
| @FunctionalInterface | ||
| public interface PreSkyDisc { | ||
| boolean execute(SkyRenderContext context); | ||
| } | ||
|
|
||
| @FunctionalInterface | ||
| public interface PostSkyDisc { | ||
| void execute(SkyRenderContext context); | ||
| } | ||
|
|
||
| @FunctionalInterface | ||
| public interface PreSunriseSunset { | ||
| boolean execute(SkyRenderContext context); | ||
| } | ||
|
|
||
| @FunctionalInterface | ||
| public interface PostSunriseSunset { | ||
| void execute(SkyRenderContext context); | ||
| } | ||
|
|
||
| @FunctionalInterface | ||
| public interface PostSunMoonStars { | ||
| void execute(SkyRenderContext context); | ||
| } | ||
|
|
||
| @FunctionalInterface | ||
| public interface PreCelestial { | ||
| boolean execute(CelestialRenderContext context); | ||
| } | ||
|
|
||
| @FunctionalInterface | ||
| public interface PostCelestial { | ||
| void execute(CelestialRenderContext context); | ||
| } | ||
|
|
||
| @FunctionalInterface | ||
| public interface PreCustomElement { | ||
| boolean execute(Identifier key, Object context); | ||
| } | ||
|
|
||
| @FunctionalInterface | ||
| public interface PostCustomElement { | ||
| void execute(Identifier key, Object context); | ||
| } | ||
| } | ||
56 changes: 56 additions & 0 deletions
56
...client/java/net/fabricmc/fabric/impl/client/rendering/level/sky/SkyRenderContextImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| /* | ||
| * Copyright (c) 2016, 2017, 2018, 2019 FabricMC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package net.fabricmc.fabric.impl.client.rendering.level.sky; | ||
|
|
||
| import net.minecraft.client.renderer.SkyRenderer; | ||
| import net.minecraft.client.renderer.state.level.SkyRenderState; | ||
|
|
||
| import net.fabricmc.fabric.api.client.rendering.v1.level.sky.CelestialRenderContext; | ||
| import net.fabricmc.fabric.api.client.rendering.v1.level.sky.SkyRenderContext; | ||
|
|
||
| public class SkyRenderContextImpl implements SkyRenderContext { | ||
| private SkyRenderer skyRenderer; | ||
| private SkyRenderState skyRenderState; | ||
|
|
||
| public void prepare(final SkyRenderer skyRenderer, final SkyRenderState skyRenderState) { | ||
| this.skyRenderer = skyRenderer; | ||
| this.skyRenderState = skyRenderState; | ||
| } | ||
|
|
||
| @Override | ||
| public SkyRenderer skyRenderer() { | ||
| return this.skyRenderer; | ||
| } | ||
|
|
||
| @Override | ||
| public SkyRenderState skyRenderState() { | ||
| return this.skyRenderState; | ||
| } | ||
|
|
||
| public static class CelestialContextImpl extends SkyRenderContextImpl implements CelestialRenderContext { | ||
| private Type type; | ||
|
|
||
| public void setType(final Type type) { | ||
| this.type = type; | ||
| } | ||
|
|
||
| @Override | ||
| public Type type() { | ||
| return this.type; | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Needs docs.
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.
Will do sometime soon