Skip to content

Commit a04cff9

Browse files
author
eaglercraft
committed
u45
1 parent f4fab59 commit a04cff9

File tree

37 files changed

+566
-203
lines changed

37 files changed

+566
-203
lines changed

desktopRuntime/resources/assets/minecraft/lang/en_US.lang

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ eaglercraft.singleplayer.demo.create.create.tooltip=Play the Minecraft 1.8 demo
592592
eaglercraft.singleplayer.demo.create.join=Join Shared World
593593
eaglercraft.singleplayer.demo.create.join.tooltip=Join someone else's world and play multiplayer
594594

595-
eaglercraft.createWorld.seedNote=Note: Vanilla seeds now work!
595+
eaglercraft.createWorld.seedNote=Note: Vanilla seeds work
596596

597597
eaglercraft.singleplayer.oldseedwarning.title=Old World Detected!
598598
eaglercraft.singleplayer.oldseedwarning.msg1=Please use EaglercraftX u32 or older to "Re-Create" this world

src/game/java/net/minecraft/client/gui/GuiMultiplayer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,8 @@ public void initGui() {
100100
this.serverListSelector.func_148195_a(this.savedServerList);
101101
if (lanServerList == null) {
102102
lanServerList = new LANServerList();
103-
} else {
104-
lanServerList.forceRefresh();
105103
}
104+
lanServerList.forceRefresh();
106105
} else {
107106
this.serverListSelector.setDimensions(this.width, this.height, 32, this.height - 64);
108107
}

src/lwjgl/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformInput.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
import org.lwjgl.glfw.GLFWVidMode;
1515
import org.lwjgl.system.MemoryStack;
1616

