Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-03 14:50:19 +01:00
Some more micro optimizations
Dieser Commit ist enthalten in:
Ursprung
1ad952b581
Commit
95a1cbfa24
@ -36,11 +36,11 @@ import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.utils.FileUtils;
|
||||
import org.geysermc.connector.utils.LanguageUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PacketTranslatorRegistry<T> {
|
||||
private final Map<Class<? extends T>, PacketTranslator<? extends T>> translators = new HashMap<>();
|
||||
private final Map<Class<? extends T>, PacketTranslator<? extends T>> translators = new IdentityHashMap<>();
|
||||
|
||||
public static final PacketTranslatorRegistry<Packet> JAVA_TRANSLATOR = new PacketTranslatorRegistry<>();
|
||||
public static final PacketTranslatorRegistry<BedrockPacket> BEDROCK_TRANSLATOR = new PacketTranslatorRegistry<>();
|
||||
|
@ -44,7 +44,7 @@ import org.geysermc.connector.utils.Object2IntBiMap;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@ -54,7 +54,7 @@ public class CollisionRegistryLoader extends MultiResourceRegistryLoader<String,
|
||||
public Map<Integer, BlockCollision> load(Pair<String, String> input) {
|
||||
Int2ObjectMap<BlockCollision> collisions = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
Map<Class<?>, CollisionInfo> annotationMap = new HashMap<>();
|
||||
Map<Class<?>, CollisionInfo> annotationMap = new IdentityHashMap<>();
|
||||
for (Class<?> clazz : FileUtils.getGeneratedClassesForAnnotation(CollisionRemapper.class.getName())) {
|
||||
GeyserConnector.getInstance().getLogger().debug("Found annotated collision translator: " + clazz.getCanonicalName());
|
||||
|
||||
@ -75,7 +75,7 @@ public class CollisionRegistryLoader extends MultiResourceRegistryLoader<String,
|
||||
Object2IntBiMap<String> javaIdBlockMap = BlockRegistries.JAVA_IDENTIFIERS.get();
|
||||
|
||||
// Map of classes that don't change based on parameters that have already been created
|
||||
Map<Class<?>, BlockCollision> instantiatedCollision = new HashMap<>();
|
||||
Map<Class<?>, BlockCollision> instantiatedCollision = new IdentityHashMap<>();
|
||||
for (Object2IntMap.Entry<String> entry : javaIdBlockMap.object2IntEntrySet()) {
|
||||
BlockCollision newCollision = instantiateCollision(entry.getKey(), entry.getIntValue(), annotationMap, instantiatedCollision, collisionList);
|
||||
if (newCollision != null) {
|
||||
|
@ -67,7 +67,7 @@ public class RecipeRegistryPopulator {
|
||||
}
|
||||
|
||||
int currentRecipeId = LAST_RECIPE_NET_ID;
|
||||
for (Map.Entry<Integer, ItemMappings> version : Registries.ITEMS.get().entrySet()) {
|
||||
for (Int2ObjectMap.Entry<ItemMappings> version : Registries.ITEMS.get().int2ObjectEntrySet()) {
|
||||
// Make a bit of an assumption here that the last recipe net ID will be equivalent between all versions
|
||||
LAST_RECIPE_NET_ID = currentRecipeId;
|
||||
Map<RecipeType, List<CraftingData>> craftingData = new EnumMap<>(RecipeType.class);
|
||||
@ -113,8 +113,8 @@ public class RecipeRegistryPopulator {
|
||||
c -> new ObjectArrayList<>()).add(getCraftingDataFromJsonNode(entry, recipes, version.getValue()));
|
||||
}
|
||||
|
||||
Registries.CRAFTING_DATA.register(version.getKey(), craftingData);
|
||||
Registries.RECIPES.register(version.getKey(), recipes);
|
||||
Registries.CRAFTING_DATA.register(version.getIntKey(), craftingData);
|
||||
Registries.RECIPES.register(version.getIntKey(), recipes);
|
||||
}
|
||||
}
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren