Rewrote Entire Project

Rewrote the entire project using Lax1dude's OpenGL Emulator from his project "Eaglercraft"
This commit is contained in:
PeytonPlayz595 2023-07-11 19:49:00 -04:00
parent 6f7c2a3608
commit b1c7e93b97
225 changed files with 4083 additions and 3275 deletions

View File

@ -1,40 +0,0 @@
package com.mojang.minecraft.gui;
import com.mojang.minecraft.Minecraft;
public class GuiMods extends GuiScreen {
GuiScreen parent = null;
String title = "Optifine";
public GuiMods(GuiScreen parent) {
this.parent = parent;
}
public final void onOpen() {
this.buttons.add(new OptionButton(1, this.width / 2 - 155 + 0 % 2 * 160, this.height / 6 + 24 * (0 >> 1), minecraft.settings.getSetting(11)));
this.buttons.add(new OptionButton(2, this.width / 2 - 155 + 1 % 2 * 160, this.height / 6 + 24 * (1 >> 1), minecraft.settings.getSetting(12)));
this.buttons.add(new Button(200, this.width / 2 - 100, this.height / 6 + 168 + 12, "Done"));
}
public final void onButtonClick(Button var1) {
if(var1.id == 1) {
minecraft.settings.toggleSetting(11, 0);
var1.text = minecraft.settings.getSetting(11);
}
if(var1.id == 2) {
minecraft.settings.toggleSetting(12, 0);
var1.text = minecraft.settings.getSetting(12);
}
if(var1.id == 200) {
minecraft.setCurrentScreen(parent);
}
}
public final void render(int var1, int var2) {
drawFadingBox(0, 0, this.width, this.height, 1610941696, -1607454624);
drawCenteredString(this.fontRenderer, this.title, this.width / 2, 20, 16777215);
super.render(var1, var2);
}
}

View File

@ -1,40 +0,0 @@
package com.mojang.minecraft.gui;
import com.mojang.minecraft.Minecraft;
public class GuiMore extends GuiScreen {
GuiScreen parent = null;
String title;
public GuiMore(GuiScreen parent) {
this.parent = parent;
this.title = "More Options...";
}
public final void onOpen() {
this.buttons.add(new Button(50, this.width / 2 - 100, this.height / 6 + 0 + 12, "Mods"));
this.buttons.add(new Button(100, this.width / 2 - 100, this.height / 6 + 25 + 12, "Optifine"));
this.buttons.add(new Button(200, this.width / 2 - 100, this.height / 6 + 168 + 12, "Done"));
}
public final void onButtonClick(Button var1) {
if(var1.id == 50) {
minecraft.setCurrentScreen(new GuiMods(this));
}
if(var1.id == 100) {
minecraft.setCurrentScreen(new GuiOptifine(this));
}
if(var1.id == 200) {
minecraft.setCurrentScreen(parent);
}
}
public final void render(int var1, int var2) {
drawFadingBox(0, 0, this.width, this.height, 1610941696, -1607454624);
drawCenteredString(this.fontRenderer, this.title, this.width / 2, 20, 16777215);
super.render(var1, var2);
}
}

View File

@ -1,40 +0,0 @@
package com.mojang.minecraft.gui;
import com.mojang.minecraft.Minecraft;
public class GuiOptifine extends GuiScreen {
GuiScreen parent = null;
String title = "Optifine";
public GuiOptifine(GuiScreen parent) {
this.parent = parent;
}
public final void onOpen() {
this.buttons.add(new OptionButton(1, this.width / 2 - 155 + 0 % 2 * 160, this.height / 6 + 24 * (0 >> 1), minecraft.settings.getSetting(8)));
this.buttons.add(new OptionButton(2, this.width / 2 - 155 + 1 % 2 * 160, this.height / 6 + 24 * (1 >> 1), minecraft.settings.getSetting(9)));
this.buttons.add(new Button(200, this.width / 2 - 100, this.height / 6 + 168 + 12, "Done"));
}
public final void onButtonClick(Button var1) {
if(var1.id == 1) {
minecraft.settings.toggleSetting(8, 0);
var1.text = minecraft.settings.getSetting(8);
}
if(var1.id == 2) {
minecraft.settings.toggleSetting(9, 0);
var1.text = minecraft.settings.getSetting(9);
}
if(var1.id == 200) {
minecraft.setCurrentScreen(parent);
}
}
public final void render(int var1, int var2) {
drawFadingBox(0, 0, this.width, this.height, 1610941696, -1607454624);
drawCenteredString(this.fontRenderer, this.title, this.width / 2, 20, 16777215);
super.render(var1, var2);
}
}

View File

@ -1,85 +0,0 @@
package com.mojang.minecraft.gui;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.gui.Button;
import com.mojang.minecraft.gui.GuiScreen;
import org.lwjgl.input.Keyboard;
public final class LevelNameScreen extends GuiScreen {
private GuiScreen parent;
private String title = "Enter level name:";
private int id;
private String name;
private int counter = 0;
public LevelNameScreen(GuiScreen var1, String var2, int var3) {
this.parent = var1;
this.id = var3;
this.name = var2;
if(this.name.equals("-")) {
this.name = "";
}
}
public final void onOpen() {
this.buttons.clear();
Keyboard.enableRepeatEvents(true);
this.buttons.add(new Button(0, this.width / 2 - 100, this.height / 4 + 120, "Save"));
this.buttons.add(new Button(1, this.width / 2 - 100, this.height / 4 + 144, "Cancel"));
((Button)this.buttons.get(0)).active = this.name.trim().length() > 1;
}
public final void onClose() {
Keyboard.enableRepeatEvents(false);
}
public final void tick() {
++this.counter;
}
protected final void onButtonClick(Button var1) {
if(var1.active) {
if(var1.id == 0 && this.name.trim().length() > 1) {
Minecraft var10000 = this.minecraft;
int var10001 = this.id;
String var2 = this.name.trim();
int var3 = var10001;
Minecraft var4 = var10000;
var10000.levelIo.saveOnline(var4.level, var4.host, var4.session.username, var4.session.sessionId, var2, var3);
this.minecraft.setCurrentScreen((GuiScreen)null);
this.minecraft.grabMouse();
}
if(var1.id == 1) {
this.minecraft.setCurrentScreen(this.parent);
}
}
}
protected final void onKeyPress(char var1, int var2) {
if(var2 == 14 && this.name.length() > 0) {
this.name = this.name.substring(0, this.name.length() - 1);
}
if("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ,.:-_\'*!\"#%/()=+?[]{}<>".indexOf(var1) >= 0 && this.name.length() < 64) {
this.name = this.name + var1;
}
((Button)this.buttons.get(0)).active = this.name.trim().length() > 1;
}
public final void render(int var1, int var2) {
drawFadingBox(0, 0, this.width, this.height, 1610941696, -1607454624);
drawCenteredString(this.fontRenderer, this.title, this.width / 2, 40, 16777215);
int var3 = this.width / 2 - 100;
int var4 = this.height / 2 - 10;
drawBox(var3 - 1, var4 - 1, var3 + 200 + 1, var4 + 20 + 1, -6250336);
drawBox(var3, var4, var3 + 200, var4 + 20, -16777216);
drawString(this.fontRenderer, this.name + (this.counter / 6 % 2 == 0?"_":""), var3 + 4, var4 + 6, 14737632);
super.render(var1, var2);
}
}

View File

@ -1,20 +0,0 @@
package com.mojang.minecraft.level.tile;
import java.util.Random;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.level.tile.Block;
public final class DirtBlock extends Block {
protected DirtBlock(int var1, int var2) {
super(3, 2);
}
public final int getDrop() {
if(Minecraft.settings.randomDrops) {
return new Random().nextInt(49 - 1 + 1) + 1;
}
return Block.DIRT.id;
}
}

View File

@ -1,86 +0,0 @@
package com.mojang.minecraft.net;
public class PacketType
{
private PacketType(Class ... classes)
{
opcode = (byte)(nextOpcode++);
packets[opcode] = this;
params = new Class[classes.length];
int length = 0;
for(int classNumber = 0; classNumber < classes.length; classNumber++)
{
Class class_ = classes[classNumber];
params[classNumber] = class_;
if(class_ == Long.TYPE)
{
length += 8;
} else if(class_ == Integer.TYPE) {
length += 4;
} else if(class_ == Short.TYPE) {
length += 2;
} else if(class_ == Byte.TYPE) {
++length;
} else if(class_ == Float.TYPE) {
length += 4;
} else if(class_ == Double.TYPE) {
length += 8;
} else if(class_ == byte[].class) {
length += 1024;
} else if(class_ == String.class) {
length += 64;
}
}
this.length = length;
}
public static final PacketType[] packets = new PacketType[256];
public static final PacketType IDENTIFICATION = new PacketType(new Class[] {Byte.TYPE, String.class, String.class, Byte.TYPE});
public static final PacketType LEVEL_INIT;
public static final PacketType LEVEL_DATA;
public static final PacketType LEVEL_FINALIZE;
public static final PacketType PLAYER_SET_BLOCK;
public static final PacketType BLOCK_CHANGE;
public static final PacketType SPAWN_PLAYER;
public static final PacketType POSITION_ROTATION;
public static final PacketType POSITION_ROTATION_UPDATE;
public static final PacketType POSITION_UPDATE;
public static final PacketType ROTATION_UPDATE;
public static final PacketType DESPAWN_PLAYER;
public static final PacketType CHAT_MESSAGE;
public static final PacketType DISCONNECT;
public static final PacketType UPDATE_PLAYER_TYPE;
public int length;
private static int nextOpcode;
public byte opcode;
public Class[] params;
static
{
new PacketType(new Class[0]);
LEVEL_INIT = new PacketType(new Class[0]);
LEVEL_DATA = new PacketType(new Class[] {Short.TYPE, byte[].class, Byte.TYPE});
LEVEL_FINALIZE = new PacketType(new Class[] {Short.TYPE, Short.TYPE, Short.TYPE});
PLAYER_SET_BLOCK = new PacketType(new Class[] {Short.TYPE, Short.TYPE, Short.TYPE, Byte.TYPE, Byte.TYPE});
BLOCK_CHANGE = new PacketType(new Class[] {Short.TYPE, Short.TYPE, Short.TYPE, Byte.TYPE});
SPAWN_PLAYER = new PacketType(new Class[] {Byte.TYPE, String.class, Short.TYPE, Short.TYPE, Short.TYPE, Byte.TYPE, Byte.TYPE});
POSITION_ROTATION = new PacketType(new Class[] {Byte.TYPE, Short.TYPE, Short.TYPE, Short.TYPE, Byte.TYPE, Byte.TYPE});
POSITION_ROTATION_UPDATE = new PacketType(new Class[] {Byte.TYPE, Byte.TYPE, Byte.TYPE, Byte.TYPE, Byte.TYPE, Byte.TYPE});
POSITION_UPDATE = new PacketType(new Class[] {Byte.TYPE, Byte.TYPE, Byte.TYPE, Byte.TYPE});
ROTATION_UPDATE = new PacketType(new Class[] {Byte.TYPE, Byte.TYPE, Byte.TYPE});
DESPAWN_PLAYER = new PacketType(new Class[] {Byte.TYPE});
CHAT_MESSAGE = new PacketType(new Class[] {Byte.TYPE, String.class});
DISCONNECT = new PacketType(new Class[] {String.class});
UPDATE_PLAYER_TYPE = new PacketType(new Class[] {Byte.TYPE});
nextOpcode = 0;
}
}

View File

@ -1,149 +0,0 @@
package com.mojang.minecraft.render;
import java.util.ArrayList;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.util.HashMap;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import com.mojang.minecraft.GameSettings;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.render.texture.TextureFX;
import net.PeytonPlayz585.lwjgl.LWJGLUtils;
import net.PeytonPlayz585.minecraft.GLAllocation;
import net.PeytonPlayz585.minecraft.MinecraftImage;
public class RenderEngine {
public RenderEngine() {
textureMap = new HashMap<String, Integer>();
textureNameToImageMap = new HashMap<Object, Object>();
singleIntBuffer = BufferUtils.createIntBuffer(1);
imageDataB1 = BufferUtils.createByteBuffer(0x100000);
imageDataB2 = BufferUtils.createByteBuffer(0x100000);
textureList = new ArrayList<TextureFX>();
options = Minecraft.settings;
}
public int getTexture(String s) {
TextureBase texturebase = new TextureBase();
Integer integer = (Integer) textureMap.get(s);
if (integer != null) {
return integer.intValue();
}
try {
singleIntBuffer.clear();
GLAllocation.generateTextureNames(singleIntBuffer);
int i = singleIntBuffer.get(0);
if(s.equals("/terrain.png")) {
useMipmaps = true;
}
setupTexture(readTextureImage(texturebase.func_6481_a(s)), i);
useMipmaps = false;
textureMap.put(s, Integer.valueOf(i));
return i;
} catch (IOException ioexception) {
throw new RuntimeException("!!");
}
}
public void setupTexture(MinecraftImage bufferedimage, int i) {
bindTexture(i);
if (useMipmaps) {
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10241 /* GL_TEXTURE_MIN_FILTER */, GL11.GL_NEAREST_MIPMAP_LINEAR);
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10240 /* GL_TEXTURE_MAG_FILTER */, GL11.GL_NEAREST /* GL_LINEAR */);
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, GL11.GL_TEXTURE_MAX_LEVEL, 4);
} else {
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10241 /* GL_TEXTURE_MIN_FILTER */, 9728 /* GL_NEAREST */);
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10240 /* GL_TEXTURE_MAG_FILTER */, 9728 /* GL_NEAREST */);
}
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10242 /* GL_TEXTURE_WRAP_S */, 10497 /* GL_REPEAT */);
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10243 /* GL_TEXTURE_WRAP_T */, 10497 /* GL_REPEAT */);
int j = bufferedimage.w;
int k = bufferedimage.h;
int ai[] = bufferedimage.data;
byte abyte0[] = new byte[j * k * 4];
for (int l = 0; l < ai.length; l++) {
int j1 = ai[l] >> 24 & 0xff;
int l1 = ai[l] >> 16 & 0xff;
int j2 = ai[l] >> 8 & 0xff;
int l2 = ai[l] >> 0 & 0xff;
if (options != null && options.anaglyph) {
int j3 = (l1 * 30 + j2 * 59 + l2 * 11) / 100;
int l3 = (l1 * 30 + j2 * 70) / 100;
int j4 = (l1 * 30 + l2 * 70) / 100;
l1 = j3;
j2 = l3;
l2 = j4;
}
abyte0[l * 4 + 0] = (byte) l1;
abyte0[l * 4 + 1] = (byte) j2;
abyte0[l * 4 + 2] = (byte) l2;
abyte0[l * 4 + 3] = (byte) j1;
}
imageDataB1.clear();
imageDataB1.put(abyte0);
imageDataB1.position(0).limit(abyte0.length);
GL11.glTexImage2D(3553 /* GL_TEXTURE_2D */, 0, 6408 /* GL_RGBA */, j, k, 0, 6408 /* GL_RGBA */,
5121 /* GL_UNSIGNED_BYTE */, imageDataB1);
if (useMipmaps) {
for (int i1 = 1; i1 <= 4; i1++) {
int k1 = j >> i1 - 1;
int i2 = j >> i1;
int k2 = k >> i1;
imageDataB2.clear();
for (int i3 = 0; i3 < i2; i3++) {
for (int k3 = 0; k3 < k2; k3++) {
int i4 = imageDataB1.getInt((i3 * 2 + 0 + (k3 * 2 + 0) * k1) * 4);
int k4 = imageDataB1.getInt((i3 * 2 + 1 + (k3 * 2 + 0) * k1) * 4);
int l4 = imageDataB1.getInt((i3 * 2 + 1 + (k3 * 2 + 1) * k1) * 4);
int i5 = imageDataB1.getInt((i3 * 2 + 0 + (k3 * 2 + 1) * k1) * 4);
int j5 = averageColor(averageColor(i4, k4), averageColor(l4, i5));
imageDataB2.putInt((i3 + k3 * i2) * 4, j5);
}
}
GL11.glTexImage2D(3553 /* GL_TEXTURE_2D */, i1, 6408 /* GL_RGBA */, i2, k2, 0, 6408 /* GL_RGBA */,
5121 /* GL_UNSIGNED_BYTE */, imageDataB2);
ByteBuffer tmp = imageDataB1;
imageDataB1 = imageDataB2;
imageDataB2 = tmp;
}
}
}
public void bindTexture(int i) {
if (i < 0) {
return;
} else {
GL11.glBindTexture(3553 /* GL_TEXTURE_2D */, i);
return;
}
}
private int averageColor(int i, int j) {
int k = (i & 0xff000000) >> 24 & 0xff;
int l = (j & 0xff000000) >> 24 & 0xff;
return ((k + l >> 1) << 24) + ((i & 0xfefefe) + (j & 0xfefefe) >> 1);
}
private MinecraftImage readTextureImage(byte[] inputstream) throws IOException {
return LWJGLUtils.loadPNG(inputstream);
}
public static boolean useMipmaps = false;
private HashMap textureMap;
private HashMap textureNameToImageMap;
private IntBuffer singleIntBuffer;
private ByteBuffer imageDataB1;
private ByteBuffer imageDataB2;
private java.util.List<TextureFX> textureList;
private GameSettings options;
}

View File

@ -1,14 +0,0 @@
package com.mojang.minecraft.render;
import org.lwjgl.opengl.GL11;
public class TextureBase {
public TextureBase() {
//This overrides the default Java constructor insuring non-instability
}
public byte[] func_6481_a(String s) {
return GL11.loadResourceBytes(s);
}
}

View File

@ -1,43 +0,0 @@
package com.mojang.minecraft.render;
import java.util.ArrayList;
public class TextureLocation {
private String path;
private int glObject;
public TextureLocation(String path) {
this.path = path;
this.glObject = -1;
locations.add(this);
}
public static void freeTextures() {
for (TextureLocation l : locations) {
l.glObject = -1;
}
}
public int getTexturePointer() {
RenderEngine r = new RenderEngine();
if (glObject == -1) {
glObject = r.getTexture(path);
if (glObject == -1) {
System.err.println("could not load: " + path);
}
}
return glObject;
}
public void bindTexture() {
RenderEngine r = new RenderEngine();
int i = getTexturePointer();
if(i != -1) {
r.bindTexture(i);
}
}
private static final ArrayList<TextureLocation> locations = new ArrayList();
}

View File

@ -1,43 +0,0 @@
package com.mojang.util;
import com.mojang.minecraft.Minecraft;
public final class MathHelper {
private static float[] SIN_TABLE = new float[65536];
private static float[] SIN_TABLE_FAST = new float[4096];
public static final float sin(float var0) {
if(Minecraft.settings.ofFastMath) {
return SIN_TABLE_FAST[(int)(var0 * 651.8986F) & 4095];
} else {
return SIN_TABLE[(int)(var0 * 10430.378F) & '\uffff'];
}
}
public static final float cos(float var0) {
if(Minecraft.settings.ofFastMath) {
return SIN_TABLE_FAST[(int)((var0 + ((float)Math.PI / 2F)) * 651.8986F) & 4095];
} else {
return SIN_TABLE[(int)(var0 * 10430.378F + 16384.0F) & '\uffff'];
}
}
public static final float sqrt(float var0) {
return (float)Math.sqrt((double)var0);
}
static {
for(int var0 = 0; var0 < 65536; ++var0) {
SIN_TABLE[var0] = (float)Math.sin((double)var0 * 3.141592653589793D * 2.0D / 65536.0D);
}
for (int j = 0; j < 4096; ++j) {
SIN_TABLE_FAST[j] = (float)Math.sin((double)(((float)j + 0.5F) / 4096.0F * ((float)Math.PI * 2F)));
}
for (int l = 0; l < 360; l += 90) {
SIN_TABLE_FAST[(int)((float)l * 11.377778F) & 4095] = (float)Math.sin((double)((float)l * 0.017453292F));
}
}
}

View File

