-
Notifications
You must be signed in to change notification settings - Fork 832
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The existing private interface is kept intact as to not break any mods currently relying on it.
- Loading branch information
1 parent
410a730
commit f9eee56
Showing
18 changed files
with
128 additions
and
44 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
common/src/api/java/net/caffeinemc/mods/sodium/api/texture/SpriteUtil.java
This file contains 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,31 @@ | ||
package net.caffeinemc.mods.sodium.api.texture; | ||
|
||
import net.caffeinemc.mods.sodium.api.internal.DependencyInjection; | ||
import net.minecraft.client.renderer.texture.TextureAtlasSprite; | ||
import org.jetbrains.annotations.ApiStatus; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Utility functions for querying sprite information and updating per-frame information about sprite visibility. | ||
*/ | ||
@ApiStatus.Experimental | ||
public interface SpriteUtil { | ||
SpriteUtil INSTANCE = DependencyInjection.load(SpriteUtil.class, | ||
"net.caffeinemc.mods.sodium.client.render.texture.SpriteUtilImpl"); | ||
|
||
/** | ||
* Marks the sprite as "active", meaning that it is visible during this frame and should have the animation | ||
* state updated. Mods which perform their own rendering without the use of Minecraft's helpers will need to | ||
* call this method once every frame, when their sprite is actively being used in rendering. | ||
* @param sprite The sprite to mark as active | ||
*/ | ||
void markSpriteActive(@NotNull TextureAtlasSprite sprite); | ||
|
||
/** | ||
* Returns if the provided sprite has an animation. | ||
* | ||
* @param sprite The sprite to query an animation for | ||
* @return {@code true} if the provided sprite has an animation, otherwise {@code false} | ||
*/ | ||
boolean hasAnimation(@NotNull TextureAtlasSprite sprite); | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
23 changes: 23 additions & 0 deletions
23
common/src/main/java/net/caffeinemc/mods/sodium/client/render/texture/SpriteUtilImpl.java
This file contains 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,23 @@ | ||
package net.caffeinemc.mods.sodium.client.render.texture; | ||
|
||
import net.caffeinemc.mods.sodium.api.texture.SpriteUtil; | ||
import net.minecraft.client.renderer.texture.TextureAtlasSprite; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Objects; | ||
|
||
public class SpriteUtilImpl implements SpriteUtil { | ||
@Override | ||
public void markSpriteActive(@NotNull TextureAtlasSprite sprite) { | ||
Objects.requireNonNull(sprite); | ||
|
||
((SpriteContentsExtension) sprite.contents()).sodium$setActive(true); | ||
} | ||
|
||
@Override | ||
public boolean hasAnimation(@NotNull TextureAtlasSprite sprite) { | ||
Objects.requireNonNull(sprite); | ||
|
||
return ((SpriteContentsExtension) sprite.contents()).sodium$hasAnimation(); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.