Got it to compile with TeaVM

This commit is contained in:
PeytonPlayz595 2024-05-12 11:59:53 -04:00
parent 89976e5119
commit 363efd4066
17 changed files with 213 additions and 176 deletions

View File

@ -64,6 +64,28 @@ public class BufferedImage {
return rgbArray;
}
public void setRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize) {
if (startX < 0 || startY < 0 || w <= 0 || h <= 0 ||
startX + w > this.w || startY + h > this.h ||
rgbArray.length < offset + w * h) {
throw new IllegalArgumentException("Big black oily men");
}
for (int y = startY; y < startY + h; y++) {
for (int x = startX; x < startX + w; x++) {
int imageDataIndex = y * this.w + x;
int rgb = rgbArray[offset + (y - startY) * scansize + (x - startX)];
int alpha = (rgb >> 24) & 0xff;
int red = (rgb >> 16) & 0xff;
int green = (rgb >> 8) & 0xff;
int blue = rgb & 0xff;
int argb = (alpha << 24) | (red << 16) | (green << 8) | blue;
data[imageDataIndex] = argb;
}
}
}
public int getWidth() {
return w;
}

View File

@ -40,7 +40,7 @@ public class Client {
private static void run0() {
System.out.println(" -------- starting minecraft -------- ");
//instance = new Minecraft();
instance = new Minecraft();
Session session = new Session("Player", "mcpass");
instance.session = session;
LocalStorageManager.loadStorage();

View File

@ -14,4 +14,8 @@ public class ImageIO {
return GL11.loadPNG(data);
}
public static BufferedImage read(BufferedImage resource) {
return resource;
}
}

View File

@ -84,7 +84,7 @@ import net.minecraft.src.World;
import net.minecraft.src.WorldProvider;
import net.minecraft.src.WorldRenderer;
public abstract class Minecraft implements Runnable {
public class Minecraft implements Runnable {
public static byte[] field_28006_b = new byte[10485760];
private static Minecraft theMinecraft;
public PlayerController playerController;
@ -151,11 +151,9 @@ public abstract class Minecraft implements Runnable {
public void onMinecraftCrash(UnexpectedThrowable var1) {
this.hasCrashed = true;
this.displayUnexpectedThrowable(var1);
//this.displayUnexpectedThrowable(var1);
}
public abstract void displayUnexpectedThrowable(UnexpectedThrowable var1);
public void setServer(String var1, int var2) {
this.serverName = var1;
this.serverPort = var2;

View File

@ -1,6 +1,5 @@
package net.minecraft.src;
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@ -105,7 +104,7 @@ public class BiomeGenBase {
var1 = 1.0F;
}
return Color.getHSBColor(224.0F / 360.0F - var1 * 0.05F, 0.5F + var1 * 0.1F, 1.0F).getRGB();
return getHSBColor(224.0F / 360.0F - var1 * 0.05F, 0.5F + var1 * 0.1F, 1.0F);
}
public List getSpawnableList(EnumCreatureType var1) {
@ -119,6 +118,61 @@ public class BiomeGenBase {
public boolean canSpawnLightningBolt() {
return this.enableSnow ? false : this.enableRain;
}
public static int getHSBColor(float hue, float saturation, float brightness) {
float r, g, b;
if (saturation == 0) {
r = g = b = brightness;
} else {
float h = (hue - (float) Math.floor(hue)) * 6.0f;
float f = h - (float) Math.floor(h);
float p = brightness * (1.0f - saturation);
float q = brightness * (1.0f - saturation * f);
float t = brightness * (1.0f - (saturation * (1.0f - f)));
int hi = (int) h;
switch (hi) {
case 0:
r = brightness;
g = t;
b = p;
break;
case 1:
r = q;
g = brightness;
b = p;
break;
case 2:
r = p;
g = brightness;
b = t;
break;
case 3:
r = p;
g = q;
b = brightness;
break;
case 4:
r = t;
g = p;
b = brightness;
break;
case 5:
r = brightness;
g = p;
b = q;
break;
default:
r = g = b = brightness;
break;
}
}
int red = Math.round(r * 255);
int green = Math.round(g * 255);
int blue = Math.round(b * 255);
return (255 << 24) | (red << 16) | (green << 8) | blue;
}
static {
generateBiomeLookup();

View File

@ -354,8 +354,7 @@ public class Chunk {
int var2 = MathHelper.floor_double(var1.posX / 16.0D);
int var3 = MathHelper.floor_double(var1.posZ / 16.0D);
if(var2 != this.xPosition || var3 != this.zPosition) {
System.out.println("Wrong location! " + var1);
Thread.dumpStack();
System.err.println("Wrong location! " + var1);
}
int var4 = MathHelper.floor_double(var1.posY / 16.0D);

View File

@ -1,6 +1,5 @@
package net.minecraft.src;
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@ -175,9 +174,9 @@ public class GuiIngame extends Gui {
var8.drawStringWithShadow(this.mc.func_6262_n(), 2, 22, 16777215);
var8.drawStringWithShadow(this.mc.func_6245_o(), 2, 32, 16777215);
var8.drawStringWithShadow(this.mc.func_21002_o(), 2, 42, 16777215);
long var24 = Runtime.getRuntime().maxMemory();
long var29 = Runtime.getRuntime().totalMemory();
long var30 = Runtime.getRuntime().freeMemory();
long var24 = GL11.maxMemory();
long var29 = GL11.totalMemory();
long var30 = GL11.freeMemory();
long var21 = var29 - var30;
var23 = "Used memory: " + var21 * 100L / var24 + "% (" + var21 / 1024L / 1024L + "MB) of " + var24 / 1024L / 1024L + "MB";
this.drawString(var8, var23, var6 - var8.getStringWidth(var23) - 2, 2, 14737632);
@ -204,7 +203,7 @@ public class GuiIngame extends Gui {
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
var17 = 16777215;
if(this.field_22065_l) {
var17 = Color.HSBtoRGB(var25 / 50.0F, 0.7F, 0.6F) & 16777215;
var17 = HSBtoRGB(var25 / 50.0F, 0.7F, 0.6F) & 16777215;
}
var8.drawString(this.recordPlaying, -var8.getStringWidth(this.recordPlaying) / 2, -4, var17 + (var16 << 24));
@ -407,4 +406,46 @@ public class GuiIngame extends Gui {
String var3 = var2.translateKey(var1);
this.addChatMessage(var3);
}
public static int HSBtoRGB(float hue, float saturation, float brightness) {
hue = (hue % 1f) + 1f;
saturation = Math.min(1f, Math.max(0f, saturation));
brightness = Math.min(1f, Math.max(0f, brightness));
float q = brightness < 0.5f ? brightness * (1f + saturation) : brightness + saturation - brightness * saturation;
float p = 2f * brightness - q;
float r, g, b;
if (hue < 1f/6f) {
r = q;
g = p + (q - p) * 6f * hue;
b = p;
} else if (hue < 2f/6f) {
r = p - (q - p) * 6f * (hue - 1f/6f);
g = q;
b = p;
} else if (hue < 3f/6f) {
r = p;
g = q - (q - p) * 6f * (hue - 2f/6f);
b = p - (q - p) * 6f * (hue - 2f/6f);
} else if (hue < 4f/6f) {
r = p;
g = p;
b = q - (q - p) * 6f * (hue - 3f/6f);
} else if (hue < 5f/6f) {
r = p + (q - p) * 6f * (hue - 4f/6f);
g = p;
b = q;
} else {
r = q;
g = p - (q - p) * 6f * (hue - 5f/6f);
b = p;
}
int red = (int) Math.max(0f, Math.min(255f, r * 255f));
int green = (int) Math.max(0f, Math.min(255f, g * 255f));
int blue = (int) Math.max(0f, Math.min(255f, b * 255f));
return (red << 16) | (green << 8) | blue;
}
}

View File

@ -1,8 +1,5 @@
package net.minecraft.src;
import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.Minecraft;
@ -37,15 +34,6 @@ public class GuiScreen extends Gui {
}
public static String getClipboardString() {
try {
Transferable var0 = Toolkit.getDefaultToolkit().getSystemClipboard().getContents((Object)null);
if(var0 != null && var0.isDataFlavorSupported(DataFlavor.stringFlavor)) {
String var1 = (String)var0.getTransferData(DataFlavor.stringFlavor);
return var1;
}
} catch (Exception var2) {
}
return null;
}

View File

@ -1,7 +0,0 @@
package net.minecraft.src;
import java.awt.image.BufferedImage;
public interface ImageBuffer {
BufferedImage parseUserSkin(BufferedImage var1);
}

View File

@ -1,88 +0,0 @@
package net.minecraft.src;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
import java.awt.image.ImageObserver;
public class ImageBufferDownload implements ImageBuffer {
private int[] imageData;
private int imageWidth;
private int imageHeight;
public BufferedImage parseUserSkin(BufferedImage var1) {
if(var1 == null) {
return null;
} else {
this.imageWidth = 64;
this.imageHeight = 32;
BufferedImage var2 = new BufferedImage(this.imageWidth, this.imageHeight, 2);
Graphics var3 = var2.getGraphics();
var3.drawImage(var1, 0, 0, (ImageObserver)null);
var3.dispose();
this.imageData = ((DataBufferInt)var2.getRaster().getDataBuffer()).getData();
this.func_884_b(0, 0, 32, 16);
this.func_885_a(32, 0, 64, 32);
this.func_884_b(0, 16, 64, 32);
boolean var4 = false;
int var5;
int var6;
int var7;
for(var5 = 32; var5 < 64; ++var5) {
for(var6 = 0; var6 < 16; ++var6) {
var7 = this.imageData[var5 + var6 * 64];
if((var7 >> 24 & 255) < 128) {
var4 = true;
}
}
}
if(!var4) {
for(var5 = 32; var5 < 64; ++var5) {
for(var6 = 0; var6 < 16; ++var6) {
var7 = this.imageData[var5 + var6 * 64];
if((var7 >> 24 & 255) < 128) {
var4 = true;
}
}
}
}
return var2;
}
}
private void func_885_a(int var1, int var2, int var3, int var4) {
if(!this.func_886_c(var1, var2, var3, var4)) {
for(int var5 = var1; var5 < var3; ++var5) {
for(int var6 = var2; var6 < var4; ++var6) {
this.imageData[var5 + var6 * this.imageWidth] &= 16777215;
}
}
}
}
private void func_884_b(int var1, int var2, int var3, int var4) {
for(int var5 = var1; var5 < var3; ++var5) {
for(int var6 = var2; var6 < var4; ++var6) {
this.imageData[var5 + var6 * this.imageWidth] |= -16777216;
}
}
}
private boolean func_886_c(int var1, int var2, int var3, int var4) {
for(int var5 = var1; var5 < var3; ++var5) {
for(int var6 = var2; var6 < var4; ++var6) {
int var7 = this.imageData[var5 + var6 * this.imageWidth];
if((var7 >> 24 & 255) < 128) {
return true;
}
}
}
return false;
}
}

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.awt.image.BufferedImage;
import net.lax1dude.eaglercraft.BufferedImage;
public class IsoImageBuffer {
public BufferedImage field_1348_a;
@ -29,4 +29,4 @@ public class IsoImageBuffer {
this.worldObj = var1;
this.func_889_a(var2, var3);
}
}
}

View File

@ -1,53 +1,63 @@
package net.minecraft.src;
import java.io.IOException;
import java.io.PushbackReader;
import java.io.Reader;
import java.nio.CharBuffer;
final class J_PositionTrackingPushbackReader implements J_ThingWithPosition {
private final PushbackReader field_27338_a;
private final CharBuffer field_27338_a;
private int field_27337_b = 0;
private int field_27340_c = 1;
private boolean field_27339_d = false;
public J_PositionTrackingPushbackReader(Reader var1) {
this.field_27338_a = new PushbackReader(var1);
CharBuffer buffer;
try {
StringBuilder builder = new StringBuilder();
int c;
while ((c = var1.read()) != -1) {
builder.append((char) c);
}
buffer = CharBuffer.wrap(builder);
} catch(IOException e) {
buffer = CharBuffer.allocate(1);
}
this.field_27338_a = buffer;
}
public void func_27334_a(char var1) throws IOException {
--this.field_27337_b;
if(this.field_27337_b < 0) {
this.field_27337_b = 0;
public void func_27334_a(char var1) {
field_27338_a.position(field_27338_a.position() - 1);
if (var1 == '\n' && !field_27339_d) {
field_27337_b = 0;
field_27340_c--;
} else {
field_27337_b--;
if (field_27337_b < 0) {
field_27337_b = 0;
}
}
this.field_27338_a.unread(var1);
field_27339_d = var1 == '\n';
}
public void func_27335_a(char[] var1) {
this.field_27337_b -= var1.length;
if(this.field_27337_b < 0) {
this.field_27337_b = 0;
for (int i = var1.length - 1; i >= 0; i--) {
func_27334_a(var1[i]);
}
}
public int func_27333_c() throws IOException {
int var1 = this.field_27338_a.read();
this.func_27332_a(var1);
return var1;
int var1 = field_27338_a.get();
func_27332_a(var1);
return var1;
}
public int func_27336_b(char[] var1) throws IOException {
int var2 = this.field_27338_a.read(var1);
char[] var3 = var1;
int var4 = var1.length;
for(int var5 = 0; var5 < var4; ++var5) {
char var6 = var3[var5];
this.func_27332_a(var6);
}
return var2;
int var2 = field_27338_a.read(CharBuffer.wrap(var1));
for (int i = 0; i < var2; i++) {
func_27332_a(var1[i]);
}
return var2;
}
private void func_27332_a(int var1) {

View File

@ -1,8 +1,7 @@
package net.minecraft.src;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.nio.charset.StandardCharsets;
public class MD5String {
private String field_27370_a;
@ -10,15 +9,20 @@ public class MD5String {
public MD5String(String var1) {
this.field_27370_a = var1;
}
public String func_27369_a(String var1) {
try {
String var2 = this.field_27370_a + var1;
MessageDigest var3 = MessageDigest.getInstance("MD5");
var3.update(var2.getBytes(), 0, var2.length());
return (new BigInteger(1, var3.digest())).toString(16);
} catch (NoSuchAlgorithmException var4) {
throw new RuntimeException(var4);
}
}
String var2 = this.field_27370_a + var1;
String md5Hash = calculateMD5(var2);
return md5Hash;
}
private String calculateMD5(String input) {
byte[] bytes = input.getBytes(StandardCharsets.UTF_8);
BigInteger no = new BigInteger(1, bytes);
String hash = no.toString(16);
while (hash.length() < 32) {
hash = "0" + hash;
}
return hash;
}
}

View File

@ -1,9 +1,11 @@
package net.minecraft.src;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Arrays;
import javax.imageio.ImageIO;
import org.lwjgl.opengl.GL11;
import net.lax1dude.eaglercraft.BufferedImage;
import net.lax1dude.eaglercraft.ImageIO;
public class TerrainTextureManager {
private float[] field_1181_a = new float[768];
@ -16,7 +18,7 @@ public class TerrainTextureManager {
public TerrainTextureManager() {
try {
BufferedImage var1 = ImageIO.read(TerrainTextureManager.class.getResource("/terrain.png"));
BufferedImage var1 = ImageIO.read(GL11.getResource("/terrain.png"));
int[] var2 = new int[65536];
var1.getRGB(0, 0, 256, 256, var2, 0, 256);
@ -49,7 +51,7 @@ public class TerrainTextureManager {
this.field_1181_a[var3 * 3 + 2] = (float)(var6 / var9);
}
}
} catch (IOException var14) {
} catch (Exception var14) {
var14.printStackTrace();
}

View File

@ -1,8 +1,11 @@
package net.minecraft.src;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.lwjgl.opengl.GL11;
import net.lax1dude.eaglercraft.BufferedImage;
import net.lax1dude.eaglercraft.ImageIO;
import net.minecraft.client.Minecraft;
public class TextureCompassFX extends TextureFX {
@ -17,11 +20,11 @@ public class TextureCompassFX extends TextureFX {
this.tileImage = 1;
try {
BufferedImage var2 = ImageIO.read(Minecraft.class.getResource("/gui/items.png"));
BufferedImage var2 = ImageIO.read(GL11.getResource("/gui/items.png"));
int var3 = this.iconIndex % 16 * 16;
int var4 = this.iconIndex / 16 * 16;
var2.getRGB(var3, var4, 16, 16, this.compassIconImageData, 0, 16);
} catch (IOException var5) {
} catch (Exception var5) {
var5.printStackTrace();
}

View File

@ -1,8 +1,9 @@
package net.minecraft.src;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.lwjgl.opengl.GL11;
import net.lax1dude.eaglercraft.BufferedImage;
import net.lax1dude.eaglercraft.ImageIO;
import net.minecraft.client.Minecraft;
public class TextureWatchFX extends TextureFX {
@ -18,13 +19,13 @@ public class TextureWatchFX extends TextureFX {
this.tileImage = 1;
try {
BufferedImage var2 = ImageIO.read(Minecraft.class.getResource("/gui/items.png"));
BufferedImage var2 = ImageIO.read(GL11.getResource("/gui/items.png"));
int var3 = this.iconIndex % 16 * 16;
int var4 = this.iconIndex / 16 * 16;
var2.getRGB(var3, var4, 16, 16, this.watchIconImageData, 0, 16);
var2 = ImageIO.read(Minecraft.class.getResource("/misc/dial.png"));
var2 = ImageIO.read(GL11.getResource("/misc/dial.png"));
var2.getRGB(0, 0, 16, 16, this.dialImageData, 0, 16);
} catch (IOException var5) {
} catch (Exception var5) {
var5.printStackTrace();
}

View File

@ -2,6 +2,8 @@ package org.lwjgl.opengl;
import java.io.InputStream;
import net.lax1dude.eaglercraft.BufferedImage;
public class GL11 extends net.PeytonPlayz585.opengl.GL11 {
public static final int GL_GEQUAL = webgl.GEQUAL;
@ -18,5 +20,9 @@ public class GL11 extends net.PeytonPlayz585.opengl.GL11 {
public static void glDisableClientState(int glTextureState) {
glDisableVertexAttrib(glTextureState);
}
public static BufferedImage getResource(String string) {
return loadPNG(loadResourceBytes(string));
}
}