mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-28 07:55:53 +00:00
Fix a handful of broken animations (#868)
* Fix warning * Improve animated sprite tracking * Fix NPE in animation code * Fix animations for abnormally rendered items * Swap Stack for ArrayDeque
This commit is contained in:
1 parent
f9b9873637
commit
67c8628aeb
8 files changed
+94
-20
No files matched your search
@@ -8,4 +8,5 @@ public interface ITexturesCache {
|
||||
|
||||
Set<IIcon> getRenderedTextures();
|
||||
void enableTextureTracking();
|
||||
void track(IPatchedTextureAtlasSprite sprite);
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.utils;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.IPatchedTextureAtlasSprite;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ITexturesCache;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -28,4 +30,26 @@ public class AnimationsRenderUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final static ThreadLocal<ArrayDeque<ITexturesCache>> TEXTURE_CACHE_STACK = ThreadLocal.withInitial(ArrayDeque::new);
|
||||
|
||||
public static void onSpriteUsed(IPatchedTextureAtlasSprite sprite) {
|
||||
ArrayDeque<ITexturesCache> stack = TEXTURE_CACHE_STACK.get();
|
||||
|
||||
if (stack == null || stack.isEmpty()) {
|
||||
// icon was used outside of chunk building, it's probably an item in an inventory or something
|
||||
sprite.markNeedsAnimationUpdate();
|
||||
return;
|
||||
}
|
||||
|
||||
stack.peek().track(sprite);
|
||||
}
|
||||
|
||||
public static void pushCache(ITexturesCache cache) {
|
||||
TEXTURE_CACHE_STACK.get().push(cache);
|
||||
}
|
||||
|
||||
public static void popCache() {
|
||||
TEXTURE_CACHE_STACK.get().pop();
|
||||
}
|
||||
}
|
||||
+17
-2
@@ -8,6 +8,7 @@ import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ITexturesCache;
|
||||
import com.gtnewhorizons.angelica.rendering.AngelicaBlockSafetyRegistry;
|
||||
import com.gtnewhorizons.angelica.rendering.AngelicaRenderQueue;
|
||||
import com.gtnewhorizons.angelica.utils.AnimationsRenderUtils;
|
||||
import it.unimi.dsi.fastutil.longs.LongArrayFIFOQueue;
|
||||
import me.jellysquid.mods.sodium.client.SodiumClientMod;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.ChunkGraphicsState;
|
||||
@@ -132,7 +133,10 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
|
||||
final WorldSlice slice = cache.getWorldSlice();
|
||||
final RenderBlocks renderBlocks = new RenderBlocks(slice);
|
||||
if(renderBlocks instanceof ITexturesCache) ((ITexturesCache)renderBlocks).enableTextureTracking();
|
||||
if(renderBlocks instanceof ITexturesCache textureCache) {
|
||||
textureCache.enableTextureTracking();
|
||||
AnimationsRenderUtils.pushCache(textureCache);
|
||||
}
|
||||
|
||||
final int baseX = this.render.getOriginX();
|
||||
final int baseY = this.render.getOriginY();
|
||||
@@ -217,6 +221,10 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
}
|
||||
}
|
||||
|
||||
if(renderBlocks instanceof ITexturesCache) {
|
||||
AnimationsRenderUtils.popCache();
|
||||
}
|
||||
|
||||
handleRenderBlocksTextures(renderBlocks, renderData);
|
||||
|
||||
if(hasMainThreadBlocks) {
|
||||
@@ -263,7 +271,10 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
final int baseZ = this.render.getOriginZ();
|
||||
final BlockPos renderOffset = this.offset;
|
||||
final RenderBlocks rb = new RenderBlocks(slice.getWorld());
|
||||
if(rb instanceof ITexturesCache) ((ITexturesCache)rb).enableTextureTracking();
|
||||
if(rb instanceof ITexturesCache textureCache) {
|
||||
textureCache.enableTextureTracking();
|
||||
AnimationsRenderUtils.pushCache(textureCache);
|
||||
}
|
||||
while(!mainThreadBlocks.isEmpty()) {
|
||||
final long longPos = mainThreadBlocks.dequeueLong();
|
||||
if (cancellationSource.isCancelled()) {
|
||||
@@ -303,6 +314,10 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
if(AngelicaConfig.enableIris) buffers.iris$resetBlockContext();
|
||||
}
|
||||
|
||||
if(rb instanceof ITexturesCache) {
|
||||
AnimationsRenderUtils.popCache();
|
||||
}
|
||||
|
||||
handleRenderBlocksTextures(rb, renderData);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user