Minecraft 1.18.2 Proper support

This commit is contained in:
LOOHP 2022-03-05 17:43:31 +00:00
parent 26aabe66bd
commit 4ebe77d5dd
7 changed files with 4624 additions and 6474 deletions

View File

@ -24,7 +24,7 @@
<groupId>com.loohp</groupId> <groupId>com.loohp</groupId>
<artifactId>Limbo</artifactId> <artifactId>Limbo</artifactId>
<name>Limbo</name> <name>Limbo</name>
<version>0.6.11-ALPHA</version> <version>0.6.12-ALPHA</version>
<description>Standalone Limbo Minecraft Server.</description> <description>Standalone Limbo Minecraft Server.</description>
<url>https://github.com/LOOHP/Limbo</url> <url>https://github.com/LOOHP/Limbo</url>

View File

@ -126,8 +126,8 @@ public class Limbo {
//=========================== //===========================
public final String serverImplementationVersion = "1.18.1"; public final String serverImplementationVersion = "1.18.2";
public final int serverImplmentationProtocol = 757; public final int serverImplementationProtocol = 758;
public final String limboImplementationVersion; public final String limboImplementationVersion;
private AtomicBoolean isRunning; private AtomicBoolean isRunning;

View File

@ -104,7 +104,7 @@ public class ServerProperties {
prop.store(pw, COMMENT); prop.store(pw, COMMENT);
pw.close(); pw.close();
protocol = Limbo.getInstance().serverImplmentationProtocol; protocol = Limbo.getInstance().serverImplementationProtocol;
maxPlayers = Integer.parseInt(prop.getProperty("max-players")); maxPlayers = Integer.parseInt(prop.getProperty("max-players"));
serverPort = Integer.parseInt(prop.getProperty("server-port")); serverPort = Integer.parseInt(prop.getProperty("server-port"));

View File

@ -482,13 +482,13 @@ public class ClientConnection extends Thread {
String str = inetAddress.getHostName() + ":" + clientSocket.getPort() + "|" + player.getName() + "(" + player.getUniqueId() + ")"; String str = inetAddress.getHostName() + ":" + clientSocket.getPort() + "|" + player.getName() + "(" + player.getUniqueId() + ")";
Limbo.getInstance().getConsole().sendMessage("[/" + str + "] <-> Player had connected to the Limbo server!"); Limbo.getInstance().getConsole().sendMessage("[/" + str + "] <-> Player had connected to the Limbo server!");
player.playerInteractManager.update();
PacketPlayOutDeclareCommands declare = DeclareCommands.getDeclareCommandsPacket(player); PacketPlayOutDeclareCommands declare = DeclareCommands.getDeclareCommandsPacket(player);
if (declare != null) { if (declare != null) {
sendPacket(declare); sendPacket(declare);
} }
player.playerInteractManager.update();
PacketPlayOutSpawnPosition spawnPos = new PacketPlayOutSpawnPosition(BlockPosition.from(worldSpawn), worldSpawn.getPitch()); PacketPlayOutSpawnPosition spawnPos = new PacketPlayOutSpawnPosition(BlockPosition.from(worldSpawn), worldSpawn.getPitch());
sendPacket(spawnPos); sendPacket(spawnPos);
@ -665,7 +665,7 @@ public class ClientConnection extends Thread {
running = false; running = false;
} }
public static enum ClientState { public enum ClientState {
LEGACY, LEGACY,
HANDSHAKE, HANDSHAKE,
STATUS, STATUS,

View File

@ -53,18 +53,16 @@ public class ClientboundLevelChunkWithLightPacket extends PacketOut {
private long[] blockLightBitMasksEmpty; private long[] blockLightBitMasksEmpty;
private List<Byte[]> skylightArrays; private List<Byte[]> skylightArrays;
private List<Byte[]> blocklightArrays; private List<Byte[]> blocklightArrays;
public ClientboundLevelChunkWithLightPacket(int chunkX, int chunkZ, Chunk chunk, Environment environment, boolean trustEdges, List<Byte[]> skylightArrays, List<Byte[]> blocklightArrays) { public ClientboundLevelChunkWithLightPacket(int chunkX, int chunkZ, Chunk chunk, Environment environment, boolean trustEdges, List<Byte[]> skylightArrays, List<Byte[]> blocklightArrays) {
this.chunkX = chunkX; this.chunkX = chunkX;
this.chunkZ = chunkZ; this.chunkZ = chunkZ;
this.chunk = chunk; this.chunk = chunk;
this.environment = environment; this.environment = environment;
this.chunkX = chunkX;
this.chunkZ = chunkZ;
this.trustEdges = trustEdges; this.trustEdges = trustEdges;
this.skylightArrays = skylightArrays; this.skylightArrays = skylightArrays;
this.blocklightArrays = blocklightArrays; this.blocklightArrays = blocklightArrays;
BitSet skyLightBitSet = new BitSet(); BitSet skyLightBitSet = new BitSet();
BitSet skyLightBitSetInverse = new BitSet(); BitSet skyLightBitSetInverse = new BitSet();
for (int i = Math.min(17, skylightArrays.size() - 1); i >= 0; i--) { for (int i = Math.min(17, skylightArrays.size() - 1); i >= 0; i--) {
@ -73,7 +71,7 @@ public class ClientboundLevelChunkWithLightPacket extends PacketOut {
} }
skyLightBitMasks = skyLightBitSet.toLongArray(); skyLightBitMasks = skyLightBitSet.toLongArray();
skyLightBitMasksEmpty = skyLightBitSetInverse.toLongArray(); skyLightBitMasksEmpty = skyLightBitSetInverse.toLongArray();
BitSet blockLightBitSet = new BitSet(); BitSet blockLightBitSet = new BitSet();
BitSet blockLightBitSetInverse = new BitSet(); BitSet blockLightBitSetInverse = new BitSet();
for (int i = Math.min(17, blocklightArrays.size() - 1); i >= 0; i--) { for (int i = Math.min(17, blocklightArrays.size() - 1); i >= 0; i--) {
@ -87,7 +85,7 @@ public class ClientboundLevelChunkWithLightPacket extends PacketOut {
public Chunk getChunk() { public Chunk getChunk() {
return chunk; return chunk;
} }
public int getChunkX() { public int getChunkX() {
return chunkX; return chunkX;
} }
@ -95,11 +93,11 @@ public class ClientboundLevelChunkWithLightPacket extends PacketOut {
public int getChunkZ() { public int getChunkZ() {
return chunkZ; return chunkZ;
} }
public Environment getEnvironment() { public Environment getEnvironment() {
return environment; return environment;
} }
public boolean isTrustEdges() { public boolean isTrustEdges() {
return trustEdges; return trustEdges;
} }
@ -123,20 +121,20 @@ public class ClientboundLevelChunkWithLightPacket extends PacketOut {
@Override @Override
public byte[] serializePacket() throws IOException { public byte[] serializePacket() throws IOException {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(Packet.getPlayOut().get(getClass()));
output.writeInt(chunkX); output.writeInt(chunkX);
output.writeInt(chunkZ); output.writeInt(chunkZ);
DataTypeIO.writeCompoundTag(output, chunk.getHeightMaps()); DataTypeIO.writeCompoundTag(output, chunk.getHeightMaps());
ByteArrayOutputStream dataBuffer = new ByteArrayOutputStream(); ByteArrayOutputStream dataBuffer = new ByteArrayOutputStream();
DataOutputStream dataOut = new DataOutputStream(dataBuffer); DataOutputStream dataOut = new DataOutputStream(dataBuffer);
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
Section section = chunk.getSection(i); Section section = chunk.getSection(i);
if (section != null) { if (section != null) {
int counter = 0; short counter = 0;
for (int x = 0; x < 16; x++) { for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) { for (int z = 0; z < 16; z++) {
for (int y = 0; y < 16; y++) { for (int y = 0; y < 16; y++) {
@ -146,44 +144,33 @@ public class ClientboundLevelChunkWithLightPacket extends PacketOut {
} }
} }
} }
} }
dataOut.writeShort(counter); dataOut.writeShort(counter);
int newBits = 32 - Integer.numberOfLeadingZeros(section.getPalette().size() - 1); int newBits = 32 - Integer.numberOfLeadingZeros(section.getPalette().size() - 1);
newBits = Math.max(newBits, 4); newBits = Math.max(newBits, 4);
//Limbo.getInstance().getConsole().sendMessage(i + " " + newBits); //Limbo.getInstance().getConsole().sendMessage(i + " " + newBits);
if (newBits <= 8) { if (newBits <= 8) {
/*
if (newBits == 4) {
dataOut.writeByte(4);
} else {
newBits = 8;
ChunkDataUtils.adjustBlockStateBits(newBits, section, chunk.getDataVersion());
dataOut.writeByte(8);
}
*/
dataOut.writeByte(newBits); dataOut.writeByte(newBits);
DataTypeIO.writeVarInt(dataOut, section.getPalette().size()); DataTypeIO.writeVarInt(dataOut, section.getPalette().size());
//Limbo.getInstance().getConsole().sendMessage(section.getPalette().size()); //Limbo.getInstance().getConsole().sendMessage(section.getPalette().size());
Iterator<CompoundTag> itr1 = section.getPalette().iterator();
//Limbo.getInstance().getConsole().sendMessage("Nonnull -> " + i + " " + newBits); //Limbo.getInstance().getConsole().sendMessage("Nonnull -> " + i + " " + newBits);
while (itr1.hasNext()) { for (CompoundTag tag : section.getPalette()) {
CompoundTag tag = itr1.next();
DataTypeIO.writeVarInt(dataOut, GeneratedBlockDataMappings.getGlobalPaletteIDFromState(tag)); DataTypeIO.writeVarInt(dataOut, GeneratedBlockDataMappings.getGlobalPaletteIDFromState(tag));
//Limbo.getInstance().getConsole().sendMessage(tag + " -> " + GeneratedDataUtils.getGlobalPaletteIDFromState(tag)); //Limbo.getInstance().getConsole().sendMessage(tag + " -> " + GeneratedDataUtils.getGlobalPaletteIDFromState(tag));
} }
BitSet bits = BitSet.valueOf(section.getBlockStates()); BitSet bits = BitSet.valueOf(section.getBlockStates());
int shift = 64 % newBits; int shift = 64 % newBits;
int longsNeeded = (int) Math.ceil(4096 / (double) (64 / newBits)); int longsNeeded = (int) Math.ceil(4096 / (double) (64 / newBits));
for (int u = 64; u <= bits.length(); u += 64) { for (int u = 64; u <= bits.length(); u += 64) {
bits = BitsUtils.shiftAfter(bits, u - shift, shift); bits = BitsUtils.shiftAfter(bits, u - shift, shift);
} }
long[] formattedLongs = bits.toLongArray(); long[] formattedLongs = bits.toLongArray();
//Limbo.getInstance().getConsole().sendMessage(longsNeeded + ""); //Limbo.getInstance().getConsole().sendMessage(longsNeeded + "");
DataTypeIO.writeVarInt(dataOut, longsNeeded); DataTypeIO.writeVarInt(dataOut, longsNeeded);
for (int u = 0; u < longsNeeded; u++) { for (int u = 0; u < longsNeeded; u++) {
if (u < formattedLongs.length) { if (u < formattedLongs.length) {
@ -221,7 +208,7 @@ public class ClientboundLevelChunkWithLightPacket extends PacketOut {
} }
int id = list.isEmpty() ? 0 : list.remove(0); int id = list.isEmpty() ? 0 : list.remove(0);
currentLong = currentLong << 15; currentLong = currentLong << 15;
currentLong |= (long) id; currentLong |= id;
} }
DataTypeIO.writeVarInt(dataOut, longsNeeded); DataTypeIO.writeVarInt(dataOut, longsNeeded);
for (int j = 0; j < longsNeeded; j++) { for (int j = 0; j < longsNeeded; j++) {
@ -255,24 +242,24 @@ public class ClientboundLevelChunkWithLightPacket extends PacketOut {
DataTypeIO.writeVarInt(dataOut, biome); DataTypeIO.writeVarInt(dataOut, biome);
DataTypeIO.writeVarInt(dataOut, 0); DataTypeIO.writeVarInt(dataOut, 0);
} }
byte[] data = dataBuffer.toByteArray(); byte[] data = dataBuffer.toByteArray();
DataTypeIO.writeVarInt(output, data.length); DataTypeIO.writeVarInt(output, data.length);
output.write(data); output.write(data);
ListTag<CompoundTag> tileEntities = chunk.getTileEntities(); ListTag<CompoundTag> tileEntities = chunk.getTileEntities();
DataTypeIO.writeVarInt(output, tileEntities.size()); DataTypeIO.writeVarInt(output, tileEntities.size());
for (CompoundTag each : tileEntities) { for (CompoundTag each : tileEntities) {
int x = each.getInt("x") % 16; int x = each.getInt("x") % 16;
int y = each.getInt("y"); int y = each.getInt("y");
int z = each.getInt("z") % 16; int z = each.getInt("z") % 16;
output.writeByte((x << 4) | z); output.writeByte(((x & 15) << 4) | (z & 15));
output.writeShort(y); output.writeShort(y);
Integer id = Registry.BLOCK_ENTITY_TYPE.getId(new NamespacedKey(chunk.getBlockStateAt(x, y, z).getString("Name"))); Integer id = Registry.BLOCK_ENTITY_TYPE.getId(new NamespacedKey(chunk.getBlockStateAt(x, y, z).getString("Name")));
DataTypeIO.writeVarInt(output, id == null ? -1 : id); DataTypeIO.writeVarInt(output, id == null ? -1 : id);
DataTypeIO.writeCompoundTag(output, each); DataTypeIO.writeCompoundTag(output, each);
} }
output.writeBoolean(trustEdges); output.writeBoolean(trustEdges);
DataTypeIO.writeVarInt(output, skyLightBitMasks.length); DataTypeIO.writeVarInt(output, skyLightBitMasks.length);
for (long l : skyLightBitMasks) { for (long l : skyLightBitMasks) {
@ -290,7 +277,7 @@ public class ClientboundLevelChunkWithLightPacket extends PacketOut {
for (long l : blockLightBitMasksEmpty) { for (long l : blockLightBitMasksEmpty) {
output.writeLong(l); output.writeLong(l);
} }
DataTypeIO.writeVarInt(output, skylightArrays.stream().mapToInt(each -> each == null ? 0 : 1).sum()); DataTypeIO.writeVarInt(output, skylightArrays.stream().mapToInt(each -> each == null ? 0 : 1).sum());
for (int i = skylightArrays.size() - 1; i >= 0; i--) { for (int i = skylightArrays.size() - 1; i >= 0; i--) {
Byte[] array = skylightArrays.get(i); Byte[] array = skylightArrays.get(i);
@ -302,7 +289,7 @@ public class ClientboundLevelChunkWithLightPacket extends PacketOut {
} }
} }
} }
DataTypeIO.writeVarInt(output, blocklightArrays.stream().mapToInt(each -> each == null ? 0 : 1).sum()); DataTypeIO.writeVarInt(output, blocklightArrays.stream().mapToInt(each -> each == null ? 0 : 1).sum());
for (int i = blocklightArrays.size() - 1; i >= 0; i--) { for (int i = blocklightArrays.size() - 1; i >= 0; i--) {
Byte[] array = blocklightArrays.get(i); Byte[] array = blocklightArrays.get(i);
@ -314,7 +301,7 @@ public class ClientboundLevelChunkWithLightPacket extends PacketOut {
} }
} }
} }
return buffer.toByteArray(); return buffer.toByteArray();
} }

File diff suppressed because it is too large Load Diff

View File

@ -12579,8 +12579,19 @@
} }
} }
}, },
"minecraft:worldgen/structure_piece": { "minecraft:worldgen/structure_placement": {
"protocol_id": 42, "protocol_id": 42,
"entries": {
"minecraft:random_spread": {
"protocol_id": 0
},
"minecraft:concentric_rings": {
"protocol_id": 1
}
}
},
"minecraft:worldgen/structure_piece": {
"protocol_id": 43,
"entries": { "entries": {
"minecraft:mscorridor": { "minecraft:mscorridor": {
"protocol_id": 0 "protocol_id": 0
@ -12753,7 +12764,7 @@
} }
}, },
"minecraft:worldgen/placement_modifier_type": { "minecraft:worldgen/placement_modifier_type": {
"protocol_id": 43, "protocol_id": 44,
"entries": { "entries": {
"minecraft:block_predicate_filter": { "minecraft:block_predicate_filter": {
"protocol_id": 0 "protocol_id": 0
@ -12803,7 +12814,7 @@
} }
}, },
"minecraft:worldgen/block_state_provider_type": { "minecraft:worldgen/block_state_provider_type": {
"protocol_id": 44, "protocol_id": 45,
"entries": { "entries": {
"minecraft:simple_state_provider": { "minecraft:simple_state_provider": {
"protocol_id": 0 "protocol_id": 0
@ -12829,7 +12840,7 @@
} }
}, },
"minecraft:worldgen/foliage_placer_type": { "minecraft:worldgen/foliage_placer_type": {
"protocol_id": 45, "protocol_id": 46,
"entries": { "entries": {
"minecraft:blob_foliage_placer": { "minecraft:blob_foliage_placer": {
"protocol_id": 0 "protocol_id": 0
@ -12864,7 +12875,7 @@
} }
}, },
"minecraft:worldgen/trunk_placer_type": { "minecraft:worldgen/trunk_placer_type": {
"protocol_id": 46, "protocol_id": 47,
"entries": { "entries": {
"minecraft:straight_trunk_placer": { "minecraft:straight_trunk_placer": {
"protocol_id": 0 "protocol_id": 0
@ -12890,7 +12901,7 @@
} }
}, },
"minecraft:worldgen/tree_decorator_type": { "minecraft:worldgen/tree_decorator_type": {
"protocol_id": 47, "protocol_id": 48,
"entries": { "entries": {
"minecraft:trunk_vine": { "minecraft:trunk_vine": {
"protocol_id": 0 "protocol_id": 0
@ -12910,7 +12921,7 @@
} }
}, },
"minecraft:worldgen/feature_size_type": { "minecraft:worldgen/feature_size_type": {
"protocol_id": 48, "protocol_id": 49,
"entries": { "entries": {
"minecraft:two_layers_feature_size": { "minecraft:two_layers_feature_size": {
"protocol_id": 0 "protocol_id": 0
@ -12921,7 +12932,7 @@
} }
}, },
"minecraft:worldgen/biome_source": { "minecraft:worldgen/biome_source": {
"protocol_id": 49, "protocol_id": 50,
"entries": { "entries": {
"minecraft:fixed": { "minecraft:fixed": {
"protocol_id": 0 "protocol_id": 0
@ -12938,7 +12949,7 @@
} }
}, },
"minecraft:worldgen/chunk_generator": { "minecraft:worldgen/chunk_generator": {
"protocol_id": 50, "protocol_id": 51,
"entries": { "entries": {
"minecraft:noise": { "minecraft:noise": {
"protocol_id": 0 "protocol_id": 0
@ -12952,7 +12963,7 @@
} }
}, },
"minecraft:worldgen/material_condition": { "minecraft:worldgen/material_condition": {
"protocol_id": 51, "protocol_id": 52,
"entries": { "entries": {
"minecraft:biome": { "minecraft:biome": {
"protocol_id": 0 "protocol_id": 0
@ -12990,7 +13001,7 @@
} }
}, },
"minecraft:worldgen/material_rule": { "minecraft:worldgen/material_rule": {
"protocol_id": 52, "protocol_id": 53,
"entries": { "entries": {
"minecraft:bandlands": { "minecraft:bandlands": {
"protocol_id": 0 "protocol_id": 0
@ -13006,8 +13017,115 @@
} }
} }
}, },
"minecraft:worldgen/density_function_type": {
"protocol_id": 54,
"entries": {
"minecraft:blend_alpha": {
"protocol_id": 0
},
"minecraft:blend_offset": {
"protocol_id": 1
},
"minecraft:beardifier": {
"protocol_id": 2
},
"minecraft:old_blended_noise": {
"protocol_id": 3
},
"minecraft:interpolated": {
"protocol_id": 4
},
"minecraft:flat_cache": {
"protocol_id": 5
},
"minecraft:cache_2d": {
"protocol_id": 6
},
"minecraft:cache_once": {
"protocol_id": 7
},
"minecraft:cache_all_in_cell": {
"protocol_id": 8
},
"minecraft:noise": {
"protocol_id": 9
},
"minecraft:end_islands": {
"protocol_id": 10
},
"minecraft:weird_scaled_sampler": {
"protocol_id": 11
},
"minecraft:shifted_noise": {
"protocol_id": 12
},
"minecraft:range_choice": {
"protocol_id": 13
},
"minecraft:shift_a": {
"protocol_id": 14
},
"minecraft:shift_b": {
"protocol_id": 15
},
"minecraft:shift": {
"protocol_id": 16
},
"minecraft:blend_density": {
"protocol_id": 17
},
"minecraft:clamp": {
"protocol_id": 18
},
"minecraft:abs": {
"protocol_id": 19
},
"minecraft:square": {
"protocol_id": 20
},
"minecraft:cube": {
"protocol_id": 21
},
"minecraft:half_negative": {
"protocol_id": 22
},
"minecraft:quarter_negative": {
"protocol_id": 23
},
"minecraft:squeeze": {
"protocol_id": 24
},
"minecraft:slide": {
"protocol_id": 25
},
"minecraft:add": {
"protocol_id": 26
},
"minecraft:mul": {
"protocol_id": 27
},
"minecraft:min": {
"protocol_id": 28
},
"minecraft:max": {
"protocol_id": 29
},
"minecraft:spline": {
"protocol_id": 30
},
"minecraft:terrain_shaper_spline": {
"protocol_id": 31
},
"minecraft:constant": {
"protocol_id": 32
},
"minecraft:y_clamped_gradient": {
"protocol_id": 33
}
}
},
"minecraft:worldgen/structure_processor": { "minecraft:worldgen/structure_processor": {
"protocol_id": 53, "protocol_id": 55,
"entries": { "entries": {
"minecraft:block_ignore": { "minecraft:block_ignore": {
"protocol_id": 0 "protocol_id": 0
@ -13042,7 +13160,7 @@
} }
}, },
"minecraft:worldgen/structure_pool_element": { "minecraft:worldgen/structure_pool_element": {
"protocol_id": 54, "protocol_id": 56,
"entries": { "entries": {
"minecraft:single_pool_element": { "minecraft:single_pool_element": {
"protocol_id": 0 "protocol_id": 0