Skip to content

Commit

Permalink
修复CraftChunkSnapshot区块快照无法正确获取MOD方块ID
Browse files Browse the repository at this point in the history
  • Loading branch information
Luohuayu committed Oct 4, 2021
1 parent b83a23e commit 2ffea2f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/java/org/bukkit/craftbukkit/CraftChunk.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,17 @@ public ChunkSnapshot getChunkSnapshot(boolean includeMaxBlockY, boolean includeB

byte[] rawIds = new byte[4096];
NibbleArray data = new NibbleArray();
cs[i].getData().getDataForNBT(rawIds, data);
NibbleArray blockIdExtensionData = cs[i].getData().getDataForNBT(rawIds, data); // CatServer

byte[] dataValues = sectionBlockData[i] = data.getData();

// Copy base IDs
for (int j = 0; j < 4096; j++) {
blockids[j] = (short) (rawIds[j] & 0xFF);
// CatServer start
int extData = blockIdExtensionData == null ? 0 : blockIdExtensionData.get(j & 15, j >> 8 & 15, j >> 4 & 15);
int blockId = (extData << 12 | (rawIds[j] & 0xFF) << 4 | extData) >> 4;
blockids[j] = blockId > Short.MAX_VALUE ? 0 : (short)blockId; // Not support id > 32767
// CatServer end
}

sectionBlockIDs[i] = blockids;
Expand Down

0 comments on commit 2ffea2f

Please sign in to comment.