Merge branch 'main' of https://github.com/LAX1DUDE/eaglercraft into LAX1DUDE-main

This commit is contained in:
ayunami2000 2022-05-18 20:51:27 -04:00
commit 108f34c201
70 changed files with 100260 additions and 126508 deletions

View File

@ -63,7 +63,7 @@ teavm {
classesToPreserve = null;
stopOnErrors = false;
optimizationLevel = "FULL"; //org.teavm.vm.TeaVMOptimizationLevel.SIMPLE;
optimizationLevel = "ADVANCED"; //org.teavm.vm.TeaVMOptimizationLevel.SIMPLE;
fastGlobalAnalysis = false;
targetType = "JAVASCRIPT"; //org.teavm.tooling.TeaVMTargetType.JAVASCRIPT;
cacheDirectory = null;

View File

@ -38,6 +38,7 @@ public interface QueryConnection {
toSend.put("brand", EaglercraftBungee.brand);
toSend.put("vers", EaglercraftBungee.version);
toSend.put("cracked", EaglercraftBungee.cracked);
toSend.put("secure", false);
toSend.put("time", System.currentTimeMillis());
toSend.put("uuid", BungeeCord.getInstance().config.getUuid());
toSend.put("data", msg);
@ -51,6 +52,7 @@ public interface QueryConnection {
toSend.put("brand", EaglercraftBungee.brand);
toSend.put("vers", EaglercraftBungee.version);
toSend.put("cracked", EaglercraftBungee.cracked);
toSend.put("secure", false);
toSend.put("time", System.currentTimeMillis());
toSend.put("uuid", BungeeCord.getInstance().config.getUuid());
toSend.put("data", msg);

View File

@ -26,6 +26,7 @@ public class Configuration {
private boolean onlineMode;
private int playerLimit;
private String name;
private boolean showBanType;
public Configuration() {
this.timeout = 30000;
@ -51,6 +52,7 @@ public class Configuration {
this.onlineMode = false;
this.playerLimit = adapter.getInt("player_limit", this.playerLimit);
this.name = adapter.getString("server_name", EaglercraftBungee.name + " Server");
this.showBanType = adapter.getBoolean("display_ban_type_on_kick", false);
Preconditions.checkArgument(this.listeners != null && !this.listeners.isEmpty(), (Object) "No listeners defined.");
final Map<String, ServerInfo> newServers = adapter.getServers();
Preconditions.checkArgument(newServers != null && !newServers.isEmpty(), (Object) "No servers defined");
@ -102,4 +104,9 @@ public class Configuration {
public String getServerName() {
return name;
}
public boolean shouldShowBanType() {
return this.showBanType;
}
}

View File

@ -41,6 +41,7 @@ import net.md_5.bungee.api.event.ProxyPingEvent;
import net.md_5.bungee.eaglercraft.BanList;
import net.md_5.bungee.eaglercraft.WebSocketProxy;
import net.md_5.bungee.eaglercraft.BanList.BanCheck;
import net.md_5.bungee.eaglercraft.BanList.BanState;
import net.md_5.bungee.api.ServerPing;
import net.md_5.bungee.protocol.packet.PacketFEPing;
import net.md_5.bungee.Util;
@ -164,7 +165,11 @@ public class InitialHandler extends PacketHandler implements PendingConnection {
default:
System.err.println("Player '" + un + "' is banned: " + bc.string);
}
this.disconnect("" + ChatColor.RED + "You are banned.\n" + ChatColor.DARK_GRAY + "Reason: " + bc.string);
if(bc.reason == BanState.USER_BANNED || ((BungeeCord)bungee).config.shouldShowBanType()) {
this.disconnect("" + ChatColor.RED + "You are banned.\n" + ChatColor.DARK_GRAY + "Reason: " + bc.string);
}else {
this.disconnect("" + ChatColor.RED + "You are banned.");
}
return;
}
final int limit = BungeeCord.getInstance().config.getPlayerLimit();
@ -266,7 +271,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection {
@Override
public InetSocketAddress getVirtualHost() {
return (this.handshake == null) ? null : new InetSocketAddress(this.handshake.getHost(), this.handshake.getPort());
return (this.handshake == null) ? null : new InetSocketAddress(this.handshake.getHost(), this.handshake.getPort() & 0xFFFF);
}
@Override

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

View File

@ -40,7 +40,7 @@ public class VideoMapPacketCodec {
this.requiresFullResetPacket = true;
this.isDisabled = true;
}
/**
* @param mapIds 2D grid of map IDs that make up the screen (mapIds[y][x])
* @param posX audio playback X coord
@ -48,7 +48,14 @@ public class VideoMapPacketCodec {
* @param posZ audio playback Z coord
*/
public VideoMapPacketCodec(int[][] mapIds, double posX, double posY, double posZ) {
this(mapIds, posX, posY, posZ, 1.0f);
this(mapIds, posX, posY, posZ, 0.5f);
}
/**
* @param mapIds 2D grid of map IDs that make up the screen (mapIds[y][x])
*/
public VideoMapPacketCodec(int[][] mapIds) {
this(mapIds, 0, 100, 0, 0.5f);
}
/**
@ -167,7 +174,7 @@ public class VideoMapPacketCodec {
/**
* @param url URL to an MP4 or other HTML5 supported video file
* @param loop If the video file should loop
* @param durationSeconds duration of the video in seconds
* @param duration duration of the video in seconds
* @return packet to send to players
*/
public byte[] beginPlayback(String url, boolean loop, float duration) {

View File

@ -20,7 +20,7 @@ public class VideoMapPacketCodecBukkit extends VideoMapPacketCodec {
public VideoMapPacketCodecBukkit(int[][] mapIds, double posX, double posY, double posZ, float volume) {
super(mapIds, posX, posY, posZ, volume);
}
/**
* @param mapIds 2D grid of map IDs that make up the screen (mapIds[y][x])
* @param posX audio playback X coord
@ -28,13 +28,23 @@ public class VideoMapPacketCodecBukkit extends VideoMapPacketCodec {
* @param posZ audio playback Z coord
*/
public VideoMapPacketCodecBukkit(int[][] mapIds, double posX, double posY, double posZ) {
super(mapIds, posX, posY, posZ, 1.0f);
super(mapIds, posX, posY, posZ);
}
/**
* @param mapIds 2D grid of map IDs that make up the screen (mapIds[y][x])
*/
public VideoMapPacketCodecBukkit(int[][] mapIds) {
super(mapIds);
}
public static class VideoMapPacket {
protected final Object packet;
protected VideoMapPacket(byte[] packet) {
this.packet = new Packet131ItemData((short)104, (short)0, packet);
this(packet, false);
}
protected VideoMapPacket(byte[] packet, boolean image) {
this.packet = new Packet131ItemData((short)(104 + (image ? 1 : 0)), (short)0, packet);
}
public Object getNativePacket() {
return packet;
@ -72,7 +82,15 @@ public class VideoMapPacketCodecBukkit extends VideoMapPacketCodec {
public VideoMapPacket disableVideoBukkit() {
return new VideoMapPacket(disableVideo());
}
/**
* unloads image and resets all map object to vanilla renderer
* @return packet to send to players
*/
public VideoMapPacket disableImageBukkit() {
return new VideoMapPacket(disableVideo(), true);
}
/**
* syncs the server side video timestamp with players
* @return packet to send to players
@ -80,7 +98,15 @@ public class VideoMapPacketCodecBukkit extends VideoMapPacketCodec {
public VideoMapPacket syncPlaybackWithPlayersBukkit() {
return new VideoMapPacket(syncPlaybackWithPlayers());
}
/**
* syncs the server side image with players
* @return packet to send to players
*/
public VideoMapPacket syncPlaybackWithPlayersImageBukkit() {
return new VideoMapPacket(syncPlaybackWithPlayers(), true);
}
/**
* @param url URL to an MP4 or other HTML5 supported video file
* @param loop If the video file should loop
@ -90,7 +116,15 @@ public class VideoMapPacketCodecBukkit extends VideoMapPacketCodec {
public VideoMapPacket beginPlaybackBukkit(String url, boolean loop, float duration) {
return new VideoMapPacket(beginPlayback(url, loop, duration));
}
/**
* @param url URL to a PNG, JPEG, GIF, or other HTML5 supported image file
* @return packet to send to players
*/
public VideoMapPacket beginPlaybackImageBukkit(String url) {
return new VideoMapPacket(beginPlayback(url));
}
/**
* Tells the browser to pre-load a URL to a video to be played in the future
* @param url the URL of the video
@ -101,6 +135,16 @@ public class VideoMapPacketCodecBukkit extends VideoMapPacketCodec {
return new VideoMapPacket(bufferVideo(url, ttl));
}
/**
* Tells the browser to pre-load a URL to an image to be played in the future
* @param url the URL of the image
* @param ttl the amount of time the image should stay loaded
* @return packet to send to players
*/
public static VideoMapPacket bufferImageBukkit(String url, int ttl) {
return new VideoMapPacket(bufferVideo(url, ttl), true);
}
/**
* @param time time in seconds to seek the video to
*/

View File

@ -13,6 +13,7 @@ import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
@ -34,6 +35,7 @@ import java.util.LinkedList;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import javax.imageio.ImageIO;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
@ -65,6 +67,7 @@ import org.lwjgl.util.glu.GLU;
import de.cuina.fireandfuel.CodecJLayerMP3;
import net.lax1dude.eaglercraft.AssetRepository;
import net.lax1dude.eaglercraft.EaglerImage;
import net.lax1dude.eaglercraft.EarlyLoadScreen;
import net.lax1dude.eaglercraft.ServerQuery;
import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.ProgramGL;
@ -635,6 +638,18 @@ public class EaglerAdapterImpl2 {
return GL20.glGetAttribLocation(p1.obj, p2);
}
public static final EaglerImage loadPNG(byte[] data) {
try {
BufferedImage img = ImageIO.read(new ByteArrayInputStream(data));
int[] pxls = img.getRGB(0, 0, img.getWidth(), img.getHeight(), null, 0, img.getWidth());
return new EaglerImage(pxls, img.getWidth(), img.getHeight(), true);
} catch (IOException e) {
System.err.println("Could not load PNG file:");
e.printStackTrace();
return null;
}
}
public static final boolean isVideoSupported() {
return false;
}
@ -703,6 +718,43 @@ public class EaglerAdapterImpl2 {
throw new UnsupportedOperationException("Video is not supported in LWJGL runtime");
}
public static final boolean isImageSupported() {
return false;
}
public static final void loadImage(String src) {
throw new UnsupportedOperationException("Image is not supported in LWJGL runtime");
}
public static final void loadImage(String src, String setJavascriptPointer) {
throw new UnsupportedOperationException("Image is not supported in LWJGL runtime");
}
public static final void loadImage(String src, String setJavascriptPointer, String javascriptOnloadFunction) {
throw new UnsupportedOperationException("Image is not supported in LWJGL runtime");
}
public static final void bufferImage(String src, int ttl) {
throw new UnsupportedOperationException("Image is not supported in LWJGL runtime");
}
public static final void unloadImage() {
throw new UnsupportedOperationException("Image is not supported in LWJGL runtime");
}
public static final boolean isImageLoaded() {
throw new UnsupportedOperationException("Image is not supported in LWJGL runtime");
}
public static final void updateImageTexture() {
throw new UnsupportedOperationException("Image is not supported in LWJGL runtime");
}
public static final void bindImageTexture() {
throw new UnsupportedOperationException("Image is not supported in LWJGL runtime");
}
public static final int getImageWidth() {
throw new UnsupportedOperationException("Image is not supported in LWJGL runtime");
}
public static final int getImageHeight() {
throw new UnsupportedOperationException("Image is not supported in LWJGL runtime");
}
public static final void setImageFrameRate(float seconds) {
throw new UnsupportedOperationException("Image is not supported in LWJGL runtime");
}
// =======================================================================================
// =======================================================================================
// =======================================================================================
@ -1369,7 +1421,7 @@ public class EaglerAdapterImpl2 {
}
public static final String getUserAgent() {
return System.getProperty("os.name");
return "Desktop/" + System.getProperty("os.name");
}
public static final String getClipboard() {

View File

@ -1,62 +0,0 @@
package com.baislsl.png.chunk;
import com.baislsl.png.util.ByteHandler;
/**
* Created by baislsl on 17-7-9.
*/
public class Chunk {
protected long length;
protected ChunkType type;
protected byte[] data;
protected byte[] crc = new byte[4];
public byte[] dump() {
byte[] output = new byte[4 + 4 + data.length + 4];
Byte[] lengthBytes = new Byte[4];
for (int i = 0; i < 4; i++) {
output[3 - i] = (byte) (length & 0xff);
}
String typeName = type.name().toUpperCase();
for (int i = 0; i < 4; i++) {
output[4 + i] = (byte) typeName.charAt(i);
}
System.arraycopy(data, 0, output, 8, data.length);
System.arraycopy(crc, 0, output, output.length - crc.length, crc.length);
return output;
}
protected Chunk(byte[] length, byte[] type, byte[] data, byte[] crc) {
this.length = ByteHandler.byteToLong(length);
this.data = data;
this.crc = crc;
for (ChunkType chunkType : ChunkType.values()) {
if (chunkType.name().equals(ByteHandler.byteToString(type))) {
this.type = chunkType;
break;
}
}
}
public long dataLength() {
return data.length;
}
public long getLength() {
return length;
}
public ChunkType getType() {
return type;
}
public byte[] getData() {
return data;
}
public byte[] getCrc() {
return crc;
}
}

View File

@ -1,44 +0,0 @@
package com.baislsl.png.chunk;
import com.baislsl.png.decode.DecodeException;
import com.baislsl.png.decode.PNG;
/**
* Created by baislsl on 17-7-9.
*/
public enum ChunkType {
IHDR {
@Override
public void apply(PNG png, byte[] length, byte[] type, byte[] data, byte[] crc) throws DecodeException {
png.setIhdr(new IHDR(length, type, data, crc));
}
},
tRNS {
@Override
public void apply(PNG png, byte[] length, byte[] type, byte[] data, byte[] crc) throws DecodeException {
png.setTrns(new tRNS(length, type, data, crc));
}
},
PLTE {
@Override
public void apply(PNG png, byte[] length, byte[] type, byte[] data, byte[] crc) throws DecodeException {
png.setPlte(new PLTE(length, type, data, crc));
}
},
IDAT {
@Override
public void apply(PNG png, byte[] length, byte[] type, byte[] data, byte[] crc) throws DecodeException {
png.add(new IDAT(length, type, data, crc));
}
},
IEND {
@Override
public void apply(PNG png, byte[] length, byte[] type, byte[] data, byte[] crc) throws DecodeException {
png.setIend(new IEND(length, type, data, crc));
}
};
public abstract void apply(PNG png, byte[] length, byte[] type, byte[] data, byte[] crc) throws DecodeException;
}

View File

@ -1,11 +0,0 @@
package com.baislsl.png.chunk;
/**
* Created by baislsl on 17-7-10.
*/
public class IDAT extends Chunk {
public IDAT(byte[] length, byte[] type, byte[] data, byte[] crc) {
super(length, type, data, crc);
}
}

View File

@ -1,10 +0,0 @@
package com.baislsl.png.chunk;
/**
* Created by baislsl on 17-7-9.
*/
public class IEND extends Chunk {
public IEND(byte[] length, byte[] type, byte[] data, byte[] crc) {
super(length, type, data, crc);
}
}

View File

@ -1,119 +0,0 @@
package com.baislsl.png.chunk;
import com.baislsl.png.decode.DecodeException;
import com.baislsl.png.util.ByteHandler;
/**
* Created by baislsl on 17-7-9.
*/
public class IHDR extends Chunk {
private long width, height;
private int bitDepth, colorType, compressionMethod, filterMethod, interlaceMethod;
final private static int[] colorTypeValid = { 0, 2, 3, 4, 6 };
final private static int[][] mapColorBitDepth = { { 1, 2, 4, 8, 16 }, // color type = 0
{}, { 8, 16 }, // color type = 2
{ 1, 2, 4, 8 }, // color type = 3
{ 8, 16 }, // color type = 4
{}, { 8, 16 } // color type = 6
};
// the number of bytes per complete pixel, rounding up to one
public int getBpp() {
if (colorType == 2) { // Each pixel is an R,G,B triple.
return 3;
} else if (colorType == 6) { // Each pixel is an R,G,B triple, followed by an alpha sample.
return 4;
} else if (colorType == 3) { // palette index, roll up to 1
return 1;
} else {
// LOG.error("Error when find bpp");
return 0;
}
}
public IHDR(byte[] length, byte[] type, byte[] data, byte[] crc) throws DecodeException {
super(length, type, data, crc);
build();
checkLegal();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("width=");
sb.append(width);
sb.append("height=");
sb.append(height);
sb.append("bitDepth=");
sb.append(bitDepth);
sb.append("colorType=");
sb.append(colorType);
sb.append("compressionMethod=");
sb.append(compressionMethod);
sb.append("filterMethod=");
sb.append(filterMethod);
sb.append("interlaceMethod=");
sb.append(interlaceMethod);
return sb.toString();
}
private void build() {
this.width = ByteHandler.byteToLong(data);
this.height = ByteHandler.byteToLong(data, 4);
this.bitDepth = ((int) data[8]) & 0xFF;
this.colorType = ((int) data[9]) & 0xFF;
this.compressionMethod = ((int) data[10]) & 0xFF;
this.filterMethod = ((int) data[11]) & 0xFF;
this.interlaceMethod = ((int) data[12]) & 0xFF;
}
private void checkLegal() throws DecodeException {
boolean legal = false;
for (int c : colorTypeValid) {
if (c == colorType) {
legal = true;
break;
}
}
if (!legal) {
throw new DecodeException("Initialize IHDR : color type not legal to be " + colorType);
}
for (int b : mapColorBitDepth[colorType]) {
if (b == bitDepth) {
return;
}
}
throw new DecodeException(
"Initialzie IHDR : bit depth " + bitDepth + " not valid matching color type " + colorType);
}
public long getWidth() {
return this.width;
}
public long getHeight() {
return this.height;
}
public int getBitDepth() {
return bitDepth;
}
public int getColorType() {
return colorType;
}
public int getCompressionMethod() {
return compressionMethod;
}
public int getFilterMethod() {
return filterMethod;
}
public int getInterlaceMethod() {
return interlaceMethod;
}
}

View File

@ -1,35 +0,0 @@
package com.baislsl.png.chunk;
import com.baislsl.png.decode.DecodeException;
/**
* Created by baislsl on 17-7-9.
*/
public class PLTE extends Chunk {
private int[] color;
public PLTE(byte[] length, byte[] type, byte[] data, byte[] crc) throws DecodeException {
super(length, type, data, crc);
build();
}
private void build() throws DecodeException {
if (this.length % 3 != 0)
throw new DecodeException("PLTE length can not be divide by 3");
int size = (int) length / 3;
color = new int[size];
for (int i = 0; i < size; i++) {
color[i] = (((int) data[i * 3]) & 0xFF) << 16 | (((int) data[i * 3 + 1]) & 0xFF) << 8
| (((int) data[i * 3 + 2]) & 0xFF) | 0xFF000000;
}
}
public int getColor(int i) {
return color[i];
}
public int getPaletteSize() {
return color.length;
}
}

View File

@ -1,18 +0,0 @@
package com.baislsl.png.chunk;
import com.baislsl.png.decode.DecodeException;
/**
* Created by baislsl on 17-7-9.
*/
public class tRNS extends Chunk {
public tRNS(byte[] length, byte[] type, byte[] data, byte[] crc) throws DecodeException {
super(length, type, data, crc);
}
public int getAlpha() {
return (int)data[0] & 0xFF;
}
}

View File

@ -1,22 +0,0 @@
package com.baislsl.png.decode;
/**
* Created by baislsl on 17-7-9.
*/
public class DecodeException extends Exception {
public DecodeException() {
}
public DecodeException(String message) {
super(message);
}
public DecodeException(String message, Throwable cause) {
super(message, cause);
}
public DecodeException(Throwable cause) {
super(cause);
}
}

View File

@ -1,96 +0,0 @@
package com.baislsl.png.decode;
import com.baislsl.png.chunk.ChunkType;
import com.baislsl.png.util.CRC;
import com.baislsl.png.util.ByteHandler;
import java.io.IOException;
import java.io.InputStream;
import static com.baislsl.png.util.ByteHandler.byteToLong;
/**
* Created by baislsl on 17-7-9.
*/
public class Decoder {
// private final static Logger LOG = LoggerFactory.getLogger(Decoder.class);
private final InputStream in;
private final static char[] head = { 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a };
public Decoder(InputStream in) {
this.in = in;
}
private void readHeader() throws DecodeException, IOException {
byte[] header = readBytes(8);
for (int i = 0; i < 8; i++) {
if ((header[i] & 0xff) != (int) head[i])
throw new DecodeException("It seems that this is not a PNG files");
}
// LOG.info(ByteHandler.byteToString(header));
}
private boolean readChunk(PNG png, String chunkName, byte[] length, byte[] type, byte[] data, byte[] crc)
throws IOException, DecodeException {
for (ChunkType chunkType : ChunkType.values()) {
if (chunkType.name().equalsIgnoreCase(chunkName)) {
chunkType.apply(png, length, type, data, crc);
return true;
}
}
return false;
}
private boolean checkCrc(byte[] data, long crcNumber) {
return crcNumber == CRC.crc(data, data.length);
}
private boolean checkCrc(byte[] type, byte[] data, byte[] crc) {
long crcNumber = byteToLong(crc);
byte[] crcData = new byte[4 + data.length];
System.arraycopy(type, 0, crcData, 0, 4);
System.arraycopy(data, 0, crcData, 4, data.length);
return checkCrc(crcData, crcNumber);
}
public PNG readInPNG() throws IOException, DecodeException {
PNG png = new PNG();
readHeader();
String chunkName;
do {
byte[] length = readBytes(4);
long size = byteToLong(length);
byte[] type = readBytes(4);
chunkName = ByteHandler.byteToString(type).toUpperCase();
if ("IEND".equals(chunkName)) {
break;
}
byte[] data = readBytes((int) size);
byte[] crc = readBytes(4);
// LOG.info(ByteHandler.byteToString(type));
boolean found = readChunk(png, chunkName, length, type, data, crc);
if (!found) {
// LOG.info("Not support chunk name {}", chunkName);
}
boolean crcMatch = checkCrc(type, data, crc);
if (!crcMatch) {
throw new DecodeException("Error data stream for incorrect crc");
}
} while (!"IEND".equals(chunkName));
return png;
}
private byte[] readBytes(int size) throws IOException {
byte[] result = new byte[size];
int ret = in.read(result, 0, size);
if (ret == -1)
return null;
return result;
}
}

View File

@ -1,23 +0,0 @@
package com.baislsl.png.decode;
import com.baislsl.png.chunk.IDAT;
import java.util.ArrayList;
public class IDATManager extends ArrayList<IDAT> {
public byte[] getIDATData() {
int dataSize = 0;
for (IDAT idat : this) {
dataSize += idat.dataLength();
}
byte[] data = new byte[dataSize];
int curPos = 0;
for (IDAT idat : this) {
System.arraycopy(idat.getData(), 0, data, curPos, (int) idat.dataLength());
curPos += idat.dataLength();
}
return data;
}
}

View File

@ -1,132 +0,0 @@
package com.baislsl.png.decode;
import com.baislsl.png.chunk.*;
import com.baislsl.png.util.ReverseFilter;
import net.lax1dude.eaglercraft.EaglerInflater;
import java.io.IOException;
/**
* Created by baislsl on 17-7-9.
*/
public class PNG {
// private final static Logger LOG = LoggerFactory.getLogger(PNG.class);
public IHDR ihdr;
public IDATManager idats = new IDATManager();
public PLTE plte;
public tRNS trns;
public IEND iend;
public PNG() {
}
public boolean isAlpha() {
return this.trns != null || ihdr.getBpp() == 4;
}
public int[] getColor() throws DecodeException {
byte[] rawData = idats.getIDATData();
byte[] uncompressData = applyLZ77(rawData);
byte[][] transferData = applyReverseFilter(uncompressData);
int[] colors = applyColorTransfer(transferData);
return colors;
}
private int[] applyColorTransfer(byte[][] data) throws DecodeException {
int bpp = ihdr.getBpp();
int width = (int) ihdr.getWidth();
int height = (int) ihdr.getHeight();
int colorType = ihdr.getColorType();
int bitDepth = ihdr.getBitDepth();
int[] colors = new int[width * height];
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
int idx = i * width + j;
switch (colorType) {
case 2:
if (bitDepth == 8) { // bpp = 3
colors[idx] = ((int) data[i][bpp * j] & 0xff) << 16 | ((int) data[i][bpp * j + 1] & 0xff) << 8
| ((int) data[i][bpp * j + 2] & 0xff);
} else {
throw new DecodeException("not supported");
}
break;
case 6:
if (bitDepth == 8) { // bpp = 4
colors[idx] = ((int) data[i][bpp * j] & 0xff) << 16 | ((int) data[i][bpp * j + 1] & 0xff) << 8
| ((int) data[i][bpp * j + 2] & 0xff) | ((int) data[i][bpp * j + 3] & 0xff) << 24;
} else {
throw new DecodeException("not supported");
}
break;
case 3:
int gap = 8 / bitDepth;
int a = (1 << bitDepth) - 1;
int b = gap - (j % gap) - 1;
int pi = (data[i][j / gap] >> (b * bitDepth)) & a;
if (trns != null && trns.getAlpha() == pi) {
colors[idx] = 0;
}else {
colors[idx] = plte.getColor(pi);
}
break;
default:
throw new DecodeException("Do not support color type " + colorType);
}
}
}
return colors;
}
private byte[] applyLZ77(byte[] data) throws DecodeException {
byte[] result;
try {
result = EaglerInflater.uncompress(data);
} catch (IOException e) {
// LOG.error("LZ77 decode error", e);
throw new DecodeException(e);
}
// LOG.info("Size after decode={}", result.length);
return result;
}
private byte[][] applyReverseFilter(byte[] data) {
int width = (int) ihdr.getWidth(), height = (int) ihdr.getHeight();
return ReverseFilter.apply(data, width, height, ihdr.getBpp());
}
public void setIdats(IDATManager idats) {
this.idats = idats;
}
public void setIhdr(IHDR ihdr) {
this.ihdr = ihdr;
}
public void setPlte(PLTE plte) {
this.plte = plte;
}
public void setTrns(tRNS trns) {
this.trns = trns;
}
public void setIend(IEND iend) {
this.iend = iend;
}
public void add(IDAT idat) throws DecodeException {
idats.add(idat);
}
public long getWidth() {
return ihdr.getWidth();
}
public long getHeight() {
return ihdr.getHeight();
}
}

View File

@ -1,32 +0,0 @@
package com.baislsl.png.util;
/**
* Created by baislsl on 17-7-10.
*/
public class ByteHandler {
public static long byteToLong(byte[] data, int offset, int size) {
long result = 0;
for (int i = 0; i < size; i++) {
result <<= 8;
result |= ((long) data[offset + i] & 0xff);
}
return result;
}
public static long byteToLong(byte[] data, int offset) {
return byteToLong(data, offset, 4);
}
public static long byteToLong(byte[] data) {
return byteToLong(data, 0, 4);
}
public static String byteToString(byte[] data) {
StringBuilder str = new StringBuilder();
for (byte b : data) {
str.append((char) (0x0ff & b));
}
return str.toString();
}
}

View File

@ -1,35 +0,0 @@
package com.baislsl.png.util;
/**
* Created by baislsl on 17-7-9.
*/
public class CRC {
private final static long[] crcTable = new long[256];
static {
for (int i = 0; i < 256; i++) {
long c = i;
for (int k = 0; k < 8; k++) {
if ((c & 1) != 0) {
c = 0xedb88320L ^ (c >> 1);
} else {
c >>= 1;
}
}
crcTable[i] = c;
}
}
private static long updateCrc(long crc, byte[] buf, int size) {
long ans = crc;
for (int i = 0; i < size; i++) {
ans = crcTable[(int) ((ans ^ buf[i]) & 0xff)] ^ (ans >> 8);
}
return ans;
}
public static long crc(byte[] buf, int size) {
return updateCrc(0xffffffffL, buf, size) ^ 0xffffffffL;
}
}

View File

@ -1,64 +0,0 @@
package com.baislsl.png.util;
public class ReverseFilter {
private ReverseFilter() {
}
private static int paethPredictor(int a, int b, int c) {
int p = a + b - c;
int pa = Math.abs(p - a), pb = Math.abs(p - b), pc = Math.abs(p - c);
if (pa <= pb && pa <= pc)
return a;
if (pb <= pc)
return b;
return c;
}
// apply reverse Filter Algorithms to byte data
// bpp = 3
public static byte[][] apply(byte[] data, int width, int height, int bpp) {
int[] filterType = new int[height];
int[][] blocks = new int[height][width * bpp];
int dataIndex = 0;
for (int i = 0; i < height; i++) {
filterType[i] = (int) (data[dataIndex++]) & 0xFF;
for (int j = 0; j < width * bpp; j++) {
blocks[i][j] = (int) (data[dataIndex++]) & 0xFF;
}
}
for (int i = 0; i < height; i++) {
for (int j = 0; j < width * bpp; j++) {
int prior = (i == 0) ? 0 : blocks[i - 1][j];
int rawBpp = (j < bpp) ? 0 : blocks[i][j - bpp];
int bppPrior = (i == 0 || j < bpp) ? 0 : blocks[i - 1][j - bpp];
switch (filterType[i]) {
case 0: // none
break;
case 1: // sub
blocks[i][j] = blocks[i][j] + rawBpp;
break;
case 2: // up
blocks[i][j] = blocks[i][j] + prior;
break;
case 3: // average
blocks[i][j] = blocks[i][j] + (rawBpp + prior) / 2;
break;
case 4: // paeth
blocks[i][j] = blocks[i][j] + paethPredictor(rawBpp, prior, bppPrior);
break;
default:
}
blocks[i][j] &= 0xff;
}
}
byte[][] result = new byte[height][width * bpp];
for (int i = 0; i < height; i++) {
for (int j = 0; j < width * bpp; j++) {
result[i][j] = (byte) blocks[i][j];
}
}
return result;
}
}

View File

@ -6,7 +6,7 @@ public class ConfigConstants {
public static boolean profanity = false;
public static final String version = "22w16h";
public static final String version = "22w20b";
public static final String mainMenuString = "ayuncraft " + version;
public static final String forkMe = "https://github.com/ayunami2000/ayuncraft";
@ -26,4 +26,9 @@ public class ConfigConstants {
+ "(([0-9]{1,3}\\.){3})[0-9]{1,3})" // Ip
+ "(:"
+ "[0-9]{1,5})?$"); // Port
public static int mainMenuItem = -1;
public static String mainMenuItemLine0 = null;
public static String mainMenuItemLine1 = null;
public static String mainMenuItemLine2 = null;
public static String mainMenuItemLink = null;
}

View File

@ -1,12 +1,5 @@
package net.lax1dude.eaglercraft;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import com.baislsl.png.decode.DecodeException;
import com.baislsl.png.decode.Decoder;
import com.baislsl.png.decode.PNG;
public class EaglerImage {
public final int[] data;
@ -37,16 +30,7 @@ public class EaglerImage {
}
public static final EaglerImage loadImage(byte[] file) {
try {
PNG p = (new Decoder(new ByteArrayInputStream(file))).readInPNG();
return new EaglerImage(p.getColor(), (int)p.getWidth(), (int)p.getHeight(), p.isAlpha());
} catch (IOException e) {
e.printStackTrace();
return null;
} catch (DecodeException e) {
e.printStackTrace();
return null;
}
return EaglerAdapter.loadPNG(file);
}
public EaglerImage getSubImage(int x, int y, int pw, int ph) {

View File

@ -24,7 +24,8 @@ public class EarlyLoadScreen {
_wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_MIN_FILTER, _wGL_NEAREST);
_wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_WRAP_S, _wGL_CLAMP);
_wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_WRAP_T, _wGL_CLAMP);
EaglerImage img = EaglerImage.loadImage(Base64.decodeBase64(loadScreen));
//EaglerImage img = EaglerImage.loadImage(Base64.decodeBase64(loadScreen));
EaglerImage img = EaglerAdapter.loadPNG(Base64.decodeBase64(loadScreen));
IntBuffer upload = GLAllocation.createDirectIntBuffer(192*192);
upload.put(img.data);
upload.flip();
@ -116,7 +117,8 @@ public class EarlyLoadScreen {
_wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_MIN_FILTER, _wGL_NEAREST);
_wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_WRAP_S, _wGL_CLAMP);
_wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_WRAP_T, _wGL_CLAMP);
EaglerImage img = EaglerImage.loadImage(Base64.decodeBase64(enableScreen));
//EaglerImage img = EaglerImage.loadImage(Base64.decodeBase64(enableScreen));
EaglerImage img = EaglerAdapter.loadPNG(Base64.decodeBase64(enableScreen));
IntBuffer upload = GLAllocation.createDirectIntBuffer(128*128);
upload.put(img.data);
upload.flip();

View File

@ -0,0 +1,47 @@
package net.lax1dude.eaglercraft;
public enum EnumBrowser {
DESKTOP("Desktop"), CHROME("Chrome"), EDGE("Edge"), IE("IE"), FIREFOX("Firefox"), SAFARI("Safari"), OPERA("Opera"), WEBKIT("WebKit"), GECKO("Gecko"), UNKNOWN("Unknown");
public final String name;
private EnumBrowser(String string) {
this.name = string;
}
private static EnumBrowser identifiedBrowser = null;
public static EnumBrowser getBrowser() {
if(identifiedBrowser == null) {
String ua = " " + EaglerAdapter.getUserAgent().toLowerCase();
if(ua.contains(" edg/")) {
identifiedBrowser = EDGE;
}else if(ua.contains(" opr/")) {
identifiedBrowser = OPERA;
}else if(ua.contains(" chrome/")) {
identifiedBrowser = CHROME;
}else if(ua.contains(" firefox/")) {
identifiedBrowser = FIREFOX;
}else if(ua.contains(" safari/")) {
identifiedBrowser = SAFARI;
}else if(ua.contains(" trident/") || ua.contains(" msie")) {
identifiedBrowser = IE;
}else if(ua.contains(" webkit/")) {
identifiedBrowser = WEBKIT;
}else if(ua.contains(" gecko/")) {
identifiedBrowser = GECKO;
}else if(ua.contains(" desktop/")) {
identifiedBrowser = DESKTOP;
}else {
identifiedBrowser = UNKNOWN;
}
}
return identifiedBrowser;
}
public String toString() {
return name;
}
}

View File

@ -134,7 +134,8 @@ public class TextureTerrainMap implements IconRegister {
if(data == null) {
map.replaceTexture(this, map.missingData);
}else {
EaglerImage img = EaglerImage.loadImage(data);
//EaglerImage img = EaglerImage.loadImage(data);
EaglerImage img = EaglerAdapter.loadPNG(data);
if(img == null) {
map.replaceTexture(this, map.missingData);
}else {

View File

@ -951,7 +951,7 @@ public class Minecraft implements Runnable {
public void displayEaglercraftText(String s) {
if(this.thePlayer != null && shownPlayerMessages.add(s)) {
this.thePlayer.sendChatToPlayer("notice: "+s);
this.thePlayer.sendChatToPlayer(s);
}
}
@ -1235,6 +1235,11 @@ public class Minecraft implements Runnable {
this.gameSettings.thirdPersonView = 0;
}
}
if (EaglerAdapter.getEventKey() == 7 && this.gameSettings.keyBindFunction.pressed) {
this.gameSettings.showCoordinates = !this.gameSettings.showCoordinates;
this.gameSettings.saveOptions();
}
if (EaglerAdapter.getEventKey() == 9 && this.gameSettings.keyBindFunction.pressed) {
this.gameSettings.smoothCamera = !this.gameSettings.smoothCamera;
@ -1332,7 +1337,7 @@ public class Minecraft implements Runnable {
if (this.theWorld != null) {
if (this.thePlayer != null) {
++this.joinPlayerCounter;
if (this.joinPlayerCounter == 30) {
this.joinPlayerCounter = 0;
this.theWorld.joinEntityInSurroundings(this.thePlayer);
@ -1479,7 +1484,13 @@ public class Minecraft implements Runnable {
StringTranslate var4 = StringTranslate.getInstance();
if(!this.gameSettings.fancyGraphics || this.gameSettings.ambientOcclusion == 0) {
displayEaglercraftText(var4.translateKey("fancyGraphicsNote"));
displayEaglercraftText("Note: " + var4.translateKey("fancyGraphicsNote"));
}
if(this.gameSettings.showCoordinates) {
displayEaglercraftText(EnumChatFormatting.LIGHT_PURPLE + "Note: use F+6 to hide the coordinates off of the screen (if you're in public)");
}else {
displayEaglercraftText(EnumChatFormatting.LIGHT_PURPLE + "Note: use F+6 to show your coordinates on the screen");
}
this.thePlayer.preparePlayerToSpawn();

View File

@ -130,7 +130,8 @@ public class FontRenderer {
}
private void readFontTexture(String par1Str) {
EaglerImage e = EaglerImage.loadImage(EaglerAdapter.loadResourceBytes(par1Str));
//EaglerImage e = EaglerImage.loadImage(EaglerAdapter.loadResourceBytes(par1Str));
EaglerImage e = EaglerAdapter.loadPNG(EaglerAdapter.loadResourceBytes(par1Str));
int[] var5 = e.data;
int var3 = e.w;
int var4 = e.h;

View File

@ -68,7 +68,7 @@ public class GLAllocation {
* Creates and returns a direct byte buffer with the specified capacity. Applies
* native ordering to speed up access.
*/
public static synchronized ByteBuffer createDirectByteBuffer(int par0) {
public static ByteBuffer createDirectByteBuffer(int par0) {
return EaglerAdapter.isWebGL ? ByteBuffer.wrap(new byte[par0]).order(ByteOrder.nativeOrder()) : ByteBuffer.allocateDirect(par0).order(ByteOrder.nativeOrder());
}

View File

@ -113,6 +113,8 @@ public class GameSettings {
/** true if debug info should be displayed instead of version */
public boolean showDebugInfo;
public boolean showDebugProfilerChart;
public boolean showCoordinates;
/** The lastServer string. */
public String lastServer;
@ -149,6 +151,7 @@ public class GameSettings {
this.thirdPersonView = 0;
this.showDebugInfo = false;
this.showDebugProfilerChart = true;
this.showCoordinates = true;
this.lastServer = "";
this.noclip = false;
this.smoothCamera = false;
@ -514,6 +517,7 @@ public class GameSettings {
if(yee.hasKey("chatScale")) this.chatScale = yee.getFloat("chatScale");
if(yee.hasKey("chatWidth")) this.chatWidth = yee.getFloat("chatWidth");
if(yee.hasKey("patchAnisotropic")) this.patchAnisotropic = yee.getBoolean("patchAnisotropic");
if(yee.hasKey("showCoordinates")) this.showCoordinates = yee.getBoolean("showCoordinates");
for (int var4 = 0; var4 < this.keyBindings.length; ++var4) {
if(yee.hasKey(keyBindings[var4].keyDescription)) this.keyBindings[var4].keyCode = yee.getInteger(keyBindings[var4].keyDescription);
@ -567,6 +571,7 @@ public class GameSettings {
yee.setFloat("chatScale", this.chatScale);
yee.setFloat("chatWidth", this.chatWidth);
yee.setBoolean("patchAnisotropic", this.patchAnisotropic);
yee.setBoolean("showCoordinates", this.showCoordinates);
for (int var4 = 0; var4 < this.keyBindings.length; ++var4) {
yee.setInteger(keyBindings[var4].keyDescription, keyBindings[var4].keyCode);

View File

@ -8,6 +8,7 @@ import net.minecraft.client.Minecraft;
import net.lax1dude.eaglercraft.ConfigConstants;
import net.lax1dude.eaglercraft.EaglerAdapter;
import net.lax1dude.eaglercraft.EaglercraftRandom;
import net.lax1dude.eaglercraft.EnumBrowser;
import net.lax1dude.eaglercraft.TextureLocation;
import net.lax1dude.eaglercraft.adapter.Tessellator;
import net.lax1dude.eaglercraft.glemu.EffectPipeline;
@ -397,17 +398,27 @@ public class GuiIngame extends Gui {
var8.drawStringWithShadow(this.mc.getEntityDebug(), 2, 22, 16777215);
var8.drawStringWithShadow(this.mc.debugInfoEntities(), 2, 32, 16777215);
var8.drawStringWithShadow(this.mc.getWorldProviderName(), 2, 42, 16777215);
long var39;
long var37;
long var41;
var39 = EaglerAdapter.maxMemory();
var37 = EaglerAdapter.totalMemory();
var41 = EaglerAdapter.freeMemory();
long var44 = var37 - var41;
String var45 = "Used memory: " + var44 * 100L / var39 + "% (" + var44 / 1024L / 1024L + "MB) of " + var39 / 1024L / 1024L + "MB";
this.drawString(var8, var45, var6 - var8.getStringWidth(var45) - 2, 2, 14737632);
var45 = "Allocated memory: " + var37 * 100L / var39 + "% (" + var37 / 1024L / 1024L + "MB)";
this.drawString(var8, var45, var6 - var8.getStringWidth(var45) - 2, 12, 14737632);
String var45;
int offset = 0;
if(EaglerAdapter._wisWebGL()) {
var45 = "Game is running in a browser (" + EnumBrowser.getBrowser().toString() + ")";
this.drawString(var8, var45, var6 - var8.getStringWidth(var45) - 2, 2, 14737632);
offset = -10;
}else {
long var39;
long var37;
long var41;
var39 = EaglerAdapter.maxMemory();
var37 = EaglerAdapter.totalMemory();
var41 = EaglerAdapter.freeMemory();
long var44 = var37 - var41;
var45 = "Used memory: " + var44 * 100L / var39 + "% (" + var44 / 1024L / 1024L + "MB) of " + var39 / 1024L / 1024L + "MB";
this.drawString(var8, var45, var6 - var8.getStringWidth(var45) - 2, 2, 14737632);
var45 = "Allocated memory: " + var37 * 100L / var39 + "% (" + var37 / 1024L / 1024L + "MB)";
this.drawString(var8, var45, var6 - var8.getStringWidth(var45) - 2, 12, 14737632);
offset = 0;
}
this.drawString(var8, "Player is not using an xbox live account", 2, 64, 0xFFBBBB);
this.drawString(var8, "Using cracked server @ " + mc.getServerURI(), 2, 73, 0xFFBBBB);
var47 = MathHelper.floor_double(this.mc.thePlayer.posX);
@ -418,28 +429,29 @@ public class GuiIngame extends Gui {
this.drawString(var8, "z: "+doubleToShorterString(this.mc.thePlayer.posZ)+" ("+var23+") // c: "+(var23 >> 4)+" ("+(var23 & 15)+")", 2, 108, 14737632);
var24 = MathHelper.floor_double((double) (this.mc.thePlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
this.drawString(var8, "f: " + var24 + " (" + Direction.directions[var24] + ") / " + MathHelper.wrapAngleTo180_float(this.mc.thePlayer.rotationYaw), 2, 116, 14737632);
this.drawString(var8, "Press F+6 to " + (mc.gameSettings.showCoordinates ? "disable" : "enable") + " showing coords in ingame GUI", 2, 135, 0xFFFFFFFF);
//this.drawString(var8, String.format("ws: %.3f, fs: %.3f, g: %b, fl: %d", new Object[] { Float.valueOf(this.mc.thePlayer.capabilities.getWalkSpeed()), Float.valueOf(this.mc.thePlayer.capabilities.getFlySpeed()),
// Boolean.valueOf(this.mc.thePlayer.onGround), Integer.valueOf(this.mc.theWorld.getHeightValue(var47, var23)) }), 2, 104, 14737632);
var45 = "opengl emulator status - v1.0";
this.drawString(var8, var45, var6 - var8.getStringWidth(var45) - 2, 36, 14737632);
this.drawString(var8, var45, var6 - var8.getStringWidth(var45) - 2, offset + 36, 14737632);
var45 = "lists: "+EaglerAdapter.getDisplayListCount()+", upload: "+(EaglerAdapter.getBitsPerSecond() / 1000000)+"mbps";
this.drawString(var8, var45, var6 - var8.getStringWidth(var45) - 2, 46, 14737632);
this.drawString(var8, var45, var6 - var8.getStringWidth(var45) - 2, offset + 46, 14737632);
var45 = "verts: "+(EaglerAdapter.getVertexesPerSecond() / 1000)+"k, triangles: "+(EaglerAdapter.getTrianglesPerSecond() / 1000)+"k";
this.drawString(var8, var45, var6 - var8.getStringWidth(var45) - 2, 56, 14737632);
this.drawString(var8, var45, var6 - var8.getStringWidth(var45) - 2, offset + 56, 14737632);
var45 = "rendering backend: "+(EaglerAdapter.isWebGL ? "webgl20" : "opengl30");
this.drawString(var8, var45, var6 - var8.getStringWidth(var45) - 2, 66, 14737632);
this.drawString(var8, var45, var6 - var8.getStringWidth(var45) - 2, offset + 66, 14737632);
var45 = "glsl "+(EaglerAdapter._wgetShaderHeader() +", 32 bytes/vert");
this.drawString(var8, var45, var6 - var8.getStringWidth(var45) - 2, 76, 14737632);
this.drawString(var8, var45, var6 - var8.getStringWidth(var45) - 2, offset + 76, 14737632);
var45 = "Bound Shaders:";
this.drawString(var8, var45, var6 - var8.getStringWidth(var45) - 2, 100, 14737632);
this.drawString(var8, var45, var6 - var8.getStringWidth(var45) - 2, offset + 100, 14737632);
var45 = "/glsl/core.glsl";
this.drawString(var8, var45, var6 - var8.getStringWidth(var45) - 2, 110, 14737632);
this.drawString(var8, var45, var6 - var8.getStringWidth(var45) - 2, offset + 110, 14737632);
var45 = "/glsl/occl.glsl";
this.drawString(var8, var45, var6 - var8.getStringWidth(var45) - 2, 120, 14737632);
this.drawString(var8, var45, var6 - var8.getStringWidth(var45) - 2, offset + 120, 14737632);
for(int i = 0; i < EffectPipeline.pipeline.length; i++) {
var45 = EffectPipeline.pipeline[i];
this.drawString(var8, var45, var6 - var8.getStringWidth(var45) - 2, 130 + i*10, 14737632);
this.drawString(var8, var45, var6 - var8.getStringWidth(var45) - 2, offset + 130 + i*10, 14737632);
}
EaglerAdapter.glPopMatrix();
this.mc.mcProfiler.endSection();
@ -447,7 +459,11 @@ public class GuiIngame extends Gui {
EaglerAdapter.glPushMatrix();
EaglerAdapter.glScalef(0.75f, 0.75f, 0.75f);
var8.drawStringWithShadow(this.mc.renderGlobal.getDebugInfoShort(), 2, 2, 16777215);
var8.drawStringWithShadow("x: "+MathHelper.floor_double(this.mc.thePlayer.posX)+", y: "+MathHelper.floor_double(this.mc.thePlayer.posY)+", z: "+MathHelper.floor_double(this.mc.thePlayer.posZ), 2, 12, 16777215);
if(mc.gameSettings.showCoordinates) {
var8.drawStringWithShadow("x: "+MathHelper.floor_double(this.mc.thePlayer.posX)+", y: "+MathHelper.floor_double(this.mc.thePlayer.posY)+", z: "+MathHelper.floor_double(this.mc.thePlayer.posZ), 2, 12, 16777215);
}
int offset = this.mc.isChatOpen() ? 135 : 0;
int offset2 = this.mc.isChatOpen() ? 4 : 0;
String str = "not using an xbox live account";

View File

@ -198,6 +198,7 @@ public class GuiMainMenu extends GuiScreen {
int w = this.fontRenderer.getStringWidth("eaglercraft readme.txt") * 3 / 4;
if(par1 >= (this.width - w - 4) && par1 <= this.width && par2 >= 0 && par2 <= 9) {
showAck = true;
return;
}
/*
w = this.fontRenderer.getStringWidth("debug console") * 3 / 4;
@ -205,6 +206,31 @@ public class GuiMainMenu extends GuiScreen {
EaglerAdapter.openConsole();
}
*/
if(ConfigConstants.mainMenuItem > 0 && ConfigConstants.mainMenuItemLink != null) {
//drawRect((this.width - w - 4), 0, this.width, 9, 0x55200000);
int posX = this.width / 2 - 170 - this.width / 10;
int posY = this.height / 4 + 70;
int ww = 66;
int hh = 46;
int ln0w = ConfigConstants.mainMenuItemLine0 == null ? 0 : fontRenderer.getStringWidth(ConfigConstants.mainMenuItemLine0);
ww = ww < ln0w ? ln0w : ww;
hh = hh < ln0w ? hh + 12 : hh;
int ln1w = ConfigConstants.mainMenuItemLine1 == null ? 0 : fontRenderer.getStringWidth(ConfigConstants.mainMenuItemLine1);
ww = ww < ln1w ? ln1w : ww;
hh = hh < ln1w ? hh + 12 : hh;
int ln2w = ConfigConstants.mainMenuItemLine2 == null ? 0 : fontRenderer.getStringWidth(ConfigConstants.mainMenuItemLine2);
ww = ww < ln2w ? ln2w : ww;
hh = hh < ln2w ? hh + 12 : hh;
ww += 20;
hh += 20;
if(par1 > posX && par1 < posX + (ww / 4 * 3) && par2 > posY && par2 < posY + (hh / 4 * 3)) {
EaglerAdapter.openLink(ConfigConstants.mainMenuItemLink);
return;
}
}
}
}else {
if(par3 == 0) {
@ -413,6 +439,7 @@ public class GuiMainMenu extends GuiScreen {
private static final TextureLocation mclogo = new TextureLocation("/title/mclogo.png");
private static final TextureLocation ackbk = new TextureLocation("/gui/demo_bg.png");
private static final TextureLocation beaconx = new TextureLocation("/gui/beacon.png");
private static final TextureLocation items = new TextureLocation("/gui/items.png");
/**
* Draws the screen and all the components in it.
@ -504,6 +531,92 @@ public class GuiMainMenu extends GuiScreen {
this.drawString(this.fontRenderer, var10, 0, 0, 16777215);
EaglerAdapter.glPopMatrix();
*/
if(ConfigConstants.mainMenuItem > 0 && ConfigConstants.mainMenuItemLink != null) {
//drawRect((this.width - w - 4), 0, this.width, 9, 0x55200000);
int posX = this.width / 2 - 170 - this.width / 10;
int posY = this.height / 4 + 70;
int ww = 66;
int hh = 46;
int ln0w = ConfigConstants.mainMenuItemLine0 == null ? 0 : fontRenderer.getStringWidth(ConfigConstants.mainMenuItemLine0);
ww = ww < ln0w ? ln0w : ww;
hh = hh < ln0w ? hh + 12 : hh;
int ln1w = ConfigConstants.mainMenuItemLine1 == null ? 0 : fontRenderer.getStringWidth(ConfigConstants.mainMenuItemLine1);
ww = ww < ln1w ? ln1w : ww;
hh = hh < ln1w ? hh + 12 : hh;
int ln2w = ConfigConstants.mainMenuItemLine2 == null ? 0 : fontRenderer.getStringWidth(ConfigConstants.mainMenuItemLine2);
ww = ww < ln2w ? ln2w : ww;
hh = hh < ln2w ? hh + 12 : hh;
ww += 20;
hh += 20;
boolean over = par1 > posX && par1 < posX + (ww / 4 * 3) && par2 > posY && par2 < posY + (hh / 4 * 3);
int iconSize = 45;
if(over) {
EaglerAdapter.glPushMatrix();
EaglerAdapter.glTranslatef(posX, posY, 0.0f);
EaglerAdapter.glScalef(0.75f, 0.75f, 0.75f);
drawRect(0, 0, ww, hh, 0x44000022);
drawRect(3, 3, ww - 3, 4, 0x99999999);
drawRect(3, hh - 4, ww - 3, hh - 3, 0x99999999);
drawRect(3, 4, 4, hh - 4, 0x99999999);
drawRect(ww - 4, 4, ww - 3, hh - 4, 0x99999999);
int i = 10;
if(ln0w > 0) {
this.drawString(this.fontRenderer, ConfigConstants.mainMenuItemLine0, (ww - ln0w) / 2, i, 0xFFFF99);
i += 12;
}
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);
i += iconSize + 5;
if(ln1w > 0) {
this.drawString(this.fontRenderer, ConfigConstants.mainMenuItemLine1, (ww - ln1w) / 2, i, 0xFFFF99);
i += 12;
}
if(ln2w > 0) {
this.drawString(this.fontRenderer, ConfigConstants.mainMenuItemLine2, (ww - ln2w) / 2, i, 0xDDDDDD);
}
int ww75 = (ww * 4 / 3);
int hh75 = (hh * 4 / 3);
//this.drawString(this.fontRenderer, var10, this.width - this.fontRenderer.getStringWidth(var10) - 2, this.height - 10, 16777215);
EaglerAdapter.glPopMatrix();
}else {
EaglerAdapter.glEnable(EaglerAdapter.GL_BLEND);
EaglerAdapter.glBlendFunc(EaglerAdapter.GL_SRC_ALPHA, EaglerAdapter.GL_ONE_MINUS_SRC_ALPHA);
EaglerAdapter.glColor4f(0.9f, 0.9f, 0.9f, MathHelper.sin((float)(System.currentTimeMillis() % 1000000l) / 300f) * 0.17f + 0.5f);
items.bindTexture();
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);
EaglerAdapter.glPopMatrix();
EaglerAdapter.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
EaglerAdapter.glDisable(EaglerAdapter.GL_BLEND);
}
}
if(showAck) {
super.drawScreen(0, 0, par3);
this.drawGradientRect(0, 0, this.width, this.height, -1072689136, -804253680);

View File

@ -360,4 +360,64 @@ public class ItemMap extends ItemMapBase {
e.printStackTrace();
}
}
public static void processImageMap(WorldClient theWorld, byte[] data) {
if(!EaglerAdapter.isImageSupported()) {
return;
}
try {
DataInputStream dat = new DataInputStream(new ByteArrayInputStream(data));
int op = dat.read();
if(op == 0) {
int count = dat.read();
int w = (count >> 4) & 0xF;
int h = count & 0xF;
for(int y = 0; y < h; ++y) {
for(int x = 0; x < w; ++x) {
getMapById(theWorld, dat.readUnsignedShort()).enableVideoPlayback = false;
}
}
EaglerAdapter.unloadImage();
}else if(op == 8) {
int ttl = dat.readInt();
String src = dat.readUTF();
EaglerAdapter.bufferImage(src, ttl);
}else {
boolean fullResetPacket = (op & 2) == 2;
boolean positionPacket = (op & 4) == 4;
int fps = 0;
int len = 0;
String url = null;
if(fullResetPacket) {
int count = dat.read();
int w = (count >> 4) & 0xF;
int h = count & 0xF;
float wf = 1.0f / w;
float hf = 1.0f / h;
for(int y = 0; y < h; ++y) {
for(int x = 0; x < w; ++x) {
MapData mp = getMapById(theWorld, dat.readUnsignedShort());
mp.videoX1 = x * wf;
mp.videoY1 = y * hf;
mp.videoX2 = mp.videoX1 + wf;
mp.videoY2 = mp.videoY1 + hf;
mp.enableVideoPlayback = true;
}
}
fps = dat.read();
len = dat.readInt();
url = dat.readUTF();
}
if(fullResetPacket) {
EaglerAdapter.setImageFrameRate(fps);
EaglerAdapter.loadImage(url);
}
}
}catch(IOException e) {
System.err.println("Failed to read image map packet! " + e.toString());
e.printStackTrace();
}
}
}

View File

@ -1,6 +1,5 @@
package net.minecraft.src;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;

View File

@ -30,7 +30,9 @@ public class MapItemRenderer {
float texX2 = 1.0f;
float texY1 = 0.0f;
float texY2 = 1.0f;
boolean isVideoMode = EaglerAdapter.isVideoSupported() && par3MapData.enableVideoPlayback && EaglerAdapter.isVideoLoaded();
boolean isVideoOrImageMode = EaglerAdapter.isVideoSupported() && par3MapData.enableVideoPlayback;
boolean isVideoMode = isVideoOrImageMode && EaglerAdapter.isVideoLoaded();
boolean isImageMode = isVideoOrImageMode && EaglerAdapter.isImageLoaded();
if(isVideoMode) {
EaglerAdapter.glEnable(EaglerAdapter.EAG_SWAP_RB);
EaglerAdapter.updateVideoTexture();
@ -39,32 +41,40 @@ public class MapItemRenderer {
texY1 = par3MapData.videoY1;
texX2 = par3MapData.videoX2;
texY2 = par3MapData.videoY2;
}else if(isImageMode) {
EaglerAdapter.glEnable(EaglerAdapter.EAG_SWAP_RB);
EaglerAdapter.updateImageTexture();
EaglerAdapter.bindImageTexture();
texX1 = par3MapData.videoX1;
texY1 = par3MapData.videoY1;
texX2 = par3MapData.videoX2;
texY2 = par3MapData.videoY2;
}else {
if(par3MapData.enableAyunami) {
System.arraycopy(par3MapData.ayunamiPixels, 0, intArray, 0, intArray.length);
}else {
for (int var4 = 0; var4 < 16384; ++var4) {
byte var5 = par3MapData.colors[var4];
if (var5 / 4 == 0) {
this.intArray[var4] = (var4 + var4 / 128 & 1) * 8 + 16 << 24;
} else {
int var6 = MapColor.mapColorArray[var5 / 4].colorValue;
int var7 = var5 & 3;
short var8 = 220;
if (var7 == 2) {
var8 = 255;
}
if (var7 == 0) {
var8 = 180;
}
int var9 = (var6 >> 16 & 255) * var8 / 255;
int var10 = (var6 >> 8 & 255) * var8 / 255;
int var11 = (var6 & 255) * var8 / 255;
if (this.gameSettings.anaglyph) {
int var12 = (var9 * 30 + var10 * 59 + var11 * 11) / 100;
int var13 = (var9 * 30 + var10 * 70) / 100;
@ -73,14 +83,14 @@ public class MapItemRenderer {
var10 = var13;
var11 = var14;
}
this.intArray[var4] = -16777216 | var9 << 16 | var10 << 8 | var11;
}
}
}
par2RenderEngine.createTextureFromBytes(this.intArray, 128, 128, this.bufferedImage);
}
byte var15 = 0;
byte var16 = 0;
Tessellator var17 = Tessellator.instance;
@ -97,15 +107,15 @@ public class MapItemRenderer {
EaglerAdapter.glEnable(EaglerAdapter.GL_ALPHA_TEST);
EaglerAdapter.glDisable(EaglerAdapter.GL_BLEND);
par2RenderEngine.resetBoundTexture();
if(isVideoMode) {
if(isVideoMode || isImageMode) {
EaglerAdapter.glDisable(EaglerAdapter.EAG_SWAP_RB);
}
if(!par3MapData.enableAyunami && !isVideoMode) {
if(!par3MapData.enableAyunami && !(isVideoMode || isImageMode)) {
mapicons.bindTexture();
int var19 = 0;
for (Iterator var20 = par3MapData.playersVisibleOnMap.values().iterator(); var20.hasNext(); ++var19) {
MapCoord var21 = (MapCoord) var20.next();
EaglerAdapter.glPushMatrix();

View File

@ -330,4 +330,8 @@ public class NBTTagCompound extends NBTBase {
public static Map getTagMap(NBTTagCompound par0NBTTagCompound) {
return par0NBTTagCompound.tagMap;
}
public String getStringOrNull(String string) {
return !this.tagMap.containsKey(string) ? null : ((NBTTagString) this.tagMap.get(string)).data;
}
}

View File

@ -1021,6 +1021,8 @@ public class NetClientHandler extends NetHandler {
ItemMap.readAyunamiMapPacket(this.mc.theWorld, par1Packet131MapData.uniqueID, par1Packet131MapData.itemData);
} else if (par1Packet131MapData.itemID == 104) {
ItemMap.processVideoMap(this.mc.theWorld, par1Packet131MapData.itemData);
} else if (par1Packet131MapData.itemID == 105) {
ItemMap.processImageMap(this.mc.theWorld, par1Packet131MapData.itemData);
} else {
System.err.println("Unknown itemid: " + par1Packet131MapData.itemID);
}

View File

@ -67,7 +67,8 @@ public class RenderEngine {
if (var7 == null) {
var4 = this.missingTextureImage.data;
} else {
var4 = EaglerImage.loadImage(var7).data;
//var4 = EaglerImage.loadImage(var7).data;
var4 = EaglerAdapter.loadPNG(var7).data;
}
this.textureContentsMap.put(par1Str, var4);
@ -124,7 +125,7 @@ public class RenderEngine {
if (var6 == null) {
this.setupTextureExt(this.missingTextureImage, var3, var9, var5);
} else {
this.setupTextureExt(this.readTextureImage(var6), var3, var9, var5);
this.setupTextureExt(EaglerImage.loadImage(var6), var3, var9, var5);
}
this.textureMap.put(var8, Integer.valueOf(var3));
@ -299,13 +300,16 @@ public class RenderEngine {
var11 = var11.substring(7);
}
byte[] b = var1.getResourceAsBytes(var11);
if(b != null) {
EaglerImage var5 = this.readTextureImage(b);
//byte[] b = var1.getResourceAsBytes(var11); //what the fuck
//if(b != null) {
EaglerImage var5 = EaglerAdapter.loadPNG(var1.getResourceAsBytes(var11));
if(var5 == null) {
throw new IOException("Could not load PNG");
}
this.setupTextureExt(var5, var12, var6, var7);
}else {
System.err.println("could not reload: "+var11);
}
//}else {
// System.err.println("could not reload: "+var11);
//}
} catch (IOException var9) {
var9.printStackTrace();
}
@ -317,7 +321,10 @@ public class RenderEngine {
var11 = (String) var2.next();
try {
var4 = this.readTextureImage(var1.getResourceAsBytes(var11));
var4 = EaglerAdapter.loadPNG(var1.getResourceAsBytes(var11));
if(var4 == null) {
throw new IOException("Could not load PNG");
}
System.arraycopy(var4.data, 0, (int[]) this.textureContentsMap.get(var11), 0, var4.data.length);
} catch (IOException var8) {
var8.printStackTrace();
@ -332,7 +339,8 @@ public class RenderEngine {
* Returns a BufferedImage read off the provided input stream. Args: inputStream
*/
private EaglerImage readTextureImage(byte[] par1InputStream) throws IOException {
return EaglerImage.loadImage(par1InputStream);
return null;//EaglerImage.loadImage(par1InputStream);
//return EaglerAdapter.loadPNG(par1InputStream);
}
public void refreshTextureMaps() {

View File

@ -40,6 +40,16 @@ public class ServerList {
hideDownDefaultServers = nbt.getBoolean("hide_down");
ConfigConstants.ayonullTitle = nbt.hasKey("serverListTitle") ? nbt.getString("serverListTitle") : null;
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.mainMenuItemLine0 = cmp.getStringOrNull("itemLine0");
ConfigConstants.mainMenuItemLine1 = cmp.getStringOrNull("itemLine1");
ConfigConstants.mainMenuItemLine2 = cmp.getStringOrNull("itemLine2");
ConfigConstants.mainMenuItemLink = cmp.getStringOrNull("itemLink");
}
}
forcedServers.clear();
NBTTagList list = nbt.getTagList("servers");
for (int i = 0; i < list.tagCount(); ++i) {

View File

@ -52,7 +52,8 @@ public class TextureManager {
ITexturePack var3 = Minecraft.getMinecraft().texturePackList.getSelectedTexturePack();
byte[] b = var3.getResourceAsBytes("/" + par1Str);
if(b != null) {
EaglerImage var9 = EaglerImage.loadImage(b);
//EaglerImage var9 = EaglerImage.loadImage(b);
EaglerImage var9 = EaglerAdapter.loadPNG(b);
int var10 = var9.w;
int var11 = var9.h;
String var12 = this.getBasename(par1Str);

View File

@ -62,7 +62,8 @@ public abstract class TexturePackImplementation implements ITexturePack {
* Load and initialize thumbnailImage from the the /pack.png file.
*/
private void loadThumbnailImage() {
this.thumbnailImage = EaglerImage.loadImage(EaglerAdapter.loadResourceBytes("/pack.png"));
//this.thumbnailImage = EaglerImage.loadImage(EaglerAdapter.loadResourceBytes("/pack.png"));
this.thumbnailImage = EaglerAdapter.loadPNG(EaglerAdapter.loadResourceBytes("/pack.png"));
}
/**

View File

@ -25,6 +25,8 @@ import org.teavm.jso.ajax.ReadyStateChangeHandler;
import org.teavm.jso.ajax.XMLHttpRequest;
import org.teavm.jso.browser.TimerHandler;
import org.teavm.jso.browser.Window;
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.events.KeyboardEvent;
@ -35,11 +37,13 @@ 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.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.Float32Array;
import org.teavm.jso.typedarrays.Int32Array;
import org.teavm.jso.typedarrays.Uint8Array;
import org.teavm.jso.typedarrays.Uint8ClampedArray;
import org.teavm.jso.webaudio.AudioBuffer;
import org.teavm.jso.webaudio.AudioBufferSourceNode;
import org.teavm.jso.webaudio.AudioContext;
@ -62,6 +66,7 @@ import org.teavm.jso.websocket.WebSocket;
import net.lax1dude.eaglercraft.AssetRepository;
import net.lax1dude.eaglercraft.Base64;
import net.lax1dude.eaglercraft.EaglerImage;
import net.lax1dude.eaglercraft.EarlyLoadScreen;
import net.lax1dude.eaglercraft.LocalStorageManager;
import net.lax1dude.eaglercraft.ServerQuery;
@ -183,6 +188,8 @@ public class EaglerAdapterImpl2 {
public static HTMLDocument doc = null;
public static HTMLElement parent = null;
public static HTMLCanvasElement canvas = null;
public static CanvasRenderingContext2D frameBuffer = null;
public static HTMLCanvasElement renderingCanvas = null;
public static WebGL2RenderingContext webgl = null;
public static Window win = null;
private static byte[] loadedPackage = null;
@ -226,8 +233,14 @@ public class EaglerAdapterImpl2 {
doc = win.getDocument();
canvas = (HTMLCanvasElement)doc.createElement("canvas");
canvas.setAttribute("id", "deevis589723589");
canvas.setWidth(parent.getClientWidth());
canvas.setHeight(parent.getClientHeight());
rootElement.appendChild(canvas);
webgl = (WebGL2RenderingContext) canvas.getContext("webgl2", youEagler());
renderingCanvas = (HTMLCanvasElement)doc.createElement("canvas");
renderingCanvas.setWidth(canvas.getWidth());
renderingCanvas.setHeight(canvas.getHeight());
frameBuffer = (CanvasRenderingContext2D) canvas.getContext("2d");
webgl = (WebGL2RenderingContext) renderingCanvas.getContext("webgl2", youEagler());
if(webgl == null) {
throw new RuntimeException("WebGL 2.0 is not supported in your browser ("+getString("window.navigator.userAgent")+")");
}
@ -910,7 +923,74 @@ public class EaglerAdapterImpl2 {
public static final boolean isWindows() {
return getString("window.navigator.platform").toLowerCase().contains("win");
}
private static HTMLCanvasElement imageLoadCanvas = null;
private static CanvasRenderingContext2D imageLoadContext = null;
@JSBody(params = { "buf", "mime" }, script = "return URL.createObjectURL(new Blob([buf], {type: mime}));")
private static native String getDataURL(ArrayBuffer buf, String mime);
@JSBody(params = { "url" }, script = "URL.revokeObjectURL(url);")
private static native void freeDataURL(String url);
public static final EaglerImage loadPNG(byte[] data) {
ArrayBuffer arr = ArrayBuffer.create(data.length);
Uint8Array.create(arr).set(data);
return loadPNG0(arr);
}
@Async
private static native EaglerImage loadPNG0(ArrayBuffer data);
private static void loadPNG0(ArrayBuffer data, final AsyncCallback<EaglerImage> ret) {
final HTMLImageElement toLoad = (HTMLImageElement) doc.createElement("img");
toLoad.addEventListener("load", new EventListener<Event>() {
@Override
public void handleEvent(Event evt) {
if(imageLoadCanvas == null) {
imageLoadCanvas = (HTMLCanvasElement) doc.createElement("canvas");
}
if(imageLoadCanvas.getWidth() < toLoad.getWidth()) {
imageLoadCanvas.setWidth(toLoad.getWidth());
}
if(imageLoadCanvas.getHeight() < toLoad.getHeight()) {
imageLoadCanvas.setHeight(toLoad.getHeight());
}
if(imageLoadContext == null) {
imageLoadContext = (CanvasRenderingContext2D) imageLoadCanvas.getContext("2d");
}
imageLoadContext.clearRect(0, 0, toLoad.getWidth(), toLoad.getHeight());
imageLoadContext.drawImage(toLoad, 0, 0, toLoad.getWidth(), toLoad.getHeight());
ImageData pxlsDat = imageLoadContext.getImageData(0, 0, toLoad.getWidth(), toLoad.getHeight());
Uint8ClampedArray pxls = pxlsDat.getData();
int totalPixels = pxlsDat.getWidth() * pxlsDat.getHeight();
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 EaglerImage(pixels, pxlsDat.getWidth(), pxlsDat.getHeight(), true));
}
});
toLoad.addEventListener("error", new EventListener<Event>() {
@Override
public void handleEvent(Event evt) {
freeDataURL(toLoad.getSrc());
ret.complete(null);
}
});
String src = getDataURL(data, "image/png");
if(src == null) {
ret.complete(null);
}else {
toLoad.setSrc(src);
}
}
private static HTMLVideoElement currentVideo = null;
private static TextureGL videoTexture = null;
private static boolean videoIsLoaded = false;
@ -1212,6 +1292,171 @@ public class EaglerAdapterImpl2 {
frameRate = 1;
}
}
private static HTMLImageElement currentImage = null;
private static TextureGL imageTexture = null;
private static boolean imageIsLoaded = false;
private static boolean imageTexIsInitialized = false;
private static int imageFrameRate = 33;
private static long imageFrameTimer = 0l;
public static final boolean isImageSupported() {
return true;
}
public static final void loadImage(String src) {
loadImage(src, null);
}
public static final void loadImage(String src, String setJavascriptPointer) {
loadImage(src, setJavascriptPointer, null);
}
@JSBody(params = { "ptr", "el" }, script = "window[ptr] = el;")
private static native void setImagePointer(String ptr, HTMLImageElement el);
@JSBody(params = { "ptr", "el" }, script = "window[ptr](el);")
private static native void callImageLoadEvent(String ptr, HTMLImageElement el);
public static final void loadImage(String src, String setJavascriptPointer, final String javascriptOnloadFunction) {
imageIsLoaded = false;
imageTexIsInitialized = false;
if(imageTexture == null) {
imageTexture = _wglGenTextures();
}
if(currentImage != null) {
currentImage.setSrc("");
}
BufferedImageElem img = imagesBuffer.get(src);
if(img != null) {
currentImage = img.imageElement;
imagesBuffer.remove(src);
}else {
currentImage = (HTMLImageElement) win.getDocument().createElement("img");
currentImage.setAttribute("crossorigin", "anonymous");
}
if(setJavascriptPointer != null) {
setImagePointer(setJavascriptPointer, currentImage);
}
currentImage.addEventListener("load", new EventListener<Event>() {
@Override
public void handleEvent(Event evt) {
imageIsLoaded = true;
if(javascriptOnloadFunction != null) {
callImageLoadEvent(javascriptOnloadFunction, currentImage);
}
}
});
if(img == null) {
currentImage.setSrc(src);
}
}
private static class BufferedImageElem {
protected final HTMLImageElement imageElement;
protected final String url;
protected final long requestedTime;
protected final int ttl;
public BufferedImageElem(HTMLImageElement imageElement, String url, int ttl) {
this.imageElement = imageElement;
this.url = url;
this.requestedTime = System.currentTimeMillis();
this.ttl = ttl;
}
}
private static final HashMap<String, BufferedImageElem> imagesBuffer = new HashMap();
public static final void bufferImage(String src, int ttl) {
if(!imagesBuffer.containsKey(src)) {
HTMLImageElement image = (HTMLImageElement) win.getDocument().createElement("img");
image.setAttribute("crossorigin", "anonymous");
image.setSrc(src);
imagesBuffer.put(src, new BufferedImageElem(image, src, ttl));
}
}
public static final void unloadImage() {
if(imageTexture != null) {
_wglDeleteTextures(imageTexture);
imageTexture = null;
}
if(currentImage != null) {
currentImage.setSrc("");
currentImage = null;
}
}
public static final boolean isImageLoaded() {
return imageTexture != null && currentImage != null && imageIsLoaded;
}
@JSBody(
params = {"ctx", "target", "internalformat", "format", "type", "image"},
script = "ctx.texImage2D(target, 0, internalformat, format, type, image);"
)
private static native void html5ImageTexImage2D(WebGL2RenderingContext ctx, int target, int internalformat, int format, int type, HTMLImageElement image);
@JSBody(
params = {"ctx", "target", "format", "type", "image"},
script = "ctx.texSubImage2D(target, 0, 0, 0, format, type, image);"
)
private static native void html5ImageTexSubImage2D(WebGL2RenderingContext ctx, int target, int format, int type, HTMLImageElement image);
public static final void updateImageTexture() {
long ms = System.currentTimeMillis();
if(ms - imageFrameTimer < imageFrameRate && imageTexIsInitialized) {
return;
}
imageFrameTimer = ms;
if(currentImage != null && imageTexture != null && imageIsLoaded) {
try {
_wglBindTexture(_wGL_TEXTURE_2D, imageTexture);
if(imageTexIsInitialized) {
html5ImageTexSubImage2D(webgl, _wGL_TEXTURE_2D, _wGL_RGBA, _wGL_UNSIGNED_BYTE, currentImage);
}else {
html5ImageTexImage2D(webgl, _wGL_TEXTURE_2D, _wGL_RGBA, _wGL_RGBA, _wGL_UNSIGNED_BYTE, currentImage);
_wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_WRAP_S, _wGL_CLAMP);
_wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_WRAP_T, _wGL_CLAMP);
_wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_MIN_FILTER, _wGL_LINEAR);
_wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_MAG_FILTER, _wGL_LINEAR);
imageTexIsInitialized = true;
}
}catch(Throwable t) {
// rip
}
}
}
public static final void bindImageTexture() {
if(imageTexture != null) {
_wglBindTexture(_wGL_TEXTURE_2D, imageTexture);
}
}
public static final int getImageWidth() {
if(currentImage != null && imageIsLoaded) {
return currentImage.getWidth();
}else {
return -1;
}
}
public static final int getImageHeight() {
if(currentImage != null && imageIsLoaded) {
return currentImage.getHeight();
}else {
return -1;
}
}
public static final void setImageFrameRate(float fps) {
frameRate = (int)(1000.0f / fps);
if(frameRate < 1) {
frameRate = 1;
}
}
private static MouseEvent currentEvent = null;
private static KeyboardEvent currentEventK = null;
@ -1331,7 +1576,22 @@ public class EaglerAdapterImpl2 {
private static native int commitContext(JSObject obj);
public static final void updateDisplay() {
commitContext(webgl);
//commitContext(webgl);
int w = parent.getClientWidth();
int h = parent.getClientHeight();
if(canvas.getWidth() != w) {
canvas.setWidth(w);
}
if(canvas.getHeight() != h) {
canvas.setHeight(h);
}
frameBuffer.drawImage(renderingCanvas, 0, 0, w, h);
if(renderingCanvas.getWidth() != w) {
renderingCanvas.setWidth(w);
}
if(renderingCanvas.getHeight() != h) {
renderingCanvas.setHeight(h);
}
try {
Thread.sleep(1l);
} catch (InterruptedException e) {
@ -1367,14 +1627,10 @@ public class EaglerAdapterImpl2 {
return win.getScreen().getAvailHeight();
}
public static final int getCanvasWidth() {
int w = parent.getClientWidth();
canvas.setWidth(w);
return w;
return renderingCanvas.getWidth();
}
public static final int getCanvasHeight() {
int h = parent.getClientHeight();
canvas.setHeight(h);
return h;
return renderingCanvas.getHeight();
}
public static final void setDisplaySize(int x, int y) {

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -0,0 +1,2 @@
# eaglercraft secure mode certificate list
https://raw.githubusercontent.com/LAX1DUDE/eaglercraft/main/stable-download/certs/22w20b-1.dat

View File

@ -0,0 +1,14 @@
DO NOT IGNORE THIS MESSAGE, USE YOUR BRAIN AND READ!
Bukkit is a piece of shit, if you "/op LAX1DUDE", a player joining as 'laX1DUDE' or 'LaX1dUdE' or 'lax1dude' will all have /op too
Either don't use /op and install an actual permissions plugin, or move "BitchFilerPlugin.jar" into this server's "/plugins" folder and use only lowercase letters in your /op profile names!
Again, if you install the bitchfilter plugin, you need to /op yourself with ALL LOWERCASE LETTERS like "/op lax1dude", and then when you want to join as an op you don't type 'LAX1DUDE' you have to join as 'lax1dude' or you will be kicked by the plugin for security
PLEASE PLEASE PLEASE DO NOT IGNORE THIS MESSAGE!!!
IF YOU IGNORE THIS AND USE /op WITH MIXED CASE THEN YOU WILL BE HACKED!!!
DO NOT MAKE THIS MISTAKE OR YOU CAN LOSE YOUR WHOLE SERVER IN MINUTES!!!

View File

@ -0,0 +1,45 @@
# This is the main configuration file for Bukkit.
# As you can see, there's actually not that much to configure without any plugins.
# For a reference for any variable inside this file, check out the bukkit wiki at
# http://wiki.bukkit.org/Bukkit.yml
settings:
allow-end: true
warn-on-overload: true
permissions-file: permissions.yml
update-folder: update
ping-packet-limit: 100
use-exact-login-location: false
plugin-profiling: false
connection-throttle: 4000
query-plugins: true
deprecated-verbose: default
shutdown-message: Server closed
spawn-limits:
monsters: 70
animals: 15
water-animals: 5
ambient: 15
chunk-gc:
period-in-ticks: 600
load-threshold: 0
ticks-per:
animal-spawns: 400
monster-spawns: 1
autosave: 0
auto-updater:
enabled: true
on-broken:
- warn-console
- warn-ops
on-update:
- warn-console
- warn-ops
preferred-channel: rb
host: dl.bukkit.org
suggest-channels: true
database:
username: bukkit
isolation: SERIALIZABLE
driver: org.sqlite.JDBC
password: walrus
url: jdbc:sqlite:{DIR}{NAME}.db

View File

@ -0,0 +1,56 @@
# This is the help configuration file for Bukkit.
#
# By default you do not need to modify this file. Help topics for all plugin commands are automatically provided by
# or extracted from your installed plugins. You only need to modify this file if you wish to add new help pages to
# your server or override the help pages of existing plugin commands.
#
# This file is divided up into the following parts:
# -- general-topics: lists admin defined help topics
# -- index-topics: lists admin defined index topics
# -- amend-topics: lists topic amendments to apply to existing help topics
# -- ignore-plugins: lists any plugins that should be excluded from help
#
# Examples are given below. When amending command topic, the string <text> will be replaced with the existing value
# in the help topic. Color codes can be used in topic text. The color code character is & followed by 0-F.
# ================================================================
#
# Set this to true to list the individual command help topics in the master help.
# command-topics-in-master-index: true
#
# Each general topic will show up as a separate topic in the help index along with all the plugin command topics.
# general-topics:
# Rules:
# shortText: Rules of the server
# fullText: |
# &61. Be kind to your fellow players.
# &B2. No griefing.
# &D3. No swearing.
# permission: topics.rules
#
# Each index topic will show up as a separate sub-index in the help index along with all the plugin command topics.
# To override the default help index (displayed when the user executes /help), name the index topic "Default".
# index-topics:
# Ban Commands:
# shortText: Player banning commands
# preamble: Moderator - do not abuse these commands
# permission: op
# commands:
# - /ban
# - /ban-ip
# - /banlist
#
# Topic amendments are used to change the content of automatically generated plugin command topics.
# amended-topics:
# /stop:
# shortText: Stops the server cold....in its tracks!
# fullText: <text> - This kills the server.
# permission: you.dont.have
#
# Any plugin in the ignored plugins list will be excluded from help. The name must match the name displayed by
# the /plugins command. Ignore "Bukkit" to remove the standard bukkit commands from the index. Ignore "All"
# to completely disable automatic help topic generation.
# ignore-plugins:
# - PluginNameOne
# - PluginNameTwo
# - PluginNameThree

View File

@ -0,0 +1,14 @@
DO NOT IGNORE THIS MESSAGE, USE YOUR BRAIN AND READ!
Bukkit is a piece of shit, if you "/op LAX1DUDE", a player joining as 'laX1DUDE' or 'LaX1dUdE' or 'lax1dude' will all have /op too
Either don't use /op and install an actual permissions plugin, or move "BitchFilerPlugin.jar" into this server's "/plugins" folder and use only lowercase letters in your /op profile names!
Again, if you install the bitchfilter plugin, you need to /op yourself with ALL LOWERCASE LETTERS like "/op lax1dude", and then when you want to join as an op you don't type 'LAX1DUDE' you have to join as 'lax1dude' or you will be kicked by the plugin for security
PLEASE PLEASE PLEASE DO NOT IGNORE THIS MESSAGE!!!
IF YOU IGNORE THIS AND USE /op WITH MIXED CASE THEN YOU WILL BE HACKED!!!
DO NOT MAKE THIS MISTAKE OR YOU CAN LOSE YOUR WHOLE SERVER IN MINUTES!!!

View File

@ -0,0 +1,3 @@
@echo off
java -Xmx512M -Xms512M -jar craftbukkit-1.5.2-R1.0.jar
pause

View File

@ -0,0 +1,2 @@
#!/bin/sh
java -Xmx512M -Xms512M -jar craftbukkit-1.5.2-R1.0.jar

View File

@ -0,0 +1,30 @@
#Minecraft server properties
#Fri Dec 17 18:41:02 PST 2021
view-distance=10
max-build-height=256
server-ip=127.0.0.1
level-seed=
allow-nether=true
server-port=25569
gamemode=0
enable-rcon=false
enable-query=false
generator-settings=
level-name=world
motd=A Minecraft Server
force-gamemode=false
hardcore=false
white-list=false
pvp=true
texture-pack=
spawn-npcs=true
generate-structures=true
spawn-animals=true
snooper-enabled=true
difficulty=1
level-type=DEFAULT
spawn-monsters=true
max-players=20
spawn-protection=16
online-mode=false
allow-flight=false

View File

@ -0,0 +1,5 @@
## EaglercraftBungee
This is regular BungeeCord except it accepts WebSockets instead of raw TCP connections
**To add an animated MOTD: [https://github.com/LAX1DUDE/eaglercraft-motd/](https://github.com/LAX1DUDE/eaglercraft-motd/)**

View File

@ -0,0 +1,51 @@
#
# This file allows you to configure bans for eaglercraftbungee
# When it is saved, eaglercraft should reload it automatically
# (check the console though to be safe)
#
# For a [Usernames] ban, just add the player's name. Use a colon ':' to put in a ban reason
# For a [IPs] ban, just add the player's IP, or a subnet like 69.69.0.0/16 to ban all IPs beginning with 69.69.*
# For a [Wildcards] ban, type a string and prefix and/or suffix it with * to define the wildcard
# For a [Regex] ban, type a valid regular expression in the java.util.regex format
#
# All bans are case-insensitive, USERNAMES ARE CONVERTED TO LOWERCASE BEFORE BEING MATCHED VIA REGEX
# Java regex syntax: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
#
# set this to false to use "/eag-ban" to ban on bungee instead of just "/ban"
# (most likely needs a restart to take effect)
replace-bukkit=false
[Usernames]
# ban_test1: The ban hammer has spoken!
# ban_test2: custom ban message here
# ban_test3
# (remove the '#' before each line to enable)
[IPs]
# WARNING: if you're using nginx, banning any player's IP is gonna ban ALL PLAYERS on your server
# For this reason, the ban IP command doesn't ban 127.0.0.1 or any other 'private' range IPs
# 101.202.69.11
# 123.21.43.0/24
# 2601:1062:69:418:BEEF::10
# 2601:6090:420::/48
[Wildcards]
# *fuck*
# shi*
[Regex]
# you.+are.(a|the).+bitch
# end of file

View File

@ -0,0 +1,80 @@
listeners:
- fallback_server: lobby
tab_list: GLOBAL_PING
websocket: true
texture_size: 16
host: 0.0.0.0:25565
forced_hosts: {}
max_players: 60
tab_size: 60
default_server: lobby
force_default_server: true
forward_ip: false
server_icon: server-icon.png
motd1: '&6An Eaglercraft server'
allow_motd: true
allow_query: true
request_motd_cache:
cache_ttl: 7200
online_server_list_animation: false
online_server_list_results: true
online_server_list_trending: true
online_server_list_portfolios: false
ratelimit:
ip:
enable: true
period: 90
limit: 60
limit_lockout: 80
lockout_duration: 1200
exceptions: []
login:
enable: true
period: 50
limit: 5
limit_lockout: 10
lockout_duration: 300
exceptions: []
motd:
enable: true
period: 30
limit: 5
limit_lockout: 15
lockout_duration: 300
exceptions: []
query:
enable: true
period: 30
limit: 15
limit_lockout: 25
lockout_duration: 900
exceptions: []
player_limit: -1
timeout: 30000
servers:
lobby:
address: localhost:25569
restricted: false
server_name: EaglercraftBungee Server
certificates:
- https://raw.githubusercontent.com/LAX1DUDE/eaglercraft/main/stable-download/certs/index.txt
display_ban_type_on_kick: false
permissions:
default:
- bungeecord.command.server
- bungeecord.command.list
admin:
- bungeecord.command.alert
- bungeecord.command.end
- bungeecord.command.ip
- bungeecord.command.reload
- bungeecord.command.eag.ban
- bungeecord.command.eag.banwildcard
- bungeecord.command.eag.banip
- bungeecord.command.eag.banregex
- bungeecord.command.eag.reloadban
- bungeecord.command.eag.banned
- bungeecord.command.eag.banlist
- bungeecord.command.eag.unban
- bungeecord.command.eag.ratelimit
groups: {}

View File

@ -0,0 +1,3 @@
@echo off
java -Xmx32M -Xms32M -jar bungee-dist.jar
pause

View File

@ -0,0 +1,2 @@
#!/bin/sh
java -Xmx32M -Xms32M -jar bungee-dist.jar

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,40 @@
<!DOCTYPE html>
<html>
<head>
<title>eagler</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Eaglercraft is real Minecraft 1.5.2 that you can play in any regular web browser. That includes school chromebooks, it works on all chromebooks. You can join real Minecraft 1.5.2 servers with it through a custom proxy based on Bungeecord." />
<meta name="keywords" content="minecraft, applet, chromebook, lax1dude, games, eaglercraft, eagler" />
<meta name="author" content="LAX1DUDE" />
<meta property="og:title" content="Eaglercraft" />
<meta property="og:locale" content="en-US" />
<meta property="og:type" content="website" />
<meta property="og:image" content="https://media.discordapp.net/attachments/378764518081429506/932053915061587978/thumbnail2.png" />
<meta property="og:description" content="Eaglercraft is real Minecraft 1.5.2 that you can play in any regular web browser. That includes school chromebooks, it works on all chromebooks. You can join real Minecraft 1.5.2 servers with it through a custom proxy based on Bungeecord." />
<!-- Change this: <meta property="og:url" content="https://g.eags.us/eaglercraft/" /> -->
<script type="text/javascript" src="classes.js"></script>
<script type="text/javascript">
if(document.location.href.startsWith("file:")) {
alert("You're not supposed to 'open' this file in your browser. Please upload this folder to your HTTP(s) server and access it via the internet. This is not a bug, please read the documentation");
}else {
window.addEventListener("load", function(){
window.minecraftOpts = [
"game_frame","assets.epk",
"CgAACQAHc2VydmVycwoAAAABCAACaXAAIHdzKHMpOi8vIChhZGRyZXNzIGhlcmUpOihwb3J0KSAvCAAEbmFtZQAIdGVtcGxhdGUBAAtoaWRlQWRkcmVzcwEIAApmb3JjZWRNT1REABl0aGlzIGlzIG5vdCBhIHJlYWwgc2VydmVyAAA="
];
(function(){
var q = window.location.search;
if(typeof q === 'string' && q.startsWith("?")) {
q = new URLSearchParams(q);
var s = q.get("server");
if(s) window.minecraftOpts.push(s);
}
})();
main();
});}
</script>
</head>
<body style="margin:0px;width:100vw;height:100vh;" id="game_frame">
</body>
</html>

Binary file not shown.