aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/api/objects/minecraft/SafeTexture.java
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2019-12-08 02:00:35 +0000
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2019-12-08 02:00:35 +0000
commit10d4c7d4b4fd651d64f17936a916785b36a43f92 (patch)
tree88f09ab780bd2271cdf7abb282ba8cc42bfb7e4b /src/Java/gtPlusPlus/api/objects/minecraft/SafeTexture.java
parent7fbe8a8aae1cc923ec4a0a9f5b7075d30568d94c (diff)
downloadGT5-Unofficial-10d4c7d4b4fd651d64f17936a916785b36a43f92.tar.gz
GT5-Unofficial-10d4c7d4b4fd651d64f17936a916785b36a43f92.tar.bz2
GT5-Unofficial-10d4c7d4b4fd651d64f17936a916785b36a43f92.zip
+ Added an assembly recipe for tier 1 Round Robinators.
+ Added localization for Rotor Housing achievement. + Added the Algae Farm (WIP). - Removed Durability bar on Iridium Rotors. - Reverted 2A hatch fix on Multiblocks. % Adjusted all Robinator recipes, removing the fluid requirements. $ Fixed Robinators Crashing on Servers. $ Implemented new backend for all future non-GT tile entities.
Diffstat (limited to 'src/Java/gtPlusPlus/api/objects/minecraft/SafeTexture.java')
-rw-r--r--src/Java/gtPlusPlus/api/objects/minecraft/SafeTexture.java64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/SafeTexture.java b/src/Java/gtPlusPlus/api/objects/minecraft/SafeTexture.java
new file mode 100644
index 0000000000..7c418b5a77
--- /dev/null
+++ b/src/Java/gtPlusPlus/api/objects/minecraft/SafeTexture.java
@@ -0,0 +1,64 @@
+package gtPlusPlus.api.objects.minecraft;
+
+import java.util.HashMap;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import gregtech.api.GregTech_API;
+import gtPlusPlus.core.util.Utils;
+import net.minecraft.util.IIcon;
+
+/**
+ * A Server Side safe object that can hold {@link IIcon}s.
+ * @author Alkalus
+ *
+ */
+public class SafeTexture implements Runnable {
+
+ @SideOnly(Side.CLIENT)
+ private static final HashMap<Integer, IIcon> mHashToIconCache = new HashMap<Integer, IIcon>();
+
+ @SideOnly(Side.CLIENT)
+ private static final HashMap<String, Integer> mPathToHashCash = new HashMap<String, Integer>();
+
+ private static final HashMap<String, SafeTexture> mTextureObjectCache = new HashMap<String, SafeTexture>();
+
+ private final int mHash;
+
+ private final String mTextureName;
+
+ private final static String getKey(String aTexPath) {
+ String aNameKey = Utils.sanitizeString(aTexPath);
+ aNameKey = aNameKey.replace('/', ' ');
+ aNameKey = aNameKey.toLowerCase();
+ return aNameKey;
+ }
+
+ public static SafeTexture register(String aTexturePath) {
+ String aNameKey = getKey(aTexturePath);
+ SafeTexture g = mTextureObjectCache.get(aNameKey);
+ if (g == null) {
+ g = new SafeTexture(aTexturePath);
+ mTextureObjectCache.put(aNameKey, g);
+ mPathToHashCash.put(aTexturePath, aTexturePath.hashCode());
+ }
+ return g;
+ }
+
+ private SafeTexture(String aTexturePath) {
+ mTextureName = aTexturePath;
+ mHash = getKey(aTexturePath).hashCode();
+ GregTech_API.sGTBlockIconload.add(this);
+ }
+
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon() {
+ return mHashToIconCache.get(mHash);
+ }
+
+ @Override
+ public void run() {
+ mHashToIconCache.put(getKey(mTextureName).hashCode(), GregTech_API.sBlockIcons.registerIcon(mTextureName));
+ }
+
+}