@ -1,268 +0,0 @@
package net.PeytonPlayz585.lwjgl;
import org.lwjgl.input.Keyboard;
/**
* Copyright (c) 2022 LAX1DUDE. All Rights Reserved.
*
* WITH THE EXCEPTION OF PATCH FILES, MINIFIED JAVASCRIPT, AND ALL FILES
* NORMALLY FOUND IN AN UNMODIFIED MINECRAFT RESOURCE PACK, YOU ARE NOT ALLOWED
* TO SHARE, DISTRIBUTE, OR REPURPOSE ANY FILE USED BY OR PRODUCED BY THE
* SOFTWARE IN THIS REPOSITORY WITHOUT PRIOR PERMISSION FROM THE PROJECT AUTHOR.
*
* NOT FOR COMMERCIAL OR MALICIOUS USE
*
* (please read the 'LICENSE' file this repo's root directory for more info)
*
*/
public class KeyboardConstants {
private static final String[] keyboardNames = new String[256];
private static final int[] keyboardGLFWToMinecraft = new int[384];
private static final int[] keyboardMinecraftToGLFW = new int[256];
private static final int[] keyboardBrowserToMinecraft = new int[384 * 4];
private static final int[] keyboardMinecraftToBrowser = new int[256];
private static final char[] keyboardChars = new char[256];
private static final int GLFW_KEY_SPACE = 32, GLFW_KEY_APOSTROPHE = 39, GLFW_KEY_COMMA = 44, GLFW_KEY_MINUS = 45,
GLFW_KEY_PERIOD = 46, GLFW_KEY_SLASH = 47, GLFW_KEY_0 = 48, GLFW_KEY_1 = 49, GLFW_KEY_2 = 50,
GLFW_KEY_3 = 51, GLFW_KEY_4 = 52, GLFW_KEY_5 = 53, GLFW_KEY_6 = 54, GLFW_KEY_7 = 55, GLFW_KEY_8 = 56,
GLFW_KEY_9 = 57, GLFW_KEY_SEMICOLON = 59, GLFW_KEY_EQUAL = 61, GLFW_KEY_A = 65, GLFW_KEY_B = 66,
GLFW_KEY_C = 67, GLFW_KEY_D = 68, GLFW_KEY_E = 69, GLFW_KEY_F = 70, GLFW_KEY_G = 71, GLFW_KEY_H = 72,
GLFW_KEY_I = 73, GLFW_KEY_J = 74, GLFW_KEY_K = 75, GLFW_KEY_L = 76, GLFW_KEY_M = 77, GLFW_KEY_N = 78,
GLFW_KEY_O = 79, GLFW_KEY_P = 80, GLFW_KEY_Q = 81, GLFW_KEY_R = 82, GLFW_KEY_S = 83, GLFW_KEY_T = 84,
GLFW_KEY_U = 85, GLFW_KEY_V = 86, GLFW_KEY_W = 87, GLFW_KEY_X = 88, GLFW_KEY_Y = 89, GLFW_KEY_Z = 90,
GLFW_KEY_LEFT_BRACKET = 91, GLFW_KEY_BACKSLASH = 92, GLFW_KEY_RIGHT_BRACKET = 93,
GLFW_KEY_GRAVE_ACCENT = 96, GLFW_KEY_WORLD_1 = 161, GLFW_KEY_WORLD_2 = 162;
private static final int GLFW_KEY_ESCAPE = 256, GLFW_KEY_ENTER = 257, GLFW_KEY_TAB = 258, GLFW_KEY_BACKSPACE = 259,
GLFW_KEY_INSERT = 260, GLFW_KEY_DELETE = 261, GLFW_KEY_RIGHT = 262, GLFW_KEY_LEFT = 263,
GLFW_KEY_DOWN = 264, GLFW_KEY_UP = 265, GLFW_KEY_PAGE_UP = 266, GLFW_KEY_PAGE_DOWN = 267,
GLFW_KEY_HOME = 268, GLFW_KEY_END = 269, GLFW_KEY_CAPS_LOCK = 280, GLFW_KEY_SCROLL_LOCK = 281,
GLFW_KEY_NUM_LOCK = 282, GLFW_KEY_PRINT_SCREEN = 283, GLFW_KEY_PAUSE = 284, GLFW_KEY_F1 = 290,
GLFW_KEY_F2 = 291, GLFW_KEY_F3 = 292, GLFW_KEY_F4 = 293, GLFW_KEY_F5 = 294, GLFW_KEY_F6 = 295,
GLFW_KEY_F7 = 296, GLFW_KEY_F8 = 297, GLFW_KEY_F9 = 298, GLFW_KEY_F10 = 299, GLFW_KEY_F11 = 300,
GLFW_KEY_F12 = 301, GLFW_KEY_F13 = 302, GLFW_KEY_F14 = 303, GLFW_KEY_F15 = 304, GLFW_KEY_F16 = 305,
GLFW_KEY_F17 = 306, GLFW_KEY_F18 = 307, GLFW_KEY_F19 = 308, GLFW_KEY_F20 = 309, GLFW_KEY_F21 = 310,
GLFW_KEY_F22 = 311, GLFW_KEY_F23 = 312, GLFW_KEY_F24 = 313, GLFW_KEY_F25 = 314, GLFW_KEY_KP_0 = 320,
GLFW_KEY_KP_1 = 321, GLFW_KEY_KP_2 = 322, GLFW_KEY_KP_3 = 323, GLFW_KEY_KP_4 = 324, GLFW_KEY_KP_5 = 325,
GLFW_KEY_KP_6 = 326, GLFW_KEY_KP_7 = 327, GLFW_KEY_KP_8 = 328, GLFW_KEY_KP_9 = 329,
GLFW_KEY_KP_DECIMAL = 330, GLFW_KEY_KP_DIVIDE = 331, GLFW_KEY_KP_MULTIPLY = 332, GLFW_KEY_KP_SUBTRACT = 333,
GLFW_KEY_KP_ADD = 334, GLFW_KEY_KP_ENTER = 335, GLFW_KEY_KP_EQUAL = 336, GLFW_KEY_LEFT_SHIFT = 340,
GLFW_KEY_LEFT_CONTROL = 341, GLFW_KEY_LEFT_ALT = 342, GLFW_KEY_LEFT_SUPER = 343, GLFW_KEY_RIGHT_SHIFT = 344,
GLFW_KEY_RIGHT_CONTROL = 345, GLFW_KEY_RIGHT_ALT = 346, GLFW_KEY_RIGHT_SUPER = 347, GLFW_KEY_MENU = 348,
GLFW_KEY_LAST = GLFW_KEY_MENU;
private static final int DOM_KEY_LOCATION_STANDARD = 0, DOM_KEY_LOCATION_LEFT = 1, DOM_KEY_LOCATION_RIGHT = 2,
DOM_KEY_LOCATION_NUMPAD = 3;
private static void register(int minecraftId, int glfwId, int browserId, int browserLocation, String name, char character) {
if(keyboardMinecraftToGLFW[minecraftId] != 0) throw new IllegalArgumentException("Duplicate keyboardMinecraftToGLFW entry: " + minecraftId + " -> " + glfwId);
keyboardMinecraftToGLFW[minecraftId] = glfwId;
if(keyboardGLFWToMinecraft[glfwId] != 0) throw new IllegalArgumentException("Duplicate keyboardGLFWToMinecraft entry: " + glfwId + " -> " + minecraftId);
keyboardGLFWToMinecraft[glfwId] = minecraftId;
if(browserLocation == 0) {
if(keyboardMinecraftToBrowser[minecraftId] != 0) throw new IllegalArgumentException("Duplicate keyboardMinecraftToBrowser entry: " + minecraftId + " -> " + browserId + "(0)");
keyboardMinecraftToBrowser[minecraftId] = browserId;
if(keyboardBrowserToMinecraft[browserId] != 0) throw new IllegalArgumentException("Duplicate keyboardBrowserToMinecraft entry: " + browserId + "(0) -> " + minecraftId);
keyboardBrowserToMinecraft[browserId] = minecraftId;
}else {
browserLocation *= 384;
if(keyboardMinecraftToBrowser[minecraftId] != 0) throw new IllegalArgumentException("Duplicate keyboardMinecraftToBrowser entry: " + minecraftId + " -> " + browserId + "(" + browserLocation + ")");
keyboardMinecraftToBrowser[minecraftId] = browserId + browserLocation;
if(keyboardBrowserToMinecraft[browserId + browserLocation] != 0) throw new IllegalArgumentException("Duplicate keyboardBrowserToMinecraft entry: " + browserId + "(" + browserLocation + ") -> " + minecraftId);
keyboardBrowserToMinecraft[browserId + browserLocation] = minecraftId;
}
if(keyboardNames[minecraftId] != null) throw new IllegalArgumentException("Duplicate keyboardNames entry: " + minecraftId + " -> " + name);
keyboardNames[minecraftId] = name;
if(keyboardChars[minecraftId] != '\0') throw new IllegalArgumentException("Duplicate keyboardChars entry: " + minecraftId + " -> " + character);
keyboardChars[minecraftId] = character;
}
private static void registerAlt(int minecraftId, int browserId, int browserLocation) {
if(browserLocation == 0) {
if(keyboardBrowserToMinecraft[browserId] != 0) throw new IllegalArgumentException("Duplicate (alt) keyboardBrowserToMinecraft entry: " + browserId + " -> " + minecraftId);
keyboardBrowserToMinecraft[browserId] = minecraftId;
}else {
browserLocation *= 384;
if(keyboardBrowserToMinecraft[browserId + browserLocation] != 0) throw new IllegalArgumentException("Duplicate (alt) keyboardBrowserToMinecraft entry: " + browserId + "(" + browserLocation + ") -> " + minecraftId);
keyboardBrowserToMinecraft[browserId + browserLocation] = minecraftId;
}
}
static {
register(Keyboard.KEY_SPACE, GLFW_KEY_SPACE, 32, DOM_KEY_LOCATION_STANDARD, "Space", ' ');
register(Keyboard.KEY_APOSTROPHE, GLFW_KEY_APOSTROPHE, 222, DOM_KEY_LOCATION_STANDARD, "Quote", '\'');
register(Keyboard.KEY_COMMA, GLFW_KEY_COMMA, 188, DOM_KEY_LOCATION_STANDARD, "Comma", ',');
register(Keyboard.KEY_MINUS, GLFW_KEY_MINUS, 189, DOM_KEY_LOCATION_STANDARD, "Minus", '-');
register(Keyboard.KEY_PERIOD, GLFW_KEY_PERIOD, 190, DOM_KEY_LOCATION_STANDARD, "Period", '.');
register(Keyboard.KEY_SLASH, GLFW_KEY_SLASH, 191, DOM_KEY_LOCATION_STANDARD, "Slash", '/');
register(Keyboard.KEY_0, GLFW_KEY_0, 48, DOM_KEY_LOCATION_STANDARD, "0", '0');
register(Keyboard.KEY_1, GLFW_KEY_1, 49, DOM_KEY_LOCATION_STANDARD, "1", '1');
register(Keyboard.KEY_2, GLFW_KEY_2, 50, DOM_KEY_LOCATION_STANDARD, "2", '2');
register(Keyboard.KEY_3, GLFW_KEY_3, 51, DOM_KEY_LOCATION_STANDARD, "3", '3');
register(Keyboard.KEY_4, GLFW_KEY_4, 52, DOM_KEY_LOCATION_STANDARD, "4", '4');
register(Keyboard.KEY_5, GLFW_KEY_5, 53, DOM_KEY_LOCATION_STANDARD, "5", '5');
register(Keyboard.KEY_6, GLFW_KEY_6, 54, DOM_KEY_LOCATION_STANDARD, "6", '6');
register(Keyboard.KEY_7, GLFW_KEY_7, 55, DOM_KEY_LOCATION_STANDARD, "7", '7');
register(Keyboard.KEY_8, GLFW_KEY_8, 56, DOM_KEY_LOCATION_STANDARD, "8", '8');
register(Keyboard.KEY_9, GLFW_KEY_9, 57, DOM_KEY_LOCATION_STANDARD, "9", '9');
register(Keyboard.KEY_SEMICOLON, GLFW_KEY_SEMICOLON, 186, DOM_KEY_LOCATION_STANDARD, "Semicolon", ';');
register(Keyboard.KEY_EQUALS, GLFW_KEY_EQUAL, 187, DOM_KEY_LOCATION_STANDARD, "Equals", '=');
register(Keyboard.KEY_A, GLFW_KEY_A, 65, DOM_KEY_LOCATION_STANDARD, "A", 'a');
register(Keyboard.KEY_B, GLFW_KEY_B, 66, DOM_KEY_LOCATION_STANDARD, "B", 'b');
register(Keyboard.KEY_C, GLFW_KEY_C, 67, DOM_KEY_LOCATION_STANDARD, "C", 'c');
register(Keyboard.KEY_D, GLFW_KEY_D, 68, DOM_KEY_LOCATION_STANDARD, "D", 'd');
register(Keyboard.KEY_E, GLFW_KEY_E, 69, DOM_KEY_LOCATION_STANDARD, "E", 'e');
register(Keyboard.KEY_F, GLFW_KEY_F, 70, DOM_KEY_LOCATION_STANDARD, "F", 'f');
register(Keyboard.KEY_G, GLFW_KEY_G, 71, DOM_KEY_LOCATION_STANDARD, "G", 'g');
register(Keyboard.KEY_H, GLFW_KEY_H, 72, DOM_KEY_LOCATION_STANDARD, "H", 'h');
register(Keyboard.KEY_I, GLFW_KEY_I, 73, DOM_KEY_LOCATION_STANDARD, "I", 'i');
register(Keyboard.KEY_J, GLFW_KEY_J, 74, DOM_KEY_LOCATION_STANDARD, "J", 'j');
register(Keyboard.KEY_K, GLFW_KEY_K, 75, DOM_KEY_LOCATION_STANDARD, "K", 'k');
register(Keyboard.KEY_L, GLFW_KEY_L, 76, DOM_KEY_LOCATION_STANDARD, "L", 'l');
register(Keyboard.KEY_M, GLFW_KEY_M, 77, DOM_KEY_LOCATION_STANDARD, "M", 'm');
register(Keyboard.KEY_N, GLFW_KEY_N, 78, DOM_KEY_LOCATION_STANDARD, "N", 'n');
register(Keyboard.KEY_O, GLFW_KEY_O, 79, DOM_KEY_LOCATION_STANDARD, "O", 'o');
register(Keyboard.KEY_P, GLFW_KEY_P, 80, DOM_KEY_LOCATION_STANDARD, "P", 'p');
register(Keyboard.KEY_Q, GLFW_KEY_Q, 81, DOM_KEY_LOCATION_STANDARD, "Q", 'q');
register(Keyboard.KEY_R, GLFW_KEY_R, 82, DOM_KEY_LOCATION_STANDARD, "R", 'r');
register(Keyboard.KEY_S, GLFW_KEY_S, 83, DOM_KEY_LOCATION_STANDARD, "S", 's');
register(Keyboard.KEY_T, GLFW_KEY_T, 84, DOM_KEY_LOCATION_STANDARD, "T", 't');
register(Keyboard.KEY_U, GLFW_KEY_U, 85, DOM_KEY_LOCATION_STANDARD, "U", 'u');
register(Keyboard.KEY_V, GLFW_KEY_V, 86, DOM_KEY_LOCATION_STANDARD, "V", 'v');
register(Keyboard.KEY_W, GLFW_KEY_W, 87, DOM_KEY_LOCATION_STANDARD, "W", 'w');
register(Keyboard.KEY_X, GLFW_KEY_X, 88, DOM_KEY_LOCATION_STANDARD, "X", 'x');
register(Keyboard.KEY_Y, GLFW_KEY_Y, 89, DOM_KEY_LOCATION_STANDARD, "Y", 'y');
register(Keyboard.KEY_Z, GLFW_KEY_Z, 90, DOM_KEY_LOCATION_STANDARD, "Z", 'z');
register(Keyboard.KEY_LBRACKET, GLFW_KEY_LEFT_BRACKET, 219, DOM_KEY_LOCATION_STANDARD, "L. Bracket", '[');
register(Keyboard.KEY_BACKSLASH, GLFW_KEY_BACKSLASH, 220, DOM_KEY_LOCATION_STANDARD, "Backslash", '\\');
register(Keyboard.KEY_RBRACKET, GLFW_KEY_RIGHT_BRACKET, 221, DOM_KEY_LOCATION_STANDARD, "R. Bracket", ']');
register(Keyboard.KEY_GRAVE, GLFW_KEY_GRAVE_ACCENT, 192, DOM_KEY_LOCATION_STANDARD, "Backtick", '`');
register(Keyboard.KEY_ESCAPE, GLFW_KEY_ESCAPE, 27, DOM_KEY_LOCATION_STANDARD, "Escape", '\0');
register(Keyboard.KEY_RETURN, GLFW_KEY_ENTER, 13, DOM_KEY_LOCATION_STANDARD, "Enter", '\n');
register(Keyboard.KEY_TAB, GLFW_KEY_TAB, 9, DOM_KEY_LOCATION_STANDARD, "Tab", '\t');
register(Keyboard.KEY_BACK, GLFW_KEY_BACKSPACE, 8, DOM_KEY_LOCATION_STANDARD, "Backspace", '\0');
register(Keyboard.KEY_INSERT, GLFW_KEY_INSERT, 45, DOM_KEY_LOCATION_STANDARD, "Insert", '\0');
register(Keyboard.KEY_DELETE, GLFW_KEY_DELETE, 46, DOM_KEY_LOCATION_STANDARD, "Delete", '\0');
register(Keyboard.KEY_RIGHT, GLFW_KEY_RIGHT, 39, DOM_KEY_LOCATION_STANDARD, "Right", '\0');
register(Keyboard.KEY_LEFT, GLFW_KEY_LEFT, 37, DOM_KEY_LOCATION_STANDARD, "Left", '\0');
register(Keyboard.KEY_DOWN, GLFW_KEY_DOWN, 40, DOM_KEY_LOCATION_STANDARD, "Down", '\0');
register(Keyboard.KEY_UP, GLFW_KEY_UP, 38, DOM_KEY_LOCATION_STANDARD, "Up", '\0');
register(Keyboard.KEY_PRIOR, GLFW_KEY_PAGE_UP, 33, DOM_KEY_LOCATION_STANDARD, "Page Up", '\0');
register(Keyboard.KEY_NEXT, GLFW_KEY_PAGE_DOWN, 34, DOM_KEY_LOCATION_STANDARD, "Page Down", '\0');
register(Keyboard.KEY_HOME, GLFW_KEY_HOME, 36, DOM_KEY_LOCATION_STANDARD, "Home", '\0');
register(Keyboard.KEY_END, GLFW_KEY_END, 35, DOM_KEY_LOCATION_STANDARD, "End", '\0');
register(Keyboard.KEY_CAPITAL, GLFW_KEY_CAPS_LOCK, 20, DOM_KEY_LOCATION_STANDARD, "Caps Lock", '\0');
register(Keyboard.KEY_SCROLL, GLFW_KEY_SCROLL_LOCK, 145, DOM_KEY_LOCATION_STANDARD, "Scroll Lock", '\0');
register(Keyboard.KEY_NUMLOCK, GLFW_KEY_NUM_LOCK, 144, DOM_KEY_LOCATION_STANDARD, "Num Lock", '\0');
register(Keyboard.KEY_PAUSE, GLFW_KEY_PAUSE, 19, DOM_KEY_LOCATION_STANDARD, "Pause", '\0');
register(Keyboard.KEY_F1, GLFW_KEY_F1, 112, DOM_KEY_LOCATION_STANDARD, "F1", '\0');
register(Keyboard.KEY_F2, GLFW_KEY_F2, 113, DOM_KEY_LOCATION_STANDARD, "F2", '\0');
register(Keyboard.KEY_F3, GLFW_KEY_F3, 114, DOM_KEY_LOCATION_STANDARD, "F3", '\0');
register(Keyboard.KEY_F4, GLFW_KEY_F4, 115, DOM_KEY_LOCATION_STANDARD, "F4", '\0');
register(Keyboard.KEY_F5, GLFW_KEY_F5, 116, DOM_KEY_LOCATION_STANDARD, "F5", '\0');
register(Keyboard.KEY_F6, GLFW_KEY_F6, 117, DOM_KEY_LOCATION_STANDARD, "F6", '\0');
register(Keyboard.KEY_F7, GLFW_KEY_F7, 118, DOM_KEY_LOCATION_STANDARD, "F7", '\0');
register(Keyboard.KEY_F8, GLFW_KEY_F8, 119, DOM_KEY_LOCATION_STANDARD, "F8", '\0');
register(Keyboard.KEY_F9, GLFW_KEY_F9, 120, DOM_KEY_LOCATION_STANDARD, "F9", '\0');
register(Keyboard.KEY_F10, GLFW_KEY_F10, 121, DOM_KEY_LOCATION_STANDARD, "F10", '\0');
register(Keyboard.KEY_F11, GLFW_KEY_F11, 122, DOM_KEY_LOCATION_STANDARD, "F11", '\0');
register(Keyboard.KEY_F12, GLFW_KEY_F12, 123, DOM_KEY_LOCATION_STANDARD, "F12", '\0');
register(Keyboard.KEY_NUMPAD0, GLFW_KEY_KP_0, 96, DOM_KEY_LOCATION_NUMPAD, "Keypad 0", '0');
register(Keyboard.KEY_NUMPAD1, GLFW_KEY_KP_1, 97, DOM_KEY_LOCATION_NUMPAD, "Keypad 1", '1');
register(Keyboard.KEY_NUMPAD2, GLFW_KEY_KP_2, 98, DOM_KEY_LOCATION_NUMPAD, "Keypad 2", '2');
register(Keyboard.KEY_NUMPAD3, GLFW_KEY_KP_3, 99, DOM_KEY_LOCATION_NUMPAD, "Keypad 3", '3');
register(Keyboard.KEY_NUMPAD4, GLFW_KEY_KP_4, 100, DOM_KEY_LOCATION_NUMPAD, "Keypad 4", '4');
register(Keyboard.KEY_NUMPAD5, GLFW_KEY_KP_5, 101, DOM_KEY_LOCATION_NUMPAD, "Keypad 5", '5');
register(Keyboard.KEY_NUMPAD6, GLFW_KEY_KP_6, 102, DOM_KEY_LOCATION_NUMPAD, "Keypad 6", '6');
register(Keyboard.KEY_NUMPAD7, GLFW_KEY_KP_7, 103, DOM_KEY_LOCATION_NUMPAD, "Keypad 7", '7');
register(Keyboard.KEY_NUMPAD8, GLFW_KEY_KP_8, 104, DOM_KEY_LOCATION_NUMPAD, "Keypad 8", '8');
register(Keyboard.KEY_NUMPAD9, GLFW_KEY_KP_9, 105, DOM_KEY_LOCATION_NUMPAD, "Keypad 9", '9');
register(Keyboard.KEY_DECIMAL, GLFW_KEY_KP_DECIMAL, 110, DOM_KEY_LOCATION_NUMPAD, "Decimal", '.');
register(Keyboard.KEY_DIVIDE, GLFW_KEY_KP_DIVIDE, 111, DOM_KEY_LOCATION_NUMPAD, "Divide", '/');
register(Keyboard.KEY_MULTIPLY, GLFW_KEY_KP_MULTIPLY, 106, DOM_KEY_LOCATION_NUMPAD, "Multiply", '*');
register(Keyboard.KEY_SUBTRACT, GLFW_KEY_KP_SUBTRACT, 109, DOM_KEY_LOCATION_NUMPAD, "Subtract", '-');
register(Keyboard.KEY_ADD, GLFW_KEY_KP_ADD, 107, DOM_KEY_LOCATION_NUMPAD, "Add", '+');
register(Keyboard.KEY_NUMPADENTER, GLFW_KEY_KP_ENTER, 13, DOM_KEY_LOCATION_NUMPAD, "Enter", '\n');
register(Keyboard.KEY_NUMPADEQUALS, GLFW_KEY_KP_EQUAL, 187, DOM_KEY_LOCATION_NUMPAD, "Equals", '=');
register(Keyboard.KEY_LSHIFT, GLFW_KEY_LEFT_SHIFT, 16, DOM_KEY_LOCATION_LEFT, "L. Shift", '\0');
register(Keyboard.KEY_LCONTROL, GLFW_KEY_LEFT_CONTROL, 17, DOM_KEY_LOCATION_LEFT, "L. Control", '\0');
register(Keyboard.KEY_LMENU, GLFW_KEY_LEFT_ALT, 18, DOM_KEY_LOCATION_LEFT, "L. Alt", '\0');
registerAlt(Keyboard.KEY_LSHIFT, 16, DOM_KEY_LOCATION_STANDARD);
registerAlt(Keyboard.KEY_LCONTROL, 17, DOM_KEY_LOCATION_STANDARD);
registerAlt(Keyboard.KEY_LMENU, 18, DOM_KEY_LOCATION_STANDARD);
register(Keyboard.KEY_RSHIFT, GLFW_KEY_RIGHT_SHIFT, 16, DOM_KEY_LOCATION_RIGHT, "R. Shift", '\0');
register(Keyboard.KEY_RCONTROL, GLFW_KEY_RIGHT_CONTROL, 17, DOM_KEY_LOCATION_RIGHT, "R. Control", '\0');
register(Keyboard.KEY_RMENU, GLFW_KEY_RIGHT_ALT, 18, DOM_KEY_LOCATION_RIGHT, "R. Alt", '\0');
}
public static String getKeyName(int key) {
if (key < 0 || key >= 256 || keyboardNames[key] == null) {
return "Unknown";
} else {
return keyboardNames[key];
}
}
public static int getMinecraftKeyFromGLFW(int key) {
if (key < 0 || key >= 384) {
return 0;
} else {
return keyboardGLFWToMinecraft[key];
}
}
public static int getGLFWKeyFromMinecraft(int key) {
if (key < 0 || key >= 256) {
return 0;
} else {
return keyboardMinecraftToGLFW[key];
}
}
public static int getMinecraftKeyFromBrowser(int key) {
return getMinecraftKeyFromBrowser(key, 0);
}
public static int getMinecraftKeyFromBrowser(int key, int location) {
if (key < 0 || key >= 384) {
return 0;
} else {
if(location <= 0 || location >= 4) {
return keyboardBrowserToMinecraft[key];
}else {
int i = keyboardBrowserToMinecraft[key + location * 384];
if(i == 0) {
i = keyboardBrowserToMinecraft[key];
}
return i;
}
}
}
public static int getBrowserKeyFromMinecraft(int key) {
if (key < 0 || key >= 256) {
return 0;
} else {
return keyboardMinecraftToBrowser[key] % 384;
}
}
public static int getBrowserLocationFromMinecraft(int key) {
if (key < 0 || key >= 384) {
return 0;
} else {
return keyboardMinecraftToBrowser[key] / 384;
}
}
public static char getKeyCharFromMinecraft(int key) {
if (key < 0 || key >= 256) {
return '\0';
} else {
return keyboardChars[key];
}
}
}

