diff --git a/fabric-rendering-v0/build.gradle b/fabric-rendering-v0/build.gradle index 650e04989..43eeaa5d8 100644 --- a/fabric-rendering-v0/build.gradle +++ b/fabric-rendering-v0/build.gradle @@ -1,6 +1,7 @@ archivesBaseName = "fabric-rendering-v0" -version = getSubprojectVersion(project, "1.0.1") +version = getSubprojectVersion(project, "1.1.0") dependencies { compile project(path: ':fabric-api-base', configuration: 'dev') + compile project(path: ':fabric-rendering-v1', configuration: 'dev') } diff --git a/fabric-rendering-v0/src/main/java/net/fabricmc/fabric/api/client/render/ColorProviderRegistry.java b/fabric-rendering-v0/src/main/java/net/fabricmc/fabric/api/client/render/ColorProviderRegistry.java index 27e0cbc7e..5326ca6b9 100644 --- a/fabric-rendering-v0/src/main/java/net/fabricmc/fabric/api/client/render/ColorProviderRegistry.java +++ b/fabric-rendering-v0/src/main/java/net/fabricmc/fabric/api/client/render/ColorProviderRegistry.java @@ -21,12 +21,34 @@ import net.minecraft.client.color.block.BlockColorProvider; import net.minecraft.client.color.item.ItemColorProvider; import net.minecraft.item.ItemConvertible; -import net.fabricmc.fabric.impl.client.rendering.ColorProviderRegistryImpl; - +/** + * @deprecated Replaced by {@link net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry} + */ +@Deprecated public interface ColorProviderRegistry { - ColorProviderRegistry ITEM = ColorProviderRegistryImpl.ITEM; + ColorProviderRegistry ITEM = new ColorProviderRegistry() { + @Override + public void register(ItemColorProvider itemColorProvider, ItemConvertible... objects) { + net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry.ITEM.register(itemColorProvider, objects); + } - ColorProviderRegistry BLOCK = ColorProviderRegistryImpl.BLOCK; + @Override + public ItemColorProvider get(ItemConvertible object) { + return net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry.ITEM.get(object); + } + }; + + ColorProviderRegistry BLOCK = new ColorProviderRegistry() { + @Override + public void register(BlockColorProvider blockColorProvider, Block... objects) { + net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry.BLOCK.register(blockColorProvider, objects); + } + + @Override + public BlockColorProvider get(Block object) { + return net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry.BLOCK.get(object); + } + }; /** * Register a color provider for one or more objects. diff --git a/fabric-rendering-v0/src/main/java/net/fabricmc/fabric/api/client/render/InvalidateRenderStateCallback.java b/fabric-rendering-v0/src/main/java/net/fabricmc/fabric/api/client/render/InvalidateRenderStateCallback.java index 24557baa6..7670f44ef 100644 --- a/fabric-rendering-v0/src/main/java/net/fabricmc/fabric/api/client/render/InvalidateRenderStateCallback.java +++ b/fabric-rendering-v0/src/main/java/net/fabricmc/fabric/api/client/render/InvalidateRenderStateCallback.java @@ -27,7 +27,10 @@ import net.fabricmc.fabric.api.event.EventFactory; *

Render chunks and other render-related object instances will be made null * or invalid after this event so do not use it to capture dependent state. * Instead, use it to invalidate state and reinitialize lazily. + * + * @deprecated Replaced by {@link net.fabricmc.fabric.api.client.rendering.v1.InvalidateRenderStateCallback} */ +@Deprecated public interface InvalidateRenderStateCallback { Event EVENT = EventFactory.createArrayBacked(InvalidateRenderStateCallback.class, (listeners) -> () -> { diff --git a/fabric-rendering-v0/src/main/java/net/fabricmc/fabric/impl/client/rendering/RenderingCallbackInvoker.java b/fabric-rendering-v0/src/main/java/net/fabricmc/fabric/impl/client/rendering/RenderingCallbackInvoker.java new file mode 100644 index 000000000..3c3c874e0 --- /dev/null +++ b/fabric-rendering-v0/src/main/java/net/fabricmc/fabric/impl/client/rendering/RenderingCallbackInvoker.java @@ -0,0 +1,27 @@ +/* + * 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; + +import net.fabricmc.api.ClientModInitializer; +import net.fabricmc.fabric.api.client.rendering.v1.InvalidateRenderStateCallback; + +public class RenderingCallbackInvoker implements ClientModInitializer { + @Override + public void onInitializeClient() { + InvalidateRenderStateCallback.EVENT.register(() -> net.fabricmc.fabric.api.client.render.InvalidateRenderStateCallback.EVENT.invoker().onInvalidate()); + } +} diff --git a/fabric-rendering-v0/src/main/resources/fabric.mod.json b/fabric-rendering-v0/src/main/resources/fabric.mod.json index bf1d475f0..0290e6039 100644 --- a/fabric-rendering-v0/src/main/resources/fabric.mod.json +++ b/fabric-rendering-v0/src/main/resources/fabric.mod.json @@ -15,13 +15,16 @@ "authors": [ "FabricMC" ], + "entrypoints": { + "client": [ + "net.fabricmc.fabric.impl.client.rendering.RenderingCallbackInvoker" + ] + }, "depends": { "fabricloader": ">=0.4.0", "minecraft": ">=1.15-alpha.19.39.a", - "fabric-api-base": "*" + "fabric-api-base": "*", + "fabric-rendering-v1": "*" }, - "description": "Hooks and registries for rendering-related things.", - "mixins": [ - "fabric-rendering-v0.mixins.json" - ] + "description": "Hooks and registries for rendering-related things." } diff --git a/fabric-rendering-v1/build.gradle b/fabric-rendering-v1/build.gradle new file mode 100644 index 000000000..40d9ca72c --- /dev/null +++ b/fabric-rendering-v1/build.gradle @@ -0,0 +1,6 @@ +archivesBaseName = "fabric-rendering-v1" +version = getSubprojectVersion(project, "0.1.0") + +dependencies { + compile project(path: ':fabric-api-base', configuration: 'dev') +} diff --git a/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/ColorProviderRegistry.java b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/ColorProviderRegistry.java new file mode 100644 index 000000000..44619153a --- /dev/null +++ b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/ColorProviderRegistry.java @@ -0,0 +1,49 @@ +/* + * 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; + +import net.minecraft.block.Block; +import net.minecraft.client.color.block.BlockColorProvider; +import net.minecraft.client.color.item.ItemColorProvider; +import net.minecraft.item.ItemConvertible; + +import net.fabricmc.fabric.impl.client.rendering.ColorProviderRegistryImpl; + +public interface ColorProviderRegistry { + ColorProviderRegistry ITEM = ColorProviderRegistryImpl.ITEM; + + ColorProviderRegistry BLOCK = ColorProviderRegistryImpl.BLOCK; + + /** + * Register a color provider for one or more objects. + * + * @param provider The color provider to register. + * @param objects The objects which should be colored using this provider. + */ + void register(Provider provider, T... objects); + + /** + * Get a color provider for the given object. + * + *

Please note that the underlying registry may not be fully populated or stable until the game has started, + * as other mods may overwrite the registry. + * + * @param object The object to acquire the provide for. + * @return The registered mapper for this provider, or {@code null} if none is registered or available. + */ + Provider get(T object); +} diff --git a/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/HudRenderCallback.java b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/HudRenderCallback.java new file mode 100644 index 000000000..1a5f7ab64 --- /dev/null +++ b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/HudRenderCallback.java @@ -0,0 +1,36 @@ +/* + * 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; + +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.event.EventFactory; + +public interface HudRenderCallback { + Event EVENT = EventFactory.createArrayBacked(HudRenderCallback.class, (listeners) -> + (delta) -> { + for (HudRenderCallback event : listeners) { + event.onHudRender(delta); + } + }); + + /** + * Called after rendering the whole hud, which is displayed in game, in a world. + * + * @param tickDelta Progress for linearly interpolating between the previous and current game state + */ + void onHudRender(float tickDelta); +} diff --git a/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/InvalidateRenderStateCallback.java b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/InvalidateRenderStateCallback.java new file mode 100644 index 000000000..b72da7c9a --- /dev/null +++ b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/InvalidateRenderStateCallback.java @@ -0,0 +1,41 @@ +/* + * 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; + +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.event.EventFactory; + +/** + * Called when the world renderer reloads, usually as result of changing resource pack + * or video configuration, or when the player types F3+A in the debug screen. + * Afterwards all render chunks will be reset and reloaded. + * + *

Render chunks and other render-related object instances will be made null + * or invalid after this event so do not use it to capture dependent state. + * Instead, use it to invalidate state and reinitialize lazily. + */ +public interface InvalidateRenderStateCallback { + Event EVENT = EventFactory.createArrayBacked(InvalidateRenderStateCallback.class, + (listeners) -> () -> { + for (InvalidateRenderStateCallback event : listeners) { + event.onInvalidate(); + } + } + ); + + void onInvalidate(); +} diff --git a/fabric-rendering-v0/src/main/java/net/fabricmc/fabric/impl/client/rendering/ColorProviderRegistryImpl.java b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/impl/client/rendering/ColorProviderRegistryImpl.java similarity index 97% rename from fabric-rendering-v0/src/main/java/net/fabricmc/fabric/impl/client/rendering/ColorProviderRegistryImpl.java rename to fabric-rendering-v1/src/main/java/net/fabricmc/fabric/impl/client/rendering/ColorProviderRegistryImpl.java index 93590cf0a..d6435d7f4 100644 --- a/fabric-rendering-v0/src/main/java/net/fabricmc/fabric/impl/client/rendering/ColorProviderRegistryImpl.java +++ b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/impl/client/rendering/ColorProviderRegistryImpl.java @@ -26,7 +26,7 @@ import net.minecraft.client.color.item.ItemColorProvider; import net.minecraft.client.color.item.ItemColors; import net.minecraft.item.ItemConvertible; -import net.fabricmc.fabric.api.client.render.ColorProviderRegistry; +import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; public abstract class ColorProviderRegistryImpl implements ColorProviderRegistry { public static final ColorProviderRegistryImpl BLOCK = new ColorProviderRegistryImpl() { diff --git a/fabric-rendering-v0/src/main/java/net/fabricmc/fabric/mixin/client/rendering/MixinBlockColorMap.java b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/mixin/client/rendering/MixinBlockColorMap.java similarity index 100% rename from fabric-rendering-v0/src/main/java/net/fabricmc/fabric/mixin/client/rendering/MixinBlockColorMap.java rename to fabric-rendering-v1/src/main/java/net/fabricmc/fabric/mixin/client/rendering/MixinBlockColorMap.java diff --git a/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/mixin/client/rendering/MixinInGameHud.java b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/mixin/client/rendering/MixinInGameHud.java new file mode 100644 index 000000000..b84b83392 --- /dev/null +++ b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/mixin/client/rendering/MixinInGameHud.java @@ -0,0 +1,34 @@ +/* + * 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.mixin.client.rendering; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import net.minecraft.client.gui.hud.InGameHud; + +import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; + +@Mixin(InGameHud.class) +public class MixinInGameHud { + @Inject(method = "render", at = @At(value = "RETURN", shift = At.Shift.BY, by = -6)) + public void render(float tickDelta, CallbackInfo callbackInfo) { + HudRenderCallback.EVENT.invoker().onHudRender(tickDelta); + } +} diff --git a/fabric-rendering-v0/src/main/java/net/fabricmc/fabric/mixin/client/rendering/MixinItemColorMap.java b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/mixin/client/rendering/MixinItemColorMap.java similarity index 100% rename from fabric-rendering-v0/src/main/java/net/fabricmc/fabric/mixin/client/rendering/MixinItemColorMap.java rename to fabric-rendering-v1/src/main/java/net/fabricmc/fabric/mixin/client/rendering/MixinItemColorMap.java diff --git a/fabric-rendering-v0/src/main/java/net/fabricmc/fabric/mixin/client/rendering/MixinWorldRenderer.java b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/mixin/client/rendering/MixinWorldRenderer.java similarity index 93% rename from fabric-rendering-v0/src/main/java/net/fabricmc/fabric/mixin/client/rendering/MixinWorldRenderer.java rename to fabric-rendering-v1/src/main/java/net/fabricmc/fabric/mixin/client/rendering/MixinWorldRenderer.java index 6796157ad..07ee7d968 100644 --- a/fabric-rendering-v0/src/main/java/net/fabricmc/fabric/mixin/client/rendering/MixinWorldRenderer.java +++ b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/mixin/client/rendering/MixinWorldRenderer.java @@ -23,7 +23,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import net.minecraft.client.render.WorldRenderer; -import net.fabricmc.fabric.api.client.render.InvalidateRenderStateCallback; +import net.fabricmc.fabric.api.client.rendering.v1.InvalidateRenderStateCallback; @Mixin(WorldRenderer.class) public abstract class MixinWorldRenderer { diff --git a/fabric-rendering-v1/src/main/resources/assets/fabric-rendering-v1/icon.png b/fabric-rendering-v1/src/main/resources/assets/fabric-rendering-v1/icon.png new file mode 100644 index 000000000..2931efbf6 Binary files /dev/null and b/fabric-rendering-v1/src/main/resources/assets/fabric-rendering-v1/icon.png differ diff --git a/fabric-rendering-v0/src/main/resources/fabric-rendering-v0.mixins.json b/fabric-rendering-v1/src/main/resources/fabric-rendering-v1.mixins.json similarity index 92% rename from fabric-rendering-v0/src/main/resources/fabric-rendering-v0.mixins.json rename to fabric-rendering-v1/src/main/resources/fabric-rendering-v1.mixins.json index 44bfc5655..4c50428dc 100644 --- a/fabric-rendering-v0/src/main/resources/fabric-rendering-v0.mixins.json +++ b/fabric-rendering-v1/src/main/resources/fabric-rendering-v1.mixins.json @@ -4,6 +4,7 @@ "compatibilityLevel": "JAVA_8", "client": [ "MixinBlockColorMap", + "MixinInGameHud", "MixinItemColorMap", "MixinWorldRenderer" ], diff --git a/fabric-rendering-v1/src/main/resources/fabric.mod.json b/fabric-rendering-v1/src/main/resources/fabric.mod.json new file mode 100644 index 000000000..5b21b99b5 --- /dev/null +++ b/fabric-rendering-v1/src/main/resources/fabric.mod.json @@ -0,0 +1,26 @@ +{ + "schemaVersion": 1, + "id": "fabric-rendering-v1", + "name": "Fabric Rendering (v1)", + "version": "${version}", + "environment": "client", + "license": "Apache-2.0", + "icon": "assets/fabric-rendering-v1/icon.png", + "contact": { + "homepage": "https://fabricmc.net", + "irc": "irc://irc.esper.net:6667/fabric", + "issues": "https://github.com/FabricMC/fabric/issues", + "sources": "https://github.com/FabricMC/fabric" + }, + "authors": [ + "FabricMC" + ], + "depends": { + "fabricloader": ">=0.4.0", + "fabric-api-base": "*" + }, + "description": "Hooks and registries for rendering-related things.", + "mixins": [ + "fabric-rendering-v1.mixins.json" + ] +} diff --git a/settings.gradle b/settings.gradle index 1335d3656..ef7a1b243 100644 --- a/settings.gradle +++ b/settings.gradle @@ -36,9 +36,10 @@ include 'fabric-renderer-api-v1' include 'fabric-renderer-indigo' include 'fabric-renderer-registries-v1' include 'fabric-rendering-v0' +include 'fabric-rendering-v1' include 'fabric-rendering-data-attachment-v1' include 'fabric-rendering-fluids-v1' include 'fabric-resource-loader-v0' include 'fabric-tag-extensions-v0' include 'fabric-textures-v0' -include 'fabric-dimensions-v1' \ No newline at end of file +include 'fabric-dimensions-v1'