Fixed flowing water and lava textures
This commit is contained in:
parent
4e8af24d35
commit
733e52036d
|
@ -1563,4 +1563,11 @@ public class EaglerAdapterImpl2 {
|
|||
return serverToJoinOnLaunch;
|
||||
}
|
||||
|
||||
/**
|
||||
* I'm pretty sure my IntBuffers address this problem but if byte order glitches (such as corrupted textures) appear then change to true
|
||||
*/
|
||||
public static final boolean isBigEndian() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ public class ConfigConstants {
|
|||
|
||||
public static boolean profanity = false;
|
||||
|
||||
public static final String version = "22w20b";
|
||||
public static final String version = "22w22a";
|
||||
public static final String mainMenuString = "eaglercraft " + version;
|
||||
|
||||
public static final String forkMe = "https://github.com/LAX1DUDE/eaglercraft";
|
||||
|
@ -14,7 +14,6 @@ public class ConfigConstants {
|
|||
public static String ayonullTitle = null;
|
||||
public static String ayonullLink = null;
|
||||
|
||||
public static int mainMenuItem = -1;
|
||||
public static String mainMenuItemLine0 = null;
|
||||
public static String mainMenuItemLine1 = null;
|
||||
public static String mainMenuItemLine2 = null;
|
||||
|
|
75
src/main/java/net/lax1dude/eaglercraft/DebugIconImpl.java
Normal file
75
src/main/java/net/lax1dude/eaglercraft/DebugIconImpl.java
Normal file
|
@ -0,0 +1,75 @@
|
|||
package net.lax1dude.eaglercraft;
|
||||
|
||||
import net.minecraft.src.Icon;
|
||||
|
||||
public class DebugIconImpl implements Icon {
|
||||
|
||||
private final int sheetW;
|
||||
private final int sheetH;
|
||||
|
||||
public DebugIconImpl() {
|
||||
this(1024, 1024);
|
||||
}
|
||||
|
||||
public DebugIconImpl(int sheetW, int sheetH) {
|
||||
this.sheetW = sheetW;
|
||||
this.sheetH = sheetH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOriginX() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOriginY() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMinU() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMaxU() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getInterpolatedU(double var1) {
|
||||
return (float)var1 / 16.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMinV() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMaxV() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getInterpolatedV(double var1) {
|
||||
return (float)var1 / 16.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconName() {
|
||||
return "debug_icon";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSheetWidth() {
|
||||
return sheetW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSheetHeight() {
|
||||
return sheetH;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -17,11 +17,12 @@ import net.minecraft.src.RenderManager;
|
|||
//supports only 16x16 textures, mipmap is four levels deep
|
||||
public class TextureTerrainMap implements IconRegister {
|
||||
|
||||
private static class TerrainIcon implements Icon {
|
||||
private static class TerrainIconV2 implements Icon {
|
||||
|
||||
public final TextureTerrainMap map;
|
||||
public final String name;
|
||||
public final int id;
|
||||
public final int size;
|
||||
private EaglerImage[][] frames = null;
|
||||
private int[] framesIdx = null;
|
||||
|
||||
|
@ -42,16 +43,29 @@ public class TextureTerrainMap implements IconRegister {
|
|||
protected int frameCounter = 0;
|
||||
protected int frameCurrent = 0;
|
||||
|
||||
private TerrainIcon(int id, TextureTerrainMap map, String name) {
|
||||
private TerrainIconV2(int id, int s, TextureTerrainMap map, String name) {
|
||||
this.id = id;
|
||||
this.size = s;
|
||||
this.map = map;
|
||||
this.name = name;
|
||||
this.originX = (id % (map.width / 48)) * 48;
|
||||
this.originY = (id / (map.width / 48)) * 48;
|
||||
|
||||
if(s != 1 && s != 2) {
|
||||
throw new IllegalArgumentException("Size " + s + " (" + (s * 16) + "px) is not supported on this texture map");
|
||||
}
|
||||
|
||||
int tw = s * 16 + 32;
|
||||
|
||||
int adjId = id;
|
||||
if(s == 2) {
|
||||
adjId = (map.width / tw - 1) * (map.height / tw - 1) - id;
|
||||
}
|
||||
|
||||
this.originX = (adjId % (map.width / tw)) * tw;
|
||||
this.originY = (adjId / (map.width / tw)) * tw;
|
||||
this.minU = (float)originX / (float)map.width;
|
||||
this.minV = (float)originY / (float)map.height;
|
||||
this.maxU = (float)(originX + 48) / (float)map.width;
|
||||
this.maxV = (float)(originY + 48) / (float)map.height;
|
||||
this.maxU = (float)(originX + tw) / (float)map.width;
|
||||
this.maxV = (float)(originY + tw) / (float)map.height;
|
||||
this.originX_center = originX + 16;
|
||||
this.originY_center = originY + 16;
|
||||
this.minU_center = (float)(originX_center + 0.1f) / (float)map.width;
|
||||
|
@ -83,7 +97,7 @@ public class TextureTerrainMap implements IconRegister {
|
|||
@Override
|
||||
public float getInterpolatedU(double var1) {
|
||||
float var3 = this.maxU_center - this.minU_center;
|
||||
return this.minU_center + var3 * ((float) var1 / 16.0F);
|
||||
return this.minU_center + var3 * ((float) var1 * size / 16.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -99,7 +113,7 @@ public class TextureTerrainMap implements IconRegister {
|
|||
@Override
|
||||
public float getInterpolatedV(double var1) {
|
||||
float var3 = this.maxV_center - this.minV_center;
|
||||
return this.minV_center + var3 * ((float) var1 / 16.0F);
|
||||
return this.minV_center + var3 * ((float) var1 * size / 16.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -134,12 +148,12 @@ public class TextureTerrainMap implements IconRegister {
|
|||
if(data == null) {
|
||||
map.replaceTexture(this, map.missingData);
|
||||
}else {
|
||||
//EaglerImage img = EaglerImage.loadImage(data);
|
||||
EaglerImage img = EaglerAdapter.loadPNG(data);
|
||||
if(img == null) {
|
||||
map.replaceTexture(this, map.missingData);
|
||||
}else {
|
||||
int divs = img.h / 16;
|
||||
int ss = size * 16;
|
||||
int divs = img.h / ss;
|
||||
if(divs == 1) {
|
||||
this.frames = null;
|
||||
this.framesIdx = null;
|
||||
|
@ -147,7 +161,7 @@ public class TextureTerrainMap implements IconRegister {
|
|||
}else {
|
||||
frames = new EaglerImage[divs][];
|
||||
for(int i = 0; i < divs; ++i) {
|
||||
frames[i] = generateMip(img.getSubImage(0, i * 16, 16, 16));
|
||||
frames[i] = generateMip(img.getSubImage(0, i * ss, ss, ss));
|
||||
}
|
||||
String dat = EaglerAdapter.fileContents("/" + map.basePath + name + ".txt");
|
||||
if(dat != null) System.out.println("Found animation info for: " + map.basePath + name + ".png");
|
||||
|
@ -189,20 +203,20 @@ public class TextureTerrainMap implements IconRegister {
|
|||
private final String basePath;
|
||||
private final int width;
|
||||
private final int height;
|
||||
private TerrainIcon missingImage;
|
||||
private ArrayList<TerrainIcon> iconList;
|
||||
private TerrainIconV2 missingImage;
|
||||
private ArrayList<TerrainIconV2> iconList;
|
||||
public final int texture;
|
||||
private final EaglerImage[] missingData;
|
||||
|
||||
private static final IntBuffer uploadBuffer = EaglerAdapter.isWebGL ? IntBuffer.wrap(new int[4096]) : ByteBuffer.allocateDirect(4096 << 2).order(ByteOrder.nativeOrder()).asIntBuffer();
|
||||
private int[] nextSlot = new int[3];
|
||||
|
||||
private int nextSlot = 0;
|
||||
private static final IntBuffer uploadBuffer = EaglerAdapter.isWebGL ? IntBuffer.wrap(new int[4096]) : ByteBuffer.allocateDirect(4096 << 2).order(ByteOrder.nativeOrder()).asIntBuffer();
|
||||
|
||||
public TextureTerrainMap(int size, String par2, String par3Str, EaglerImage par4BufferedImage) {
|
||||
this.width = size;
|
||||
this.height = size;
|
||||
this.basePath = par3Str;
|
||||
this.missingImage = new TerrainIcon(nextSlot++, this, null);
|
||||
this.missingImage = new TerrainIconV2(nextSlot[1]++, 1, this, null);
|
||||
this.iconList = new ArrayList();
|
||||
this.texture = EaglerAdapter.glGenTextures();
|
||||
EaglerAdapter.glBindTexture(EaglerAdapter.GL_TEXTURE_2D, texture);
|
||||
|
@ -212,28 +226,28 @@ public class TextureTerrainMap implements IconRegister {
|
|||
for(int i = 0; i < blank.limit(); ++i) {
|
||||
blank.put(i, ((i / width + (i % width)) % 2 == 0) ? 0xffff00ff : 0xff000000);
|
||||
}
|
||||
EaglerAdapter.glTexParameteri(EaglerAdapter.GL_TEXTURE_2D, EaglerAdapter.GL_TEXTURE_MIN_FILTER, EaglerAdapter.GL_NEAREST_MIPMAP_LINEAR);
|
||||
EaglerAdapter.glTexParameteri(EaglerAdapter.GL_TEXTURE_2D, EaglerAdapter.GL_TEXTURE_MAG_FILTER, EaglerAdapter.GL_NEAREST);
|
||||
EaglerAdapter.glTexParameteri(EaglerAdapter.GL_TEXTURE_2D, EaglerAdapter.GL_TEXTURE_WRAP_S, EaglerAdapter.GL_CLAMP);
|
||||
EaglerAdapter.glTexParameteri(EaglerAdapter.GL_TEXTURE_2D, EaglerAdapter.GL_TEXTURE_WRAP_T, EaglerAdapter.GL_CLAMP);
|
||||
EaglerAdapter.glTexParameteri(EaglerAdapter.GL_TEXTURE_2D, EaglerAdapter.GL_TEXTURE_MAX_LEVEL, 4);
|
||||
EaglerAdapter.glTexParameterf(EaglerAdapter.GL_TEXTURE_2D, EaglerAdapter.GL_TEXTURE_MAX_ANISOTROPY, 1.0f);
|
||||
for(int i = 0; i < 5; ++i) {
|
||||
blank.clear().limit(levelW * levelH);
|
||||
EaglerAdapter.glTexImage2D(EaglerAdapter.GL_TEXTURE_2D, i, EaglerAdapter.GL_RGBA, levelW, levelH, 0, EaglerAdapter.GL_RGBA, EaglerAdapter.GL_UNSIGNED_BYTE, blank);
|
||||
levelW /= 2;
|
||||
levelH /= 2;
|
||||
}
|
||||
EaglerAdapter.glTexParameteri(EaglerAdapter.GL_TEXTURE_2D, EaglerAdapter.GL_TEXTURE_MIN_FILTER, EaglerAdapter.GL_NEAREST_MIPMAP_LINEAR);
|
||||
EaglerAdapter.glTexParameteri(EaglerAdapter.GL_TEXTURE_2D, EaglerAdapter.GL_TEXTURE_MAG_FILTER, EaglerAdapter.GL_NEAREST);
|
||||
EaglerAdapter.glTexParameteri(EaglerAdapter.GL_TEXTURE_2D, EaglerAdapter.GL_TEXTURE_WRAP_S, EaglerAdapter.GL_CLAMP);
|
||||
EaglerAdapter.glTexParameteri(EaglerAdapter.GL_TEXTURE_2D, EaglerAdapter.GL_TEXTURE_WRAP_T, EaglerAdapter.GL_CLAMP);
|
||||
EaglerAdapter.glTexParameteri(EaglerAdapter.GL_TEXTURE_2D, EaglerAdapter.GL_TEXTURE_MAX_LEVEL, 4);
|
||||
EaglerAdapter.glTexParameterf(EaglerAdapter.GL_TEXTURE_2D, EaglerAdapter.GL_TEXTURE_MAX_ANISOTROPY, 1.0f);
|
||||
replaceTexture(missingImage, missingData = generateMip(par4BufferedImage));
|
||||
}
|
||||
|
||||
public static EaglerImage[] generateMip(EaglerImage src16x16) {
|
||||
EaglerImage[] ret = new EaglerImage[5];
|
||||
ret[0] = populateAlpha(src16x16);
|
||||
ret[1] = generateLevel(ret[0]); ret[0] = create3x3(ret[0]);
|
||||
ret[2] = generateLevel(ret[1]); ret[1] = create3x3(ret[1]);
|
||||
ret[3] = generateLevel(ret[2]); ret[2] = create3x3(ret[2]);
|
||||
ret[4] = create3x3_2(generateLevel(ret[3])); ret[3] = create3x3(ret[3]);
|
||||
ret[0] = populateAlpha(create3x3_V2(src16x16));
|
||||
ret[1] = generateLevel(ret[0]);
|
||||
ret[2] = generateLevel(ret[1]);
|
||||
ret[3] = generateLevel(ret[2]);
|
||||
ret[4] = generateLevel(ret[3]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -257,22 +271,6 @@ public class TextureTerrainMap implements IconRegister {
|
|||
return e;
|
||||
}
|
||||
|
||||
public static EaglerImage premultiplyAlpha(EaglerImage src) {
|
||||
EaglerImage e = new EaglerImage(src.w, src.h, true);
|
||||
for(int i = 0; i < src.data.length; ++i) {
|
||||
int x = src.data[i];
|
||||
int a = (x >> 24) & 255;
|
||||
int r = (x >> 16) & 255;
|
||||
int g = (x >> 8) & 255;
|
||||
int b = x & 255;
|
||||
r = (r * a) / 255;
|
||||
g = (g * a) / 255;
|
||||
b = (b * a) / 255;
|
||||
e.data[i] = (a << 24) | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
public static EaglerImage populateAlpha(EaglerImage src) {
|
||||
EaglerImage ret = new EaglerImage(src.w, src.h, true);
|
||||
int reducedR = 0;
|
||||
|
@ -361,49 +359,58 @@ public class TextureTerrainMap implements IconRegister {
|
|||
return ret;
|
||||
}
|
||||
|
||||
public static EaglerImage create3x3(EaglerImage src) {
|
||||
EaglerImage ret = new EaglerImage(src.w * 3, src.h * 3, true);
|
||||
public static EaglerImage create3x3_V2(EaglerImage src) {
|
||||
EaglerImage ret = new EaglerImage(src.w + 32, src.h + 32, true);
|
||||
for(int y = 0; y < src.h; ++y) {
|
||||
for(int x = 0; x < src.w; ++x) {
|
||||
int pixel = src.data[y * src.w + x];
|
||||
|
||||
//if(y != src.h - 1) {
|
||||
ret.data[y * ret.w + (x)] = pixel;
|
||||
ret.data[y * ret.w + (x + src.w)] = pixel;
|
||||
ret.data[y * ret.w + (x + src.w*2)] = pixel;
|
||||
//}
|
||||
ret.data[(y + 16) * ret.w + (x + 16)] = pixel;
|
||||
|
||||
ret.data[(y + src.h) * ret.w + (x)] = pixel;
|
||||
ret.data[(y + src.h) * ret.w + (x + src.w)] = pixel;
|
||||
ret.data[(y + src.h) * ret.w + (x + src.w*2)] = pixel;
|
||||
|
||||
//if(y != 0) {
|
||||
ret.data[(y + src.h * 2) * ret.w + (x)] = pixel;
|
||||
ret.data[(y + src.h * 2) * ret.w + (x + src.w)] = pixel;
|
||||
ret.data[(y + src.h * 2) * ret.w + (x + src.w*2)] = pixel;
|
||||
//}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
if(x < 16) {
|
||||
ret.data[(y + 16) * ret.w + x] = pixel;
|
||||
}
|
||||
|
||||
public static EaglerImage create3x3_2(EaglerImage src) {
|
||||
EaglerImage ret = new EaglerImage(3, 3, true);
|
||||
ret.data[0] = src.data[0];
|
||||
ret.data[1] = src.data[0];
|
||||
ret.data[2] = src.data[0];
|
||||
ret.data[3] = src.data[0];
|
||||
ret.data[4] = src.data[0];
|
||||
ret.data[5] = src.data[0];
|
||||
ret.data[6] = src.data[0];
|
||||
ret.data[7] = src.data[0];
|
||||
ret.data[8] = src.data[0];
|
||||
if(y < 16) {
|
||||
ret.data[y * ret.w + (x + 16)] = pixel;
|
||||
}
|
||||
|
||||
if(x < 16 && y < 16) {
|
||||
ret.data[y * ret.w + x] = pixel;
|
||||
}
|
||||
|
||||
int mw = src.w - 16;
|
||||
int mh = src.h - 16;
|
||||
|
||||
if(x >= mw) {
|
||||
ret.data[(y + 16) * ret.w + src.w + (x - mw + 16)] = pixel;
|
||||
}
|
||||
|
||||
if(y >= mh) {
|
||||
ret.data[(y - mh + src.h + 16) * ret.w + (x + 16)] = pixel;
|
||||
}
|
||||
|
||||
if(x >= mw && y >= mh) {
|
||||
ret.data[(y - mh + src.h + 16) * ret.w + src.w + (x - mw + 16)] = pixel;
|
||||
}
|
||||
|
||||
if(x >= mw && y < 16) {
|
||||
ret.data[y * ret.w + src.w + (x - mw + 16)] = pixel;
|
||||
}
|
||||
|
||||
if(x < 16 && y >= mh) {
|
||||
ret.data[(y - mh + src.h + 16) * ret.w + x] = pixel;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void refreshTextures() {
|
||||
iconList.clear();
|
||||
nextSlot = 1;
|
||||
nextSlot = new int[3];
|
||||
nextSlot[1] = 1;
|
||||
Block[] var1 = Block.blocksList;
|
||||
int var2 = var1.length;
|
||||
|
||||
|
@ -418,12 +425,12 @@ public class TextureTerrainMap implements IconRegister {
|
|||
Minecraft.getMinecraft().renderGlobal.registerDestroyBlockIcons(this);
|
||||
RenderManager.instance.updateIcons(this);
|
||||
|
||||
for(TerrainIcon t : iconList) {
|
||||
for(TerrainIconV2 t : iconList) {
|
||||
t.loadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void replaceTexture(TerrainIcon icon, EaglerImage[] textures) {
|
||||
private void replaceTexture(TerrainIconV2 icon, EaglerImage[] textures) {
|
||||
int levelW = width;
|
||||
int levelH = height;
|
||||
int divisor = 1;
|
||||
|
@ -432,7 +439,8 @@ public class TextureTerrainMap implements IconRegister {
|
|||
uploadBuffer.clear();
|
||||
uploadBuffer.put(textures[i].data);
|
||||
uploadBuffer.flip();
|
||||
EaglerAdapter.glTexSubImage2D(EaglerAdapter.GL_TEXTURE_2D, i, icon.originX / divisor, icon.originY / divisor, 48 / divisor, 48 / divisor, EaglerAdapter.GL_RGBA, EaglerAdapter.GL_UNSIGNED_BYTE, uploadBuffer);
|
||||
EaglerAdapter.glTexSubImage2D(EaglerAdapter.GL_TEXTURE_2D, i, icon.originX / divisor, icon.originY / divisor,
|
||||
(16 * icon.size + 32) / divisor, (16 * icon.size + 32) / divisor, EaglerAdapter.GL_RGBA, EaglerAdapter.GL_UNSIGNED_BYTE, uploadBuffer);
|
||||
levelW /= 2;
|
||||
levelH /= 2;
|
||||
divisor *= 2;
|
||||
|
@ -440,19 +448,22 @@ public class TextureTerrainMap implements IconRegister {
|
|||
}
|
||||
|
||||
public void updateAnimations() {
|
||||
for(TerrainIcon t : iconList) {
|
||||
for(TerrainIconV2 t : iconList) {
|
||||
t.updateAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
public Icon registerIcon(String par1Str) {
|
||||
if(par1Str != null) {
|
||||
for(TerrainIcon t : iconList) {
|
||||
if(par1Str.equals(t.name)) {
|
||||
public Icon registerIcon(String par1Str, int w) {
|
||||
if(w != 1 && w != 2) {
|
||||
System.err.println("Error, texture '" + par1Str + "' was registered with size " + w + ", the terrain texure map only supports size 1 and 2 (16px and 32px)");
|
||||
return missingImage;
|
||||
}else if(par1Str != null) {
|
||||
for(TerrainIconV2 t : iconList) {
|
||||
if(par1Str.equals(t.name) && w == t.size) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
TerrainIcon ret = new TerrainIcon(nextSlot++, this, par1Str);
|
||||
TerrainIconV2 ret = new TerrainIconV2(nextSlot[w]++, w, this, par1Str);
|
||||
iconList.add(ret);
|
||||
return ret;
|
||||
}else{
|
||||
|
|
|
@ -523,9 +523,9 @@ public abstract class BlockFluid extends Block {
|
|||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister) {
|
||||
if (this.blockMaterial == Material.lava) {
|
||||
this.theIcon = new Icon[] { par1IconRegister.registerIcon("lava"), par1IconRegister.registerIcon("lava_flow") };
|
||||
this.theIcon = new Icon[] { par1IconRegister.registerIcon("lava"), par1IconRegister.registerIcon("lava_flow", 2) };
|
||||
} else {
|
||||
this.theIcon = new Icon[] { par1IconRegister.registerIcon("water"), par1IconRegister.registerIcon("water_flow") };
|
||||
this.theIcon = new Icon[] { par1IconRegister.registerIcon("water"), par1IconRegister.registerIcon("water_flow", 2) };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,22 @@ public class GuiMainMenu extends GuiScreen {
|
|||
private String splashText = "missingno";
|
||||
private GuiButton buttonResetDemo;
|
||||
|
||||
private static boolean showingEndian = true;
|
||||
private static final int showRandomItem;
|
||||
|
||||
static {
|
||||
if(ConfigConstants.mainMenuItemLink != null) {
|
||||
EaglercraftRandom rand = new EaglercraftRandom();
|
||||
int itm = 0;
|
||||
do {
|
||||
itm = rand.nextInt(256) + 256;
|
||||
}while(Item.itemsList[itm] == null);
|
||||
showRandomItem = itm;
|
||||
}else {
|
||||
showRandomItem = -1;
|
||||
}
|
||||
}
|
||||
|
||||
private long start;
|
||||
|
||||
/**
|
||||
|
@ -206,7 +222,7 @@ public class GuiMainMenu extends GuiScreen {
|
|||
EaglerAdapter.openConsole();
|
||||
}
|
||||
*/
|
||||
if(ConfigConstants.mainMenuItem > 0 && ConfigConstants.mainMenuItemLink != null) {
|
||||
if(ConfigConstants.mainMenuItemLink != null) {
|
||||
//drawRect((this.width - w - 4), 0, this.width, 9, 0x55200000);
|
||||
|
||||
int posX = this.width / 2 - 170 - this.width / 10;
|
||||
|
@ -256,14 +272,17 @@ public class GuiMainMenu extends GuiScreen {
|
|||
*/
|
||||
protected void actionPerformed(GuiButton par1GuiButton) {
|
||||
if (par1GuiButton.id == 0) {
|
||||
showingEndian = false;
|
||||
this.mc.displayGuiScreen(new GuiOptions(this, this.mc.gameSettings));
|
||||
}
|
||||
|
||||
if (par1GuiButton.id == 5) {
|
||||
showingEndian = false;
|
||||
this.mc.displayGuiScreen(new GuiLanguage(this, this.mc.gameSettings));
|
||||
}
|
||||
|
||||
if (par1GuiButton.id == 2) {
|
||||
showingEndian = false;
|
||||
this.mc.displayGuiScreen(new GuiMultiplayer(this));
|
||||
}
|
||||
|
||||
|
@ -273,6 +292,7 @@ public class GuiMainMenu extends GuiScreen {
|
|||
}
|
||||
|
||||
if (par1GuiButton.id == 4) {
|
||||
showingEndian = false;
|
||||
this.mc.displayGuiScreen(new GuiScreenEditProfile(this));
|
||||
}
|
||||
}
|
||||
|
@ -471,6 +491,10 @@ public class GuiMainMenu extends GuiScreen {
|
|||
var10 = "site resources are";
|
||||
this.drawString(this.fontRenderer, var10, this.width - this.fontRenderer.getStringWidth(var10) - 2, this.height - 20, 16777215);
|
||||
|
||||
if(showingEndian && EaglerAdapter.isBigEndian()) {
|
||||
this.drawCenteredString(fontRenderer, "(BIG Endian)", this.width / 2, this.height - 10, 0xFFFFBBBB);
|
||||
}
|
||||
|
||||
if (this.field_92025_p != null && this.field_92025_p.length() > 0) {
|
||||
drawRect(this.field_92022_t - 2, this.field_92021_u - 2, this.field_92020_v + 2, this.field_92019_w - 1, 1428160512);
|
||||
this.drawString(this.fontRenderer, this.field_92025_p, this.field_92022_t, this.field_92021_u, 16777215);
|
||||
|
@ -518,7 +542,7 @@ public class GuiMainMenu extends GuiScreen {
|
|||
EaglerAdapter.glPopMatrix();
|
||||
*/
|
||||
|
||||
if(ConfigConstants.mainMenuItem > 0 && ConfigConstants.mainMenuItemLink != null) {
|
||||
if(ConfigConstants.mainMenuItemLink != null) {
|
||||
//drawRect((this.width - w - 4), 0, this.width, 9, 0x55200000);
|
||||
|
||||
int posX = this.width / 2 - 170 - this.width / 10;
|
||||
|
@ -527,13 +551,13 @@ public class GuiMainMenu extends GuiScreen {
|
|||
int hh = 46;
|
||||
int ln0w = ConfigConstants.mainMenuItemLine0 == null ? 0 : fontRenderer.getStringWidth(ConfigConstants.mainMenuItemLine0);
|
||||
ww = ww < ln0w ? ln0w : ww;
|
||||
hh = hh < ln0w ? hh + 12 : hh;
|
||||
hh = ln0w > 0 ? hh + 12 : hh;
|
||||
int ln1w = ConfigConstants.mainMenuItemLine1 == null ? 0 : fontRenderer.getStringWidth(ConfigConstants.mainMenuItemLine1);
|
||||
ww = ww < ln1w ? ln1w : ww;
|
||||
hh = hh < ln1w ? hh + 12 : hh;
|
||||
hh = ln1w > 0 ? hh + 12 : hh;
|
||||
int ln2w = ConfigConstants.mainMenuItemLine2 == null ? 0 : fontRenderer.getStringWidth(ConfigConstants.mainMenuItemLine2);
|
||||
ww = ww < ln2w ? ln2w : ww;
|
||||
hh = hh < ln2w ? hh + 12 : hh;
|
||||
hh = ln2w > 0 ? hh + 12 : hh;
|
||||
|
||||
ww += 20;
|
||||
hh += 20;
|
||||
|
@ -564,7 +588,7 @@ public class GuiMainMenu extends GuiScreen {
|
|||
items.bindTexture();
|
||||
|
||||
EaglerAdapter.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
this.drawTexturedModelRectFromIcon((ww - iconSize) / 2, i, Item.itemsList[ConfigConstants.mainMenuItem].getIconFromDamage(0), iconSize, iconSize);
|
||||
this.drawTexturedModelRectFromIcon((ww - iconSize) / 2, i, Item.itemsList[showRandomItem].getIconFromDamage(0), iconSize, iconSize);
|
||||
|
||||
i += iconSize + 5;
|
||||
|
||||
|
@ -594,7 +618,7 @@ public class GuiMainMenu extends GuiScreen {
|
|||
EaglerAdapter.glPushMatrix();
|
||||
EaglerAdapter.glTranslatef(posX, posY, 0.0f);
|
||||
EaglerAdapter.glScalef(0.75f, 0.75f, 0.75f);
|
||||
this.drawTexturedModelRectFromIcon((ww - iconSize) / 2, ln0w > 0 ? 22 : 10, Item.itemsList[ConfigConstants.mainMenuItem].getIconFromDamage(0), iconSize, iconSize);
|
||||
this.drawTexturedModelRectFromIcon((ww - iconSize) / 2, ln0w > 0 ? 22 : 10, Item.itemsList[showRandomItem].getIconFromDamage(0), iconSize, iconSize);
|
||||
EaglerAdapter.glPopMatrix();
|
||||
|
||||
EaglerAdapter.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
package net.minecraft.src;
|
||||
|
||||
public interface IconRegister {
|
||||
Icon registerIcon(String var1);
|
||||
|
||||
Icon registerIcon(String var1, int w);
|
||||
|
||||
default Icon registerIcon(String var1) {
|
||||
return registerIcon(var1, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,12 +42,11 @@ public class ServerList {
|
|||
ConfigConstants.ayonullLink = nbt.hasKey("serverListLink") ? nbt.getString("serverListLink") : null;
|
||||
if(nbt.hasKey("mainMenu")) {
|
||||
NBTTagCompound cmp = nbt.getCompoundTag("mainMenu");
|
||||
ConfigConstants.mainMenuItem = cmp.hasKey("mainMenuItem") ? (int)cmp.getShort("mainMenuItem") & 0xffff : -1;
|
||||
if(ConfigConstants.mainMenuItem > 0) {
|
||||
ConfigConstants.mainMenuItemLink = cmp.getStringOrNull("itemLink");
|
||||
if(ConfigConstants.mainMenuItemLink != null) {
|
||||
ConfigConstants.mainMenuItemLine0 = cmp.getStringOrNull("itemLine0");
|
||||
ConfigConstants.mainMenuItemLine1 = cmp.getStringOrNull("itemLine1");
|
||||
ConfigConstants.mainMenuItemLine2 = cmp.getStringOrNull("itemLine2");
|
||||
ConfigConstants.mainMenuItemLink = cmp.getStringOrNull("itemLink");
|
||||
}
|
||||
}
|
||||
forcedServers.clear();
|
||||
|
|
|
@ -158,7 +158,11 @@ public class TextureMap implements IconRegister {
|
|||
return this.atlasTexture;
|
||||
}
|
||||
|
||||
public Icon registerIcon(String par1Str) {
|
||||
public Icon registerIcon(String par1Str, int w) {
|
||||
if(w != 1) {
|
||||
System.err.println("Error, texture '" + par1Str + "' was registered with size " + w + ", the item texure map only supports size 1 (16px)");
|
||||
return missingTextureStiched;
|
||||
}else {
|
||||
if (par1Str == null) {
|
||||
(new RuntimeException("Don\'t register null!")).printStackTrace();
|
||||
}
|
||||
|
@ -172,6 +176,7 @@ public class TextureMap implements IconRegister {
|
|||
|
||||
return var2;
|
||||
}
|
||||
}
|
||||
|
||||
public Icon getMissingIcon() {
|
||||
return this.missingTextureStiched;
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package net.lax1dude.eaglercraft;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import org.teavm.jso.JSBody;
|
||||
import org.teavm.jso.browser.Window;
|
||||
import org.teavm.jso.core.JSError;
|
||||
|
@ -19,7 +22,14 @@ public class Client {
|
|||
registerErrorHandler();
|
||||
//try {
|
||||
String[] e = getOpts();
|
||||
try {
|
||||
EaglerAdapterImpl2.initializeContext(rootElement = Window.current().getDocument().getElementById(e[0]), e[1]);
|
||||
}catch(Throwable t) {
|
||||
StringWriter s = new StringWriter();
|
||||
t.printStackTrace(new PrintWriter(s));
|
||||
showCrashScreen(s.toString());
|
||||
return;
|
||||
}
|
||||
LocalStorageManager.loadStorage();
|
||||
if(e.length > 2 && e[2].length() > 0) {
|
||||
ServerList.loadDefaultServers(e[2]);
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.teavm.jso.dom.html.HTMLVideoElement;
|
|||
import org.teavm.jso.dom.html.HTMLImageElement;
|
||||
import org.teavm.jso.media.MediaError;
|
||||
import org.teavm.jso.typedarrays.ArrayBuffer;
|
||||
import org.teavm.jso.typedarrays.DataView;
|
||||
import org.teavm.jso.typedarrays.Float32Array;
|
||||
import org.teavm.jso.typedarrays.Int32Array;
|
||||
import org.teavm.jso.typedarrays.Uint8Array;
|
||||
|
@ -70,11 +71,9 @@ import net.lax1dude.eaglercraft.EaglerImage;
|
|||
import net.lax1dude.eaglercraft.EarlyLoadScreen;
|
||||
import net.lax1dude.eaglercraft.LocalStorageManager;
|
||||
import net.lax1dude.eaglercraft.ServerQuery;
|
||||
import net.lax1dude.eaglercraft.ServerQuery.QueryResponse;
|
||||
import net.lax1dude.eaglercraft.adapter.teavm.WebGLQuery;
|
||||
import net.lax1dude.eaglercraft.adapter.teavm.WebGLVertexArray;
|
||||
import net.minecraft.src.MathHelper;
|
||||
import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.RateLimit;
|
||||
import net.lax1dude.eaglercraft.adapter.teavm.WebGL2RenderingContext;
|
||||
import static net.lax1dude.eaglercraft.adapter.teavm.WebGL2RenderingContext.*;
|
||||
|
||||
|
@ -635,18 +634,18 @@ public class EaglerAdapterImpl2 {
|
|||
}
|
||||
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());
|
||||
DataView deevis = DataView.create(uploadBuffer.getBuffer());
|
||||
for(int i = 0; i < len; ++i) {
|
||||
deevis.set(i, p9.get());
|
||||
deevis.setInt32(i * 4, p9.get(), true);
|
||||
}
|
||||
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());
|
||||
DataView deevis = DataView.create(uploadBuffer.getBuffer());
|
||||
for(int i = 0; i < len; ++i) {
|
||||
deevis.set(i, p9.get());
|
||||
deevis.setInt32(i * 4, p9.get(), true);
|
||||
}
|
||||
Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len*4);
|
||||
webgl.texSubImage2D(p1, p2, p3, p4, p5, p6, p7, p8, data);
|
||||
|
@ -666,6 +665,7 @@ public class EaglerAdapterImpl2 {
|
|||
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(swapEndian ? ((i >> 2) + (3 - (i & 3))) : i, (short) ((int)p9.get() & 0xff));
|
||||
uploadBuffer.set(i, (short) ((int)p9.get() & 0xff));
|
||||
}
|
||||
Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len);
|
||||
|
@ -724,18 +724,18 @@ public class EaglerAdapterImpl2 {
|
|||
}
|
||||
public static final void _wglBufferData0(int p1, IntBuffer p2, int p3) {
|
||||
int len = p2.remaining();
|
||||
Int32Array deevis = Int32Array.create(uploadBuffer.getBuffer());
|
||||
DataView deevis = DataView.create(uploadBuffer.getBuffer());
|
||||
for(int i = 0; i < len; ++i) {
|
||||
deevis.set(i, p2.get());
|
||||
deevis.setInt32(i * 4, p2.get(), true);
|
||||
}
|
||||
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());
|
||||
DataView deevis = DataView.create(uploadBuffer.getBuffer());
|
||||
for(int i = 0; i < len; ++i) {
|
||||
deevis.set(i, p3.get());
|
||||
deevis.setInt32(i * 4, p3.get(), true);
|
||||
}
|
||||
Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len*4);
|
||||
webgl.bufferSubData(p1, p2, data);
|
||||
|
@ -2476,4 +2476,63 @@ public class EaglerAdapterImpl2 {
|
|||
return serverToJoinOnLaunch;
|
||||
}
|
||||
|
||||
private static boolean endianWasChecked = false;
|
||||
private static boolean isBigEndian = false;
|
||||
private static boolean isLittleEndian = false;
|
||||
|
||||
public static final boolean isBigEndian() {
|
||||
if(!endianWasChecked) {
|
||||
int checkIntegerA = 0xFF000000;
|
||||
int checkIntegerB = 0x000000FF;
|
||||
|
||||
ArrayBuffer buf = ArrayBuffer.create(4);
|
||||
Int32Array bufW = Int32Array.create(buf);
|
||||
Uint8Array bufR = Uint8Array.create(buf);
|
||||
|
||||
bufW.set(0, checkIntegerA);
|
||||
|
||||
boolean knownBig1 = false;
|
||||
if(bufR.get(0) == (short)0xFF && bufR.get(1) == (short)0 && bufR.get(2) == (short)0 && bufR.get(3) == (short)0) {
|
||||
knownBig1 = true;
|
||||
}
|
||||
|
||||
boolean knownLittle1 = false;
|
||||
if(bufR.get(0) == (short)0 && bufR.get(1) == (short)0 && bufR.get(2) == (short)0 && bufR.get(3) == (short)0xFF) {
|
||||
knownLittle1 = true;
|
||||
}
|
||||
|
||||
bufW.set(0, checkIntegerB);
|
||||
|
||||
boolean knownBig2 = false;
|
||||
if(bufR.get(0) == (short)0 && bufR.get(1) == (short)0 && bufR.get(2) == (short)0 && bufR.get(3) == (short)0xFF) {
|
||||
knownBig2 = true;
|
||||
}
|
||||
|
||||
boolean knownLittle2 = false;
|
||||
if(bufR.get(0) == (short)0xFF && bufR.get(1) == (short)0 && bufR.get(2) == (short)0 && bufR.get(3) == (short)0) {
|
||||
knownLittle2 = true;
|
||||
}
|
||||
|
||||
if(knownBig1 == knownBig2 && knownLittle1 == knownLittle2 && knownBig1 != knownLittle1) {
|
||||
isBigEndian = knownBig1;
|
||||
isLittleEndian = knownLittle1;
|
||||
}
|
||||
|
||||
if(isBigEndian) {
|
||||
System.out.println("This browser is BIG endian!");
|
||||
}else if(isLittleEndian) {
|
||||
System.out.println("This browser is LITTLE endian!");
|
||||
}else {
|
||||
System.out.println("The byte order of this browser is inconsistent!");
|
||||
System.out.println(" - the sequence FF000000 was " + (knownBig1 ? "" : "not ") + "big endian.");
|
||||
System.out.println(" - the sequence FF000000 was " + (knownLittle1 ? "" : "not ") + "little endian.");
|
||||
System.out.println(" - the sequence 000000FF was " + (knownBig2 ? "" : "not ") + "big endian.");
|
||||
System.out.println(" - the sequence 000000FF was " + (knownLittle2 ? "" : "not ") + "little endian.");
|
||||
}
|
||||
|
||||
endianWasChecked = true;
|
||||
}
|
||||
return !isLittleEndian;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user