001package net.minecraft.client.renderer.texture; 002 003import cpw.mods.fml.relauncher.Side; 004import cpw.mods.fml.relauncher.SideOnly; 005 006import java.awt.image.BufferedImage; 007import java.io.BufferedReader; 008import java.util.ArrayList; 009import java.util.List; 010 011import net.minecraft.client.texturepacks.ITexturePack; 012import net.minecraft.util.Icon; 013import net.minecraft.util.Tuple; 014 015@SideOnly(Side.CLIENT) 016public class TextureStitched implements Icon 017{ 018 private final String field_94235_h; 019 protected Texture field_94228_a; 020 protected List field_94226_b; 021 private List field_94236_i; 022 protected boolean field_94227_c; 023 protected int field_94224_d; 024 protected int field_94225_e; 025 private int field_94233_j; 026 private int field_94234_k; 027 private float field_94231_l; 028 private float field_94232_m; 029 private float field_94229_n; 030 private float field_94230_o; 031 private float field_94238_p; 032 private float field_94237_q; 033 protected int field_94222_f = 0; 034 protected int field_94223_g = 0; 035 036 public static TextureStitched func_94220_a(String par0Str) 037 { 038 return (TextureStitched)("clock".equals(par0Str) ? new TextureClock() : ("compass".equals(par0Str) ? new TextureCompass() : new TextureStitched(par0Str))); 039 } 040 041 protected TextureStitched(String par1) 042 { 043 this.field_94235_h = par1; 044 } 045 046 public void func_94218_a(Texture par1Texture, List par2List, int par3, int par4, int par5, int par6, boolean par7) 047 { 048 this.field_94228_a = par1Texture; 049 this.field_94226_b = par2List; 050 this.field_94224_d = par3; 051 this.field_94225_e = par4; 052 this.field_94233_j = par5; 053 this.field_94234_k = par6; 054 this.field_94227_c = par7; 055 this.field_94231_l = (float)par3 / (float)par1Texture.func_94275_d(); 056 this.field_94232_m = (float)(par3 + par5) / (float)par1Texture.func_94275_d(); 057 this.field_94229_n = (float)par4 / (float)par1Texture.func_94276_e(); 058 this.field_94230_o = (float)(par4 + par6) / (float)par1Texture.func_94276_e(); 059 this.field_94238_p = (float)par5 / 16.0F; 060 this.field_94237_q = (float)par6 / 16.0F; 061 } 062 063 public void func_94217_a(TextureStitched par1TextureStitched) 064 { 065 this.func_94218_a(par1TextureStitched.field_94228_a, par1TextureStitched.field_94226_b, par1TextureStitched.field_94224_d, par1TextureStitched.field_94225_e, par1TextureStitched.field_94233_j, par1TextureStitched.field_94234_k, par1TextureStitched.field_94227_c); 066 } 067 068 public int func_94211_a() 069 { 070 return this.field_94224_d; 071 } 072 073 public int func_94216_b() 074 { 075 return this.field_94225_e; 076 } 077 078 public float func_94209_e() 079 { 080 return this.field_94231_l; 081 } 082 083 public float func_94212_f() 084 { 085 return this.field_94232_m - Float.MIN_VALUE; 086 } 087 088 public float func_94214_a(double par1) 089 { 090 float f = this.field_94232_m - this.field_94231_l; 091 return this.field_94231_l + f * ((float)par1 / 16.0F) - Float.MIN_VALUE; 092 } 093 094 public float func_94206_g() 095 { 096 return this.field_94229_n; 097 } 098 099 public float func_94210_h() 100 { 101 return this.field_94230_o - Float.MIN_VALUE; 102 } 103 104 public float func_94207_b(double par1) 105 { 106 float f = this.field_94230_o - this.field_94229_n; 107 return this.field_94229_n + f * ((float)par1 / 16.0F) - Float.MIN_VALUE; 108 } 109 110 public String func_94215_i() 111 { 112 return this.field_94235_h; 113 } 114 115 public int func_94213_j() 116 { 117 return this.field_94228_a.func_94275_d(); 118 } 119 120 public int func_94208_k() 121 { 122 return this.field_94228_a.func_94276_e(); 123 } 124 125 public void func_94219_l() 126 { 127 if (this.field_94236_i != null) 128 { 129 Tuple tuple = (Tuple)this.field_94236_i.get(this.field_94222_f); 130 ++this.field_94223_g; 131 132 if (this.field_94223_g >= ((Integer)tuple.getSecond()).intValue()) 133 { 134 int i = ((Integer)tuple.getFirst()).intValue(); 135 this.field_94222_f = (this.field_94222_f + 1) % this.field_94236_i.size(); 136 this.field_94223_g = 0; 137 tuple = (Tuple)this.field_94236_i.get(this.field_94222_f); 138 int j = ((Integer)tuple.getFirst()).intValue(); 139 140 if (i != j && j >= 0 && j < this.field_94226_b.size()) 141 { 142 this.field_94228_a.func_94281_a(this.field_94224_d, this.field_94225_e, (Texture)this.field_94226_b.get(j), this.field_94227_c); 143 } 144 } 145 } 146 else 147 { 148 int k = this.field_94222_f; 149 this.field_94222_f = (this.field_94222_f + 1) % this.field_94226_b.size(); 150 151 if (k != this.field_94222_f) 152 { 153 this.field_94228_a.func_94281_a(this.field_94224_d, this.field_94225_e, (Texture)this.field_94226_b.get(this.field_94222_f), this.field_94227_c); 154 } 155 } 156 } 157 158 public void func_94221_a(BufferedReader par1BufferedReader) 159 { 160 ArrayList arraylist = new ArrayList(); 161 162 try 163 { 164 for (String s = par1BufferedReader.readLine(); s != null; s = par1BufferedReader.readLine()) 165 { 166 s = s.trim(); 167 168 if (s.length() > 0) 169 { 170 String[] astring = s.split(","); 171 String[] astring1 = astring; 172 int i = astring.length; 173 174 for (int j = 0; j < i; ++j) 175 { 176 String s1 = astring1[j]; 177 int k = s1.indexOf(42); 178 179 if (k > 0) 180 { 181 Integer integer = new Integer(s1.substring(0, k)); 182 Integer integer1 = new Integer(s1.substring(k + 1)); 183 arraylist.add(new Tuple(integer, integer1)); 184 } 185 else 186 { 187 arraylist.add(new Tuple(new Integer(s1), Integer.valueOf(1))); 188 } 189 } 190 } 191 } 192 } 193 catch (Exception exception) 194 { 195 System.err.println("Failed to read animation info for " + this.field_94235_h + ": " + exception.getMessage()); 196 } 197 198 if (!arraylist.isEmpty() && arraylist.size() < 600) 199 { 200 this.field_94236_i = arraylist; 201 } 202 } 203 204 //=================================================================================================== 205 // Forge Start 206 //=================================================================================================== 207 /** 208 * Called when texture packs are refreshed, from TextureManager.createNewTexture, 209 * allows for finer control over loading the animation lists and verification of the image. 210 * If the return value from this is true, no further loading will be done by vanilla code. 211 * 212 * You need to add all Texture's to the textures argument. At the end of this function at least one 213 * entry should be in that argument, or a error should of been thrown. 214 * 215 * @param manager The invoking manager 216 * @param texturepack Current texture pack 217 * @param name The name of the texture 218 * @param fileName Resource path for this texture 219 * @param image Buffered image of the loaded resource 220 * @param textures ArrayList of element type Texture, split textures should be added to this list for the stitcher to handle. 221 * @return Return true to skip further vanilla texture loading for this texture 222 */ 223 public boolean loadTexture(TextureManager manager, ITexturePack texturepack, String name, String fileName, BufferedImage image, ArrayList textures) 224 { 225 return false; 226 } 227}