Fix fluid texture animation (#136)

This commit is contained in:
miozune authored and GitHub committed 2023-07-13 19:37:54 +09:00
1 parent 6afa01da74
commit 95a72f0e08
4 files changed
+39 -9

No files matched your search

@@ -19,6 +19,8 @@ import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.render.tank.ModelCertusTank;
import com.glodblock.github.common.tile.TileCertusQuartzTank;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.ModAndClassUtil;
import com.mitchej123.hodgepodge.textures.IPatchedTextureAtlasSprite;
import cpw.mods.fml.client.registry.ClientRegistry;
@@ -66,6 +68,9 @@ public class ItemCertusQuartzTankRender implements IItemRenderer {
if (storedFluid != null && storedFluid.getFluid() != null) {
IIcon fluidIcon = storedFluid.getFluid().getIcon();
if (fluidIcon == null) fluidIcon = FluidRegistry.LAVA.getIcon();
if (ModAndClassUtil.HODGEPODGE && fluidIcon instanceof IPatchedTextureAtlasSprite) {
((IPatchedTextureAtlasSprite) fluidIcon).markNeedsAnimationUpdate();
}
Tessellator tessellator = Tessellator.instance;
RenderBlocks renderer = new RenderBlocks();
GL11.glScalef(1, 1, -1);
@@ -3,8 +3,11 @@ package com.glodblock.github.client.render.tank;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nonnull;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.init.Blocks;
import net.minecraft.util.IIcon;
@@ -75,7 +78,7 @@ public class FluidTankRenderer {
return null;
}
Map<Fluid, int[]> cache = flowing ? flowingRenderCache : stillRenderCache;
int[] diplayLists = cache.get(fluid);
int[] diplayLists = getCachedData(fluid, cache);
if (diplayLists != null) {
return diplayLists;
}
@@ -118,4 +121,12 @@ public class FluidTankRenderer {
return diplayLists;
}
private static int[] getCachedData(@Nonnull Fluid fluid, Map<Fluid, int[]> cache) {
IIcon icon = fluid.getIcon();
if (icon instanceof TextureAtlasSprite sprite && sprite.hasAnimationMetadata()) {
return null;
}
return cache.get(fluid);
}
}