mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 08:14:23 +01:00
Remove the cache again
This commit is contained in:
parent
e3a496be16
commit
310e713d71
1 changed files with 2 additions and 27 deletions
|
@ -1,9 +1,6 @@
|
|||
package com.minelittlepony.client.pony;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.PonyRenderManager;
|
||||
import com.minelittlepony.client.render.IPonyRender;
|
||||
|
@ -16,8 +13,6 @@ import net.minecraft.block.Material;
|
|||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.texture.MissingSprite;
|
||||
import net.minecraft.client.texture.NativeImage;
|
||||
import net.minecraft.client.texture.NativeImageBackedTexture;
|
||||
import net.minecraft.client.texture.Texture;
|
||||
import net.minecraft.client.texture.TextureManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
|
@ -37,8 +32,6 @@ import javax.annotation.Nullable;
|
|||
import javax.annotation.concurrent.Immutable;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static com.mojang.blaze3d.platform.GlStateManager.getTexLevelParameter;
|
||||
|
@ -49,10 +42,6 @@ public class Pony implements IPony {
|
|||
|
||||
private static final AtomicInteger ponyCount = new AtomicInteger();
|
||||
|
||||
private static final LoadingCache<Identifier, NativeImage> nativeCache = CacheBuilder.newBuilder()
|
||||
.expireAfterAccess(30, TimeUnit.SECONDS)
|
||||
.build(CacheLoader.from(Pony::constructFromGlBuffer));
|
||||
|
||||
private final int ponyId = ponyCount.getAndIncrement();
|
||||
|
||||
private final Identifier texture;
|
||||
|
@ -104,24 +93,10 @@ public class Pony implements IPony {
|
|||
}
|
||||
|
||||
private static NativeImage getBufferedImage(@Nullable Identifier resource) {
|
||||
if (resource != null) {
|
||||
try {
|
||||
Texture texture = MinecraftClient.getInstance().getTextureManager().getTexture(resource);
|
||||
|
||||
if (texture instanceof NativeImageBackedTexture) {
|
||||
return ((NativeImageBackedTexture)texture).getImage();
|
||||
}
|
||||
|
||||
return nativeCache.get(resource);
|
||||
} catch (ExecutionException e) {
|
||||
MineLittlePony.logger.fatal("Error fetching native image from gl buffer", e);
|
||||
}
|
||||
if (resource == null) {
|
||||
return MissingSprite.getMissingSpriteTexture().getImage();
|
||||
}
|
||||
|
||||
return MissingSprite.getMissingSpriteTexture().getImage();
|
||||
}
|
||||
|
||||
private static NativeImage constructFromGlBuffer(Identifier resource) {
|
||||
MinecraftClient mc = MinecraftClient.getInstance();
|
||||
TextureManager textures = mc.getTextureManager();
|
||||
|
||||
|
|
Loading…
Reference in a new issue