Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makes the server log when it finds an unknown BlockId:Meta combination #247

Merged
merged 2 commits into from
May 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Click the link above to see the future.
- [#246] Anvil checking the enchantment table property instead of the enchantment id
- [#246] Compatibility rules for unbreaking, fortune, mending, riptide, loyalty and channeling enchantments.

### Changed
- [#247] Invalid BlockId:Meta combinations now log an error when found. It logs only once.

## [1.2.0.1-PN] - 2020-05-08 ([Check the milestone](https://github.com/GameModsBR/PowerNukkit/milestone/8?closed=1))
Fixes several anvil issues.

Expand Down Expand Up @@ -220,3 +223,4 @@ Fixes several anvil issues.
[#240]: https://github.com/GameModsBR/PowerNukkit/issues/240
[#243]: https://github.com/GameModsBR/PowerNukkit/issues/243
[#246]: https://github.com/GameModsBR/PowerNukkit/issues/246
[#247]: https://github.com/GameModsBR/PowerNukkit/pull/247
11 changes: 5 additions & 6 deletions src/main/java/cn/nukkit/level/GlobalBlockPalette.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
import cn.nukkit.nbt.NBTIO;
import cn.nukkit.nbt.tag.CompoundTag;
import cn.nukkit.nbt.tag.ListTag;
import it.unimi.dsi.fastutil.ints.Int2IntMap;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.ints.*;

import java.io.BufferedInputStream;
import java.io.IOException;
Expand All @@ -24,6 +21,7 @@ public class GlobalBlockPalette {
private static final Map<String, Integer> stringToLegacyId = new HashMap<>();
private static final AtomicInteger runtimeIdAllocator = new AtomicInteger(0);
public static final byte[] BLOCK_PALETTE;
private static final Int2ObjectMap<IntSet> unknownRuntimeIds = new Int2ObjectOpenHashMap<>();

static {
legacyToRuntimeId.defaultReturnValue(-1);
Expand Down Expand Up @@ -105,9 +103,10 @@ public static int getOrCreateRuntimeId(int id, int meta) {
int legacyId = id << 6 | meta;
int runtimeId = legacyToRuntimeId.get(legacyId);
if (runtimeId == -1) {
//runtimeId = registerMapping(runtimeIdAllocator.incrementAndGet(), legacyId);
runtimeId = legacyToRuntimeId.get(248 << 6);
//throw new NoSuchElementException("Unmapped block registered id:" + id + " meta:" + meta);
if (unknownRuntimeIds.computeIfAbsent(id, k -> new IntOpenHashSet(5)).add(meta)) {
Server.getInstance().getLogger().error("Found an unknown BlockId:Meta combination: "+id+":"+meta+", replacing with an \"UPDATE!\" block.");
}
}
return runtimeId;
}
Expand Down