View File

@ -1,586 +0,0 @@
package net.PeytonPlayz585.lwjgl;
import static net.PeytonPlayz585.teavm.WebGL2RenderingContext.*;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.nio.charset.Charset;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSObject;
import org.teavm.jso.typedarrays.ArrayBuffer;
import org.teavm.jso.typedarrays.Float32Array;
import org.teavm.jso.typedarrays.Int32Array;
import org.teavm.jso.typedarrays.Uint8Array;
import org.teavm.jso.webgl.WebGLBuffer;
import org.teavm.jso.webgl.WebGLFramebuffer;
import org.teavm.jso.webgl.WebGLProgram;
import org.teavm.jso.webgl.WebGLRenderbuffer;
import org.teavm.jso.webgl.WebGLShader;
import org.teavm.jso.webgl.WebGLTexture;
import org.teavm.jso.webgl.WebGLUniformLocation;
import net.PeytonPlayz585.main.MinecraftMain;
import net.PeytonPlayz585.minecraft.GlStateManager;
import net.PeytonPlayz585.minecraft.MinecraftClient;
import net.PeytonPlayz585.teavm.WebGL2RenderingContext;
import net.PeytonPlayz585.teavm.WebGLQuery;
import net.PeytonPlayz585.teavm.WebGLVertexArray;
public class LWJGL {
static WebGL2RenderingContext webgl = null;
public static final void initWebGL(WebGL2RenderingContext wgl2rc) {
webgl = wgl2rc;
}
public static final String _wgetShaderHeader() {
return "#version 300 es";
}
public static final class TextureGL {
protected final WebGLTexture obj;
public int w = -1;
public int h = -1;
public boolean nearest = true;
public boolean anisotropic = false;
protected TextureGL(WebGLTexture obj) {
this.obj = obj;
}
}
public static final class BufferGL {
protected final WebGLBuffer obj;
protected BufferGL(WebGLBuffer obj) {
this.obj = obj;
}
}
public static final class ShaderGL {
protected final WebGLShader obj;
protected ShaderGL(WebGLShader obj) {
this.obj = obj;
}
}
private static int progId = 0;
public static final class ProgramGL {
protected final WebGLProgram obj;
protected final int hashcode;
protected ProgramGL(WebGLProgram obj) {
this.obj = obj;
this.hashcode = ++progId;
}
}
public static final class UniformGL {
protected final WebGLUniformLocation obj;
protected UniformGL(WebGLUniformLocation obj) {
this.obj = obj;
}
}
public static final class BufferArrayGL {
protected final WebGLVertexArray obj;
public boolean isQuadBufferBound;
protected BufferArrayGL(WebGLVertexArray obj) {
this.obj = obj;
this.isQuadBufferBound = false;
}
}
public static final class FramebufferGL {
protected final WebGLFramebuffer obj;
protected FramebufferGL(WebGLFramebuffer obj) {
this.obj = obj;
}
}
public static final class RenderbufferGL {
protected final WebGLRenderbuffer obj;
protected RenderbufferGL(WebGLRenderbuffer obj) {
this.obj = obj;
}
}
public static final class QueryGL {
protected final WebGLQuery obj;
protected QueryGL(WebGLQuery obj) {
this.obj = obj;
}
}
public static final void _wglEnable(int p1) {
webgl.enable(p1);
}
public static final void _wglClearDepth(float p1) {
webgl.clearDepth(p1);
}
public static final void _wglDepthFunc(int p1) {
webgl.depthFunc(p1);
}
public static final void _wglCullFace(int p1) {
webgl.cullFace(p1);
}
private static int[] viewportCache = new int[4];
public static final void _wglViewport(int p1, int p2, int p3, int p4) {
viewportCache[0] = p1; viewportCache[1] = p2;
viewportCache[2] = p3; viewportCache[3] = p4;
webgl.viewport(p1, p2, p3, p4);
}
public static final void _wglClear(int p1) {
webgl.clear(p1);
}
public static final void _wglClearColor(float p1, float p2, float p3, float p4) {
webgl.clearColor(p1, p2, p3, p4);
}
public static final void _wglDisable(int p1) {
webgl.disable(p1);
}
public static final int _wglGetError() {
return webgl.getError();
}
public static final void _wglFlush() {
//webgl.flush();
}
private static Uint8Array uploadBuffer = Uint8Array.create(ArrayBuffer.create(4 * 1024 * 1024));
public static final void _wglTexImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, ByteBuffer p9) {
if(p9 == null) {
webgl.texImage2D(p1, p2, p3, p4, p5, p6, p7, p8, null);
}else {
int len = p9.remaining();
Uint8Array uploadBuffer1 = uploadBuffer;
for(int i = 0; i < len; ++i) {
uploadBuffer1.set(i, (short) ((int)p9.get() & 0xff));
}
Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len);
webgl.texImage2D(p1, p2, p3, p4, p5, p6, p7, p8, data);
}
}
public static final void _wglBlendFunc(int p1, int p2) {
webgl.blendFunc(p1, p2);
}
public static final void _wglDepthMask(boolean p1) {
webgl.depthMask(p1);
}
public static final void _wglColorMask(boolean p1, boolean p2, boolean p3, boolean p4) {
webgl.colorMask(p1, p2, p3, p4);
}
public static final void _wglBindTexture(int p1, TextureGL p2) {
webgl.bindTexture(p1, p2 == null ? null : p2.obj);
}
public static final void _wglCopyTexSubImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8) {
webgl.copyTexSubImage2D(p1, p2, p3, p4, p5, p6, p7, p8);
}
public static final void _wglTexParameteri(int p1, int p2, int p3) {
webgl.texParameteri(p1, p2, p3);
}
public static final void _wglTexParameterf(int p1, int p2, float p3) {
webgl.texParameterf(p1, p2, p3);
}
public static final void _wglTexImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, IntBuffer p9) {
int len = p9.remaining();
Int32Array deevis = Int32Array.create(uploadBuffer.getBuffer());
for(int i = 0; i < len; ++i) {
deevis.set(i, p9.get());
}
Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len*4);
webgl.texImage2D(p1, p2, p3, p4, p5, p6, p7, p8, data);
}
public static final void _wglTexSubImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, IntBuffer p9) {
int len = p9.remaining();
Int32Array deevis = Int32Array.create(uploadBuffer.getBuffer());
for(int i = 0; i < len; ++i) {
deevis.set(i, p9.get());
}
Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len*4);
webgl.texSubImage2D(p1, p2, p3, p4, p5, p6, p7, p8, data);
}
public static final void _wglDeleteTextures(TextureGL p1) {
webgl.deleteTexture(p1.obj);
}
public static final void _wglDrawArrays(int p1, int p2, int p3) {
webgl.drawArrays(p1, p2, p3);
}
public static final void _wglDrawElements(int p1, int p2, int p3, int p4) {
webgl.drawElements(p1, p2, p3, p4);
}
public static final TextureGL _wglGenTextures() {
return new TextureGL(webgl.createTexture());
}
public static final void _wglTexSubImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, ByteBuffer p9) {
int len = p9.remaining();
for(int i = 0; i < len; ++i) {
uploadBuffer.set(i, (short) ((int)p9.get() & 0xff));
}
Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len);
webgl.texSubImage2D(p1, p2, p3, p4, p5, p6, p7, p8, data);
}
public static final void _wglActiveTexture(int p1) {
webgl.activeTexture(p1);
}
public static final ProgramGL _wglCreateProgram() {
return new ProgramGL(webgl.createProgram());
}
public static final ShaderGL _wglCreateShader(int p1) {
return new ShaderGL(webgl.createShader(p1));
}
public static final void _wglAttachShader(ProgramGL p1, ShaderGL p2) {
webgl.attachShader(p1.obj, p2.obj);
}
public static final void _wglDetachShader(ProgramGL p1, ShaderGL p2) {
webgl.detachShader(p1.obj, p2.obj);
}
public static final void _wglCompileShader(ShaderGL p1) {
webgl.compileShader(p1.obj);
}
public static final void _wglLinkProgram(ProgramGL p1) {
webgl.linkProgram(p1.obj);
}
public static final void _wglShaderSource(ShaderGL p1, String p2) {
webgl.shaderSource(p1.obj, p2);
}
public static final String _wglGetShaderInfoLog(ShaderGL p1) {
return webgl.getShaderInfoLog(p1.obj);
}
public static final String _wglGetProgramInfoLog(ProgramGL p1) {
return webgl.getProgramInfoLog(p1.obj);
}
public static final boolean _wglGetShaderCompiled(ShaderGL p1) {
return webgl.getShaderParameteri(p1.obj, COMPILE_STATUS) == 1;
}
public static final boolean _wglGetProgramLinked(ProgramGL p1) {
return webgl.getProgramParameteri(p1.obj, LINK_STATUS) == 1;
}
public static final void _wglDeleteShader(ShaderGL p1) {
webgl.deleteShader(p1.obj);
}
public static final void _wglDeleteProgram(ProgramGL p1) {
webgl.deleteProgram(p1.obj);
}
public static final BufferGL _wglCreateBuffer() {
return new BufferGL(webgl.createBuffer());
}
public static final void _wglDeleteBuffer(BufferGL p1) {
webgl.deleteBuffer(p1.obj);
}
public static final void _wglBindBuffer(int p1, BufferGL p2) {
webgl.bindBuffer(p1, p2 == null ? null : p2.obj);
}
public static final void _wglBufferData0(int p1, IntBuffer p2, int p3) {
int len = p2.remaining();
Int32Array deevis = Int32Array.create(uploadBuffer.getBuffer());
for(int i = 0; i < len; ++i) {
deevis.set(i, p2.get());
}
Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len*4);
webgl.bufferData(p1, data, p3);
}
public static final void _wglBufferSubData0(int p1, int p2, IntBuffer p3) {
int len = p3.remaining();
Int32Array deevis = Int32Array.create(uploadBuffer.getBuffer());
for(int i = 0; i < len; ++i) {
deevis.set(i, p3.get());
}
Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len*4);
webgl.bufferSubData(p1, p2, data);
}
public static final void _wglBufferData(int p1, Object p2, int p3) {
webgl.bufferData(p1, (Int32Array)p2, p3);
}
public static final void _wglBufferSubData(int p1, int p2, Object p3) {
webgl.bufferSubData(p1, p2, (Int32Array)p3);
}
public static final void _wglBindAttribLocation(ProgramGL p1, int p2, String p3) {
webgl.bindAttribLocation(p1.obj, p2, p3);
}
public static final void _wglEnableVertexAttribArray(int p1) {
webgl.enableVertexAttribArray(p1);
}
public static final void _wglDisableVertexAttribArray(int p1) {
webgl.disableVertexAttribArray(p1);
}
public static final UniformGL _wglGetUniformLocation(ProgramGL p1, String p2) {
WebGLUniformLocation u = webgl.getUniformLocation(p1.obj, p2);
return u == null ? null : new UniformGL(u);
}
public static final void _wglBindAttributeLocation(ProgramGL p1, int p2, String p3) {
webgl.bindAttribLocation(p1.obj, p2, p3);
}
public static final void _wglUniform1f(UniformGL p1, float p2) {
if(p1 != null) webgl.uniform1f(p1.obj, p2);
}
public static final void _wglUniform2f(UniformGL p1, float p2, float p3) {
if(p1 != null) webgl.uniform2f(p1.obj, p2, p3);
}
public static final void _wglUniform3f(UniformGL p1, float p2, float p3, float p4) {
if(p1 != null) webgl.uniform3f(p1.obj, p2, p3, p4);
}
public static final void _wglUniform4f(UniformGL p1, float p2, float p3, float p4, float p5) {
if(p1 != null) webgl.uniform4f(p1.obj, p2, p3, p4, p5);
}
public static final void _wglUniform1i(UniformGL p1, int p2) {
if(p1 != null) webgl.uniform1i(p1.obj, p2);
}
public static final void _wglUniform2i(UniformGL p1, int p2, int p3) {
if(p1 != null) webgl.uniform2i(p1.obj, p2, p3);
}
public static final void _wglUniform3i(UniformGL p1, int p2, int p3, int p4) {
if(p1 != null) webgl.uniform3i(p1.obj, p2, p3, p4);
}
public static final void _wglUniform4i(UniformGL p1, int p2, int p3, int p4, int p5) {
if(p1 != null) webgl.uniform4i(p1.obj, p2, p3, p4, p5);
}
private static Float32Array mat2 = Float32Array.create(4);
private static Float32Array mat3 = Float32Array.create(9);
private static Float32Array mat4 = Float32Array.create(16);
public static final void _wglUniformMat2fv(UniformGL p1, float[] mat) {
mat2.set(mat);
if(p1 != null) webgl.uniformMatrix2fv(p1.obj, false, mat2);
}
public static final void _wglUniformMat3fv(UniformGL p1, float[] mat) {
mat3.set(mat);
if(p1 != null) webgl.uniformMatrix3fv(p1.obj, false, mat3);
}
public static final void _wglUniformMat4fv(UniformGL p1, float[] mat) {
mat4.set(mat);
if(p1 != null) webgl.uniformMatrix4fv(p1.obj, false, mat4);
}
private static int currentProgram = -1;
public static final void _wglUseProgram(ProgramGL p1) {
if(p1 != null && currentProgram != p1.hashcode) {
currentProgram = p1.hashcode;
webgl.useProgram(p1.obj);
}
}
public static final void _wglGetParameter(int p1, int size, int[] ret) {
if(p1 == _wGL_VIEWPORT) {
ret[0] = viewportCache[0];
ret[1] = viewportCache[1];
ret[2] = viewportCache[2];
ret[3] = viewportCache[3];
}
}
public static final void _wglPolygonOffset(float p1, float p2) {
webgl.polygonOffset(p1, p2);
}
public static final void _wglVertexAttribPointer(int p1, int p2, int p3, boolean p4, int p5, int p6) {
webgl.vertexAttribPointer(p1, p2, p3, p4, p5, p6);
}
public static final void _wglBindFramebuffer(int p1, FramebufferGL p2) {
webgl.bindFramebuffer(p1, p2 == null ? null : p2.obj);
}
public static final FramebufferGL _wglCreateFramebuffer() {
return new FramebufferGL(webgl.createFramebuffer());
}
public static final void _wglDeleteFramebuffer(FramebufferGL p1) {
webgl.deleteFramebuffer(p1.obj);
}
public static final void _wglFramebufferTexture2D(int p1, TextureGL p2) {
webgl.framebufferTexture2D(FRAMEBUFFER, p1, TEXTURE_2D, p2 == null ? null : p2.obj, 0);
}
public static final QueryGL _wglCreateQuery() {
return new QueryGL(webgl.createQuery());
}
public static final void _wglBeginQuery(int p1, QueryGL p2) {
webgl.beginQuery(p1, p2.obj);
}
public static final void _wglEndQuery(int p1) {
webgl.endQuery(p1);
}
public static final void _wglDeleteQuery(QueryGL p1) {
webgl.deleteQuery(p1.obj);
}
public static final int _wglGetQueryObjecti(QueryGL p1, int p2) {
return webgl.getQueryParameter(p1.obj, p2);
}
public static final BufferArrayGL _wglCreateVertexArray() {
return new BufferArrayGL(webgl.createVertexArray());
}
public static final void _wglDeleteVertexArray(BufferArrayGL p1) {
webgl.deleteVertexArray(p1.obj);
}
public static final void _wglBindVertexArray(BufferArrayGL p1) {
webgl.bindVertexArray(p1 == null ? null : p1.obj);
}
public static final void _wglDrawBuffer(int p1) {
webgl.drawBuffers(new int[] { p1 });
}
public static final RenderbufferGL _wglCreateRenderBuffer() {
return new RenderbufferGL(webgl.createRenderbuffer());
}
public static final void _wglBindRenderbuffer(RenderbufferGL p1) {
webgl.bindRenderbuffer(RENDERBUFFER, p1 == null ? null : p1.obj);
}
public static final void _wglRenderbufferStorage(int p1, int p2, int p3) {
webgl.renderbufferStorage(RENDERBUFFER, p1, p2, p3);
}
public static final void _wglFramebufferRenderbuffer(int p1, RenderbufferGL p2) {
webgl.framebufferRenderbuffer(FRAMEBUFFER, p1, RENDERBUFFER, p2 == null ? null : p2.obj);
}
public static final void _wglDeleteRenderbuffer(RenderbufferGL p1) {
webgl.deleteRenderbuffer(p1.obj);
}
public static final void _wglRenderbufferStorageMultisample(int p1, int p2, int p3, int p4) {
webgl.renderbufferStorageMultisample(RENDERBUFFER, p1, p2, p3, p4);
}
public static final void _wglBlitFramebuffer(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9, int p10) {
webgl.blitFramebuffer(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
}
public static final int _wglGetAttribLocation(ProgramGL p1, String p2) {
return webgl.getAttribLocation(p1.obj, p2);
}
@JSBody(params = { "ctx", "p" }, script = "return ctx.getTexParameter(0x0DE1, p) | 0;")
private static final native int __wglGetTexParameteri(WebGL2RenderingContext ctx, int p);
public static final int _wglGetTexParameteri(int p1) {
return __wglGetTexParameteri(webgl, p1);
}
@JSBody(params = { "ctx", "p" }, script = "return (0.0 + ctx.getTexParameter(0x0DE1, p));")
private static final native float __wglGetTexParameterf(WebGL2RenderingContext ctx, int p);
public static final float _wglGetTexParameterf(int p1) {
return __wglGetTexParameterf(webgl, p1);
}
public static final int _wArrayByteLength(Object obj) {
return ((Int32Array)obj).getByteLength();
}
public static final Object _wCreateLowLevelIntBuffer(int len) {
return Int32Array.create(len);
}
private static int appendbufferindex = 0;
private static Int32Array appendbuffer = Int32Array.create(ArrayBuffer.create(525000*4));
public static final void _wAppendLowLevelBuffer(Object arr) {
Int32Array a = ((Int32Array)arr);
if(appendbufferindex + a.getLength() < appendbuffer.getLength()) {
appendbuffer.set(a, appendbufferindex);
appendbufferindex += a.getLength();
}
}
public static final Object _wGetLowLevelBuffersAppended() {
Int32Array ret = Int32Array.create(appendbuffer.getBuffer(), 0, appendbufferindex);
appendbufferindex = 0;
return ret;
}
@JSBody(params = { "obj" }, script = "if(obj.commit) obj.commit();")
private static native int commitContext(JSObject obj);
public static final void updateDisplay() {
commitContext(webgl);
MinecraftMain.canvasContext.drawImage(MinecraftMain.canvasBack, 0d, 0d, MinecraftMain.canvas.getWidth(), MinecraftMain.canvas.getHeight());
int ww = MinecraftMain.canvas.getClientWidth();
int hh = MinecraftMain.canvas.getClientHeight();
if(ww != MinecraftMain.width || hh != MinecraftMain.height) {
MinecraftMain.width = ww;
MinecraftMain.height = hh;
MinecraftMain.canvasBack.setWidth(ww);
MinecraftMain.canvasBack.setHeight(hh);
}
try {
Thread.sleep(1l);
} catch (InterruptedException e) {
;
}
}
public static final byte[] loadResourceBytes(String path) {
return MinecraftClient.getResource(path);
}
public static final String fileContents(String path) {
byte[] contents = loadResourceBytes(path);
if(contents == null) {
return null;
}else {
return new String(contents, Charset.forName("UTF-8"));
}
}
public static final int _wGL_TEXTURE_2D = TEXTURE_2D;
public static final int _wGL_DEPTH_TEST = DEPTH_TEST;
public static final int _wGL_LEQUAL = LEQUAL;
public static final int _wGL_GEQUAL = GEQUAL;
public static final int _wGL_GREATER = GREATER;
public static final int _wGL_LESS = LESS;
public static final int _wGL_BACK = BACK;
public static final int _wGL_FRONT = FRONT;
public static final int _wGL_FRONT_AND_BACK = FRONT_AND_BACK;
public static final int _wGL_COLOR_BUFFER_BIT = COLOR_BUFFER_BIT;
public static final int _wGL_DEPTH_BUFFER_BIT = DEPTH_BUFFER_BIT;
public static final int _wGL_BLEND = BLEND;
public static final int _wGL_RGBA = RGBA;
public static final int _wGL_RGB = RGB;
public static final int _wGL_RGB8 = RGB8;
public static final int _wGL_RGBA8 = RGBA8;
public static final int _wGL_UNSIGNED_BYTE = UNSIGNED_BYTE;
public static final int _wGL_UNSIGNED_SHORT = UNSIGNED_SHORT;
public static final int _wGL_SRC_ALPHA = SRC_ALPHA;
public static final int _wGL_ONE_MINUS_SRC_ALPHA = ONE_MINUS_SRC_ALPHA;
public static final int _wGL_ONE_MINUS_DST_COLOR = ONE_MINUS_DST_COLOR;
public static final int _wGL_ONE_MINUS_SRC_COLOR = ONE_MINUS_SRC_COLOR;
public static final int _wGL_ZERO = ZERO;
public static final int _wGL_CULL_FACE = CULL_FACE;
public static final int _wGL_TEXTURE_MIN_FILTER = TEXTURE_MIN_FILTER;
public static final int _wGL_TEXTURE_MAG_FILTER = TEXTURE_MAG_FILTER;
public static final int _wGL_LINEAR = LINEAR;
public static final int _wGL_EQUAL = EQUAL;
public static final int _wGL_SRC_COLOR = SRC_COLOR;
public static final int _wGL_ONE = ONE;
public static final int _wGL_NEAREST = NEAREST;
public static final int _wGL_CLAMP = CLAMP_TO_EDGE;
public static final int _wGL_TEXTURE_WRAP_S = TEXTURE_WRAP_S;
public static final int _wGL_TEXTURE_WRAP_T = TEXTURE_WRAP_T;
public static final int _wGL_REPEAT = REPEAT;
public static final int _wGL_DST_COLOR = DST_COLOR;
public static final int _wGL_DST_ALPHA = DST_ALPHA;
public static final int _wGL_FLOAT = FLOAT;
public static final int _wGL_SHORT = SHORT;
public static final int _wGL_TRIANGLES = TRIANGLES;
public static final int _wGL_TRIANGLE_STRIP = TRIANGLE_STRIP;
public static final int _wGL_TRIANGLE_FAN = TRIANGLE_FAN;
public static final int _wGL_LINE_STRIP = LINE_STRIP;
public static final int _wGL_LINES = LINES;
public static final int _wGL_PACK_ALIGNMENT = PACK_ALIGNMENT;
public static final int _wGL_UNPACK_ALIGNMENT = UNPACK_ALIGNMENT;
public static final int _wGL_TEXTURE0 = TEXTURE0;
public static final int _wGL_TEXTURE1 = TEXTURE1;
public static final int _wGL_TEXTURE2 = TEXTURE2;
public static final int _wGL_TEXTURE3 = TEXTURE3;
public static final int _wGL_VIEWPORT = VIEWPORT;
public static final int _wGL_VERTEX_SHADER = VERTEX_SHADER;
public static final int _wGL_FRAGMENT_SHADER = FRAGMENT_SHADER;
public static final int _wGL_ARRAY_BUFFER = ARRAY_BUFFER;
public static final int _wGL_ELEMENT_ARRAY_BUFFER = ELEMENT_ARRAY_BUFFER;
public static final int _wGL_STATIC_DRAW = STATIC_DRAW;
public static final int _wGL_DYNAMIC_DRAW = DYNAMIC_DRAW;
public static final int _wGL_INVALID_ENUM = INVALID_ENUM;
public static final int _wGL_INVALID_VALUE= INVALID_VALUE;
public static final int _wGL_INVALID_OPERATION = INVALID_OPERATION;
public static final int _wGL_OUT_OF_MEMORY = OUT_OF_MEMORY;
public static final int _wGL_CONTEXT_LOST_WEBGL = CONTEXT_LOST_WEBGL;
public static final int _wGL_FRAMEBUFFER_COMPLETE = FRAMEBUFFER_COMPLETE;
public static final int _wGL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
public static final int _wGL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
public static final int _wGL_COLOR_ATTACHMENT0 = COLOR_ATTACHMENT0;
public static final int _wGL_DEPTH_STENCIL_ATTACHMENT = DEPTH_STENCIL_ATTACHMENT;
public static final int _wGL_DEPTH_STENCIL = DEPTH_STENCIL;
public static final int _wGL_NEAREST_MIPMAP_LINEAR = NEAREST_MIPMAP_LINEAR;
public static final int _wGL_LINEAR_MIPMAP_LINEAR = LINEAR_MIPMAP_LINEAR;
public static final int _wGL_LINEAR_MIPMAP_NEAREST = LINEAR_MIPMAP_NEAREST;
public static final int _wGL_NEAREST_MIPMAP_NEAREST = NEAREST_MIPMAP_NEAREST;
public static final int _wGL_TEXTURE_MAX_LEVEL = TEXTURE_MAX_LEVEL;
public static final int _wGL_UNSIGNED_INT_24_8 = UNSIGNED_INT_24_8;
public static final int _wGL_UNSIGNED_INT = UNSIGNED_INT;
public static final int _wGL_ANY_SAMPLES_PASSED = ANY_SAMPLES_PASSED;
public static final int _wGL_QUERY_RESULT = QUERY_RESULT;
public static final int _wGL_QUERY_RESULT_AVAILABLE = QUERY_RESULT_AVAILABLE;
public static final int _wGL_TEXTURE_MAX_ANISOTROPY = TEXTURE_MAX_ANISOTROPY_EXT;
public static final int _wGL_DEPTH24_STENCIL8 = DEPTH24_STENCIL8;
public static final int _wGL_DEPTH_COMPONENT32F = DEPTH_COMPONENT32F;
public static final int _wGL_DEPTH_ATTACHMENT = DEPTH_ATTACHMENT;
public static final int _wGL_MULTISAMPLE = -1;
public static final int _wGL_LINE_SMOOTH = -1;
public static final int _wGL_READ_FRAMEBUFFER = READ_FRAMEBUFFER;
public static final int _wGL_DRAW_FRAMEBUFFER = DRAW_FRAMEBUFFER;
public static final int _wGL_FRAMEBUFFER = FRAMEBUFFER;
public static final int _wGL_POLYGON_OFFSET_FILL = POLYGON_OFFSET_FILL;
}

