From 9aca0968da5b2b88b5b77dedb936557e8504fb19 Mon Sep 17 00:00:00 2001 From: Minecraftschurli Date: Wed, 29 Nov 2023 19:55:28 +0100 Subject: [PATCH] Apply suggestions --- .../texture/atlas/SpriteResourceLoader.java.patch | 2 +- .../client/event/RegisterSpriteSourceTypesEvent.java | 4 +++- ...onstructor.java => SpriteContentsConstructor.java} | 11 ++++++++++- .../neoforge/debug/client/CustomSpriteSourceTest.java | 3 +++ .../resources/assets/minecraft/atlases/blocks.json | 2 +- 5 files changed, 18 insertions(+), 4 deletions(-) rename src/main/java/net/neoforged/neoforge/client/textures/{SpriteContentConstructor.java => SpriteContentsConstructor.java} (62%) diff --git a/patches/net/minecraft/client/renderer/texture/atlas/SpriteResourceLoader.java.patch b/patches/net/minecraft/client/renderer/texture/atlas/SpriteResourceLoader.java.patch index 0f66136cd6..741d3182a2 100644 --- a/patches/net/minecraft/client/renderer/texture/atlas/SpriteResourceLoader.java.patch +++ b/patches/net/minecraft/client/renderer/texture/atlas/SpriteResourceLoader.java.patch @@ -28,5 +28,5 @@ + } + + @Nullable -+ SpriteContents loadSprite(ResourceLocation id, Resource resource, net.neoforged.neoforge.client.textures.SpriteContentConstructor constructor); ++ SpriteContents loadSprite(ResourceLocation id, Resource resource, net.neoforged.neoforge.client.textures.SpriteContentsConstructor constructor); } diff --git a/src/main/java/net/neoforged/neoforge/client/event/RegisterSpriteSourceTypesEvent.java b/src/main/java/net/neoforged/neoforge/client/event/RegisterSpriteSourceTypesEvent.java index 0c2c516c65..543949d408 100644 --- a/src/main/java/net/neoforged/neoforge/client/event/RegisterSpriteSourceTypesEvent.java +++ b/src/main/java/net/neoforged/neoforge/client/event/RegisterSpriteSourceTypesEvent.java @@ -19,7 +19,9 @@ import org.jetbrains.annotations.ApiStatus.Internal; /** - * Fired to allow mods to register their own {@linkplain SpriteSourceType}. This event is fired once during the construction of the {@link Minecraft} instance or before datagen when client datagen is enabled. + * Fired to allow mods to register their own {@linkplain SpriteSourceType}. + * This event is fired once during the construction of the {@link Minecraft} instance or + * before datagen when client datagen is enabled. * *

This event is not {@linkplain ICancellableEvent cancellable}, and does not {@linkplain HasResult have a result}.

* diff --git a/src/main/java/net/neoforged/neoforge/client/textures/SpriteContentConstructor.java b/src/main/java/net/neoforged/neoforge/client/textures/SpriteContentsConstructor.java similarity index 62% rename from src/main/java/net/neoforged/neoforge/client/textures/SpriteContentConstructor.java rename to src/main/java/net/neoforged/neoforge/client/textures/SpriteContentsConstructor.java index ee65ba4f68..47fce0eaca 100644 --- a/src/main/java/net/neoforged/neoforge/client/textures/SpriteContentConstructor.java +++ b/src/main/java/net/neoforged/neoforge/client/textures/SpriteContentsConstructor.java @@ -17,7 +17,16 @@ * but nullable to support skipping based on metadata. */ @FunctionalInterface -public interface SpriteContentConstructor { +public interface SpriteContentsConstructor { + /** + * Construct an instance of SpriteContents or return null to not load the sprite. + * + * @param id the id of the sprite + * @param frameSize the frame size of the sprite + * @param nativeImage the image of the sprite + * @param resourceMetadata the metadata of the resource + * @return an instance of SpriteContents or return null to not load the sprite + */ @Nullable SpriteContents create(ResourceLocation id, FrameSize frameSize, NativeImage nativeImage, ResourceMetadata resourceMetadata); } diff --git a/tests/src/main/java/net/neoforged/neoforge/debug/client/CustomSpriteSourceTest.java b/tests/src/main/java/net/neoforged/neoforge/debug/client/CustomSpriteSourceTest.java index 367ecd8408..8189aaaacb 100644 --- a/tests/src/main/java/net/neoforged/neoforge/debug/client/CustomSpriteSourceTest.java +++ b/tests/src/main/java/net/neoforged/neoforge/debug/client/CustomSpriteSourceTest.java @@ -31,6 +31,9 @@ import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; +/** + * A test creating a custom sprite source provider a sprite using it and an item using that sprite. + */ @Mod(CustomSpriteSourceTest.MOD_ID) public class CustomSpriteSourceTest { private static final boolean ENABLED = true; diff --git a/tests/src/main/resources/assets/minecraft/atlases/blocks.json b/tests/src/main/resources/assets/minecraft/atlases/blocks.json index 2b01793150..546f163471 100644 --- a/tests/src/main/resources/assets/minecraft/atlases/blocks.json +++ b/tests/src/main/resources/assets/minecraft/atlases/blocks.json @@ -5,4 +5,4 @@ "id": "custom_sprite_source_test:test_item" } ] -} \ No newline at end of file +}