Skip to content

Commit

Permalink
Preserve old ids when mapping not found and remove -1 logic since tha…
Browse files Browse the repository at this point in the history
…t is only applicable for wildcards and causes the paste to fail.
  • Loading branch information
spacebuilder2020 committed Feb 19, 2025
1 parent 32ae870 commit 932db3d
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,12 @@ public Clipboard read(WorldData data) throws IOException {
BlockVector pt = new BlockVector(x, y, z);

if (!blockConversionMap.isEmpty()) {
blocks[index] = blockConversionMap.get(blocks[index]);
blocks[index] = blockConversionMap.getOrDefault(blocks[index], blocks[index]);
}

BaseBlock block = new BaseBlock(
Short.toUnsignedInt(blocks[index]),
blockData[index] < -1 || extraData != null
? Byte.toUnsignedInt(blockData[index]) + (extraData != null ? (extraData[index] << 8) : 0)
: blockData[index]);
Byte.toUnsignedInt(blockData[index]) + (extraData != null ? (extraData[index] << 8) : 0));

if (tileEntitiesMap.containsKey(pt)) {
BiPredicate<CompoundTag, String[]> isItem = (itemTag, idPtr) -> {
Expand Down Expand Up @@ -295,15 +293,15 @@ public CompoundTag apply(CompoundTag nbtData) {
id = nbtData.getShort(idPtr[0]);
}
HashMap<String, Tag> itemMap = new HashMap<>(nbtData.getValue());

short newId = itemConversionMap.getOrDefault(id, id);
if (id_data != null) {
log.log(Level.WARNING, "ID" + id);
log.log(Level.WARNING, "Convert" + itemConversionMap.get(id));
itemMap.put(
idPtr[0],
new IntTag(itemConversionMap.get(id) + (id_data & 0xFFFF0000)));
new IntTag(newId + (id_data & 0xFFFF0000)));
} else {
itemMap.put(idPtr[0], new ShortTag(itemConversionMap.get(id)));
itemMap.put(idPtr[0], new ShortTag(newId));
}

if (nbtData.containsKey("tag") && itemMap.get("tag") instanceof CompoundTag nbt) {
Expand Down

0 comments on commit 932db3d

Please sign in to comment.