View File

@ -1,82 +0,0 @@
package net.PeytonPlayz585.lwjgl;
import org.lwjgl.opengl.GL11;
import org.teavm.interop.Async;
import org.teavm.interop.AsyncCallback;
import org.teavm.jso.canvas.CanvasRenderingContext2D;
import org.teavm.jso.canvas.ImageData;
import org.teavm.jso.dom.events.Event;
import org.teavm.jso.dom.events.EventListener;
import org.teavm.jso.dom.html.HTMLCanvasElement;
import org.teavm.jso.dom.html.HTMLImageElement;
import org.teavm.jso.typedarrays.ArrayBuffer;
import org.teavm.jso.typedarrays.Uint8Array;
import org.teavm.jso.typedarrays.Uint8ClampedArray;
import net.PeytonPlayz585.main.MinecraftMain;
import net.PeytonPlayz585.minecraft.MinecraftImage;
public class LWJGLUtils extends GL11 {
public LWJGLUtils() {
}
public static final MinecraftImage loadPNG(byte[] data) {
ArrayBuffer arr = ArrayBuffer.create(data.length);
Uint8Array.create(arr).set(data);
return loadPNG0(arr);
}
@Async
private static native MinecraftImage loadPNG0(ArrayBuffer data);
private static void loadPNG0(ArrayBuffer data, final AsyncCallback<MinecraftImage> ret) {
final HTMLImageElement toLoad = (HTMLImageElement) MinecraftMain.doc.createElement("img");
toLoad.addEventListener("load", new EventListener<Event>() {
@Override
public void handleEvent(Event evt) {
if(MinecraftMain.imageLoadCanvas == null) {
MinecraftMain.imageLoadCanvas = (HTMLCanvasElement) MinecraftMain.doc.createElement("canvas");
}
if(MinecraftMain.imageLoadCanvas.getWidth() < toLoad.getWidth()) {
MinecraftMain.imageLoadCanvas.setWidth(toLoad.getWidth());
}
if(MinecraftMain.imageLoadCanvas.getHeight() < toLoad.getHeight()) {
MinecraftMain.imageLoadCanvas.setHeight(toLoad.getHeight());
}
if(MinecraftMain.imageLoadContext == null) {
MinecraftMain.imageLoadContext = (CanvasRenderingContext2D) MinecraftMain.imageLoadCanvas.getContext("2d");
}
MinecraftMain.imageLoadContext.clearRect(0, 0, toLoad.getWidth(), toLoad.getHeight());
MinecraftMain.imageLoadContext.drawImage(toLoad, 0, 0, toLoad.getWidth(), toLoad.getHeight());
ImageData pxlsDat = MinecraftMain.imageLoadContext.getImageData(0, 0, toLoad.getWidth(), toLoad.getHeight());
Uint8ClampedArray pxls = pxlsDat.getData();
int totalPixels = pxlsDat.getWidth() * pxlsDat.getHeight();
MinecraftMain.freeDataURL(toLoad.getSrc());
if(pxls.getByteLength() < totalPixels * 4) {
ret.complete(null);
return;
}
int[] pixels = new int[totalPixels];
for(int i = 0; i < pixels.length; ++i) {
pixels[i] = (pxls.get(i * 4) << 16) | (pxls.get(i * 4 + 1) << 8) | pxls.get(i * 4 + 2) | (pxls.get(i * 4 + 3) << 24);
}
ret.complete(new MinecraftImage(pixels, pxlsDat.getWidth(), pxlsDat.getHeight(), true));
}
});
toLoad.addEventListener("error", new EventListener<Event>() {
@Override
public void handleEvent(Event evt) {
MinecraftMain.freeDataURL(toLoad.getSrc());
ret.complete(null);
}
});
String src = MinecraftMain.getDataURL(data, "image/png");
if(src == null) {
ret.complete(null);
}else {
toLoad.setSrc(src);
}
}
}

View File

@ -1,58 +0,0 @@
package net.PeytonPlayz585.lwjgl;
import org.lwjgl.BufferUtils;
import java.nio.FloatBuffer;
/**
* Utility class that emulates immediate mode vertex data submission.
* Can be used to create VBO data.
*/
public final class ModeBuffer {
private FloatBuffer buffer;
public ModeBuffer(final int startSize) {
this.buffer = BufferUtils.createFloatBuffer(startSize);
}
private void checkSize(final int count) {
while ( buffer.remaining() < count ) {
final FloatBuffer newBuffer = BufferUtils.createFloatBuffer(buffer.capacity() << 1);
buffer.flip();
newBuffer.put(buffer);
buffer = newBuffer;
}
}
public FloatBuffer getBuffer() {
buffer.flip();
return buffer;
}
public void glVertex2f(final float x, final float y) {
checkSize(2);
buffer.put(x).put(y);
}
public void glVertex3f(final float x, final float y, final float z) {
checkSize(3);
buffer.put(x).put(y).put(z);
}
public void glVertex4f(final float x, final float y, final float z, final float w) {
checkSize(4);
buffer.put(x).put(y).put(z).put(w);
}
public void glNormal3f(final float x, final float y, final float z) {
checkSize(3);
buffer.put(x).put(y).put(z);
}
public void glTexCoord2f(final float s, final float t) {
checkSize(2);
buffer.put(s).put(t);
}
}

View File

@ -1,507 +0,0 @@
package net.PeytonPlayz585.lwjgl;
import java.util.LinkedList;
import java.util.List;
import org.lwjgl.input.Keyboard;
import org.teavm.jso.JSBody;
import org.teavm.jso.browser.TimerHandler;
import org.teavm.jso.browser.Window;
import org.teavm.jso.dom.events.EventListener;
import org.teavm.jso.dom.events.KeyboardEvent;
import org.teavm.jso.dom.events.MouseEvent;
import org.teavm.jso.dom.events.WheelEvent;
import org.teavm.jso.dom.html.HTMLCanvasElement;
import org.teavm.jso.webgl.WebGLFramebuffer;
import org.teavm.jso.webgl.WebGLRenderbuffer;
import net.PeytonPlayz585.main.MinecraftMain;
import net.PeytonPlayz585.teavm.WebGL2RenderingContext;
import static net.PeytonPlayz585.teavm.WebGL2RenderingContext.*;
/**
* Copyright (c) 2022 LAX1DUDE. All Rights Reserved.
*
* WITH THE EXCEPTION OF PATCH FILES, MINIFIED JAVASCRIPT, AND ALL FILES
* NORMALLY FOUND IN AN UNMODIFIED MINECRAFT RESOURCE PACK, YOU ARE NOT ALLOWED
* TO SHARE, DISTRIBUTE, OR REPURPOSE ANY FILE USED BY OR PRODUCED BY THE
* SOFTWARE IN THIS REPOSITORY WITHOUT PRIOR PERMISSION FROM THE PROJECT AUTHOR.
*
* NOT FOR COMMERCIAL OR MALICIOUS USE
*
* (please read the 'LICENSE' file this repo's root directory for more info)
*
*/
public class PlatformInput {
static WebGLFramebuffer mainFramebuffer = null;
static WebGLRenderbuffer mainColorRenderbuffer = null;
static WebGLRenderbuffer mainDepthRenderbuffer = null;
private static int framebufferWidth = -1;
private static int framebufferHeight = -1;
private static EventListener contextmenu = null;
private static EventListener mousedown = null;
private static EventListener mouseup = null;
private static EventListener mousemove = null;
private static EventListener mouseenter = null;
private static EventListener mouseleave = null;
private static EventListener keydown = null;
private static EventListener keyup = null;
private static EventListener keypress = null;
private static EventListener wheel = null;
private static EventListener pointerlock = null;
private static List<MouseEvent> mouseEvents = new LinkedList();
private static List<KeyboardEvent> keyEvents = new LinkedList();
private static int mouseX = 0;
private static int mouseY = 0;
private static double mouseDX = 0.0D;
private static double mouseDY = 0.0D;
private static double mouseDWheel = 0.0D;
private static int width = 0;
private static int height = 0;
private static boolean enableRepeatEvents = true;
private static boolean isWindowFocused = true;
private static boolean isMouseOverWindow = true;
static boolean unpressCTRL = false;
private static int windowWidth = -1;
private static int windowHeight = -1;
private static int lastWasResizedWindowWidth = -2;
private static int lastWasResizedWindowHeight = -2;
private static MouseEvent currentEvent = null;
private static KeyboardEvent currentEventK = null;
private static boolean[] buttonStates = new boolean[8];
private static boolean[] keyStates = new boolean[256];
private static int functionKeyModifier = Keyboard.KEY_F;
private static long mouseUngrabTimer = 0l;
private static long mouseGrabTimer = 0l;
private static int mouseUngrabTimeout = -1;
private static boolean pointerLockFlag = false;
@JSBody(params = { }, script = "window.onbeforeunload = () => {return false;};")
private static native void onBeforeCloseRegister();
public static void initHooks() {
MinecraftMain.win.addEventListener("contextmenu", contextmenu = new EventListener<MouseEvent>() {
@Override
public void handleEvent(MouseEvent evt) {
evt.preventDefault();
evt.stopPropagation();
}
});
MinecraftMain.canvas.addEventListener("mousedown", mousedown = new EventListener<MouseEvent>() {
@Override
public void handleEvent(MouseEvent evt) {
evt.preventDefault();
evt.stopPropagation();
int b = evt.getButton();
buttonStates[b == 1 ? 2 : (b == 2 ? 1 : b)] = true;
mouseEvents.add(evt);
}
});
MinecraftMain.canvas.addEventListener("mouseup", mouseup = new EventListener<MouseEvent>() {
@Override
public void handleEvent(MouseEvent evt) {
evt.preventDefault();
evt.stopPropagation();
int b = evt.getButton();
buttonStates[b == 1 ? 2 : (b == 2 ? 1 : b)] = false;
mouseEvents.add(evt);
}
});
MinecraftMain.canvas.addEventListener("mousemove", mousemove = new EventListener<MouseEvent>() {
@Override
public void handleEvent(MouseEvent evt) {
evt.preventDefault();
evt.stopPropagation();
mouseX = (int)(getOffsetX(evt) * MinecraftMain.win.getDevicePixelRatio());
mouseY = (int)((MinecraftMain.canvas.getClientHeight() - getOffsetY(evt)) * MinecraftMain.win.getDevicePixelRatio());
mouseDX += evt.getMovementX();
mouseDY += -evt.getMovementY();
if(hasBeenActive()) {
mouseEvents.add(evt);
}
}
});
MinecraftMain.canvas.addEventListener("mouseenter", mouseenter = new EventListener<MouseEvent>() {
@Override
public void handleEvent(MouseEvent evt) {
isMouseOverWindow = true;
}
});
MinecraftMain.canvas.addEventListener("mouseleave", mouseleave = new EventListener<MouseEvent>() {
@Override
public void handleEvent(MouseEvent evt) {
isMouseOverWindow = false;
}
});
MinecraftMain.win.addEventListener("keydown", keydown = new EventListener<KeyboardEvent>() {
@Override
public void handleEvent(KeyboardEvent evt) {
int w = getWhich(evt);
if (w == 122) return; // F11
evt.preventDefault();
evt.stopPropagation();
if(!enableRepeatEvents && evt.isRepeat()) return;
w = processFunctionKeys(w);
keyStates[KeyboardConstants.getMinecraftKeyFromBrowser(w, evt.getLocation())] = true;
keyEvents.add(evt);
}
});
MinecraftMain.win.addEventListener("keyup", keyup = new EventListener<KeyboardEvent>() {
@Override
public void handleEvent(KeyboardEvent evt) {
int w = getWhich(evt);
if (w == 122) return; // F11
evt.preventDefault();
evt.stopPropagation();
if(!enableRepeatEvents && evt.isRepeat()) return;
w = processFunctionKeys(w);
keyStates[KeyboardConstants.getMinecraftKeyFromBrowser(w, evt.getLocation())] = false;
keyEvents.add(evt);
}
});
MinecraftMain.win.addEventListener("keypress", keypress = new EventListener<KeyboardEvent>() {
@Override
public void handleEvent(KeyboardEvent evt) {
evt.preventDefault();
evt.stopPropagation();
if(enableRepeatEvents && evt.isRepeat()) keyEvents.add(evt);
}
});
MinecraftMain.canvas.addEventListener("wheel", wheel = new EventListener<WheelEvent>() {
@Override
public void handleEvent(WheelEvent evt) {
evt.preventDefault();
evt.stopPropagation();
mouseEvents.add(evt);
mouseDWheel += evt.getDeltaY();
}
});
MinecraftMain.win.addEventListener("blur", new EventListener<WheelEvent>() {
@Override
public void handleEvent(WheelEvent evt) {
isWindowFocused = false;
for(int i = 0; i < buttonStates.length; ++i) {
buttonStates[i] = false;
}
for(int i = 0; i < keyStates.length; ++i) {
keyStates[i] = false;
}
}
});
MinecraftMain.win.addEventListener("focus", new EventListener<WheelEvent>() {
@Override
public void handleEvent(WheelEvent evt) {
isWindowFocused = true;
}
});
MinecraftMain.win.getDocument().addEventListener("pointerlockchange", pointerlock = new EventListener<WheelEvent>() {
@Override
public void handleEvent(WheelEvent evt) {
Window.setTimeout(new TimerHandler() {
@Override
public void onTimer() {
boolean grab = isPointerLocked();
if(!grab) {
if(pointerLockFlag) {
mouseUngrabTimer = System.currentTimeMillis();
}
}
pointerLockFlag = grab;
}
}, 60);
mouseDX = 0.0D;
mouseDY = 0.0D;
}
});
onBeforeCloseRegister();
}
@JSBody(params = { }, script = "if(window.navigator.userActivation){return window.navigator.userActivation.hasBeenActive;}else{return false;}")
public static native boolean hasBeenActive();
@JSBody(params = { "m" }, script = "return m.offsetX;")
private static native int getOffsetX(MouseEvent m);
@JSBody(params = { "m" }, script = "return m.offsetY;")
private static native int getOffsetY(MouseEvent m);
@JSBody(params = { "e" }, script = "return e.which;")
private static native int getWhich(KeyboardEvent e);
public static int getWindowWidth() {
return windowWidth;
}
public static int getWindowHeight() {
return windowHeight;
}
public static boolean getWindowFocused() {
return isWindowFocused || isPointerLocked();
}
public static boolean isCloseRequested() {
return false;
}
public static void update() {
double r = MinecraftMain.win.getDevicePixelRatio();
int w = MinecraftMain.parent.getClientWidth();
int h = MinecraftMain.parent.getClientHeight();
int w2 = windowWidth = (int)(w * r);
int h2 = windowHeight = (int)(h * r);
if(MinecraftMain.canvas.getWidth() != w2) {
MinecraftMain.canvas.setWidth(w2);
}
if(MinecraftMain.canvas.getHeight() != h2) {
MinecraftMain.canvas.setHeight(h2);
}
flipBuffer();
MinecraftMain.sleep(1l);
}
public static void initFramebuffer(WebGLFramebuffer fbo, int sw, int sh) {
mainFramebuffer = fbo;
framebufferWidth = windowWidth = sw;
framebufferHeight = windowHeight = sh;
MinecraftMain.webgl.bindFramebuffer(FRAMEBUFFER, fbo);
mainColorRenderbuffer = MinecraftMain.webgl.createRenderbuffer();
mainDepthRenderbuffer = MinecraftMain.webgl.createRenderbuffer();
MinecraftMain.webgl.bindRenderbuffer(RENDERBUFFER, mainColorRenderbuffer);
MinecraftMain.webgl.renderbufferStorage(RENDERBUFFER, RGBA8, sw, sh);
MinecraftMain.webgl.framebufferRenderbuffer(FRAMEBUFFER, COLOR_ATTACHMENT0, RENDERBUFFER, mainColorRenderbuffer);
MinecraftMain.webgl.bindRenderbuffer(RENDERBUFFER, mainDepthRenderbuffer);
MinecraftMain.webgl.renderbufferStorage(RENDERBUFFER, DEPTH_COMPONENT32F, sw, sh);
MinecraftMain.webgl.framebufferRenderbuffer(FRAMEBUFFER, DEPTH_ATTACHMENT, RENDERBUFFER, mainDepthRenderbuffer);
MinecraftMain.webgl.drawBuffers(new int[] { COLOR_ATTACHMENT0 });
}
private static void flipBuffer() {
MinecraftMain.webgl.bindFramebuffer(READ_FRAMEBUFFER, mainFramebuffer);
MinecraftMain.webgl.bindFramebuffer(DRAW_FRAMEBUFFER, null);
MinecraftMain.webgl.blitFramebuffer(0, 0, framebufferWidth, framebufferHeight, 0, 0, windowWidth, windowHeight, COLOR_BUFFER_BIT, NEAREST);
MinecraftMain.webgl.bindFramebuffer(FRAMEBUFFER, mainFramebuffer);
if(windowWidth != framebufferWidth || windowHeight != framebufferHeight) {
framebufferWidth = windowWidth;
framebufferHeight = windowHeight;
MinecraftMain.webgl.bindRenderbuffer(RENDERBUFFER, mainColorRenderbuffer);
MinecraftMain.webgl.renderbufferStorage(RENDERBUFFER, RGBA8, framebufferWidth, framebufferHeight);
MinecraftMain.webgl.bindRenderbuffer(RENDERBUFFER, mainDepthRenderbuffer);
MinecraftMain.webgl.renderbufferStorage(RENDERBUFFER, DEPTH_COMPONENT32F, framebufferWidth, framebufferHeight);
}
}
public static boolean wasResized() {
if(windowWidth != lastWasResizedWindowWidth || windowHeight != lastWasResizedWindowHeight) {
lastWasResizedWindowWidth = windowWidth;
lastWasResizedWindowHeight = windowHeight;
return true;
}else {
return false;
}
}
public static boolean keyboardNext() {
if(unpressCTRL) { //un-press ctrl after copy/paste permission
keyEvents.clear();
currentEventK = null;
keyStates[29] = false;
keyStates[157] = false;
keyStates[28] = false;
keyStates[219] = false;
keyStates[220] = false;
unpressCTRL = false;
return false;
}
currentEventK = null;
return !keyEvents.isEmpty() && (currentEventK = keyEvents.remove(0)) != null;
}
public static boolean keyboardGetEventKeyState() {
return currentEventK == null? false : !currentEventK.getType().equals("keyup");
}
public static int keyboardGetEventKey() {
int w = processFunctionKeys(getWhich(currentEventK));
return currentEventK == null ? -1 : KeyboardConstants.getMinecraftKeyFromBrowser(w, currentEventK.getLocation());
}
public static char keyboardGetEventCharacter() {
if(currentEventK == null) return '\0';
String s = currentEventK.getKey();
return currentEventK == null ? ' ' : (char) (s.length() > 1 ? '\0' : s.charAt(0));
}
public static boolean keyboardIsKeyDown(int key) {
if(unpressCTRL) { //un-press ctrl after copy/paste permission
keyStates[28] = false;
keyStates[29] = false;
keyStates[157] = false;
keyStates[219] = false;
keyStates[220] = false;
}
return key < 0 || key >= keyStates.length ? false : keyStates[key];
}
public static boolean keyboardIsRepeatEvent() {
return currentEventK == null ? false : currentEventK.isRepeat();
}
public static void keyboardEnableRepeatEvents(boolean b) {
enableRepeatEvents = b;
}
public static boolean mouseNext() {
currentEvent = null;
return !mouseEvents.isEmpty() && (currentEvent = mouseEvents.remove(0)) != null;
}
public static boolean mouseGetEventButtonState() {
return currentEvent == null ? false : currentEvent.getType().equals(MouseEvent.MOUSEDOWN);
}
public static int mouseGetEventButton() {
if(currentEvent == null || currentEvent.getType().equals(MouseEvent.MOUSEMOVE)) return -1;
int b = currentEvent.getButton();
return b == 1 ? 2 : (b == 2 ? 1 : b);
}
public static int mouseGetEventX() {
return currentEvent == null ? -1 : (int)(currentEvent.getClientX() * MinecraftMain.win.getDevicePixelRatio());
}
public static int mouseGetEventY() {
return currentEvent == null ? -1 : (int)((MinecraftMain.canvas.getClientHeight() - currentEvent.getClientY()) * MinecraftMain.win.getDevicePixelRatio());
}
public static int mouseGetEventDWheel() {
return ("wheel".equals(currentEvent.getType())) ? (((WheelEvent)currentEvent).getDeltaY() == 0.0D ? 0 : (((WheelEvent)currentEvent).getDeltaY() > 0.0D ? -1 : 1)) : 0;
}
public static int mouseGetX() {
return mouseX;
}
public static int mouseGetY() {
return mouseY;
}
public static boolean mouseIsButtonDown(int i) {
return buttonStates[i];
}
public static int mouseGetDWheel() {
int ret = (int)mouseDWheel;
mouseDWheel = 0.0D;
return ret;
}
public static void mouseSetGrabbed(boolean grab) {
long t = System.currentTimeMillis();
pointerLockFlag = grab;
mouseGrabTimer = t;
if(grab) {
MinecraftMain.canvas.requestPointerLock();
if(mouseUngrabTimeout != -1) Window.clearTimeout(mouseUngrabTimeout);
mouseUngrabTimeout = -1;
if(t - mouseUngrabTimer < 3000l) {
mouseUngrabTimeout = Window.setTimeout(new TimerHandler() {
@Override
public void onTimer() {
MinecraftMain.canvas.requestPointerLock();
}
}, 3100 - (int)(t - mouseUngrabTimer));
}
}else {
if(mouseUngrabTimeout != -1) Window.clearTimeout(mouseUngrabTimeout);
mouseUngrabTimeout = -1;
Window.current().getDocument().exitPointerLock();
}
mouseDX = 0.0D;
mouseDY = 0.0D;
}
public static boolean isMouseGrabbed() {
return pointerLockFlag;
}
@JSBody(params = { }, script = "return document.pointerLockElement != null;")
public static native boolean isPointerLocked();
public static int mouseGetDX() {
int ret = (int)mouseDX;
mouseDX = 0.0D;
return ret;
}
public static int mouseGetDY() {
int ret = (int)mouseDY;
mouseDY = 0.0D;
return ret;
}
public static void mouseSetCursorPosition(int x, int y) {
// obsolete
}
public static boolean mouseIsInsideWindow() {
return isMouseOverWindow;
}
private static int processFunctionKeys(int key) {
if(keyboardIsKeyDown(functionKeyModifier)) {
if(key >= 49 && key <= 57) {
key = key - 49 + 112;
}
}
return key;
}
public static void setFunctionKeyModifier(int key) {
functionKeyModifier = key;
}
public static void removeEventHandlers() {
MinecraftMain.win.removeEventListener("contextmenu", contextmenu);
MinecraftMain.canvas.removeEventListener("mousedown", mousedown);
MinecraftMain.canvas.removeEventListener("mouseup", mouseup);
MinecraftMain.canvas.removeEventListener("mousemove", mousemove);
MinecraftMain.canvas.removeEventListener("mouseenter", mouseenter);
MinecraftMain.canvas.removeEventListener("mouseleave", mouseleave);
MinecraftMain.win.removeEventListener("keydown", keydown);
MinecraftMain.win.removeEventListener("keyup", keyup);
MinecraftMain.win.removeEventListener("keypress", keypress);
MinecraftMain.canvas.removeEventListener("wheel", wheel);
MinecraftMain.win.getDocument().removeEventListener("pointerlockchange", pointerlock);
if(mouseUngrabTimeout != -1) {
Window.clearTimeout(mouseUngrabTimeout);
mouseUngrabTimeout = -1;
}
}
public static void clearEvenBuffers() {
mouseEvents.clear();
keyEvents.clear();
}
}