17-
import net.lax1dude.eaglercraft.v1_8.Display;
18-
1917
/**
2018
* Copyright (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
2119
*
@@ -302,7 +300,7 @@ public static void update() {
302300
update(0);
303301
}
304302

305-
private static final long[] syncTimer = new long[1];
303+
private static long syncTimer = 0l;
306304

307305
public static void update(int limitFps) {
308306
glfwPollEvents();
@@ -311,10 +309,23 @@ public static void update(int limitFps) {
311309
glfwVSyncState = vsync;
312310
}
313311
glfwSwapBuffers(win);
314-
if(limitFps > 0 && !vsync) {
315-
Display.sync(limitFps, syncTimer);
312+
if(!vsync && limitFps > 0 && limitFps <= 1000) {
313+
long frameNanos = (1000000000l / limitFps);
314+
if(syncTimer == 0l) {
315+
syncTimer = System.nanoTime() + frameNanos;
316+
}else {
317+
long nanos = System.nanoTime();
318+
int remaining = (int)((syncTimer - nanos) / 1000000l);
319+
if(remaining > 0) {
320+
PlatformRuntime.sleep(remaining);
321+
nanos = System.nanoTime();
322+
}
323+
if((syncTimer += frameNanos) < nanos) {
324+
syncTimer = nanos;
325+
}
326+
}
316327
}else {
317-
syncTimer[0] = 0l;
328+
syncTimer = 0l;
318329
}
319330
}
320331

src/lwjgl/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformRuntime.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,4 +647,8 @@ public static void immediateContinue() {
647647
// nope
648648
}
649649

650+
public static boolean immediateContinueSupported() {
651+
return false;
652+
}
653+
650654
}

src/lwjgl/java/net/lax1dude/eaglercraft/v1_8/internal/buffer/EaglerLWJGLAllocator.java

Lines changed: 60 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,48 +33,74 @@ public static int getAllocCount() {
3333
return allocCount;
3434
}
3535

36+
private static final ByteBuffer ZERO_LENGTH_BYTE_BUFFER = new EaglerLWJGLByteBuffer(0l, 0, true);
37+
3638
public static ByteBuffer allocByteBuffer(int len) {
37-
long ret = JEmalloc.nje_malloc(len);
38-
if(ret == 0l) {
39-
throw new OutOfMemoryError("Native je_malloc call returned null pointer!");
39+
if(len != 0) {
40+
long ret = JEmalloc.nje_malloc(len);
41+
if(ret == 0l) {
42+
throw new OutOfMemoryError("Native je_malloc call returned null pointer!");
43+
}
44+
if(enableAllocCount) ++allocCount;
45+
return new EaglerLWJGLByteBuffer(ret, len, true);
46+
}else {
47+
return ZERO_LENGTH_BYTE_BUFFER;
4048
}
41-
if(enableAllocCount) ++allocCount;
42-
return new EaglerLWJGLByteBuffer(ret, len, true);
4349
}
4450

51+
private static final ShortBuffer ZERO_LENGTH_SHORT_BUFFER = new EaglerLWJGLShortBuffer(0l, 0, true);
52+
4553
public static ShortBuffer allocShortBuffer(int len) {
46-
long ret = JEmalloc.nje_malloc(len << 1);
47-
if(ret == 0l) {
48-
throw new OutOfMemoryError("Native je_malloc call returned null pointer!");
54+
if(len != 0) {
55+
long ret = JEmalloc.nje_malloc(len << 1);
56+
if(ret == 0l) {
57+
throw new OutOfMemoryError("Native je_malloc call returned null pointer!");
58+
}
59+
if(enableAllocCount) ++allocCount;
60+
return new EaglerLWJGLShortBuffer(ret, len, true);
61+
}else {
62+
return ZERO_LENGTH_SHORT_BUFFER;
4963
}
50-
if(enableAllocCount) ++allocCount;
51-
return new EaglerLWJGLShortBuffer(ret, len, true);
5264
}
5365

66+
private static final IntBuffer ZERO_LENGTH_INT_BUFFER = new EaglerLWJGLIntBuffer(0l, 0, true);
67+
5468
public static IntBuffer allocIntBuffer(int len) {
55-
long ret = JEmalloc.nje_malloc(len << 2);
56-
if(ret == 0l) {
57-
throw new OutOfMemoryError("Native je_malloc call returned null pointer!");
69+
if(len != 0) {
70+
long ret = JEmalloc.nje_malloc(len << 2);
71+
if(ret == 0l) {
72+
throw new OutOfMemoryError("Native je_malloc call returned null pointer!");
73+
}
74+
if(enableAllocCount) ++allocCount;
75+
return new EaglerLWJGLIntBuffer(ret, len, true);
76+
}else {
77+
return ZERO_LENGTH_INT_BUFFER;
5878
}
59-
if(enableAllocCount) ++allocCount;
60-
return new EaglerLWJGLIntBuffer(ret, len, true);
6179
}
6280

81+
private static final FloatBuffer ZERO_LENGTH_FLOAT_BUFFER = new EaglerLWJGLFloatBuffer(0l, 0, true);
82+
6383
public static FloatBuffer allocFloatBuffer(int len) {
64-
long ret = JEmalloc.nje_malloc(len << 2);
65-
if(ret == 0l) {
66-
throw new OutOfMemoryError("Native je_malloc call returned null pointer!");
84+
if(len != 0) {
85+
long ret = JEmalloc.nje_malloc(len << 2);
86+
if(ret == 0l) {
87+
throw new OutOfMemoryError("Native je_malloc call returned null pointer!");
88+
}
89+
if(enableAllocCount) ++allocCount;
90+
return new EaglerLWJGLFloatBuffer(ret, len, true);
91+
}else {
92+
return ZERO_LENGTH_FLOAT_BUFFER;
6793
}
68-
if(enableAllocCount) ++allocCount;
69-
return new EaglerLWJGLFloatBuffer(ret, len, true);
7094
}
7195

7296
public static void freeByteBuffer(ByteBuffer buffer) {
7397
if(buffer instanceof EaglerLWJGLByteBuffer) {
7498
EaglerLWJGLByteBuffer buf = (EaglerLWJGLByteBuffer)buffer;
7599
if(buf.original) {
76-
JEmalloc.nje_free(buf.address);
77-
if(enableAllocCount) --allocCount;
100+
if(buf.address != 0l) {
101+
JEmalloc.nje_free(buf.address);
102+
if(enableAllocCount) --allocCount;
103+
}
78104
}else {
79105
throwNotOriginal(buffer);
80106
}
@@ -96,8 +122,10 @@ public static void freeShortBuffer(ShortBuffer buffer) {
96122
if(buffer instanceof EaglerLWJGLShortBuffer) {
97123
EaglerLWJGLShortBuffer buf = (EaglerLWJGLShortBuffer)buffer;
98124
if(buf.original) {
99-
JEmalloc.nje_free(buf.address);
100-
if(enableAllocCount) --allocCount;
125+
if(buf.address != 0l) {
126+
JEmalloc.nje_free(buf.address);
127+
if(enableAllocCount) --allocCount;
128+
}
101129
}else {
102130
throwNotOriginal(buffer);
103131
}
@@ -119,8 +147,10 @@ public static void freeIntBuffer(IntBuffer buffer) {
119147
if(buffer instanceof EaglerLWJGLIntBuffer) {
120148
EaglerLWJGLIntBuffer buf = (EaglerLWJGLIntBuffer)buffer;
121149
if(buf.original) {
122-
JEmalloc.nje_free(buf.address);
123-
if(enableAllocCount) --allocCount;
150+
if(buf.address != 0l) {
151+
JEmalloc.nje_free(buf.address);
152+
if(enableAllocCount) --allocCount;
153+
}
124154
}else {
125155
throwNotOriginal(buffer);
126156
}
@@ -142,8 +172,10 @@ public static void freeFloatBuffer(FloatBuffer buffer) {
142172
if(buffer instanceof EaglerLWJGLFloatBuffer) {
143173
EaglerLWJGLFloatBuffer buf = (EaglerLWJGLFloatBuffer)buffer;
144174
if(buf.original) {
145-
JEmalloc.nje_free(buf.address);
146-
if(enableAllocCount) --allocCount;
175+
if(buf.address != 0l) {
176+
JEmalloc.nje_free(buf.address);
177+
if(enableAllocCount) --allocCount;
178+
}
147179
}else {
148180
throwNotOriginal(buffer);
149181
}

src/main/java/net/lax1dude/eaglercraft/v1_8/Display.java

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
*/
2020
public class Display {
2121

22-
private static long lastSwap = 0l;
2322
private static long lastDPIUpdate = -250l;
2423
private static float cacheDPI = 1.0f;
2524

@@ -79,41 +78,6 @@ public static void update(int limitFramerate) {
7978
PlatformInput.update(limitFramerate);
8079
}
8180

82-
private static final long[] defaultSyncPtr = new long[1];
83-
84-
public static void sync(int limitFramerate) {
85-
sync(limitFramerate, defaultSyncPtr);
86-
}
87-
88-
public static boolean sync(int limitFramerate, long[] timerPtr) {
89-
boolean limitFPS = limitFramerate > 0 && limitFramerate < 1000;
90-
boolean blocked = false;
91-
92-
if(limitFPS) {
93-
if(timerPtr[0] == 0l) {
94-
timerPtr[0] = EagRuntime.steadyTimeMillis();
95-
}else {
96-
long millis = EagRuntime.steadyTimeMillis();
97-
long frameMillis = (1000l / limitFramerate);
98-
long frameTime = millis - timerPtr[0];
99-
if(frameTime > 2000l || frameTime < 0l) {
100-
frameTime = frameMillis;
101-
timerPtr[0] = millis;
102-
}else {
103-
timerPtr[0] += frameMillis;
104-
}
105-
if(frameTime >= 0l && frameTime < frameMillis) {
106-
EagUtils.sleep(frameMillis - frameTime);
107-
blocked = true;
108-
}
109-
}
110-
}else {
111-
timerPtr[0] = 0l;
112-
}
113-
114-
return blocked;
115-
}
116-
11781
public static boolean contextLost() {
11882
return PlatformInput.contextLost();
11983
}

src/main/java/net/lax1dude/eaglercraft/v1_8/EagRuntime.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,4 +375,8 @@ public static void immediateContinue() {
375375
PlatformRuntime.immediateContinue();
376376
}
377377

378+
public static boolean immediateContinueSupported() {
379+
return PlatformRuntime.immediateContinueSupported();
380+
}
381+
378382
}

