Enhance compatibility and feature support for Minecraft 1.21: Add ProtocolWrapper21, update gamerule management, streamline entity tracking, and refine chunk hider logic.

This commit is contained in:
2025-07-31 11:34:56 +02:00
parent cf52b50333
commit e7803dcf82
18 changed files with 135 additions and 35 deletions
@@ -157,14 +157,21 @@ public final class Reflection {
} else if(MAJOR_VERSION < 21 || MINOR_VERSION < 4) {
return Class.forName(spigotClassnames.getOrDefault(name, name));
} else {
Class<?> clazz = Class.forName(name);
if (clazz.getName().equals(name)) {
Class<?> clazz = null;
try {
clazz = Class.forName(name);
} catch (ClassNotFoundException e) {}
if (clazz != null && clazz.getName().equals(name)) {
return clazz;
}
try {
return Core.class.getClassLoader().getParent().loadClass(name);
} catch (ClassNotFoundException e) {
if (clazz == null) {
throw e;
}
return clazz;
}
}
@@ -147,8 +147,9 @@ public interface ChunkHider {
return;
}
int longs = (int) (((long) entries * bitsPerBlock + 63) >> 6);
out.writeBytes(in, longs * Long.BYTES);
char valuesPerLong = (char)(64 / bitsPerBlock);
int i1 = (entries + valuesPerLong - 1) / valuesPerLong;
out.writeBytes(in, i1 * Long.BYTES);
}
public long[] readDataArray() {
@@ -164,9 +165,10 @@ public interface ChunkHider {
return new long[entries];
}
int longs = (int) (((long) entries * bitsPerBlock + 63) >> 6);
long[] array = new long[longs];
for(int i = 0; i < longs; i++)
char valuesPerLong = (char) (64 / bitsPerBlock);
int i1 = (entries + valuesPerLong - 1) / valuesPerLong;
long[] array = new long[i1];
for(int i = 0; i < i1; i++)
array[i] = in.readLong();
return array;