View File

@ -1,192 +0,0 @@
package net.PeytonPlayz585.main;
import java.io.IOException;
import org.lwjgl.opengl.GL11;
import org.teavm.interop.Async;
import org.teavm.interop.AsyncCallback;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSObject;
import org.teavm.jso.ajax.ReadyStateChangeHandler;
import org.teavm.jso.ajax.XMLHttpRequest;
import org.teavm.jso.browser.Window;
import org.teavm.jso.canvas.CanvasRenderingContext2D;
import org.teavm.jso.dom.html.HTMLCanvasElement;
import org.teavm.jso.dom.html.HTMLDocument;
import org.teavm.jso.dom.html.HTMLElement;
import org.teavm.jso.typedarrays.ArrayBuffer;
import org.teavm.jso.typedarrays.Uint8Array;
import org.teavm.jso.webgl.WebGLFramebuffer;
import org.teavm.jso.webgl.WebGLRenderingContext;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.SessionData;
import net.PeytonPlayz585.lwjgl.PlatformInput;
import net.PeytonPlayz585.minecraft.MinecraftClient;
import net.PeytonPlayz585.teavm.WebGL2RenderingContext;
public class MinecraftMain {
public static Window win = null;
public static HTMLCanvasElement canvas = null;
public static HTMLElement rootElement = null;
public static WebGL2RenderingContext webgl = null;
public static HTMLElement parent = null;
public static HTMLDocument doc = null;
public static CanvasRenderingContext2D canvasContext = null;
public static HTMLCanvasElement canvasBack = null;
public static HTMLCanvasElement imageLoadCanvas = null;
public static CanvasRenderingContext2D imageLoadContext = null;
private static byte[] loadedPackage = null;
static WebGLFramebuffer mainFramebuffer = null;
public static int width = 0;
public static int height = 0;
public static void main(String args[]) {
String[] element = getClassicConfig();
try {
initContext(rootElement = Window.current().getDocument().getElementById(element[0]), element[1]);
} catch (Exception e) {
e.printStackTrace();
}
}
public final static void initContext(HTMLElement rootElement, String assetsURI) throws Exception {
parent = rootElement;
String s = parent.getAttribute("style");
parent.setAttribute("style", (s == null ? "" : s)+"overflow-x:hidden;overflow-y:hidden;");
win = Window.current();
doc = win.getDocument();
canvas = (HTMLCanvasElement)doc.createElement("canvas");
width = rootElement.getClientWidth();
height = rootElement.getClientHeight();
canvas.setWidth(width);
canvas.setHeight(height);
canvasContext = (CanvasRenderingContext2D) canvas.getContext("2d");
canvas.setAttribute("id", "minecraftClassicBrowser");
rootElement.appendChild(canvas);
canvasBack = (HTMLCanvasElement)doc.createElement("canvas");
imageLoadCanvas = (HTMLCanvasElement) doc.createElement("canvas");
imageLoadContext = (CanvasRenderingContext2D) imageLoadCanvas.getContext("2d");
double r = win.getDevicePixelRatio();
int iw = parent.getClientWidth();
int ih = parent.getClientHeight();
int sw = (int)(r * iw);
int sh = (int)(r * ih);
canvasBack.setWidth(width);
canvasBack.setHeight(height);
try {
PlatformInput.initHooks();
}catch(Throwable t) {
throw new Exception("Exception while registering window event handlers");
}
try {
doc.exitPointerLock();
}catch(Throwable t) {
throw new Exception("Mouse cursor lock is not available on this device!");
}
webgl = (WebGL2RenderingContext) canvasBack.getContext("webgl2");
if(webgl == null) {
throw new RuntimeException("WebGL 2.0 is not supported in your browser, please get a new one!");
}
setCurrentContext(webgl);
GL11.initWebGL(webgl);
mainFramebuffer = webgl.createFramebuffer();
PlatformInput.initFramebuffer(mainFramebuffer, sw, sh);
webgl.getExtension("EXT_texture_filter_anisotropic");
downloadAssetPack(assetsURI);
try {
MinecraftClient.install(loadedPackage);
} catch (IOException e) {
e.printStackTrace();
}
//Start Game
Minecraft minecraft = new Minecraft(canvas.getWidth(), canvas.getHeight(), true);
//minecraft.host = "127.0.0.1:25565";
minecraft.session = new SessionData("PeytonPlayz585", "TeaVM-WebGL");
minecraft.levelLoaded = true;
canvas.focus();
Thread thread = null;
thread = new Thread(minecraft);
thread.start();
minecraft.waiting = false;
}
@Async
public static native String downloadAssetPack(String assetPackageURI);
private static void downloadAssetPack(String assetPackageURI, final AsyncCallback<String> cb) {
final XMLHttpRequest request = XMLHttpRequest.create();
request.setResponseType("arraybuffer");
request.open("GET", assetPackageURI, true);
request.setOnReadyStateChange(new ReadyStateChangeHandler() {
@Override
public void stateChanged() {
if(request.getReadyState() == XMLHttpRequest.DONE) {
Uint8Array bl = Uint8Array.create((ArrayBuffer)request.getResponse());
loadedPackage = new byte[bl.getByteLength()];
for(int i = 0; i < loadedPackage.length; ++i) {
loadedPackage[i] = (byte) bl.get(i);
}
cb.complete("yee");
}
}
});
request.send();
}
public static final int getCanvasWidth() {
int w = parent.getClientWidth();
if(w != width) {
canvas.setWidth(w);
canvasBack.setWidth(w);
width = w;
}
return w;
}
public static final int getCanvasHeight() {
int h = parent.getClientHeight();
if(h != height) {
canvas.setHeight(h);
canvasBack.setHeight(h);
height = h;
}
return h;
}
public static void sleep(long millis) {
try {
Thread.sleep(millis);
}catch(InterruptedException ex) {
}
}
@JSBody(params = { "obj" }, script = "window.currentContext = obj;")
private static native int setCurrentContext(JSObject obj);
@JSBody(params = { }, script = "return window.classicConfig;")
public static native String[] getClassicConfig();
@JSBody(params = { "obj" }, script = "if(obj.commit) obj.commit();")
public static native int commitContext(JSObject obj);
@JSBody(params = { "url" }, script = "URL.revokeObjectURL(url);")
public static native void freeDataURL(String url);
@JSBody(params = { "buf", "mime" }, script = "return URL.createObjectURL(new Blob([buf], {type: mime}));")
public static native String getDataURL(ArrayBuffer buf, String mime);
}

View File

@ -1,23 +0,0 @@
package org.lwjgl;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import net.PeytonPlayz585.minecraft.GLAllocation;
public class BufferUtils {
public static ByteBuffer createByteBuffer(int parInt) {
return GLAllocation.createDirectByteBuffer(parInt);
}
public static IntBuffer createIntBuffer(int parInt) {
return GLAllocation.createDirectIntBuffer(parInt);
}
public static FloatBuffer createFloatBuffer(int parInt) {
return GLAllocation.createDirectFloatBuffer(parInt);
}
}

View File

@ -1,193 +0,0 @@
package org.lwjgl.input;
import net.PeytonPlayz585.lwjgl.KeyboardConstants;
import net.PeytonPlayz585.lwjgl.PlatformInput;
/**
* Copyright (c) 2022 LAX1DUDE. All Rights Reserved.
*
* WITH THE EXCEPTION OF PATCH FILES, MINIFIED JAVASCRIPT, AND ALL FILES
* NORMALLY FOUND IN AN UNMODIFIED MINECRAFT RESOURCE PACK, YOU ARE NOT ALLOWED
* TO SHARE, DISTRIBUTE, OR REPURPOSE ANY FILE USED BY OR PRODUCED BY THE
* SOFTWARE IN THIS REPOSITORY WITHOUT PRIOR PERMISSION FROM THE PROJECT AUTHOR.
*
* NOT FOR COMMERCIAL OR MALICIOUS USE
*
* (please read the 'LICENSE' file this repo's root directory for more info)
*
*/
public class Keyboard {
public static final int KEY_NONE = 0x00;
public static final int KEY_ESCAPE = 0x01;
public static final int KEY_1 = 0x02;
public static final int KEY_2 = 0x03;
public static final int KEY_3 = 0x04;
public static final int KEY_4 = 0x05;
public static final int KEY_5 = 0x06;
public static final int KEY_6 = 0x07;
public static final int KEY_7 = 0x08;
public static final int KEY_8 = 0x09;
public static final int KEY_9 = 0x0A;
public static final int KEY_0 = 0x0B;
public static final int KEY_MINUS = 0x0C; /* - on main keyboard */
public static final int KEY_EQUALS = 0x0D;
public static final int KEY_BACK = 0x0E; /* backspace */
public static final int KEY_TAB = 0x0F;
public static final int KEY_Q = 0x10;
public static final int KEY_W = 0x11;
public static final int KEY_E = 0x12;
public static final int KEY_R = 0x13;
public static final int KEY_T = 0x14;
public static final int KEY_Y = 0x15;
public static final int KEY_U = 0x16;
public static final int KEY_I = 0x17;
public static final int KEY_O = 0x18;
public static final int KEY_P = 0x19;
public static final int KEY_LBRACKET = 0x1A;
public static final int KEY_RBRACKET = 0x1B;
public static final int KEY_RETURN = 0x1C; /* Enter on main keyboard */
public static final int KEY_LCONTROL = 0x1D;
public static final int KEY_A = 0x1E;
public static final int KEY_S = 0x1F;
public static final int KEY_D = 0x20;
public static final int KEY_F = 0x21;
public static final int KEY_G = 0x22;
public static final int KEY_H = 0x23;
public static final int KEY_J = 0x24;
public static final int KEY_K = 0x25;
public static final int KEY_L = 0x26;
public static final int KEY_SEMICOLON = 0x27;
public static final int KEY_APOSTROPHE = 0x28;
public static final int KEY_GRAVE = 0x29; /* accent grave */
public static final int KEY_LSHIFT = 0x2A;
public static final int KEY_BACKSLASH = 0x2B;
public static final int KEY_Z = 0x2C;
public static final int KEY_X = 0x2D;
public static final int KEY_C = 0x2E;
public static final int KEY_V = 0x2F;
public static final int KEY_B = 0x30;
public static final int KEY_N = 0x31;
public static final int KEY_M = 0x32;
public static final int KEY_COMMA = 0x33;
public static final int KEY_PERIOD = 0x34; /* . on main keyboard */
public static final int KEY_SLASH = 0x35; /* / on main keyboard */
public static final int KEY_RSHIFT = 0x36;
public static final int KEY_MULTIPLY = 0x37; /* * on numeric keypad */
public static final int KEY_LMENU = 0x38; /* left Alt */
public static final int KEY_SPACE = 0x39;
public static final int KEY_CAPITAL = 0x3A;
public static final int KEY_F1 = 0x3B;
public static final int KEY_F2 = 0x3C;
public static final int KEY_F3 = 0x3D;
public static final int KEY_F4 = 0x3E;
public static final int KEY_F5 = 0x3F;
public static final int KEY_F6 = 0x40;
public static final int KEY_F7 = 0x41;
public static final int KEY_F8 = 0x42;
public static final int KEY_F9 = 0x43;
public static final int KEY_F10 = 0x44;
public static final int KEY_NUMLOCK = 0x45;
public static final int KEY_SCROLL = 0x46; /* Scroll Lock */
public static final int KEY_NUMPAD7 = 0x47;
public static final int KEY_NUMPAD8 = 0x48;
public static final int KEY_NUMPAD9 = 0x49;
public static final int KEY_SUBTRACT = 0x4A; /* - on numeric keypad */
public static final int KEY_NUMPAD4 = 0x4B;
public static final int KEY_NUMPAD5 = 0x4C;
public static final int KEY_NUMPAD6 = 0x4D;
public static final int KEY_ADD = 0x4E; /* + on numeric keypad */
public static final int KEY_NUMPAD1 = 0x4F;
public static final int KEY_NUMPAD2 = 0x50;
public static final int KEY_NUMPAD3 = 0x51;
public static final int KEY_NUMPAD0 = 0x52;
public static final int KEY_DECIMAL = 0x53; /* . on numeric keypad */
public static final int KEY_F11 = 0x57;
public static final int KEY_F12 = 0x58;
public static final int KEY_F13 = 0x64; /* (NEC PC98) */
public static final int KEY_F14 = 0x65; /* (NEC PC98) */
public static final int KEY_F15 = 0x66; /* (NEC PC98) */
public static final int KEY_F16 = 0x67; /* Extended Function keys - (Mac) */
public static final int KEY_F17 = 0x68;
public static final int KEY_F18 = 0x69;
public static final int KEY_KANA = 0x70; /* (Japanese keyboard) */
public static final int KEY_F19 = 0x71; /* Extended Function keys - (Mac) */
public static final int KEY_CONVERT = 0x79; /* (Japanese keyboard) */
public static final int KEY_NOCONVERT = 0x7B; /* (Japanese keyboard) */
public static final int KEY_YEN = 0x7D; /* (Japanese keyboard) */
public static final int KEY_NUMPADEQUALS = 0x8D; /* = on numeric keypad (NEC PC98) */
public static final int KEY_CIRCUMFLEX = 0x90; /* (Japanese keyboard) */
public static final int KEY_AT = 0x91; /* (NEC PC98) */
public static final int KEY_COLON = 0x92; /* (NEC PC98) */
public static final int KEY_UNDERLINE = 0x93; /* (NEC PC98) */
public static final int KEY_KANJI = 0x94; /* (Japanese keyboard) */
public static final int KEY_STOP = 0x95; /* (NEC PC98) */
public static final int KEY_AX = 0x96; /* (Japan AX) */
public static final int KEY_UNLABELED = 0x97; /* (J3100) */
public static final int KEY_NUMPADENTER = 0x9C; /* Enter on numeric keypad */
public static final int KEY_RCONTROL = 0x9D;
public static final int KEY_SECTION = 0xA7; /* Section symbol (Mac) */
public static final int KEY_NUMPADCOMMA = 0xB3; /* , on numeric keypad (NEC PC98) */
public static final int KEY_DIVIDE = 0xB5; /* / on numeric keypad */
public static final int KEY_SYSRQ = 0xB7;
public static final int KEY_RMENU = 0xB8; /* right Alt */
public static final int KEY_FUNCTION = 0xC4; /* Function (Mac) */
public static final int KEY_PAUSE = 0xC5; /* Pause */
public static final int KEY_HOME = 0xC7; /* Home on arrow keypad */
public static final int KEY_UP = 0xC8; /* UpArrow on arrow keypad */
public static final int KEY_PRIOR = 0xC9; /* PgUp on arrow keypad */
public static final int KEY_LEFT = 0xCB; /* LeftArrow on arrow keypad */
public static final int KEY_RIGHT = 0xCD; /* RightArrow on arrow keypad */
public static final int KEY_END = 0xCF; /* End on arrow keypad */
public static final int KEY_DOWN = 0xD0; /* DownArrow on arrow keypad */
public static final int KEY_NEXT = 0xD1; /* PgDn on arrow keypad */
public static final int KEY_INSERT = 0xD2; /* Insert on arrow keypad */
public static final int KEY_DELETE = 0xD3; /* Delete on arrow keypad */
public static final int KEY_CLEAR = 0xDA; /* Clear key (Mac) */
public static final int KEY_LMETA = 0xDB; /* Left Windows/Option key */
public static final int KEY_RMETA = 0xDC; /* Right Windows/Option key */
public static final int KEY_APPS = 0xDD; /* AppMenu key */
public static final int KEY_POWER = 0xDE;
public static final int KEY_SLEEP = 0xDF;
public static void enableRepeatEvents(boolean b) {
PlatformInput.keyboardEnableRepeatEvents(b);
}
public static boolean isCreated() {
return true;
}
public static boolean next() {
return PlatformInput.keyboardNext();
}
public static boolean getEventKeyState() {
return PlatformInput.keyboardGetEventKeyState();
}
public static char getEventCharacter() {
return PlatformInput.keyboardGetEventCharacter();
}
public static int getEventKey() {
return PlatformInput.keyboardGetEventKey();
}
public static void setFunctionKeyModifier(int key) {
PlatformInput.setFunctionKeyModifier(key);
}
public static boolean isKeyDown(int key) {
return PlatformInput.keyboardIsKeyDown(key);
}
public static String getKeyName(int key) {
return KeyboardConstants.getKeyName(key);
}
public static boolean isRepeatEvent() {
return PlatformInput.keyboardIsRepeatEvent();
}
}