src/main/java/net/lax1dude/eaglercraft/v1_8/EaglerInputStream.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,16 @@ public static byte[] inputStreamToBytes(InputStream is) throws IOException {
142142
}
143143
}
144144

145+
public static byte[] inputStreamToBytesNoClose(InputStream is) throws IOException {
146+
EaglerOutputStream os = new EaglerOutputStream(1024);
147+
byte[] buf = new byte[1024];
148+
int i;
149+
while ((i = is.read(buf)) != -1) {
150+
os.write(buf, 0, i);
151+
}
152+
return os.toByteArray();
153+
}
154+
145155
public byte[] getAsArray() {
146156
if (pos == 0 && count == buf.length) {
147157
return buf;

src/main/java/net/lax1dude/eaglercraft/v1_8/EaglercraftVersion.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class EaglercraftVersion {
1010
/// Customize these to fit your fork:
1111

1212
public static final String projectForkName = "EaglercraftX";
13-
public static final String projectForkVersion = "u44";
13+
public static final String projectForkVersion = "u45";
1414
public static final String projectForkVendor = "lax1dude";
1515

1616
public static final String projectForkURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8";
@@ -20,20 +20,20 @@ public class EaglercraftVersion {
2020
public static final String projectOriginName = "EaglercraftX";
2121
public static final String projectOriginAuthor = "lax1dude";
2222
public static final String projectOriginRevision = "1.8";
23-
public static final String projectOriginVersion = "u44";
23+
public static final String projectOriginVersion = "u45";
2424

2525
public static final String projectOriginURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8"; // rest in peace
2626

2727
// EPK Version Identifier
2828

29-
public static final String EPKVersionIdentifier = "u44"; // Set to null to disable EPK version check
29+
public static final String EPKVersionIdentifier = "u45"; // Set to null to disable EPK version check
3030

3131
// Updating configuration
3232

3333
public static final boolean enableUpdateService = true;
3434

3535
public static final String updateBundlePackageName = "net.lax1dude.eaglercraft.v1_8.client";
36-
public static final int updateBundlePackageVersionInt = 44;
36+
public static final int updateBundlePackageVersionInt = 45;
3737

3838
public static final String updateLatestLocalStorageKey = "latestUpdate_" + updateBundlePackageName;
3939

src/main/java/net/lax1dude/eaglercraft/v1_8/minecraft/EaglerFolderResourcePack.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public static EaglerFolderResourcePack importResourcePack(String name, String pr
211211
i += j;
212212
}
213213
}else {
214-
buffer = EaglerInputStream.inputStreamToBytes(ziss);
214+
buffer = EaglerInputStream.inputStreamToBytesNoClose(ziss);
215215
}
216216
(new VFile2(prefix, folderName, fn.substring(prefixLen))).setAllBytes(buffer);
217217
totalSize += buffer.length;

0 commit comments

Comments
 (0)