public AnimationMetadataSection func_110493_a(JsonElement p_110493_1_, Type p_110493_2_, JsonDeserializationContext p_110493_3_) { ArrayList var4 = Lists.newArrayList(); JsonObject var5 = (JsonObject)p_110493_1_; int var6 = this.func_110485_a(var5.get("frametime"), "frametime", Integer.valueOf(1), 1, Integer.MAX_VALUE); int var8; if(var5.has("frames")) { try { JsonArray var7 = var5.getAsJsonArray("frames"); for(var8 = 0; var8 < var7.size(); ++var8) { JsonElement var9 = var7.get(var8); AnimationFrame var10 = this.func_110492_a(var8, var9); if(var10 != null) { var4.add(var10); } } } catch (ClassCastException var11) { throw new JsonParseException("Invalid animation->frames: expected array, was " + var5.get("frames"), var11); } } int var12 = this.func_110485_a(var5.get("width"), "width", Integer.valueOf(-1), 1, Integer.MAX_VALUE); var8 = this.func_110485_a(var5.get("height"), "height", Integer.valueOf(-1), 1, Integer.MAX_VALUE); return new AnimationMetadataSection(var4, var12, var8, var6); }
private AnimationFrame func_110492_a(int p_110492_1_, JsonElement p_110492_2_) { if(p_110492_2_.isJsonPrimitive()) { try { return new AnimationFrame(p_110492_2_.getAsInt()); } catch (NumberFormatException var6) { throw new JsonParseException("Invalid animation->frames->" + p_110492_1_ + ": expected number, was " + p_110492_2_, var6); } } else if(p_110492_2_.isJsonObject()) { JsonObject var3 = p_110492_2_.getAsJsonObject(); int var4 = this.func_110485_a(var3.get("time"), "frames->" + p_110492_1_ + "->time", Integer.valueOf(-1), 1, Integer.MAX_VALUE); int var5 = this.func_110485_a(var3.get("index"), "frames->" + p_110492_1_ + "->index", (Integer)null, 0, Integer.MAX_VALUE); return new AnimationFrame(var5, var4); } else { return null; } }
public Set func_130073_e() { HashSet var1 = Sets.newHashSet(); Iterator var2 = this.field_110478_a.iterator(); while(var2.hasNext()) { AnimationFrame var3 = (AnimationFrame)var2.next(); var1.add(Integer.valueOf(var3.func_110496_c())); } return var1; }
public void loadSprite(BufferedImage[] images, AnimationMetadataSection meta) throws IOException { this.resetSprite(); int i = images[0].getWidth(); int j = images[0].getHeight(); this.width = i; this.height = j; int[][] aint = new int[images.length][]; for (int k = 0; k < images.length; ++k) { BufferedImage bufferedimage = images[k]; if (bufferedimage != null) { if (k > 0 && (bufferedimage.getWidth() != i >> k || bufferedimage.getHeight() != j >> k)) { throw new RuntimeException(String.format("Unable to load miplevel: %d, image is size: %dx%d, expected %dx%d", new Object[] {Integer.valueOf(k), Integer.valueOf(bufferedimage.getWidth()), Integer.valueOf(bufferedimage.getHeight()), Integer.valueOf(i >> k), Integer.valueOf(j >> k)})); } aint[k] = new int[bufferedimage.getWidth() * bufferedimage.getHeight()]; bufferedimage.getRGB(0, 0, bufferedimage.getWidth(), bufferedimage.getHeight(), aint[k], 0, bufferedimage.getWidth()); } } if (meta == null) { if (j != i) { throw new RuntimeException("broken aspect ratio and not an animation"); } this.framesTextureData.add(aint); } else { int j1 = j / i; int k1 = i; int l = i; this.height = this.width; if (meta.getFrameCount() > 0) { Iterator iterator = meta.getFrameIndexSet().iterator(); while (iterator.hasNext()) { int i1 = ((Integer)iterator.next()).intValue(); if (i1 >= j1) { throw new RuntimeException("invalid frameindex " + i1); } this.allocateFrameTextureData(i1); this.framesTextureData.set(i1, getFrameTextureData(aint, k1, l, i1)); } this.animationMetadata = meta; } else { List<AnimationFrame> list = Lists.<AnimationFrame>newArrayList(); for (int l1 = 0; l1 < j1; ++l1) { this.framesTextureData.add(getFrameTextureData(aint, k1, l, l1)); list.add(new AnimationFrame(l1, -1)); } this.animationMetadata = new AnimationMetadataSection(list, this.width, this.height, meta.getFrameTime(), meta.isInterpolate()); } } }
public void loadSpriteFrames(IResource resource, int mipmaplevels) throws IOException { BufferedImage bufferedimage = TextureUtil.readBufferedImage(resource.getInputStream()); AnimationMetadataSection animationmetadatasection = (AnimationMetadataSection)resource.getMetadata("animation"); int[][] aint = new int[mipmaplevels][]; aint[0] = new int[bufferedimage.getWidth() * bufferedimage.getHeight()]; bufferedimage.getRGB(0, 0, bufferedimage.getWidth(), bufferedimage.getHeight(), aint[0], 0, bufferedimage.getWidth()); if (animationmetadatasection == null) { this.framesTextureData.add(aint); } else { int i = bufferedimage.getHeight() / this.width; if (animationmetadatasection.getFrameCount() > 0) { Iterator iterator = animationmetadatasection.getFrameIndexSet().iterator(); while (iterator.hasNext()) { int j = ((Integer)iterator.next()).intValue(); if (j >= i) { throw new RuntimeException("invalid frameindex " + j); } this.allocateFrameTextureData(j); this.framesTextureData.set(j, getFrameTextureData(aint, this.width, this.width, j)); } this.animationMetadata = animationmetadatasection; } else { List<AnimationFrame> list = Lists.<AnimationFrame>newArrayList(); for (int k = 0; k < i; ++k) { this.framesTextureData.add(getFrameTextureData(aint, this.width, this.width, k)); list.add(new AnimationFrame(k, -1)); } this.animationMetadata = new AnimationMetadataSection(list, this.width, this.height, animationmetadatasection.getFrameTime(), animationmetadatasection.isInterpolate()); } } }
private AnimationFrame func_130072_d(int p_130072_1_) { return (AnimationFrame)this.field_110478_a.get(p_130072_1_); }
public int func_110472_a(int p_110472_1_) { AnimationFrame var2 = this.func_130072_d(p_110472_1_); return var2.func_110495_a()?this.field_110475_d:var2.func_110497_b(); }
public boolean func_110470_b(int p_110470_1_) { return !((AnimationFrame)this.field_110478_a.get(p_110470_1_)).func_110495_a(); }
public int func_110468_c(int p_110468_1_) { return ((AnimationFrame)this.field_110478_a.get(p_110468_1_)).func_110496_c(); }
public void func_130100_a(Resource p_130100_1_) throws IOException { this.func_130102_n(); InputStream var2 = p_130100_1_.func_110527_b(); AnimationMetadataSection var3 = (AnimationMetadataSection)p_130100_1_.func_110526_a("animation"); BufferedImage var4 = ImageIO.read(var2); this.field_130224_d = var4.getHeight(); this.field_130223_c = var4.getWidth(); int[] var5 = new int[this.field_130224_d * this.field_130223_c]; var4.getRGB(0, 0, this.field_130223_c, this.field_130224_d, var5, 0, this.field_130223_c); if(var3 == null) { if(this.field_130224_d != this.field_130223_c) { throw new RuntimeException("broken aspect ratio and not an animation"); } this.field_110976_a.add(var5); } else { int var6 = this.field_130224_d / this.field_130223_c; int var7 = this.field_130223_c; int var8 = this.field_130223_c; this.field_130224_d = this.field_130223_c; int var10; if(var3.func_110473_c() > 0) { Iterator var9 = var3.func_130073_e().iterator(); while(var9.hasNext()) { var10 = ((Integer)var9.next()).intValue(); if(var10 >= var6) { throw new RuntimeException("invalid frameindex " + var10); } this.func_130099_d(var10); this.field_110976_a.set(var10, func_130101_a(var5, var7, var8, var10)); } this.field_110982_k = var3; } else { ArrayList var11 = Lists.newArrayList(); for(var10 = 0; var10 < var6; ++var10) { this.field_110976_a.add(func_130101_a(var5, var7, var8, var10)); var11.add(new AnimationFrame(var10, -1)); } this.field_110982_k = new AnimationMetadataSection(var11, this.field_130223_c, this.field_130224_d, var3.func_110469_d()); } } }
public void loadSprite(Resource par1Resource) throws IOException { this.resetSprite(); InputStream inputstream = par1Resource.getInputStream(); AnimationMetadataSection animationmetadatasection = (AnimationMetadataSection)par1Resource.getMetadata("animation"); BufferedImage bufferedimage = ImageIO.read(inputstream); this.height = bufferedimage.getHeight(); this.width = bufferedimage.getWidth(); int[] aint = new int[this.height * this.width]; bufferedimage.getRGB(0, 0, this.width, this.height, aint, 0, this.width); if (animationmetadatasection == null) { if (this.height != this.width) { throw new RuntimeException("broken aspect ratio and not an animation"); } this.framesTextureData.add(aint); } else { int i = this.height / this.width; int j = this.width; int k = this.width; this.height = this.width; int l; if (animationmetadatasection.getFrameCount() > 0) { Iterator iterator = animationmetadatasection.getFrameIndexSet().iterator(); while (iterator.hasNext()) { l = ((Integer)iterator.next()).intValue(); if (l >= i) { throw new RuntimeException("invalid frameindex " + l); } this.allocateFrameTextureData(l); this.framesTextureData.set(l, getFrameTextureData(aint, j, k, l)); } this.animationMetadata = animationmetadatasection; } else { ArrayList arraylist = Lists.newArrayList(); for (l = 0; l < i; ++l) { this.framesTextureData.add(getFrameTextureData(aint, j, k, l)); arraylist.add(new AnimationFrame(l, -1)); } this.animationMetadata = new AnimationMetadataSection(arraylist, this.width, this.height, animationmetadatasection.getFrameTime()); } } }