View File

@ -1,98 +0,0 @@
package org.lwjgl.input;
import org.lwjgl.opengl.Display;
import net.PeytonPlayz585.lwjgl.PlatformInput;
/**
* Copyright (c) 2022 LAX1DUDE. All Rights Reserved.
*
* WITH THE EXCEPTION OF PATCH FILES, MINIFIED JAVASCRIPT, AND ALL FILES
* NORMALLY FOUND IN AN UNMODIFIED MINECRAFT RESOURCE PACK, YOU ARE NOT ALLOWED
* TO SHARE, DISTRIBUTE, OR REPURPOSE ANY FILE USED BY OR PRODUCED BY THE
* SOFTWARE IN THIS REPOSITORY WITHOUT PRIOR PERMISSION FROM THE PROJECT AUTHOR.
*
* NOT FOR COMMERCIAL OR MALICIOUS USE
*
* (please read the 'LICENSE' file this repo's root directory for more info)
*
*/
public class Mouse {
public static int getEventDWheel() {
return PlatformInput.mouseGetEventDWheel();
}
public static int getX() {
return PlatformInput.mouseGetX();
}
public static int getY() {
return PlatformInput.mouseGetY();
}
public static boolean getEventButtonState() {
return PlatformInput.mouseGetEventButtonState();
}
public static boolean isCreated() {
return true;
}
public static boolean next() {
return PlatformInput.mouseNext();
}
public static int getEventX() {
return PlatformInput.mouseGetEventX();
}
public static int getEventY() {
return PlatformInput.mouseGetEventY();
}
public static int getEventButton() {
return PlatformInput.mouseGetEventButton();
}
public static boolean isButtonDown(int i) {
return PlatformInput.mouseIsButtonDown(i);
}
public static int getDWheel() {
return PlatformInput.mouseGetDWheel();
}
public static void setGrabbed(boolean grab) {
PlatformInput.mouseSetGrabbed(grab);
}
public static int getDX() {
return PlatformInput.mouseGetDX();
}
public static int getDY() {
return PlatformInput.mouseGetDY();
}
public static void setCursorPosition(int x, int y) {
PlatformInput.mouseSetCursorPosition(x, y);
}
public static boolean isInsideWindow() {
return PlatformInput.mouseIsInsideWindow();
}
public static boolean isActuallyGrabbed() {
return PlatformInput.isPointerLocked();
}
public static boolean isMouseGrabbed() {
return PlatformInput.isMouseGrabbed();
}
public static boolean isFocused() {
return Display.isActive() && isActuallyGrabbed();
}
}

View File

@ -1,56 +0,0 @@
package org.lwjgl.opengl;
import net.PeytonPlayz585.lwjgl.PlatformInput;
import net.PeytonPlayz585.main.MinecraftMain;
public class Display {
private static long lastSwap = 0l;
public static int getWidth() {
return PlatformInput.getWindowWidth();
}
public static int getHeight() {
return PlatformInput.getWindowHeight();
}
public static boolean isActive() {
return PlatformInput.getWindowFocused();
}
public static void create() {
}
public static void setTitle(String string) {
}
public static boolean isCloseRequested() {
return PlatformInput.isCloseRequested();
}
public static void update() {
PlatformInput.update();
}
public static void sync(int limitFramerate) {
boolean limitFPS = limitFramerate > 0 && limitFramerate < 1000;
if(limitFPS) {
long millis = System.currentTimeMillis();
long frameMillis = (1000l / limitFramerate) - (millis - lastSwap);
if(frameMillis > 0l) {
MinecraftMain.sleep(frameMillis);
}
}
lastSwap = System.currentTimeMillis();
}
public static boolean wasResized() {
return PlatformInput.wasResized();
}
}

View File

@ -1,7 +0,0 @@
package org.lwjgl.opengl;
import net.PeytonPlayz585.minecraft.GlStateManager;
public class GL11 extends GlStateManager {
}

View File

@ -4,9 +4,11 @@ import com.mojang.minecraft.level.BlockMap;
import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.level.liquid.LiquidType;
import com.mojang.minecraft.level.tile.Block;
import com.mojang.minecraft.level.tile.Tile$SoundType;
import com.mojang.minecraft.model.Vec3D;
import com.mojang.minecraft.net.PositionUpdate;
import com.mojang.minecraft.phys.AABB;
import com.mojang.minecraft.render.TextureManager;
import com.mojang.util.MathHelper;
import java.io.Serializable;
import java.util.ArrayList;
@ -176,7 +178,7 @@ public abstract class Entity implements Serializable {
float var7 = var2;
float var8 = var3;
AABB var9 = this.bb.copy();
ArrayList<?> var10 = this.level.getCubes(this.bb.expand(var1, var2, var3));
ArrayList var10 = this.level.getCubes(this.bb.expand(var1, var2, var3));
for(int var11 = 0; var11 < var10.size(); ++var11) {
var2 = ((AABB)var10.get(var11)).clipYCollide(this.bb, var2);
@ -358,7 +360,7 @@ public abstract class Entity implements Serializable {
return this.level.getBrightness(var4, var2, var3);
}
public void render(float var2) {}
public void render(TextureManager var1, float var2) {}
public void setLevel(Level var1) {
this.level = var1;
@ -463,5 +465,5 @@ public abstract class Entity implements Serializable {
return false;
}
public void renderHover(float var2) {}
public void renderHover(TextureManager var1, float var2) {}
}

View File

@ -1,8 +1,6 @@
package com.mojang.minecraft;
import org.lwjgl.input.Keyboard;
import com.mojang.minecraft.gamemode.*;
import org.lwjgl.opengl.GL11;
public final class GameSettings
{
@ -10,12 +8,10 @@ public final class GameSettings
{
bindings = new KeyBinding[] {forwardKey, leftKey, backKey, rightKey, jumpKey, buildKey, chatKey, toggleFogKey, saveLocationKey, loadLocationKey};
settingCount = 8;
settingCount = 9;
this.minecraft = minecraft;
// settingsFile = new File(minecraftFolder, "options.txt");
load();
}
@ -28,11 +24,6 @@ public final class GameSettings
public boolean viewBobbing = true;
public boolean anaglyph = false;
public boolean limitFramerate = false;
public boolean ofBetterGrass = false;
public boolean ofFastMath = true;
public boolean ofSmoothFPS = false;
public boolean gamemode = false;
public boolean randomDrops = false;
public KeyBinding forwardKey = new KeyBinding("Forward", 17);
public KeyBinding leftKey = new KeyBinding("Left", 30);
public KeyBinding backKey = new KeyBinding("Back", 31);
@ -45,12 +36,11 @@ public final class GameSettings
public KeyBinding loadLocationKey = new KeyBinding("Load location", 19);
public KeyBinding[] bindings;
private Minecraft minecraft;
// private File settingsFile;
public int settingCount;
public String getBinding(int key)
{
return bindings[key].name + ": " + Keyboard.getKeyName(bindings[key].key);
return bindings[key].name + ": " + GL11.getKeyName(bindings[key].key);
}
public void setBinding(int key, int keyID)
@ -104,35 +94,6 @@ public final class GameSettings
limitFramerate = !limitFramerate;
}
if(setting == 8) {
ofBetterGrass = !ofBetterGrass;
minecraft.levelRenderer.refresh();
}
if(setting == 9) {
ofFastMath = !ofFastMath;
minecraft.levelRenderer.refresh();
}
if(setting == 11) {
if(gamemode) {
GameMode game = new SurvivalGameMode(minecraft);
game.apply(minecraft.level);
game.apply(minecraft.player);
minecraft.gamemode = game;
} else {
GameMode game = new CreativeGameMode(minecraft);
game.apply(minecraft.level);
game.apply(minecraft.player);
minecraft.gamemode = game;
}
gamemode = !gamemode;
}
if(setting == 12) {
randomDrops = !randomDrops;
}
save();
}
@ -146,12 +107,7 @@ public final class GameSettings
: (id == 5 ? "View bobbing: " + (viewBobbing ? "ON" : "OFF")
: (id == 6 ? "3d anaglyph: " + (anaglyph ? "ON" : "OFF")
: (id == 7 ? "Limit framerate: " + (limitFramerate ? "ON" : "OFF")
: (id == 8 ? "Better Grass: " + (ofBetterGrass ? "ON" : "OFF")
: (id == 9 ? "Fast Math: " + (ofFastMath ? "ON" : "OFF")
: (id == 10 ? "Smooth FPS: " + (ofSmoothFPS ? "ON" : "OFF")
: (id == 11 ? "GameMode: " + (gamemode ? "Creative" : "Survival")
: (id == 12 ? "Random Drops: " + (randomDrops ? "ON": "OFF")
: ""))))))))))));
: "")))))));
}
private void load()
@ -209,21 +165,6 @@ public final class GameSettings
// limitFramerate = setting[1].equals("true");
// }
//
// if(setting[0].equals("ofBetterGrass"))
// {
// ofBetterGrass = setting[1].equals("true");
// }
//
// if(setting[0].equals("ofFastMath"))
// {
// ofFastMath = setting[1].equals("true");
// }
//
// if(setting[0].equals("ofSmoothFPS"))
// {
// ofSmoothFPS = setting[1].equals("true");
// }
//
// for(int index = 0; index < this.bindings.length; index++)
// {
// if(setting[0].equals("key_" + bindings[index].name))
@ -256,9 +197,6 @@ public final class GameSettings
// writer.println("bobView:" + viewBobbing);
// writer.println("anaglyph3d:" + anaglyph);
// writer.println("limitFramerate:" + limitFramerate);
// writer.println("ofBetterGrass:" + ofBetterGrass);
// writer.println("ofFastMath:" + ofFastMath);
// writer.println("ofSmoothFPS:" + ofSmoothFPS);
//
// for(int binding = 0; binding < bindings.length; binding++)
// {

View File

