diff --git a/src/main/java/net/minestom/server/instance/block/BlockImpl.java b/src/main/java/net/minestom/server/instance/block/BlockImpl.java index 82af30dc4..aa816a0fc 100644 --- a/src/main/java/net/minestom/server/instance/block/BlockImpl.java +++ b/src/main/java/net/minestom/server/instance/block/BlockImpl.java @@ -68,11 +68,9 @@ record BlockImpl(@NotNull Registry.BlockEntry registry, final String query = stateEntry.getKey(); final var stateOverride = (Map) stateEntry.getValue(); final var propertyMap = BlockUtils.parseProperties(query); - + assert keys.length == propertyMap.size(); int[] propertiesArray = new int[keys.length]; - int i = 0; for (var entry : propertyMap.entrySet()) { - final int entryIndex = i++; final int keyIndex = ArrayUtils.indexOf(keys, entry.getKey()); if (keyIndex == -1) { throw new IllegalArgumentException("Unknown property key: " + entry.getKey()); @@ -81,7 +79,7 @@ record BlockImpl(@NotNull Registry.BlockEntry registry, if (valueIndex == -1) { throw new IllegalArgumentException("Unknown property value: " + entry.getValue()); } - propertiesArray[entryIndex] = valueIndex; + propertiesArray[keyIndex] = valueIndex; } final BlockImpl block = new BlockImpl(Registry.block(namespace, object, stateOverride), diff --git a/src/main/java/net/minestom/server/utils/block/BlockUtils.java b/src/main/java/net/minestom/server/utils/block/BlockUtils.java index eebd62035..4e81929c8 100644 --- a/src/main/java/net/minestom/server/utils/block/BlockUtils.java +++ b/src/main/java/net/minestom/server/utils/block/BlockUtils.java @@ -1,11 +1,11 @@ package net.minestom.server.utils.block; +import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap; import net.minestom.server.coordinate.Point; import net.minestom.server.instance.Instance; import net.minestom.server.instance.block.Block; import net.minestom.server.instance.block.BlockHandler; import net.minestom.server.tag.Tag; -import net.minestom.server.utils.ArrayUtils; import net.minestom.server.utils.StringUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -88,7 +88,7 @@ public class BlockUtils { } index++; } - return ArrayUtils.toMap(keys, values, entryCount); + return new Object2ObjectArrayMap<>(keys, values, entryCount); } public static @Nullable NBTCompound extractClientNbt(@NotNull Block block) {