-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix everything, it's all ready to go, also autoscrolling works! :DDDDD
- Loading branch information
1 parent
6a4c0d8
commit d7e452c
Showing
7 changed files
with
197 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/btpos/tools/mclowrespackgenerator/TextureEntry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package btpos.tools.mclowrespackgenerator; | ||
|
||
|
||
import java.awt.Dimension; | ||
import java.io.InputStream; | ||
import java.util.function.Supplier; | ||
|
||
public class TextureEntry { | ||
public final String path; | ||
public final Supplier<InputStream> getter; | ||
public final Dimension dimension; | ||
|
||
public TextureEntry(String path, Supplier<InputStream> getter) { | ||
this(path, getter, null); | ||
} | ||
|
||
public TextureEntry(String path, Supplier<InputStream> getter, Dimension dimension) { | ||
this.path = path; | ||
this.getter = getter; | ||
this.dimension = dimension != null ? dimension : findDimension(path, getter); | ||
} | ||
|
||
private static Dimension findDimension(String path, Supplier<InputStream> getter) { | ||
return Util.getPngDimension(path, getter.get()); | ||
} | ||
|
||
public int getTotalSize() { | ||
return dimension.height * dimension.width; | ||
} | ||
|
||
public int getBestCap() { | ||
int bigger = Math.max(dimension.height, dimension.width); | ||
int smaller = Math.min(dimension.height, dimension.width); | ||
|
||
// handle animated textures that are one block stretched over many | ||
if (bigger != smaller | ||
&& bigger % smaller == 0) | ||
{ | ||
int ratio = bigger / smaller; | ||
return Util.getClosestPowerOf2(smaller) * ratio; | ||
} else { | ||
return Util.getClosestPowerOf2(bigger); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.