@ -17,7 +17,6 @@ import com.mojang.minecraft.model.ModelManager;
import com.mojang.minecraft.model.ModelPart;
import com.mojang.minecraft.model.Vec3D;
import com.mojang.minecraft.net.NetworkPlayer;
import com.mojang.minecraft.net.PacketType;
import com.mojang.minecraft.particle.Particle;
import com.mojang.minecraft.particle.ParticleManager;
import com.mojang.minecraft.particle.WaterDropParticle;
@ -25,19 +24,18 @@ import com.mojang.minecraft.phys.AABB;
import com.mojang.minecraft.player.InputHandlerImpl;
import com.mojang.minecraft.player.Player;
import com.mojang.minecraft.render.*;
import com.mojang.minecraft.render.Renderer;
import com.mojang.minecraft.render.texture.TextureFX;
import com.mojang.minecraft.render.texture.TextureLavaFX;
import com.mojang.minecraft.render.texture.TextureWaterFX;
import com.mojang.util.MathHelper;
import net.PeytonPlayz585.main.MinecraftMain;
import net.lax1dude.eaglercraft.GLAllocation;
import org.lwjgl.BufferUtils;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.io.*;
import java.nio.IntBuffer;
import java.util.Collections;
import java.util.List;
@ -56,6 +54,7 @@ public final class Minecraft implements Runnable {
public String host;
public boolean levelLoaded = false;
public volatile boolean waiting = false;
public TextureManager textureManager;
public FontRenderer fontRenderer;
public GuiScreen currentScreen = null;
public ProgressBarDisplay progressBar = new ProgressBarDisplay(this);
@ -68,7 +67,7 @@ public final class Minecraft implements Runnable {
public HUDScreen hud;
public boolean online;
public MovingObjectPosition selected;
public static GameSettings settings;
public GameSettings settings;
String server;
int port;
volatile boolean running;
@ -78,7 +77,7 @@ public final class Minecraft implements Runnable {
public boolean raining;
public Minecraft(int var3, int var4, boolean var5) {
public Minecraft() {
this.levelIo = new LevelIO(this.progressBar);
this.ticks = 0;
this.blockHitTime = 0;
@ -95,8 +94,8 @@ public final class Minecraft implements Runnable {
this.lastClick = 0;
this.raining = false;
new SleepForeverThread(this);
this.width = var3;
this.height = var4;
this.width = GL11.getCanvasWidth();
this.height = GL11.getCanvasHeight();
}
public final void setCurrentScreen(GuiScreen var1) {
@ -114,11 +113,7 @@ public final class Minecraft implements Runnable {
if(this.hasMouse) {
this.player.releaseAllKeys();
this.hasMouse = false;
if(this.levelLoaded) {
Mouse.setGrabbed(false);
} else {
Mouse.setGrabbed(false);
}
GL11.mouseSetGrabbed(false);
}
int var2 = this.width * 240 / this.height;
@ -138,13 +133,13 @@ public final class Minecraft implements Runnable {
System.out.println("########## GL ERROR ##########");
System.out.println("@ " + var0);
System.out.println(var1 + ": " + var2);
System.exit(0);
}
}
public final void shutdown() {
this.running = false;
MinecraftMain.canvas.delete();
GL11.destroyContext();
}
public final void run() {
@ -152,9 +147,6 @@ public final class Minecraft implements Runnable {
//try {
Minecraft var1 = this;
this.width = MinecraftMain.canvas.getWidth();
this.height = MinecraftMain.canvas.getHeight();
checkGLError("Pre startup");
GL11.glEnable(3553);
GL11.glShadeModel(7425);
@ -169,10 +161,13 @@ public final class Minecraft implements Runnable {
GL11.glMatrixMode(5888);
checkGLError("Startup");
this.settings = new GameSettings(this);
this.fontRenderer = new FontRenderer(this.settings, "/default.png");
this.textureManager = new TextureManager(this.settings);
this.textureManager.registerAnimation(new TextureLavaFX());
this.textureManager.registerAnimation(new TextureWaterFX());
this.fontRenderer = new FontRenderer(this.settings, "/default.png", this.textureManager);
IntBuffer var9;
(var9 = BufferUtils.createIntBuffer(256)).clear().limit(256);
this.levelRenderer = new LevelRenderer(this);
(var9 = GLAllocation.createDirectIntBuffer(256)).clear().limit(256);
this.levelRenderer = new LevelRenderer(this, this.textureManager);
Item.initModels();
Mob.modelCache = new ModelManager();
GL11.glViewport(0, 0, this.width, this.height);
@ -181,14 +176,16 @@ public final class Minecraft implements Runnable {
(var85 = new Level()).setData(8, 8, 8, new byte[512]);
this.setLevel(var85);
} else {
boolean var10 = false;
this.generateLevel(1);
}
this.particleManager = new ParticleManager(this.level);
this.particleManager = new ParticleManager(this.level, this.textureManager);
checkGLError("Post startup");
this.hud = new HUDScreen(this, this.width, this.height);
//} catch (Exception var62) {
//var62.printStackTrace();
//JOptionPane.showMessageDialog((Component)null, var62.toString(), "Failed to start Minecraft", 0);
//throw new RuntimeException("Failed to start Minecraft! :(");
//}
@ -200,10 +197,6 @@ public final class Minecraft implements Runnable {
if(this.waiting) {
Thread.sleep(100L);
} else {
if(Display.isCloseRequested()) {
this.running = false;
}
try {
Timer var63 = this.timer;
long var16;
@ -254,11 +247,11 @@ public final class Minecraft implements Runnable {
this.gamemode.applyCracks(this.timer.delta);
float var65 = this.timer.delta;
Renderer var66 = this.renderer;
if(this.renderer.displayActive && !Display.isActive()) {
if(this.renderer.displayActive && !GL11.isFocused()) {
var66.minecraft.pause();
}
var66.displayActive = Display.isActive();
var66.displayActive = GL11.isFocused();
int var68;
int var70;
int var86;
@ -267,20 +260,10 @@ public final class Minecraft implements Runnable {
var81 = 0;
var86 = 0;
if(var66.minecraft.levelLoaded) {
// if(var66.minecraft.canvas != null) {
// Point var90;
// var70 = (var90 = MinecraftMain.canvas.mouse).x + var66.minecraft.width / 2;
// var68 = var90.y + var66.minecraft.height / 2;
// Point var75;
// var81 = (var75 = MouseInfo.getPointerInfo().getLocation()).x - var70;
// var86 = -(var75.y - var68);
// Mouse.setCursorPosition(var70, var68);
// } else {
Mouse.setCursorPosition(var66.minecraft.width / 2, var66.minecraft.height / 2);
// }
GL11.mouseSetCursorPosition(var66.minecraft.width / 2, var66.minecraft.height / 2);
} else {
var81 = Mouse.getDX();
var86 = Mouse.getDY();
var81 = GL11.mouseGetDX();
var86 = GL11.mouseGetDY();
}
byte var91 = 1;
@ -294,8 +277,8 @@ public final class Minecraft implements Runnable {
if(!var66.minecraft.online) {
var81 = var66.minecraft.width * 240 / var66.minecraft.height;
var86 = var66.minecraft.height * 240 / var66.minecraft.height;
int var94 = Mouse.getX() * var81 / var66.minecraft.width;
var70 = var86 - Mouse.getY() * var86 / var66.minecraft.height - 1;
int var94 = GL11.mouseGetX() * var81 / var66.minecraft.width;
var70 = var86 - GL11.mouseGetY() * var86 / var66.minecraft.height - 1;
if(var66.minecraft.level != null) {
float var80 = var65;
Renderer var82 = var66;
@ -519,7 +502,7 @@ public final class Minecraft implements Runnable {
var82.setLighting(true);
Vec3D var103 = var82.getPlayerVector(var80);
var89.level.blockMap.render(var103, var76, var80);
var89.level.blockMap.render(var103, var76, var89.textureManager, var80);
var82.setLighting(false);
var82.updateFog();
float var107 = var80;
@ -531,18 +514,16 @@ public final class Minecraft implements Runnable {
for(var83 = 0; var83 < 2; ++var83) {
if(var96.particles[var83].size() != 0) {
RenderEngine r = new RenderEngine();
var110 = 0;
var110 = 0;
if(var83 == 0) {
var110 = r.getTexture("/particles.png");
new TextureLocation("/particles.png").bindTexture();
var110 = var96.textureManager.load("/particles.png");
}
if(var83 == 1) {
var110 = r.getTexture("/terrain.png");
new TextureLocation("/terrain.png").bindTexture();
var110 = var96.textureManager.load("/terrain.png");
}
GL11.glBindTexture(3553, var110);
ShapeRenderer var121 = ShapeRenderer.instance;
ShapeRenderer.instance.begin();
@ -554,12 +535,12 @@ public final class Minecraft implements Runnable {
}
}
new TextureLocation("/rock.png").bindTexture();
GL11.glBindTexture(3553, var89.textureManager.load("/rock.png"));
GL11.glEnable(3553);
GL11.glCallList(var89.listId);
var82.updateFog();
var101 = var89;
new TextureLocation("/clouds.png").bindTexture();
GL11.glBindTexture(3553, var89.textureManager.load("/clouds.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
var107 = (float)(var89.level.cloudColor >> 16 & 255) / 255.0F;
var29 = (float)(var89.level.cloudColor >> 8 & 255) / 255.0F;
@ -640,9 +621,8 @@ public final class Minecraft implements Runnable {
GL11.glColor4f(1.0F, 1.0F, 1.0F, (MathHelper.sin((float)System.currentTimeMillis() / 100.0F) * 0.2F + 0.4F) * 0.5F);
if(var89.cracks > 0.0F) {
GL11.glBlendFunc(774, 768);
RenderEngine r = new RenderEngine();
var108 = r.getTexture("/terrain.png");
new TextureLocation("/terrain.png").bindTexture();
var108 = var89.textureManager.load("/terrain.png");
GL11.glBindTexture(3553, var108);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F);
GL11.glPushMatrix();
Block var10000 = (var114 = var89.level.getTile(var102.x, var102.y, var102.z)) > 0?Block.blocks[var114]:null;
@ -683,34 +663,6 @@ public final class Minecraft implements Runnable {
GL11.glDisable(3553);
GL11.glDepthMask(false);
var29 = 0.002F;
// if((var104 = var89.level.getTile(var102.x, var102.y, var102.z)) > 0) {
// AABB var111 = Block.blocks[var104].getSelectionBox(var102.x, var102.y, var102.z).grow(var29, var29, var29);
// GL11.glBegin(3);
// GL11.glVertex3f(var111.x0, var111.y0, var111.z0);
// GL11.glVertex3f(var111.x1, var111.y0, var111.z0);
// GL11.glVertex3f(var111.x1, var111.y0, var111.z1);
// GL11.glVertex3f(var111.x0, var111.y0, var111.z1);
// GL11.glVertex3f(var111.x0, var111.y0, var111.z0);
// GL11.glEnd();
// GL11.glBegin(3);
// GL11.glVertex3f(var111.x0, var111.y1, var111.z0);
// GL11.glVertex3f(var111.x1, var111.y1, var111.z0);
// GL11.glVertex3f(var111.x1, var111.y1, var111.z1);
// GL11.glVertex3f(var111.x0, var111.y1, var111.z1);
// GL11.glVertex3f(var111.x0, var111.y1, var111.z0);
// GL11.glEnd();
// GL11.glBegin(1);
// GL11.glVertex3f(var111.x0, var111.y0, var111.z0);
// GL11.glVertex3f(var111.x0, var111.y1, var111.z0);
// GL11.glVertex3f(var111.x1, var111.y0, var111.z0);
// GL11.glVertex3f(var111.x1, var111.y1, var111.z0);
// GL11.glVertex3f(var111.x1, var111.y0, var111.z1);
// GL11.glVertex3f(var111.x1, var111.y1, var111.z1);
// GL11.glVertex3f(var111.x0, var111.y0, var111.z1);
// GL11.glVertex3f(var111.x0, var111.y1, var111.z1);
// GL11.glEnd();
// }
GL11.glDepthMask(true);
GL11.glEnable(3553);
GL11.glDisable(3042);
@ -721,7 +673,7 @@ public final class Minecraft implements Runnable {
var82.updateFog();
GL11.glEnable(3553);
GL11.glEnable(3042);
new TextureLocation("/water.png").bindTexture();
GL11.glBindTexture(3553, var89.textureManager.load("/water.png"));
GL11.glCallList(var89.listId + 1);
GL11.glDisable(3042);
GL11.glEnable(3042);
@ -737,12 +689,8 @@ public final class Minecraft implements Runnable {
}
if(var120 > 0) {
new TextureLocation("/terrain.png").bindTexture();
if(settings.ofFastMath) {
GL11.glCallLists(var89.buffer_fast);
} else {
GL11.glCallLists(var89.buffer);
}
GL11.glBindTexture(3553, var89.textureManager.load("/terrain.png"));
GL11.glCallLists(var89.buffer);
}
GL11.glDepthMask(true);
@ -761,7 +709,7 @@ public final class Minecraft implements Runnable {
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
GL11.glEnable(3042);
GL11.glBlendFunc(770, 771);
new TextureLocation("/rain.png").bindTexture();
GL11.glBindTexture(3553, var82.minecraft.textureManager.load("/rain.png"));
for(var110 = var104 - 5; var110 <= var104 + 5; ++var110) {
for(var122 = var114 - 5; var122 <= var114 + 5; ++var122) {
@ -801,7 +749,7 @@ public final class Minecraft implements Runnable {
}
if(var82.entity != null) {
var82.entity.renderHover(var80);
var82.entity.renderHover(var82.minecraft.textureManager, var80);
}
GL11.glClear(256);
@ -845,10 +793,10 @@ public final class Minecraft implements Runnable {
var34 = 0.4F;
GL11.glScalef(0.4F, var34, var34);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
new TextureLocation("/terrain.png").bindTexture();
GL11.glBindTexture(3553, var112.minecraft.textureManager.load("/terrain.png"));
var112.block.renderPreview(var123);
} else {
var116.bindTexture();
var116.bindTexture(var112.minecraft.textureManager);
GL11.glScalef(1.0F, -1.0F, -1.0F);
GL11.glTranslatef(0.0F, 0.2F, 0.0F);
GL11.glRotatef(-120.0F, 0.0F, 0.0F, 1.0F);
@ -889,7 +837,7 @@ public final class Minecraft implements Runnable {
}
Thread.yield();
Display.update();
GL11.updateDisplay();
}
}
@ -926,17 +874,17 @@ public final class Minecraft implements Runnable {
}
public final void grabMouse() {
if(!this.hasMouse) {
if(!Mouse.isFocused()) {
return;
} else if(Mouse.isActuallyGrabbed()) {
return;
} else {
Mouse.setGrabbed(true);
this.setCurrentScreen((GuiScreen)null);
this.lastClick = this.ticks + 10000;
}
}
if(GL11.isFocused()) {
return;
}
if (GL11.isPointerLocked2()) {
return;
} else {
GL11.mouseSetGrabbed(true);
this.setCurrentScreen((GuiScreen)null);
this.lastClick = this.ticks + 10000;
return;
}
}
public final void pause() {
@ -1017,7 +965,7 @@ public final class Minecraft implements Runnable {
if(!this.gamemode.canPlace(var10)) {
return;
}
this.level.netSetTile(var3, var4, var5, var10);
var2 = this.renderer.heldBlock;
this.renderer.heldBlock.pos = 0.0F;
@ -1040,49 +988,51 @@ public final class Minecraft implements Runnable {
++((ChatLine)var17.chat.get(var16)).time;
}
new TextureLocation("/terrain.png").bindTexture();
GL11.glBindTexture(3553, this.textureManager.load("/terrain.png"));
TextureManager var19 = this.textureManager;
// for(var16 = 0; var16 < var19.animations.size(); ++var16) {
// TextureFX var3;
// (var3 = (TextureFX)var19.animations.get(var16)).anaglyph = var19.settings.anaglyph;
// var3.animate();
// var19.textureBuffer.clear();
// var19.textureBuffer.put(var3.textureData);
// var19.textureBuffer.position(0).limit(var3.textureData.length);
// GL11.glTexSubImage2D(3553, 0, var3.textureId % 16 << 4, var3.textureId / 16 << 4, 16, 16, 6408, 5121, var19.textureBuffer);
// }
for(var16 = 0; var16 < var19.animations.size(); ++var16) {
TextureFX var3;
(var3 = (TextureFX)var19.animations.get(var16)).anaglyph = var19.settings.anaglyph;
var3.animate();
var19.textureBuffer.clear();
var19.textureBuffer.put(var3.textureData);
var19.textureBuffer.position(0).limit(var3.textureData.length);
GL11.glTexSubImage2D(3553, 0, var3.textureId % 16 << 4, var3.textureId / 16 << 4, 16, 16, 6408, 5121, var19.textureBuffer);
}
int var4;
int var8;
int var40;
int var46;
int var45;
if(this.currentScreen == null && this.player != null && this.player.health <= 0) {
this.setCurrentScreen((GuiScreen)null);
}
if(this.currentScreen == null || this.currentScreen.grabsMouse) {
int var25;
while(Mouse.next()) {
if((var25 = Mouse.getEventDWheel()) != 0) {
while(GL11.mouseNext()) {
if((var25 = GL11.mouseGetEventDWheel()) != 0) {
this.player.inventory.swapPaint(var25);
}
if(this.currentScreen == null) {
if(!this.hasMouse && Mouse.getEventButtonState()) {
if(!this.hasMouse && GL11.mouseGetEventButtonState()) {
this.grabMouse();
} else {
if(Mouse.getEventButton() == 0 && Mouse.getEventButtonState()) {
if(GL11.mouseGetEventButton() == 0 && GL11.mouseGetEventButtonState()) {
this.onMouseClick(0);
this.lastClick = this.ticks;
}
if(Mouse.getEventButton() == 1 && Mouse.getEventButtonState()) {
if(GL11.mouseGetEventButton() == 1 && GL11.mouseGetEventButtonState()) {
this.onMouseClick(1);
this.lastClick = this.ticks;
}
if(Mouse.getEventButton() == 2 && Mouse.getEventButtonState() && this.selected != null) {
if(GL11.mouseGetEventButton() == 2 && GL11.mouseGetEventButtonState() && this.selected != null) {
if((var16 = this.level.getTile(this.selected.x, this.selected.y, this.selected.z)) == Block.GRASS.id) {
var16 = Block.DIRT.id;
}
@ -1109,69 +1059,69 @@ public final class Minecraft implements Runnable {
--this.blockHitTime;
}
while(Keyboard.next()) {
this.player.setKey(Keyboard.getEventKey(), Keyboard.getEventKeyState());
if(Keyboard.getEventKeyState()) {
while(GL11.keysNext()) {
this.player.setKey(GL11.getEventKey(), GL11.getEventKeyState());
if(GL11.getEventKeyState()) {
if(this.currentScreen != null) {
this.currentScreen.keyboardEvent();
}
if(this.currentScreen == null) {
if(Keyboard.getEventKey() == 1) {
if(GL11.getEventKey() == 1) {
this.pause();
}
if(this.gamemode instanceof CreativeGameMode) {
if(Keyboard.getEventKey() == this.settings.loadLocationKey.key) {
if(GL11.getEventKey() == this.settings.loadLocationKey.key) {
this.player.resetPos();
}
if(Keyboard.getEventKey() == this.settings.saveLocationKey.key) {
if(GL11.getEventKey() == this.settings.saveLocationKey.key) {
this.level.setSpawnPos((int)this.player.x, (int)this.player.y, (int)this.player.z, this.player.yRot);
this.player.resetPos();
}
}
Keyboard.getEventKey();
if(Keyboard.getEventKey() == 63) {
GL11.getEventKey();
if(GL11.getEventKey() == 63) {
this.raining = !this.raining;
}
if(Keyboard.getEventKey() == 15 && this.gamemode instanceof SurvivalGameMode && this.player.arrows > 0) {
if(GL11.getEventKey() == 15 && this.gamemode instanceof SurvivalGameMode && this.player.arrows > 0) {
this.level.addEntity(new Arrow(this.level, this.player, this.player.x, this.player.y, this.player.z, this.player.yRot, this.player.xRot, 1.2F));
--this.player.arrows;
}
if(Keyboard.getEventKey() == this.settings.buildKey.key) {
if(GL11.getEventKey() == this.settings.buildKey.key) {
this.gamemode.openInventory();
}
}
for(var25 = 0; var25 < 9; ++var25) {
if(Keyboard.getEventKey() == var25 + 2) {
if(GL11.getEventKey() == var25 + 2) {
this.player.inventory.selected = var25;
}
}
if(Keyboard.getEventKey() == this.settings.toggleFogKey.key) {
this.settings.toggleSetting(4, !Keyboard.isKeyDown(42) && !Keyboard.isKeyDown(54)?1:-1);
if(GL11.getEventKey() == this.settings.toggleFogKey.key) {
this.settings.toggleSetting(4, !GL11.isKeyDown(42) && !GL11.isKeyDown(54)?1:-1);
}
}
}
if(this.currentScreen == null) {
if(Mouse.isButtonDown(0) && (float)(this.ticks - this.lastClick) >= this.timer.tps / 4.0F && this.hasMouse) {
if(GL11.mouseIsButtonDown(0) && (float)(this.ticks - this.lastClick) >= this.timer.tps / 4.0F && this.hasMouse) {
this.onMouseClick(0);
this.lastClick = this.ticks;
}
if(Mouse.isButtonDown(1) && (float)(this.ticks - this.lastClick) >= this.timer.tps / 4.0F && this.hasMouse) {
if(GL11.mouseIsButtonDown(1) && (float)(this.ticks - this.lastClick) >= this.timer.tps / 4.0F && this.hasMouse) {
this.onMouseClick(1);
this.lastClick = this.ticks;
}
}
boolean var26 = this.currentScreen == null && Mouse.isButtonDown(0) && this.hasMouse;
boolean var26 = this.currentScreen == null && GL11.mouseIsButtonDown(0) && this.hasMouse;
boolean var35 = false;
if(!this.gamemode.instantBreak && this.blockHitTime <= 0) {
if(var26 && this.selected != null && this.selected.entityPos == 0) {

View File

@ -2,11 +2,7 @@ package com.mojang.minecraft;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.StopGameException;
import com.mojang.minecraft.render.RenderEngine;
import com.mojang.minecraft.render.ShapeRenderer;
import com.mojang.minecraft.render.TextureLocation;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;
public final class ProgressBarDisplay {
@ -58,9 +54,8 @@ public final class ProgressBarDisplay {
int var5 = this.minecraft.height * 240 / this.minecraft.height;
GL11.glClear(16640);
ShapeRenderer var6 = ShapeRenderer.instance;
RenderEngine r = new RenderEngine();
int var7 = r.getTexture("/dirt.png");
new TextureLocation("/dirt.png").bindTexture();
int var7 = this.minecraft.textureManager.load("/dirt.png");
GL11.glBindTexture(3553, var7);
float var10 = 32.0F;
var6.begin();
var6.color(4210752);
@ -90,7 +85,7 @@ public final class ProgressBarDisplay {
this.minecraft.fontRenderer.render(this.title, (var4 - this.minecraft.fontRenderer.getWidth(this.title)) / 2, var5 / 2 - 4 - 16, 16777215);
this.minecraft.fontRenderer.render(this.text, (var4 - this.minecraft.fontRenderer.getWidth(this.text)) / 2, var5 / 2 - 4 + 8, 16777215);
Display.update();
GL11.updateDisplay();
try {
Thread.yield();

View File

@ -1,66 +1,65 @@
package com.mojang.minecraft;
import com.mojang.minecraft.level.tile.Block;
import java.util.ArrayList;
import java.util.List;
public final class SessionData {
public static List allowedBlocks;
public String username;
public String sessionId;
public String mppass;
public boolean haspaid;
public SessionData(String var1, String var2) {
this.username = var1;
this.sessionId = var2;
}
static {
(allowedBlocks = new ArrayList()).add(Block.STONE);
allowedBlocks.add(Block.COBBLESTONE);
allowedBlocks.add(Block.BRICK);
allowedBlocks.add(Block.DIRT);
allowedBlocks.add(Block.WOOD);
allowedBlocks.add(Block.LOG);
allowedBlocks.add(Block.LEAVES);
allowedBlocks.add(Block.GLASS);
allowedBlocks.add(Block.SLAB);
allowedBlocks.add(Block.MOSSY_COBBLESTONE);
allowedBlocks.add(Block.SAPLING);
allowedBlocks.add(Block.DANDELION);
allowedBlocks.add(Block.ROSE);
allowedBlocks.add(Block.BROWN_MUSHROOM);
allowedBlocks.add(Block.RED_MUSHROOM);
allowedBlocks.add(Block.SAND);
allowedBlocks.add(Block.GRAVEL);
allowedBlocks.add(Block.SPONGE);
allowedBlocks.add(Block.RED_WOOL);
allowedBlocks.add(Block.ORANGE_WOOL);
allowedBlocks.add(Block.YELLOW_WOOL);
allowedBlocks.add(Block.LIME_WOOL);
allowedBlocks.add(Block.GREEN_WOOL);
allowedBlocks.add(Block.AQUA_GREEN_WOOL);
allowedBlocks.add(Block.CYAN_WOOL);
allowedBlocks.add(Block.BLUE_WOOL);
allowedBlocks.add(Block.PURPLE_WOOL);
allowedBlocks.add(Block.INDIGO_WOOL);
allowedBlocks.add(Block.VIOLET_WOOL);
allowedBlocks.add(Block.MAGENTA_WOOL);
allowedBlocks.add(Block.PINK_WOOL);
allowedBlocks.add(Block.BLACK_WOOL);
allowedBlocks.add(Block.GRAY_WOOL);
allowedBlocks.add(Block.WHITE_WOOL);
allowedBlocks.add(Block.COAL_ORE);
allowedBlocks.add(Block.IRON_ORE);
allowedBlocks.add(Block.GOLD_ORE);
allowedBlocks.add(Block.IRON_BLOCK);
allowedBlocks.add(Block.GOLD_BLOCK);
allowedBlocks.add(Block.BOOKSHELF);
allowedBlocks.add(Block.TNT);
allowedBlocks.add(Block.OBSIDIAN);
allowedBlocks.add(Block.BEDROCK);
}
}
package com.mojang.minecraft;
import com.mojang.minecraft.level.tile.Block;
import java.util.ArrayList;
import java.util.List;
public final class SessionData {
public static List allowedBlocks;
public String username;
public String sessionId;
public String mppass;
public boolean haspaid;
public SessionData(String var1, String var2) {
this.username = var1;
this.sessionId = var2;
}
static {
(allowedBlocks = new ArrayList()).add(Block.STONE);
allowedBlocks.add(Block.COBBLESTONE);
allowedBlocks.add(Block.BRICK);
allowedBlocks.add(Block.DIRT);
allowedBlocks.add(Block.WOOD);
allowedBlocks.add(Block.LOG);
allowedBlocks.add(Block.LEAVES);
allowedBlocks.add(Block.GLASS);
allowedBlocks.add(Block.SLAB);
allowedBlocks.add(Block.MOSSY_COBBLESTONE);
allowedBlocks.add(Block.SAPLING);
allowedBlocks.add(Block.DANDELION);
allowedBlocks.add(Block.ROSE);
allowedBlocks.add(Block.BROWN_MUSHROOM);
allowedBlocks.add(Block.RED_MUSHROOM);
allowedBlocks.add(Block.SAND);
allowedBlocks.add(Block.GRAVEL);
allowedBlocks.add(Block.SPONGE);
allowedBlocks.add(Block.RED_WOOL);
allowedBlocks.add(Block.ORANGE_WOOL);
allowedBlocks.add(Block.YELLOW_WOOL);
allowedBlocks.add(Block.LIME_WOOL);
allowedBlocks.add(Block.GREEN_WOOL);
allowedBlocks.add(Block.AQUA_GREEN_WOOL);
allowedBlocks.add(Block.CYAN_WOOL);
allowedBlocks.add(Block.BLUE_WOOL);
allowedBlocks.add(Block.PURPLE_WOOL);
allowedBlocks.add(Block.INDIGO_WOOL);
allowedBlocks.add(Block.VIOLET_WOOL);
allowedBlocks.add(Block.MAGENTA_WOOL);
allowedBlocks.add(Block.PINK_WOOL);
allowedBlocks.add(Block.BLACK_WOOL);
allowedBlocks.add(Block.GRAY_WOOL);
allowedBlocks.add(Block.WHITE_WOOL);
allowedBlocks.add(Block.COAL_ORE);
allowedBlocks.add(Block.IRON_ORE);
allowedBlocks.add(Block.GOLD_ORE);
allowedBlocks.add(Block.IRON_BLOCK);
allowedBlocks.add(Block.GOLD_BLOCK);
allowedBlocks.add(Block.BOOKSHELF);
allowedBlocks.add(Block.TNT);
allowedBlocks.add(Block.OBSIDIAN);
}
}

View File

@ -0,0 +1,51 @@
package com.mojang.minecraft;
import com.mojang.minecraft.player.Player;
import java.net.HttpURLConnection;
import java.net.URL;
import javax.imageio.ImageIO;
public class SkinDownloadThread extends Thread
{
public SkinDownloadThread(Minecraft minecraft)
{
super();
this.minecraft = minecraft;
}
@Override
public void run()
{
if(minecraft.session != null)
{
HttpURLConnection connection = null;
try {
connection = (HttpURLConnection)new URL("http://www.minecraft.net/skin/" + minecraft.session.username + ".png").openConnection();
connection.setDoInput(true);
connection.setDoOutput(false);
connection.connect();
if(connection.getResponseCode() != 404)
{
Player.newTexture = ImageIO.read(connection.getInputStream());
return;
}
} catch (Exception var4) {
var4.printStackTrace();
} finally {
if(connection != null)
{
connection.disconnect();
}
}
}
}
private Minecraft minecraft;
}

View File

@ -140,7 +140,7 @@ public final class SurvivalGameMode extends GameMode
public void preparePlayer(Player player)
{
player.inventory.slots[8] = Block.TNT.id;
player.inventory.count[8] = (int) 1e+5;
player.inventory.count[8] = 10;
}
@Override
@ -166,9 +166,4 @@ public final class SurvivalGameMode extends GameMode
spawner.spawn(area, null, minecraft.progressBar);
}
@Override
public void apply(Player player) {
}
}

View File

@ -4,8 +4,7 @@ import com.mojang.minecraft.SessionData;
import com.mojang.minecraft.gui.GuiScreen;
import com.mojang.minecraft.level.tile.Block;
import com.mojang.minecraft.render.ShapeRenderer;
import com.mojang.minecraft.render.TextureLocation;
import com.mojang.minecraft.render.TextureManager;
import org.lwjgl.opengl.GL11;
public final class BlockSelectScreen extends GuiScreen {
@ -36,8 +35,10 @@ public final class BlockSelectScreen extends GuiScreen {
}
drawCenteredString(this.fontRenderer, "Select block", this.width / 2, 40, 16777215);
TextureManager var7 = this.minecraft.textureManager;
ShapeRenderer var8 = ShapeRenderer.instance;
new TextureLocation("/terrain.png").bindTexture();
var2 = var7.load("/terrain.png");
GL11.glBindTexture(3553, var2);
for(var2 = 0; var2 < SessionData.allowedBlocks.size(); ++var2) {
Block var4 = (Block)SessionData.allowedBlocks.get(var2);

View File

@ -1,8 +1,7 @@
package com.mojang.minecraft.gui;
import com.mojang.minecraft.gui.GuiScreen;
import com.mojang.minecraft.net.PacketType;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
public final class ChatInputScreen extends GuiScreen {
@ -11,11 +10,11 @@ public final class ChatInputScreen extends GuiScreen {
public final void onOpen() {
Keyboard.enableRepeatEvents(true);
GL11.enableRepeatEvents(true);
}
public final void onClose() {
Keyboard.enableRepeatEvents(false);
GL11.enableRepeatEvents(false);
}
public final void tick() {

View File

@ -2,14 +2,12 @@ package com.mojang.minecraft.gui;
import com.mojang.minecraft.GameSettings;
import com.mojang.minecraft.render.ShapeRenderer;
import net.PeytonPlayz585.lwjgl.LWJGLUtils;
import net.PeytonPlayz585.minecraft.MinecraftImage;
import com.mojang.minecraft.render.TextureManager;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.lwjgl.opengl.GL11;
import com.mojang.minecraft.render.RenderEngine;
public final class FontRenderer {
private int[] widthmap = new int[256];
@ -17,12 +15,21 @@ public final class FontRenderer {
private GameSettings settings;
public FontRenderer(GameSettings var1, String var2) {
public FontRenderer(GameSettings var1, String var2, TextureManager var3) {
this.settings = var1;
MinecraftImage var14 = LWJGLUtils.loadPNG(GL11.loadResourceBytes(var2));
int var4 = var14.w;
int var5 = var14.h;
BufferedImage var14;
try {
var14 = ImageIO.read(TextureManager.class.getResourceAsStream(var2));
} catch (IOException var13) {
throw new RuntimeException(var13);
}
int var4 = var14.getWidth();
int var5 = var14.getHeight();
int[] var6 = new int[var4 * var5];
var14.getRGB(0, 0, var4, var5, var6, 0, var4);
for(int var15 = 0; var15 < 128; ++var15) {
var5 = var15 % 16;
int var7 = var15 / 16;
@ -46,10 +53,8 @@ public final class FontRenderer {
this.widthmap[var15] = var8;
}
RenderEngine r = new RenderEngine();
this.fontTexture = r.getTexture(var2);
this.fontTexture = var3.load(var2);
}
public final void render(String var1, int var2, int var3, int var4) {

View File

@ -1,5 +1,9 @@
package com.mojang.minecraft.gui;
import com.mojang.minecraft.gui.Button;
import com.mojang.minecraft.gui.GenerateLevelScreen;
import com.mojang.minecraft.gui.GuiScreen;
import com.mojang.minecraft.gui.OptionsScreen;
import org.lwjgl.opengl.GL11;
public final class GameOverScreen extends GuiScreen {
@ -9,7 +13,7 @@ public final class GameOverScreen extends GuiScreen {
this.buttons.add(new Button(1, this.width / 2 - 100, this.height / 4 + 72, "Generate new level..."));
this.buttons.add(new Button(2, this.width / 2 - 100, this.height / 4 + 96, "Load level.."));
if(this.minecraft.session == null) {
((Button)this.buttons.get(1)).active = false;
((Button)this.buttons.get(2)).active = false;
}
}

View File

@ -4,12 +4,8 @@ import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.gui.Button;
import com.mojang.minecraft.gui.FontRenderer;
import com.mojang.minecraft.gui.Screen;
import com.mojang.minecraft.render.TextureLocation;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
public class GuiScreen extends Screen {
@ -29,7 +25,7 @@ public class GuiScreen extends Screen {
Button var4 = var10000;
if(var10000.visible) {
FontRenderer var8 = var7.fontRenderer;
new TextureLocation("/gui/gui.png").bindTexture();
GL11.glBindTexture(3553, var7.textureManager.load("/gui/gui.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
byte var9 = 1;
boolean var6 = var1 >= var4.x && var2 >= var4.y && var1 < var4.x + var4.width && var2 < var4.y + var4.height;
@ -87,28 +83,28 @@ public class GuiScreen extends Screen {
public void onOpen() {}
public final void doInput() {
while(Mouse.next()) {
while(GL11.mouseNext()) {
this.mouseEvent();
}
while(Keyboard.next()) {
while(GL11.keysNext()) {
this.keyboardEvent();
}
}
public final void mouseEvent() {
if(Mouse.getEventButtonState()) {
int var1 = Mouse.getEventX() * this.width / this.minecraft.width;
int var2 = this.height - Mouse.getEventY() * this.height / this.minecraft.height - 1;
this.onMouseClick(var1, var2, Mouse.getEventButton());
if(GL11.mouseGetEventButtonState()) {
int var1 = GL11.mouseGetEventX() * this.width / this.minecraft.width;
int var2 = this.height - GL11.mouseGetEventY() * this.height / this.minecraft.height - 1;
this.onMouseClick(var1, var2, GL11.mouseGetEventButton());
}
}
public final void keyboardEvent() {
if(Keyboard.getEventKeyState()) {
this.onKeyPress(Keyboard.getEventCharacter(), Keyboard.getEventKey());
if(GL11.getEventKeyState()) {
this.onKeyPress(GL11.getEventChar(), GL11.getEventKey());
}
}

View File

@ -9,12 +9,11 @@ import com.mojang.minecraft.gui.Screen;
import com.mojang.minecraft.level.tile.Block;
import com.mojang.minecraft.player.Inventory;
import com.mojang.minecraft.render.ShapeRenderer;
import com.mojang.minecraft.render.TextureLocation;
import com.mojang.minecraft.render.TextureManager;
import com.mojang.util.MathHelper;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
public final class HUDScreen extends Screen {
@ -37,7 +36,8 @@ public final class HUDScreen extends Screen {
public final void render(float var1, boolean var2, int var3, int var4) {
FontRenderer var5 = this.mc.fontRenderer;
this.mc.renderer.enableGuiMode();
new TextureLocation("/gui/gui.png").bindTexture();
TextureManager var6 = this.mc.textureManager;
GL11.glBindTexture(3553, this.mc.textureManager.load("/gui/gui.png"));
ShapeRenderer var7 = ShapeRenderer.instance;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glEnable(3042);
@ -45,7 +45,7 @@ public final class HUDScreen extends Screen {
this.imgZ = -90.0F;
this.drawImage(this.width / 2 - 91, this.height - 22, 0, 0, 182, 22);
this.drawImage(this.width / 2 - 91 - 1 + var8.selected * 20, this.height - 22 - 1, 0, 22, 24, 22);
new TextureLocation("/gui/icons.png").bindTexture();
GL11.glBindTexture(3553, this.mc.textureManager.load("/gui/icons.png"));
this.drawImage(this.width / 2 - 7, this.height / 2 - 7, 0, 0, 16, 16);
boolean var9 = this.mc.player.invulnerableTime / 3 % 2 == 1;
if(this.mc.player.invulnerableTime < 10) {
@ -131,7 +131,8 @@ public final class HUDScreen extends Screen {
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(-1.5F, 0.5F, 0.5F);
GL11.glScalef(-1.0F, -1.0F, -1.0F);
new TextureLocation("/terrain.png").bindTexture();
int var20 = var6.load("/terrain.png");
GL11.glBindTexture(3553, var20);
var7.begin();
Block.blocks[var15].renderFullbright(var7);
var7.end();

View File

@ -23,7 +23,6 @@ public final class OptionsScreen extends GuiScreen {
this.buttons.add(new OptionButton(var1, this.width / 2 - 155 + var1 % 2 * 160, this.height / 6 + 24 * (var1 >> 1), this.settings.getSetting(var1)));
}
this.buttons.add(new Button(50, this.width / 2 - 100, this.height / 6 + 95 + 12, "More..."));
this.buttons.add(new Button(100, this.width / 2 - 100, this.height / 6 + 120 + 12, "Controls..."));
this.buttons.add(new Button(200, this.width / 2 - 100, this.height / 6 + 168, "Done"));
}
@ -34,10 +33,6 @@ public final class OptionsScreen extends GuiScreen {
this.settings.toggleSetting(var1.id, 1);
var1.text = this.settings.getSetting(var1.id);
}
if(var1.id == 50) {
this.minecraft.setCurrentScreen(new GuiMore(this));
}
if(var1.id == 100) {
this.minecraft.setCurrentScreen(new ControlsScreen(this, this.settings));

View File

@ -1,5 +1,10 @@
package com.mojang.minecraft.gui;
import com.mojang.minecraft.gui.Button;
import com.mojang.minecraft.gui.GenerateLevelScreen;
import com.mojang.minecraft.gui.GuiScreen;
import com.mojang.minecraft.gui.OptionsScreen;
public final class PauseScreen extends GuiScreen {
public final void onOpen() {
@ -24,6 +29,16 @@ public final class PauseScreen extends GuiScreen {
this.minecraft.setCurrentScreen(new GenerateLevelScreen(this));
}
if(this.minecraft.session != null) {
//if(var1.id == 2) {
//this.minecraft.setCurrentScreen(new SaveLevelScreen(this));
//}
//if(var1.id == 3) {
//this.minecraft.setCurrentScreen(new LoadLevelScreen(this));
//}
}
if(var1.id == 4) {
this.minecraft.setCurrentScreen((GuiScreen)null);
this.minecraft.grabMouse();

View File

@ -41,6 +41,8 @@ public class Screen {
GL11.glDisable(3553);
GL11.glEnable(3042);
GL11.glBlendFunc(770, 771);
//TODO: Rewrite later...
//GL11.glBegin(7);
GL11.glColor4f(var7, var8, var12, var6);
//GL11.glVertex2f((float)var2, (float)var1);

View File

@ -5,7 +5,7 @@ import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.phys.AABB;
import com.mojang.minecraft.player.Player;
import com.mojang.minecraft.render.ShapeRenderer;
import com.mojang.minecraft.render.TextureLocation;
import com.mojang.minecraft.render.TextureManager;
import com.mojang.util.MathHelper;
import java.util.List;
import org.lwjgl.opengl.GL11;
@ -176,9 +176,11 @@ public class Arrow extends Entity
}
@Override
public void render(float unknown0)
public void render(TextureManager textureManager, float unknown0)
{
new TextureLocation("/item/arrows.png").bindTexture();
textureId = textureManager.load("/item/arrows.png");
GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId);
float brightness = level.getBrightness((int)x, (int)y, (int)z);

View File

@ -4,7 +4,7 @@ import com.mojang.minecraft.Entity;
import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.level.tile.Block;
import com.mojang.minecraft.player.Player;
import com.mojang.minecraft.render.TextureLocation;
import com.mojang.minecraft.render.TextureManager;
import com.mojang.util.MathHelper;
import org.lwjgl.opengl.GL11;
@ -64,9 +64,11 @@ public class Item extends Entity
}
@Override
public void render(float unknown0)
public void render(TextureManager textureManager, float unknown0)
{
new TextureLocation("/terrain.png").bindTexture();
textureId = textureManager.load("/terrain.png");
GL11.glBindTexture(3553, this.textureId);
float brightness = level.getBrightness((int)x, (int)y, (int)z);
float unknown1 = rot + ((float)tickCount + unknown0) * 3.0F;

View File

@ -7,7 +7,7 @@ import com.mojang.minecraft.particle.SmokeParticle;
import com.mojang.minecraft.particle.TerrainParticle;
import com.mojang.minecraft.player.Player;
import com.mojang.minecraft.render.ShapeRenderer;
import com.mojang.minecraft.render.TextureLocation;
import com.mojang.minecraft.render.TextureManager;
import com.mojang.util.MathHelper;
import java.util.Random;
import org.lwjgl.opengl.GL11;
@ -97,9 +97,11 @@ public class PrimedTnt extends Entity
}
@Override
public void render(float unknown0)
public void render(TextureManager textureManager, float unknown0)
{
new TextureLocation("/terrain.png").bindTexture();
int textureID = textureManager.load("/terrain.png");
GL11.glBindTexture(3553, textureID);
float brightness = level.getBrightness((int)x, (int)y, (int)z);

View File

@ -2,6 +2,7 @@ package com.mojang.minecraft.item;
import com.mojang.minecraft.Entity;
import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.render.TextureManager;
public class TakeEntityAnim extends Entity
{
@ -44,9 +45,9 @@ public class TakeEntityAnim extends Entity
}
@Override
public void render(float unknown0)
public void render(TextureManager textureManager, float unknown0)
{
item.render(unknown0);
item.render(textureManager, unknown0);
}
private static final long serialVersionUID = 1L;

View File

@ -6,6 +6,7 @@ import com.mojang.minecraft.level.SyntheticClass;
import com.mojang.minecraft.model.Vec3D;
import com.mojang.minecraft.phys.AABB;
import com.mojang.minecraft.render.Frustrum;
import com.mojang.minecraft.render.TextureManager;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@ -165,7 +166,7 @@ public class BlockMap implements Serializable {
}
public void render(Vec3D var1, Frustrum var2, float var4) {
public void render(Vec3D var1, Frustrum var2, TextureManager var3, float var4) {
for(int var5 = 0; var5 < this.width; ++var5) {
float var6 = (float)((var5 << 4) - 2);
float var7 = (float)((var5 + 1 << 4) + 2);
@ -251,7 +252,7 @@ public class BlockMap implements Serializable {
}
}
var22.render(var4);
var22.render(var3, var4);
}
}
}

View File

@ -1,8 +1,5 @@
package com.mojang.minecraft.level.tile;
import java.util.Random;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.level.tile.Block;
public final class BookshelfBlock extends Block {
@ -14,13 +11,6 @@ public final class BookshelfBlock extends Block {
protected final int getTextureId(int texture) {
return texture <= 1?4:this.textureId;
}
public final int getDrop() {
if(Minecraft.settings.randomDrops) {
return new Random().nextInt(49 - 1 + 1) + 1;
}
return Block.BOOKSHELF.id;
}
public final int getDropCount() {
return 0;

View File

@ -0,0 +1,10 @@
package com.mojang.minecraft.level.tile;
import com.mojang.minecraft.level.tile.Block;
public final class DirtBlock extends Block {
protected DirtBlock(int var1, int var2) {
super(3, 2);
}
}

View File

@ -1,6 +1,5 @@
package com.mojang.minecraft.level.tile;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.phys.AABB;
import com.mojang.minecraft.render.ShapeRenderer;
@ -93,11 +92,4 @@ public class FlowerBlock extends Block {
{
return null;
}
public int getDrop() {
if(Minecraft.settings.randomDrops) {
return new Random().nextInt(49 - 1 + 1) + 1;
}
return this == Block.ROSE ? Block.ROSE.id : Block.DANDELION.id;
}
}

View File

@ -1,8 +1,5 @@
package com.mojang.minecraft.level.tile;
import java.util.Random;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.level.Level;
public final class GlassBlock extends Block {

View File

@ -1,6 +1,5 @@
package com.mojang.minecraft.level.tile;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.level.tile.Block;
import java.util.Random;
@ -14,7 +13,7 @@ public final class GrassBlock extends Block {
}
protected final int getTextureId(int texture) {
return texture == 1 ? 0 : (texture == 0 ? 2 : Minecraft.settings.ofBetterGrass ? 0 : 3);
return texture == 1?0:(texture == 0?2:3);
}
public final void update(Level level, int x, int y, int z, Random rand) {
@ -36,9 +35,6 @@ public final class GrassBlock extends Block {
}
public final int getDrop() {
if(Minecraft.settings.randomDrops) {
return new Random().nextInt(49 - 1 + 1) + 1;
}
return Block.DIRT.getDrop();
}
}

View File

@ -1,8 +1,5 @@
package com.mojang.minecraft.level.tile;
import java.util.Random;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.level.tile.Block;
public final class MetalBlock extends Block {
@ -15,11 +12,4 @@ public final class MetalBlock extends Block {
protected final int getTextureId(int texture) {
return texture == 1?this.textureId - 16:(texture == 0?this.textureId + 16:this.textureId);
}
public final int getDrop() {
if(Minecraft.settings.randomDrops) {
return new Random().nextInt(49 - 1 + 1) + 1;
}
return this == Block.GOLD_BLOCK ? Block.GOLD_BLOCK.id : Block.IRON_BLOCK.id;
}
}

View File

@ -1,6 +1,5 @@
package com.mojang.minecraft.level.tile;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.level.tile.Block;
import com.mojang.minecraft.level.tile.FlowerBlock;
@ -21,12 +20,4 @@ public final class MushroomBlock extends FlowerBlock {
}
}
@Override
public final int getDrop() {
if(Minecraft.settings.randomDrops) {
return new Random().nextInt(49 - 1 + 1) + 1;
}
return this == Block.RED_MUSHROOM ? Block.RED_MUSHROOM.id : Block.BROWN_MUSHROOM.id;
}
}

View File

@ -1,8 +1,5 @@
package com.mojang.minecraft.level.tile;
import java.util.Random;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.level.tile.Block;
public final class OreBlock extends Block {
@ -12,9 +9,6 @@ public final class OreBlock extends Block {
}
public final int getDrop() {
if(Minecraft.settings.randomDrops) {
return new Random().nextInt(49 - 1 + 1) + 1;
}
return this == Block.COAL_ORE?Block.SLAB.id:(this == Block.GOLD_ORE?Block.GOLD_BLOCK.id:(this == Block.IRON_ORE?Block.IRON_BLOCK.id:this.id));
}

View File

@ -1,8 +1,5 @@
package com.mojang.minecraft.level.tile;
import java.util.Random;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.level.liquid.LiquidType;
import com.mojang.minecraft.level.tile.Block;
@ -45,11 +42,4 @@ public final class SandBlock extends Block {
--var5;
}
}
public final int getDrop() {
if(Minecraft.settings.randomDrops) {
return new Random().nextInt(49 - 1 + 1) + 1;
}
return Block.SAND.id;
}
}

View File

@ -1,6 +1,5 @@
package com.mojang.minecraft.level.tile;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.level.tile.Block;
import com.mojang.minecraft.level.tile.FlowerBlock;
@ -28,11 +27,4 @@ public final class SaplingBlock extends FlowerBlock {
level.setTile(x, y, z, 0);
}
}
public final int getDrop() {
if(Minecraft.settings.randomDrops) {
return new Random().nextInt(49 - 1 + 1) + 1;
}
return Block.SAPLING.id;
}
}

View File

@ -1,8 +1,5 @@
package com.mojang.minecraft.level.tile;
import java.util.Random;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.level.tile.Block;
@ -47,10 +44,7 @@ public final class SlabBlock extends Block {
}
public final int getDrop() {
if(Minecraft.settings.randomDrops) {
return new Random().nextInt(49 - 1 + 1) + 1;
}
return Block.SLAB.id;
return Block.SLAB.id;
}
public final boolean isCube() {

View File

@ -1,8 +1,5 @@
package com.mojang.minecraft.level.tile;
import java.util.Random;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.level.tile.Block;
@ -36,11 +33,4 @@ public final class SpongeBlock extends Block {
}
}
public final int getDrop() {
if(Minecraft.settings.randomDrops) {
return new Random().nextInt(49 - 1 + 1) + 1;
}
return Block.SPONGE.id;
}
}

View File

@ -1,8 +1,5 @@
package com.mojang.minecraft.level.tile;
import java.util.Random;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.level.tile.Block;
public final class StoneBlock extends Block {
@ -12,9 +9,6 @@ public final class StoneBlock extends Block {
}
public final int getDrop() {
if(Minecraft.settings.randomDrops) {
return new Random().nextInt(49 - 1 + 1) + 1;
}
return Block.COBBLESTONE.id;
return Block.COBBLESTONE.id;
}
}

View File

@ -1,8 +1,5 @@
package com.mojang.minecraft.level.tile;
import java.util.Random;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.item.PrimedTnt;
import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.level.tile.Block;
@ -38,11 +35,4 @@ public final class TNTBlock extends Block {
super.spawnBreakParticles(level, x, y, z, particleManager);
}
}
public final int getDrop() {
if(Minecraft.settings.randomDrops) {
return new Random().nextInt(49 - 1 + 1) + 1;
}
return Block.TNT.id;
}
}

View File

@ -1,8 +1,5 @@
package com.mojang.minecraft.level.tile;
import java.util.Random;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.level.tile.Block;
public final class WoodBlock extends Block {
@ -17,10 +14,7 @@ public final class WoodBlock extends Block {
}
public final int getDrop() {
if(Minecraft.settings.randomDrops) {
return new Random().nextInt(49 - 1 + 1) + 1;
}
return Block.WOOD.id;
return Block.WOOD.id;
}
protected final int getTextureId(int texture) {

View File

@ -4,7 +4,7 @@ import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.mob.Mob;
import com.mojang.minecraft.model.HumanoidModel;
import com.mojang.minecraft.model.Model;
import com.mojang.minecraft.render.TextureLocation;
import com.mojang.minecraft.render.TextureManager;
import org.lwjgl.opengl.GL11;
public class HumanoidMob extends Mob {
@ -20,8 +20,8 @@ public class HumanoidMob extends Mob {
this.setPos(var2, var3, var4);
}
public void renderModel(float var2, float var3, float var4, float var5, float var6, float var7) {
super.renderModel(var2, var3, var4, var5, var6, var7);
public void renderModel(TextureManager var1, float var2, float var3, float var4, float var5, float var6, float var7) {
super.renderModel(var1, var2, var3, var4, var5, var6, var7);
Model var9 = modelCache.getModel(this.modelName);
GL11.glEnable(3008);
if(this.allowAlpha) {
@ -38,7 +38,7 @@ public class HumanoidMob extends Mob {
}
if(this.armor || this.helmet) {
new TextureLocation("/armor/plate.png").bindTexture();
GL11.glBindTexture(3553, var1.load("/armor/plate.png"));
GL11.glDisable(2884);
HumanoidModel var8;
(var8 = (HumanoidModel)modelCache.getModel("humanoid.armor")).head.render = this.helmet;

View File

@ -5,7 +5,7 @@ import com.mojang.minecraft.level.Level;
import com.mojang.minecraft.mob.ai.AI;
import com.mojang.minecraft.mob.ai.BasicAI;
import com.mojang.minecraft.model.ModelManager;
import com.mojang.minecraft.render.TextureLocation;
import com.mojang.minecraft.render.TextureManager;
import com.mojang.util.MathHelper;
import org.lwjgl.opengl.GL11;
@ -204,11 +204,12 @@ public class Mob extends Entity {
}
protected void bindTexture() {
new TextureLocation(textureName).bindTexture();
protected void bindTexture(TextureManager var1) {
this.textureId = var1.load(this.textureName);
GL11.glBindTexture(3553, this.textureId);
}
public void render(float var2) {
public void render(TextureManager var1, float var2) {
if(this.modelName != null) {
float var3;
if((var3 = (float)this.attackTime - var2) < 0.0F) {
@ -287,14 +288,14 @@ public class Mob extends Entity {
GL11.glScalef(-1.0F, 1.0F, 1.0F);
modelCache.getModel(this.modelName).attackOffset = var3 / 5.0F;
this.bindTexture();
this.renderModel(var8, var2, var5, var6, var7, var9);
this.bindTexture(var1);
this.renderModel(var1, var8, var2, var5, var6, var7, var9);
if(this.invulnerableTime > this.invulnerableDuration - 10) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.75F);
GL11.glEnable(3042);
GL11.glBlendFunc(770, 1);
this.bindTexture();
this.renderModel(var8, var2, var5, var6, var7, var9);
this.bindTexture(var1);
this.renderModel(var1, var8, var2, var5, var6, var7, var9);
GL11.glDisable(3042);
GL11.glBlendFunc(770, 771);
}
@ -309,7 +310,7 @@ public class Mob extends Entity {
}
}
public void renderModel(float var2, float var3, float var4, float var5, float var6, float var7) {
public void renderModel(TextureManager var1, float var2, float var3, float var4, float var5, float var6, float var7) {
modelCache.getModel(this.modelName).render(var2, var4, (float)this.tickCount + var3, var5, var6, var7);
}

View File

@ -8,8 +8,7 @@ import com.mojang.minecraft.mob.QuadrupedMob;
import com.mojang.minecraft.mob.Sheep$1;
import com.mojang.minecraft.model.AnimalModel;
import com.mojang.minecraft.player.Player;
import com.mojang.minecraft.render.TextureLocation;
import com.mojang.minecraft.render.TextureManager;
import org.lwjgl.opengl.GL11;
public class Sheep extends QuadrupedMob {
@ -79,15 +78,15 @@ public class Sheep extends QuadrupedMob {
}
}
public void renderModel(float var2, float var3, float var4, float var5, float var6, float var7) {
public void renderModel(TextureManager var1, float var2, float var3, float var4, float var5, float var6, float var7) {
AnimalModel var8;
float var9 = (var8 = (AnimalModel)modelCache.getModel(this.modelName)).head.y;
float var10 = var8.head.z;
var8.head.y += (this.grazeO + (this.graze - this.grazeO) * var3) * 8.0F;
var8.head.z -= this.grazeO + (this.graze - this.grazeO) * var3;
super.renderModel(var2, var3, var4, var5, var6, var7);
super.renderModel(var1, var2, var3, var4, var5, var6, var7);
if(this.hasFur) {
new TextureLocation("/mob/sheep_fur.png").bindTexture();
GL11.glBindTexture(3553, var1.load("/mob/sheep_fur.png"));
GL11.glDisable(2884);
AnimalModel var11;
(var11 = (AnimalModel)modelCache.getModel("sheep.fur")).head.yaw = var8.head.yaw;

Some files were not shown because too many files have changed in this diff Show More