Upload files to "src/openonyx/render/group_g"
This commit is contained in:
1 parent
de7b93b13d
commit
8c6508551e
4 files changed
+359
No files matched your search
@@ -0,0 +1,94 @@
|
||||
package openonyx.render.group_g;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.function.Consumer;
|
||||
import javax.imageio.ImageIO;
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import openonyx.core.MinecraftAccess;
|
||||
import openonyx.core.OnyxClient;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public final class CapeTextureLoader implements MinecraftAccess {
|
||||
private static final ResourceLocation RESOURCE_LOCATION = new ResourceLocation("onyx", "capes/source");
|
||||
private static final ExecutorService EXECUTOR_SERVICE = Executors.newSingleThreadExecutor(runnable -> {
|
||||
Thread thread = new Thread(runnable, "onyx-cape-loader");
|
||||
thread.setDaemon(true);
|
||||
return thread;
|
||||
});
|
||||
private static final ResourceLocation RESOURCE_LOCATION2 = new ResourceLocation("onyx", "capes/local");
|
||||
|
||||
public static void d(BufferedImage bufferedImage, Consumer<ResourceLocation> consumer) {
|
||||
mc.addScheduledTask(() -> {
|
||||
mc.getTextureManager().deleteTexture(RESOURCE_LOCATION2);
|
||||
mc.getTextureManager().loadTexture(RESOURCE_LOCATION2, new DynamicTexture(bufferedImage));
|
||||
consumer.accept(RESOURCE_LOCATION2);
|
||||
});
|
||||
}
|
||||
|
||||
private CapeTextureLoader() {
|
||||
}
|
||||
|
||||
public static ResourceLocation L(BufferedImage bufferedImage) {
|
||||
mc.getTextureManager().deleteTexture(RESOURCE_LOCATION);
|
||||
mc.getTextureManager().loadTexture(RESOURCE_LOCATION, new DynamicTexture(bufferedImage));
|
||||
return RESOURCE_LOCATION;
|
||||
}
|
||||
|
||||
public static void L(Consumer<ResourceLocation> consumer, Consumer<String> consumer1) {
|
||||
Consumer consumer2 = consumer;
|
||||
|
||||
try {
|
||||
bufferedImage = LogoTexture.L();
|
||||
} catch (IOException iOException) {
|
||||
OnyxClient.LOGGER.warn("CapeChanger: failed to draw the default cape", iOException);
|
||||
consumer1.accept("Can't draw the default cape");
|
||||
return;
|
||||
}
|
||||
|
||||
d(bufferedImage, consumer2);
|
||||
}
|
||||
|
||||
public static void d(String string, Consumer<BufferedImage> consumer, Consumer<String> consumer1) {
|
||||
if (!string.isEmpty()) {
|
||||
EXECUTOR_SERVICE.submit(() -> {
|
||||
String string2 = string;
|
||||
|
||||
BufferedImage bufferedImage;
|
||||
try {
|
||||
bufferedImage = ImageIO.read(new File(string2));
|
||||
} catch (IOException iOException) {
|
||||
Logger logger = OnyxClient.LOGGER;
|
||||
Object[] objects = new Object[2];
|
||||
boolean bl = true;
|
||||
objects[0] = string2;
|
||||
objects[1] = iOException;
|
||||
logger.warn("CapeChanger: failed to read '{}'", objects);
|
||||
consumer1.accept("Can't read that file");
|
||||
return;
|
||||
}
|
||||
|
||||
if (bufferedImage == null) {
|
||||
consumer1.accept("Not a readable PNG");
|
||||
} else {
|
||||
BufferedImage bufferedImage1 = bufferedImage;
|
||||
mc.addScheduledTask(() -> consumer.accept(bufferedImage1));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static void L(BufferedImage bufferedImage, FitMode fitMode, int i, double d, double e, double f, Consumer<ResourceLocation> consumer) {
|
||||
EXECUTOR_SERVICE.submit(() -> {
|
||||
try {
|
||||
d(ImageUtils.L(bufferedImage, fitMode, i, d, e, f), consumer);
|
||||
} catch (RuntimeException runtimeException) {
|
||||
OnyxClient.LOGGER.warn("CapeChanger: failed to compose the cape", runtimeException);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package openonyx.render.group_g;
|
||||
|
||||
import openonyx.history.DisplayNamed;
|
||||
|
||||
public enum FitMode implements DisplayNamed {
|
||||
AUTO("Auto"),
|
||||
FILL("Fill"),
|
||||
TEXTURE("Texture"),
|
||||
FIT("Fit"),
|
||||
STRETCH("Stretch");
|
||||
|
||||
private final String H;
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return this.H;
|
||||
}
|
||||
|
||||
private static FitMode[] L() {
|
||||
FitMode[] fitModes = new FitMode[5];
|
||||
boolean bl = true;
|
||||
fitModes[0] = AUTO;
|
||||
fitModes[1] = FIT;
|
||||
fitModes[2] = FILL;
|
||||
fitModes[3] = STRETCH;
|
||||
fitModes[4] = TEXTURE;
|
||||
return fitModes;
|
||||
}
|
||||
|
||||
FitMode(String string1) {
|
||||
this.H = string1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package openonyx.render.group_g;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.image.BufferedImage;
|
||||
import net.optifine.player.CapeUtils;
|
||||
|
||||
public final class ImageUtils {
|
||||
private static final int M = 17;
|
||||
private static final int L = 8;
|
||||
public static final int j = 1;
|
||||
public static final int m = 32;
|
||||
private static final int h = 22;
|
||||
public static final int l = 1;
|
||||
public static final int I = 10;
|
||||
public static final int d = 12;
|
||||
private static final int i = 32;
|
||||
private static final float f = 0.55F;
|
||||
public static final int H = 64;
|
||||
public static final int e = 16;
|
||||
|
||||
public static boolean L(BufferedImage bufferedImage) {
|
||||
BufferedImage bufferedImage1 = bufferedImage;
|
||||
int ix = bufferedImage1.getWidth();
|
||||
int jx = bufferedImage1.getHeight();
|
||||
return ix % 64 == 0 && jx % 32 == 0 ? ix / 64 == jx / 32 : false;
|
||||
}
|
||||
|
||||
public static BufferedImage L(BufferedImage bufferedImage, FitMode fitMode, int i, double d, double e, double f) {
|
||||
BufferedImage bufferedImage1 = bufferedImage;
|
||||
if (L(fitMode, bufferedImage1) == FitMode.TEXTURE) {
|
||||
return CapeUtils.parseCape(bufferedImage1);
|
||||
}
|
||||
|
||||
int lx = L(bufferedImage1);
|
||||
int jx = 10 * lx;
|
||||
int k = 16 * lx;
|
||||
BufferedImage bufferedImage2;
|
||||
Graphics2D graphics2D;
|
||||
Graphics2D graphics2D1 = graphics2D = (bufferedImage2 = new BufferedImage(64 * lx, 32 * lx, 2)).createGraphics();
|
||||
graphics2D1.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||
graphics2D1.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
|
||||
Color color;
|
||||
graphics2D1.setPaint(color = new Color(ix | 0xFF000000, true));
|
||||
graphics2D1.fillRect(0, 0, 22 * lx, 17 * lx);
|
||||
graphics2D1.setPaint(L(color));
|
||||
graphics2D1.fillRect(12 * lx, 1 * lx, jx, k);
|
||||
double[] g = L(bufferedImage1, L(fitMode, bufferedImage1), jx, k, dx, ex, fx);
|
||||
graphics2D.setClip(1 * lx, 1 * lx, jx, k);
|
||||
graphics2D.drawImage(
|
||||
bufferedImage1,
|
||||
1 * lx + (int)Math.round(g[0]),
|
||||
1 * lx + (int)Math.round(g[1]),
|
||||
Math.max(1, (int)Math.round(g[2])),
|
||||
Math.max(1, (int)Math.round(g[3])),
|
||||
null
|
||||
);
|
||||
graphics2D.dispose();
|
||||
return bufferedImage2;
|
||||
}
|
||||
|
||||
public static double[] L(BufferedImage bufferedImage, FitMode fitMode, double d, double e, double f, double g, double h) {
|
||||
double jx;
|
||||
double s;
|
||||
if (fitMode == FitMode.STRETCH) {
|
||||
double ix = dx;
|
||||
jx = ex;
|
||||
s = ix;
|
||||
} else {
|
||||
double k = dx / bufferedImage.getWidth();
|
||||
double lx = ex / bufferedImage.getHeight();
|
||||
double mx = fitMode == FitMode.FILL ? Math.max(k, lx) : Math.min(k, lx);
|
||||
double n = bufferedImage.getWidth() * mx;
|
||||
jx = bufferedImage.getHeight() * mx;
|
||||
s = n;
|
||||
}
|
||||
|
||||
double o = s * fx;
|
||||
jx *= fx;
|
||||
double p = (dx - o) / 2.0 + g * dx;
|
||||
double q = (ex - jx) / 2.0 + hx * ex;
|
||||
double[] r = new double[4];
|
||||
boolean bl = true;
|
||||
r[0] = p;
|
||||
r[1] = q;
|
||||
r[2] = o;
|
||||
r[3] = jx;
|
||||
return r;
|
||||
}
|
||||
|
||||
public static String decrypt(String string) {
|
||||
String string1 = string;
|
||||
int mx = --5 << 3 ^ 5;
|
||||
int n = 3 << 3 ^ 5;
|
||||
String string2;
|
||||
int p = (string2 = string1).length();
|
||||
char[] dx = new char[p];
|
||||
boolean bl = true;
|
||||
int jx;
|
||||
int o = jx = p - 1;
|
||||
char[] c = dx;
|
||||
byte b = 36;
|
||||
int k = o;
|
||||
int ix = mx;
|
||||
|
||||
while (k >= 0) {
|
||||
n = jx;
|
||||
int lx = string2.charAt(jx);
|
||||
jx--;
|
||||
c[n] = (char)(lx ^ ix);
|
||||
if (jx < 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
lx = jx--;
|
||||
c[lx] = (char)(string2.charAt(lx) ^ b);
|
||||
k = jx;
|
||||
}
|
||||
|
||||
return new String(c);
|
||||
}
|
||||
|
||||
private ImageUtils() {
|
||||
}
|
||||
|
||||
private static Color L(Color color) {
|
||||
return new Color((int)(color.getRed() * 0.55F), (int)(color.getGreen() * 0.55F), (int)(color.getBlue() * 0.55F));
|
||||
}
|
||||
|
||||
private static int L(BufferedImage bufferedImage) {
|
||||
BufferedImage bufferedImage1 = bufferedImage;
|
||||
int ix = (int)Math.ceil(Math.max(bufferedImage1.getWidth() / 10.0, bufferedImage1.getHeight() / 16.0));
|
||||
return Math.max(8, Math.min(32, ix));
|
||||
}
|
||||
|
||||
public static FitMode L(FitMode fitMode, BufferedImage bufferedImage) {
|
||||
if (fitMode != FitMode.AUTO) {
|
||||
return fitMode;
|
||||
} else {
|
||||
return L(bufferedImage) ? FitMode.TEXTURE : FitMode.FIT;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package openonyx.render.group_g;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.GradientPaint;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import javax.imageio.ImageIO;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import openonyx.core.MinecraftAccess;
|
||||
|
||||
public final class LogoTexture implements MinecraftAccess {
|
||||
private static final int D = 8;
|
||||
private static final int c = 128;
|
||||
private static final int a = 12;
|
||||
private static final float k = 0.7F;
|
||||
private static final ResourceLocation RESOURCE_LOCATION = new ResourceLocation("onyx", "textures/gui/logo.png");
|
||||
private static final int M = 176;
|
||||
private static final int L = 8;
|
||||
private static final Color COLOR = new Color(-15987695, true);
|
||||
private static final int m = 96;
|
||||
private static final Color COLOR2 = new Color(587202559, true);
|
||||
private static final int l = 136;
|
||||
private static final int I = 80;
|
||||
private static final Color COLOR3 = new Color(-16119282, true);
|
||||
private static final int i = 256;
|
||||
private static final Color COLOR4 = new Color(-14474196, true);
|
||||
private static final int H = 8;
|
||||
private static final int e = 512;
|
||||
|
||||
private LogoTexture() {
|
||||
}
|
||||
|
||||
public static BufferedImage L() throws IOException {
|
||||
InputStream inputStream = mc.getResourceManager().getResource(RESOURCE_LOCATION).getInputStream();
|
||||
|
||||
BufferedImage bufferedImage;
|
||||
try {
|
||||
bufferedImage = ImageIO.read(inputStream);
|
||||
} catch (Throwable throwable1) {
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (Throwable throwable) {
|
||||
throwable1.addSuppressed(throwable);
|
||||
throw throwable1;
|
||||
}
|
||||
|
||||
throw throwable1;
|
||||
}
|
||||
|
||||
throw throwable1;
|
||||
}
|
||||
|
||||
BufferedImage bufferedImage1;
|
||||
if (inputStream != null) {
|
||||
bufferedImage1 = bufferedImage;
|
||||
inputStream.close();
|
||||
} else {
|
||||
bufferedImage1 = bufferedImage;
|
||||
}
|
||||
|
||||
if (bufferedImage1 == null) {
|
||||
throw new IOException("logo.png is not a readable PNG");
|
||||
}
|
||||
|
||||
bufferedImage1 = new BufferedImage(512, 256, 2);
|
||||
Graphics2D graphics2D = bufferedImage1.createGraphics();
|
||||
graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||
graphics2D.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
|
||||
graphics2D.setPaint(new GradientPaint(0.0F, 0.0F, COLOR4, 0.0F, 136.0F, COLOR));
|
||||
graphics2D.fillRect(0, 0, 176, 136);
|
||||
graphics2D.setPaint(COLOR3);
|
||||
graphics2D.fillRect(96, 8, 80, 128);
|
||||
graphics2D.setPaint(COLOR2);
|
||||
graphics2D.setStroke(new BasicStroke(8.0F));
|
||||
graphics2D.drawRect(20, 20, 56, 104);
|
||||
int ix;
|
||||
int j = Math.round((float)(ix = Math.round(56.0F)) * bufferedImage.getHeight() / bufferedImage.getWidth());
|
||||
graphics2D.drawImage(bufferedImage, 8 + (80 - ix) / 2, 8 + (128 - j) / 2, ix, j, null);
|
||||
graphics2D.dispose();
|
||||
return bufferedImage1;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user