From 310e713d71fae131542fd120a30027802d94aa99 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sun, 14 Jul 2019 01:23:14 +0200 Subject: [PATCH] Remove the cache again --- .../com/minelittlepony/client/pony/Pony.java | 29 ++----------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/minelittlepony/client/pony/Pony.java b/src/main/java/com/minelittlepony/client/pony/Pony.java index 42e07506..bc480d87 100644 --- a/src/main/java/com/minelittlepony/client/pony/Pony.java +++ b/src/main/java/com/minelittlepony/client/pony/Pony.java @@ -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 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();