mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Use Object2IntMap for key id map
This commit is contained in:
parent
ef772dcfdb
commit
7a2d0effbb
2 changed files with 5 additions and 2 deletions
|
|
@ -27,6 +27,8 @@ package org.geysermc.geyser.session.cache;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
@ -159,7 +161,7 @@ public final class RegistryCache {
|
||||||
|
|
||||||
// Store each of the entries resource location IDs and their respective network ID,
|
// Store each of the entries resource location IDs and their respective network ID,
|
||||||
// used for the key mapper that's currently only used by the Enchantment class
|
// used for the key mapper that's currently only used by the Enchantment class
|
||||||
Map<Key, Integer> entryIdMap = new HashMap<>();
|
Object2IntMap<Key> entryIdMap = new Object2IntOpenHashMap<>();
|
||||||
for (int i = 0; i < entries.size(); i++) {
|
for (int i = 0; i < entries.size(); i++) {
|
||||||
entryIdMap.put(entries.get(i).getId(), i);
|
entryIdMap.put(entries.get(i).getId(), i);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
package org.geysermc.geyser.session.cache.registry;
|
package org.geysermc.geyser.session.cache.registry;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import net.kyori.adventure.key.Key;
|
import net.kyori.adventure.key.Key;
|
||||||
import org.cloudburstmc.nbt.NbtMap;
|
import org.cloudburstmc.nbt.NbtMap;
|
||||||
|
|
@ -38,7 +39,7 @@ import org.geysermc.mcprotocollib.protocol.data.game.RegistryEntry;
|
||||||
* @param keyIdMap a map for each of the resource location's in the registry and their respective network IDs.
|
* @param keyIdMap a map for each of the resource location's in the registry and their respective network IDs.
|
||||||
* @param session the Geyser session.
|
* @param session the Geyser session.
|
||||||
*/
|
*/
|
||||||
public record RegistryEntryContext(RegistryEntry entry, Map<Key, Integer> keyIdMap, GeyserSession session) {
|
public record RegistryEntryContext(RegistryEntry entry, Object2IntMap<Key> keyIdMap, GeyserSession session) {
|
||||||
|
|
||||||
public int getNetworkId(Key registryKey) {
|
public int getNetworkId(Key registryKey) {
|
||||||
return keyIdMap.getOrDefault(registryKey, 0);
|
return keyIdMap.getOrDefault(registryKey, 0);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue