Skip to content

Instantly share code, notes, and snippets.

@phase
Created June 11, 2020 22:35
Show Gist options
  • Save phase/d92421f85dd3be4995441f715c77e86a to your computer and use it in GitHub Desktop.
Save phase/d92421f85dd3be4995441f715c77e86a to your computer and use it in GitHub Desktop.
TextureMap 1.7 Optifine
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.imageio.ImageIO;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class bpz extends bpp implements bqk, rg {
private static final Logger d = LogManager.getLogger();
public static final bqx b = new bqx("textures/atlas/blocks.png");
public static final bqx c = new bqx("textures/atlas/items.png");
private final List e = Lists.newArrayList();
private final Map f = Maps.newHashMap();
private final Map g = Maps.newHashMap();
private final int h;
private final String i;
private int j;
private int k = 1;
private final bqd l = new bqd("missingno");
public bpz(int var1, String var2) {
this.h = var1;
this.i = var2;
this.g();
}
private void f() {
int[] var1;
if ((float)this.k > 1.0F) {
boolean var2 = true;
boolean var3 = true;
boolean var4 = true;
this.l.b(32);
this.l.c(32);
var1 = new int[1024];
System.arraycopy(bqi.b, 0, var1, 0, bqi.b.length);
bqi.a(var1, 16, 16, 8);
} else {
var1 = bqi.b;
this.l.b(16);
this.l.c(16);
}
int[][] var5 = new int[this.j + 1][];
var5[0] = var1;
this.l.a(Lists.newArrayList(new int[][][]{var5}));
}
public void a(bqy var1) {
this.f();
this.c();
this.b(var1);
}
public void b(bqy var1) {
int var2 = bao.D();
bpv var3 = new bpv(var2, var2, true, 0, this.j);
this.g.clear();
this.e.clear();
int var4 = 2147483647;
Iterator var5 = this.f.entrySet().iterator();
bqd var8;
while(var5.hasNext()) {
Entry var6 = (Entry)var5.next();
bqx var7 = new bqx((String)var6.getKey());
var8 = (bqd)var6.getValue();
bqx var9 = this.a(var7, 0);
try {
bqw var10 = var1.a(var9);
BufferedImage[] var11 = new BufferedImage[1 + this.j];
var11[0] = ImageIO.read(var10.b());
bsi var12 = (bsi)var10.a("texture");
if (var12 != null) {
List var13 = var12.c();
int var15;
if (!var13.isEmpty()) {
int var14 = var11[0].getWidth();
var15 = var11[0].getHeight();
if (qh.b(var14) != var14 || qh.b(var15) != var15) {
throw new RuntimeException("Unable to load extra miplevels, source-texture is not power of two");
}
}
Iterator var35 = var13.iterator();
while(var35.hasNext()) {
var15 = (Integer)var35.next();
if (var15 > 0 && var15 < var11.length - 1 && var11[var15] == null) {
bqx var16 = this.a(var7, var15);
try {
var11[var15] = ImageIO.read(var1.a(var16).b());
} catch (IOException var21) {
d.error("Unable to load miplevel {} from: {}", new Object[]{var15, var16, var21});
}
}
}
}
bsa var34 = (bsa)var10.a("animation");
var8.a(var11, var34, (float)this.k > 1.0F);
} catch (RuntimeException var22) {
d.error("Unable to parse metadata from " + var9, var22);
continue;
} catch (IOException var23) {
d.error("Using missing texture, unable to load " + var9, var23);
continue;
}
var4 = Math.min(var4, Math.min(var8.a(), var8.b()));
var3.a(var8);
}
int var24 = qh.c(var4);
if (var24 < this.j) {
d.debug("{}: dropping miplevel from {} to {}, because of minTexel: {}", new Object[]{this.i, this.j, var24, var4});
this.j = var24;
}
Iterator var25 = this.f.values().iterator();
while(var25.hasNext()) {
bqd var27 = (bqd)var25.next();
try {
var27.d(this.j);
} catch (Throwable var20) {
b var29 = b.a(var20, "Applying mipmap");
k var31 = var29.a("Sprite being mipmapped");
var31.a("Sprite name", new bqa(this, var27));
var31.a("Sprite size", new bqb(this, var27));
var31.a("Sprite frames", new bqc(this, var27));
var31.a("Mipmap levels", this.j);
throw new s(var29);
}
}
this.l.d(this.j);
var3.a(this.l);
try {
var3.c();
} catch (bpy var19) {
throw var19;
}
d.info("Created: {}x{} {}-atlas", new Object[]{var3.a(), var3.b(), this.i});
bqi.a(this.b(), this.j, var3.a(), var3.b(), (float)this.k);
HashMap var26 = Maps.newHashMap(this.f);
Iterator var28 = var3.d().iterator();
while(var28.hasNext()) {
var8 = (bqd)var28.next();
String var30 = var8.g();
var26.remove(var30);
this.g.put(var30, var8);
try {
bqi.a(var8.a(0), var8.a(), var8.b(), var8.h(), var8.i(), false, false);
} catch (Throwable var18) {
b var32 = b.a(var18, "Stitching texture atlas");
k var33 = var32.a("Texture being stitched together");
var33.a("Atlas path", this.i);
var33.a("Sprite", var8);
throw new s(var32);
}
if (var8.m()) {
this.e.add(var8);
} else {
var8.l();
}
}
var28 = var26.values().iterator();
while(var28.hasNext()) {
var8 = (bqd)var28.next();
var8.a(this.l);
}
}
private bqx a(bqx var1, int var2) {
return var2 == 0 ? new bqx(var1.b(), String.format("%s/%s%s", this.i, var1.a(), ".png")) : new bqx(var1.b(), String.format("%s/mipmaps/%s.%d%s", this.i, var1.a(), var2, ".png"));
}
private void g() {
this.f.clear();
Iterator var1;
if (this.h == 0) {
var1 = aji.c.iterator();
while(var1.hasNext()) {
aji var2 = (aji)var1.next();
if (var2.o() != awt.a) {
var2.a(this);
}
}
bao.B().g.a(this);
bnn.a.a(this);
}
var1 = adb.e.iterator();
while(var1.hasNext()) {
adb var3 = (adb)var1.next();
if (var3 != null && var3.d() == this.h) {
var3.a(this);
}
}
}
public bqd b(String var1) {
bqd var2 = (bqd)this.g.get(var1);
if (var2 == null) {
var2 = this.l;
}
return var2;
}
public void d() {
bqi.b(this.b());
Iterator var1 = this.e.iterator();
while(var1.hasNext()) {
bqd var2 = (bqd)var1.next();
var2.j();
}
}
public rf a(String var1) {
if (var1 == null) {
throw new IllegalArgumentException("Name cannot be null!");
} else if (var1.indexOf(47) == -1 && var1.indexOf(92) == -1) {
Object var2 = (bqd)this.f.get(var1);
if (var2 == null) {
if (this.h == 1) {
if ("clock".equals(var1)) {
var2 = new bql(var1);
} else if ("compass".equals(var1)) {
var2 = new bqm(var1);
} else {
var2 = new bqd(var1);
}
} else {
var2 = new bqd(var1);
}
this.f.put(var1, var2);
}
return (rf)var2;
} else {
throw new IllegalArgumentException("Name cannot contain slashes!");
}
}
public int a() {
return this.h;
}
public void e() {
this.d();
}
public void a(int var1) {
this.j = var1;
}
public void b(int var1) {
this.k = var1;
}
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.imageio.ImageIO;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.spongepowered.asm.mixin.Debug;
import shadersmod.client.ShadersTex;
@Debug
public class bpz extends bpp implements bqk, rg {
private static final boolean ENABLE_SKIP = Boolean.parseBoolean(System.getProperty("fml.skipFirstTextureLoad", "true"));
private static final Logger d = LogManager.getLogger();
public static final bqx b = new bqx("textures/atlas/blocks.png");
public static final bqx c = new bqx("textures/atlas/items.png");
private final List e;
private final Map f;
private final Map g;
public final int h;
public final String i;
private int j;
private int k;
private final bqd l;
private static final String __OBFID = "CL_00001058";
private boolean skipFirst;
public static bpz textureMapBlocks = null;
public static bpz textureMapItems = null;
private bqd[] iconGrid;
private int iconGridSize;
private int iconGridCountX;
private int iconGridCountY;
private double iconGridSizeU;
private double iconGridSizeV;
private int counterIndexInMap;
public int atlasWidth;
public int atlasHeight;
public bpz(int par1, String par2Str) {
this(par1, par2Str, false);
}
public bpz(int par1, String par2Str, boolean skipFirst) {
this.e = Lists.newArrayList();
this.f = Maps.newHashMap();
this.g = Maps.newHashMap();
this.k = 1;
this.l = new bqd("missingno");
this.skipFirst = false;
this.iconGrid = null;
this.iconGridSize = -1;
this.iconGridCountX = -1;
this.iconGridCountY = -1;
this.iconGridSizeU = -1.0D;
this.iconGridSizeV = -1.0D;
this.counterIndexInMap = 0;
this.atlasWidth = 0;
this.atlasHeight = 0;
this.h = par1;
this.i = par2Str;
if (this.h == 0) {
textureMapBlocks = this;
}
if (this.h == 1) {
textureMapItems = this;
}
this.g();
this.skipFirst = skipFirst && ENABLE_SKIP;
}
private void f() {
int[] var1;
if ((float)this.k > 1.0F) {
boolean var2 = true;
boolean var3 = true;
boolean var4 = true;
this.l.b(32);
this.l.c(32);
var1 = new int[1024];
System.arraycopy(bqi.b, 0, var1, 0, bqi.b.length);
bqi.a(var1, 16, 16, 8);
} else {
var1 = bqi.b;
this.l.b(16);
this.l.c(16);
}
int[][] var5 = new int[this.j + 1][];
var5[0] = var1;
this.l.a(Lists.newArrayList(new int[][][]{var5}));
this.l.setIndexInMap(this.counterIndexInMap++);
}
public void a(bqy par1ResourceManager) throws IOException {
ShadersTex.resManager = par1ResourceManager;
this.counterIndexInMap = 0;
this.f();
this.c();
this.b(par1ResourceManager);
}
public void b(bqy par1ResourceManager) {
ShadersTex.resManager = par1ResourceManager;
Config.dbg("Loading texture map: " + this.i);
WrUpdates.finishCurrentUpdate();
this.g();
int var2 = TextureUtils.getGLMaximumTextureSize();
bpv var3 = new bpv(var2, var2, true, 0, this.j);
this.g.clear();
this.e.clear();
int var4 = 2147483647;
Reflector.callVoid(Reflector.ForgeHooksClient_onTextureStitchedPre, new Object[]{this});
Iterator var5 = this.f.entrySet().iterator();
bqd var8;
while(var5.hasNext() && !this.skipFirst) {
Entry var6 = (Entry)var5.next();
bqx var7 = new bqx((String)var6.getKey());
var8 = (bqd)var6.getValue();
bqx var9 = this.a(var7, 0);
if (var8.getIndexInMap() < 0) {
var8.setIndexInMap(this.counterIndexInMap++);
}
if (var8.hasCustomLoader(par1ResourceManager, var7)) {
if (!var8.load(par1ResourceManager, var7)) {
var4 = Math.min(var4, Math.min(var8.a(), var8.b()));
var3.a(var8);
}
Config.dbg("Custom loader: " + var8);
} else {
try {
bqw var10 = ShadersTex.loadResource(par1ResourceManager, var9);
BufferedImage[] var11 = new BufferedImage[1 + this.j];
var11[0] = ImageIO.read(var10.b());
bsi var12 = (bsi)var10.a("texture");
if (var12 != null) {
List var13 = var12.c();
int var15;
if (!var13.isEmpty()) {
int var14 = var11[0].getWidth();
var15 = var11[0].getHeight();
if (qh.b(var14) != var14 || qh.b(var15) != var15) {
throw new RuntimeException("Unable to load extra miplevels, source-texture is not power of two");
}
}
Iterator var35 = var13.iterator();
while(var35.hasNext()) {
var15 = (Integer)var35.next();
if (var15 > 0 && var15 < var11.length - 1 && var11[var15] == null) {
bqx var16 = this.a(var7, var15);
try {
var11[var15] = ImageIO.read(ShadersTex.loadResource(par1ResourceManager, var16).b());
} catch (IOException var20) {
d.error("Unable to load miplevel {} from: {}", new Object[]{var15, var16, var20});
}
}
}
}
bsa var34 = (bsa)var10.a("animation");
var8.a(var11, var34, (float)this.k > 1.0F);
} catch (RuntimeException var22) {
d.error("Unable to parse metadata from " + var9, var22);
ReflectorForge.FMLClientHandler_trackBrokenTexture(var9, var22.getMessage());
continue;
} catch (IOException var23) {
d.error("Using missing texture, unable to load " + var9 + ", " + var23.getClass().getName());
ReflectorForge.FMLClientHandler_trackMissingTexture(var9);
continue;
}
var4 = Math.min(var4, Math.min(var8.a(), var8.b()));
var3.a(var8);
}
}
int var24 = qh.c(var4);
if (var24 < 0) {
var24 = 0;
}
if (var24 < this.j) {
d.info("{}: dropping miplevel from {} to {}, because of minTexel: {}", new Object[]{this.i, this.j, var24, var4});
this.j = var24;
}
Iterator var25 = this.f.values().iterator();
while(var25.hasNext() && !this.skipFirst) {
bqd var27 = (bqd)var25.next();
try {
var27.d(this.j);
} catch (Throwable var19) {
b var29 = b.a(var19, "Applying mipmap");
k var31 = var29.a("Sprite being mipmapped");
var31.a("Sprite name", new bqa(this, var27));
var31.a("Sprite size", new bqb(this, var27));
var31.a("Sprite frames", new bqc(this, var27));
var31.a("Mipmap levels", this.j);
throw new s(var29);
}
}
this.l.d(this.j);
var3.a(this.l);
this.skipFirst = false;
try {
var3.c();
} catch (bpy var18) {
throw var18;
}
Config.dbg("Texture size: " + this.i + ", " + var3.a() + "x" + var3.b());
int sheetWidth = var3.a();
int sheetHeight = var3.b();
BufferedImage debugImage = null;
if (System.getProperty("saveTextureMap", "false").equalsIgnoreCase("true")) {
debugImage = this.makeDebugImage(sheetWidth, sheetHeight);
}
d.info("Created: {}x{} {}-atlas", new Object[]{var3.a(), var3.b(), this.i});
if (Config.isShaders()) {
ShadersTex.allocateTextureMap(this.b(), this.j, var3.a(), var3.b(), var3, this);
} else {
bqi.a(this.b(), this.j, var3.a(), var3.b(), (float)this.k);
}
HashMap var26 = Maps.newHashMap(this.f);
Iterator var28 = var3.d().iterator();
while(var28.hasNext()) {
var8 = (bqd)var28.next();
if (Config.isShaders()) {
ShadersTex.setIconName(ShadersTex.setSprite(var8).g());
}
String var30 = var8.g();
var26.remove(var30);
this.g.put(var30, var8);
try {
if (Config.isShaders()) {
ShadersTex.uploadTexSubForLoadAtlas(var8.a(0), var8.a(), var8.b(), var8.h(), var8.i(), false, false);
} else {
bqi.a(var8.a(0), var8.a(), var8.b(), var8.h(), var8.i(), false, false);
}
if (debugImage != null) {
this.addDebugSprite(var8, debugImage);
}
} catch (Throwable var21) {
b var32 = b.a(var21, "Stitching texture atlas");
k var33 = var32.a("Texture being stitched together");
var33.a("Atlas path", this.i);
var33.a("Sprite", var8);
throw new s(var32);
}
if (var8.m()) {
this.e.add(var8);
} else {
var8.l();
}
}
var28 = var26.values().iterator();
while(var28.hasNext()) {
var8 = (bqd)var28.next();
var8.a(this.l);
}
if (debugImage != null) {
this.writeDebugImage(debugImage, "debug_" + this.i.replace('/', '_') + ".png");
}
Reflector.callVoid(Reflector.ForgeHooksClient_onTextureStitchedPost, new Object[]{this});
}
public bqx a(bqx p_147634_1_, int p_147634_2_) {
if (this.isAbsoluteLocation(p_147634_1_)) {
return p_147634_2_ == 0 ? new bqx(p_147634_1_.b(), p_147634_1_.a() + ".png") : new bqx(p_147634_1_.b(), p_147634_1_.a() + "mipmap" + p_147634_2_ + ".png");
} else {
return p_147634_2_ == 0 ? new bqx(p_147634_1_.b(), String.format("%s/%s%s", this.i, p_147634_1_.a(), ".png")) : new bqx(p_147634_1_.b(), String.format("%s/mipmaps/%s.%d%s", this.i, p_147634_1_.a(), p_147634_2_, ".png"));
}
}
private void g() {
this.f.clear();
Iterator var1;
if (this.h == 0) {
var1 = aji.c.iterator();
while(var1.hasNext()) {
aji var2 = (aji)var1.next();
if (var2.o() != awt.a) {
var2.a(this);
}
}
bao.B().g.a(this);
bnn.a.a(this);
ConnectedTextures.updateIcons(this);
}
if (this.h == 1) {
CustomItems.updateIcons(this);
}
var1 = adb.e.iterator();
while(var1.hasNext()) {
adb var3 = (adb)var1.next();
if (var3 != null && var3.d() == this.h) {
var3.a(this);
}
}
}
public bqd b(String par1Str) {
bqd var2 = (bqd)this.g.get(par1Str);
if (var2 == null) {
var2 = this.l;
}
return var2;
}
public void d() {
if (Config.isShaders()) {
ShadersTex.updatingTex = this.getMultiTexID();
}
boolean hasNormal = false;
boolean hasSpecular = false;
bqi.b(this.b());
Iterator var1 = this.e.iterator();
while(true) {
bqd var2;
while(true) {
if (!var1.hasNext()) {
if (Config.isShaders()) {
bqd textureatlassprite;
Iterator i$;
if (hasNormal) {
bqi.b(this.getMultiTexID().norm);
i$ = this.e.iterator();
label98:
while(true) {
do {
do {
if (!i$.hasNext()) {
break label98;
}
textureatlassprite = (bqd)i$.next();
} while(textureatlassprite.spriteNormal == null);
} while(!this.isTerrainAnimationActive(textureatlassprite));
if (textureatlassprite == TextureUtils.iconClock || textureatlassprite == TextureUtils.iconCompass) {
textureatlassprite.spriteNormal.g = textureatlassprite.g;
}
textureatlassprite.spriteNormal.j();
}
}
if (hasSpecular) {
bqi.b(this.getMultiTexID().spec);
i$ = this.e.iterator();
label77:
while(true) {
do {
do {
if (!i$.hasNext()) {
break label77;
}
textureatlassprite = (bqd)i$.next();
} while(textureatlassprite.spriteSpecular == null);
} while(!this.isTerrainAnimationActive(textureatlassprite));
if (textureatlassprite == TextureUtils.iconClock || textureatlassprite == TextureUtils.iconCompass) {
textureatlassprite.spriteNormal.g = textureatlassprite.g;
}
textureatlassprite.spriteSpecular.j();
}
}
if (hasNormal || hasSpecular) {
bqi.b(this.b());
}
}
if (Config.isShaders()) {
ShadersTex.updatingTex = null;
}
return;
}
var2 = (bqd)var1.next();
if (this.h == 0) {
if (!this.isTerrainAnimationActive(var2)) {
continue;
}
break;
} else if (this.h != 1 || this.isItemAnimationActive(var2)) {
break;
}
}
var2.j();
if (var2.spriteNormal != null) {
hasNormal = true;
}
if (var2.spriteSpecular != null) {
hasSpecular = true;
}
}
}
private boolean isItemAnimationActive(bqd ts) {
return ts != TextureUtils.iconClock && ts != TextureUtils.iconCompass ? Config.isAnimatedItems() : true;
}
public rf a(String par1Str) {
if (par1Str == null) {
throw new IllegalArgumentException("Name cannot be null!");
} else if (par1Str.indexOf(92) != -1 && !this.isAbsoluteLocationPath(par1Str)) {
throw new IllegalArgumentException("Name cannot contain slashes!");
} else {
Object var2 = (bqd)this.f.get(par1Str);
if (var2 == null && this.h == 1 && Reflector.ModLoader_getCustomAnimationLogic.exists()) {
var2 = Reflector.call(Reflector.ModLoader_getCustomAnimationLogic, new Object[]{par1Str});
}
if (var2 == null) {
if (this.h == 1) {
if ("clock".equals(par1Str)) {
var2 = new bql(par1Str);
} else if ("compass".equals(par1Str)) {
var2 = new bqm(par1Str);
} else {
var2 = new bqd(par1Str);
}
} else {
var2 = new bqd(par1Str);
}
this.f.put(par1Str, var2);
if (var2 instanceof bqd) {
bqd tas = (bqd)var2;
if (tas.getIndexInMap() < 0) {
tas.setIndexInMap(this.counterIndexInMap++);
}
}
}
return (rf)var2;
}
}
public int a() {
return this.h;
}
public void e() {
this.d();
}
public void a(int p_147633_1_) {
this.j = p_147633_1_;
}
public void b(int p_147632_1_) {
this.k = p_147632_1_;
}
public bqd getTextureExtry(String name) {
return (bqd)this.f.get(name);
}
public boolean setTextureEntry(String name, bqd entry) {
if (!this.f.containsKey(name)) {
this.f.put(name, entry);
if (entry.getIndexInMap() < 0) {
entry.setIndexInMap(this.counterIndexInMap++);
}
return true;
} else {
return false;
}
}
public boolean setTextureEntry(bqd entry) {
return this.setTextureEntry(entry.g(), entry);
}
public String getBasePath() {
return this.i;
}
public int getMipmapLevels() {
return this.j;
}
private boolean isAbsoluteLocation(bqx loc) {
String path = loc.a();
return this.isAbsoluteLocationPath(path);
}
private boolean isAbsoluteLocationPath(String resPath) {
String path = resPath.toLowerCase();
return path.startsWith("mcpatcher/") || path.startsWith("optifine/");
}
public bqd getIconSafe(String name) {
return (bqd)this.f.get(name);
}
private int getStandardTileSize(Collection icons) {
int[] sizeCounts = new int[16];
Iterator it = icons.iterator();
int value;
int count;
while(it.hasNext()) {
bqd tex = (bqd)it.next();
if (tex != null) {
value = TextureUtils.getPowerOfTwo(tex.getWidth());
count = TextureUtils.getPowerOfTwo(tex.getHeight());
int po2 = Math.max(value, count);
if (po2 < sizeCounts.length) {
int var10002 = sizeCounts[po2]++;
}
}
}
int mostUsedPo2 = 4;
int mostUsedCount = 0;
for(value = 0; value < sizeCounts.length; ++value) {
count = sizeCounts[value];
if (count > mostUsedCount) {
mostUsedPo2 = value;
mostUsedCount = count;
}
}
if (mostUsedPo2 < 4) {
mostUsedPo2 = 4;
}
value = TextureUtils.twoToPower(mostUsedPo2);
return value;
}
private void updateIconGrid(int sheetWidth, int sheetHeight) {
this.iconGridCountX = -1;
this.iconGridCountY = -1;
this.iconGrid = null;
if (this.iconGridSize > 0) {
this.iconGridCountX = sheetWidth / this.iconGridSize;
this.iconGridCountY = sheetHeight / this.iconGridSize;
this.iconGrid = new bqd[this.iconGridCountX * this.iconGridCountY];
this.iconGridSizeU = 1.0D / (double)this.iconGridCountX;
this.iconGridSizeV = 1.0D / (double)this.iconGridCountY;
Iterator it = this.g.values().iterator();
while(it.hasNext()) {
bqd ts = (bqd)it.next();
double deltaU = 0.5D / (double)sheetWidth;
double deltaV = 0.5D / (double)sheetHeight;
double uMin = (double)Math.min(ts.c(), ts.d()) + deltaU;
double vMin = (double)Math.min(ts.e(), ts.f()) + deltaV;
double uMax = (double)Math.max(ts.c(), ts.d()) - deltaU;
double vMax = (double)Math.max(ts.e(), ts.f()) - deltaV;
int iuMin = (int)(uMin / this.iconGridSizeU);
int ivMin = (int)(vMin / this.iconGridSizeV);
int iuMax = (int)(uMax / this.iconGridSizeU);
int ivMax = (int)(vMax / this.iconGridSizeV);
for(int iu = iuMin; iu <= iuMax; ++iu) {
if (iu >= 0 && iu < this.iconGridCountX) {
for(int iv = ivMin; iv <= ivMax; ++iv) {
if (iv >= 0 && iv < this.iconGridCountX) {
int index = iv * this.iconGridCountX + iu;
this.iconGrid[index] = ts;
} else {
Config.warn("Invalid grid V: " + iv + ", icon: " + ts.g());
}
}
} else {
Config.warn("Invalid grid U: " + iu + ", icon: " + ts.g());
}
}
}
}
}
public bqd getIconByUV(double u, double v) {
if (this.iconGrid == null) {
return null;
} else {
int iu = (int)(u / this.iconGridSizeU);
int iv = (int)(v / this.iconGridSizeV);
int index = iv * this.iconGridCountX + iu;
return index >= 0 && index <= this.iconGrid.length ? this.iconGrid[index] : null;
}
}
public bqd getMissingSprite() {
return this.l;
}
public int getMaxTextureIndex() {
return this.f.size();
}
private boolean isTerrainAnimationActive(bqd ts) {
if (ts != TextureUtils.iconWaterStill && ts != TextureUtils.iconWaterFlow) {
if (ts != TextureUtils.iconLavaStill && ts != TextureUtils.iconLavaFlow) {
if (ts != TextureUtils.iconFireLayer0 && ts != TextureUtils.iconFireLayer1) {
if (ts == TextureUtils.iconPortal) {
return Config.isAnimatedPortal();
} else {
return ts != TextureUtils.iconClock && ts != TextureUtils.iconCompass ? Config.isAnimatedTerrain() : true;
}
} else {
return Config.isAnimatedFire();
}
} else {
return Config.isAnimatedLava();
}
} else {
return Config.isAnimatedWater();
}
}
public int getCountRegisteredSprites() {
return this.counterIndexInMap;
}
public void loadTextureSafe(bqy rm) {
try {
this.a(rm);
} catch (IOException var3) {
Config.warn("Error loading texture map: " + this.i);
var3.printStackTrace();
}
}
private BufferedImage makeDebugImage(int sheetWidth, int sheetHeight) {
BufferedImage image = new BufferedImage(sheetWidth, sheetHeight, 2);
Graphics2D g = image.createGraphics();
g.setPaint(new Color(255, 255, 0));
g.fillRect(0, 0, image.getWidth(), image.getHeight());
return image;
}
private void addDebugSprite(bqd ts, BufferedImage image) {
if (ts.k() < 1) {
Config.warn("Debug sprite has no data: " + ts.g());
} else {
int[] data = ts.a(0)[0];
image.setRGB(ts.h(), ts.i(), ts.a(), ts.b(), data, 0, ts.a());
}
}
private void writeDebugImage(BufferedImage image, String pngPath) {
try {
ImageIO.write(image, "png", new File(Config.getMinecraft().w, pngPath));
} catch (Exception var4) {
var4.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment