1.15.2 EntityMetaData (big refactor update)

This commit is contained in:
Bixilon 2020-07-26 23:15:58 +02:00
parent f692d13174
commit cbf7eaffbd
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
4 changed files with 22 additions and 12 deletions

View File

@ -28,17 +28,10 @@ public class DirectPalette implements Palette {
@Override
public byte getBitsPerBlock() {
switch (version) {
case VERSION_1_9_4:
case VERSION_1_10:
case VERSION_1_11_2:
case VERSION_1_12_2:
return 13;
case VERSION_1_13_2:
case VERSION_1_14_4:
return 14;
if (version.getVersionNumber() <= ProtocolVersion.VERSION_1_12_2.getVersionNumber()) {
return 13;
}
return -1;
return 14;
}
@Override

View File

@ -56,7 +56,7 @@ public class PacketMultiBlockChange implements ClientboundPacket {
byte pos = buffer.readByte();
byte y = buffer.readByte();
int blockId = buffer.readVarInt();
blocks.put(new InChunkLocation(((pos & 0xF0) >>> 4), y, (pos & 0xF)), Blocks.getBlock(blockId, buffer.getVersion()));
blocks.put(new InChunkLocation(((pos & 0xF0 >>> 4) & 0xF), y, (pos & 0xF)), Blocks.getBlock(blockId, buffer.getVersion()));
}
return true;
}

View File

@ -27,6 +27,7 @@ import de.bixilon.minosoft.game.datatypes.scoreboard.ScoreboardObjective;
import de.bixilon.minosoft.game.datatypes.scoreboard.ScoreboardScore;
import de.bixilon.minosoft.game.datatypes.scoreboard.Team;
import de.bixilon.minosoft.game.datatypes.world.BlockPosition;
import de.bixilon.minosoft.game.datatypes.world.Chunk;
import de.bixilon.minosoft.logging.Log;
import de.bixilon.minosoft.nbt.tag.CompoundTag;
import de.bixilon.minosoft.nbt.tag.StringTag;
@ -293,7 +294,12 @@ public class PacketHandler {
}
public void handle(PacketMultiBlockChange pkg) {
connection.getPlayer().getWorld().getChunk(pkg.getLocation()).setBlocks(pkg.getBlocks());
Chunk chunk = connection.getPlayer().getWorld().getChunk(pkg.getLocation());
if (chunk == null) {
Log.warn(String.format("Server tried to change blocks in unloaded chunks! (location=%s)", pkg.getLocation()));
return;
}
chunk.setBlocks(pkg.getBlocks());
}
public void handle(PacketRespawn pkg) {

View File

@ -19,6 +19,7 @@ import de.bixilon.minosoft.game.datatypes.world.Chunk;
import de.bixilon.minosoft.game.datatypes.world.ChunkNibble;
import de.bixilon.minosoft.game.datatypes.world.ChunkNibbleLocation;
import de.bixilon.minosoft.game.datatypes.world.palette.Palette;
import de.bixilon.minosoft.logging.Log;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
@ -181,6 +182,16 @@ public class ChunkUtil {
blockId &= individualValueMask;
Block block = palette.byId(blockId);
if (block == null) {
String blockName;
if (buffer.getVersion().getVersionNumber() <= ProtocolVersion.VERSION_1_12_2.getVersionNumber()) {
blockName = String.format("%d:%d", blockId >> 4, blockId & 0xF);
} else {
blockName = String.valueOf(blockId);
}
Log.warn(String.format("Server sent unknown block: %s", blockName));
continue;
}
if (block.equals(Blocks.nullBlock)) {
continue;
}