Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-26 16:12:46 +01:00
Fix key regression with pre-built registries
Dieser Commit ist enthalten in:
Ursprung
842e1b4d12
Commit
ce3083b9b8
@ -72,7 +72,7 @@ import java.util.function.ToIntFunction;
|
|||||||
@Accessors(fluent = true)
|
@Accessors(fluent = true)
|
||||||
@Getter
|
@Getter
|
||||||
public final class RegistryCache {
|
public final class RegistryCache {
|
||||||
private static final Map<Key, Map<String, NbtMap>> DEFAULTS;
|
private static final Map<Key, Map<Key, NbtMap>> DEFAULTS;
|
||||||
private static final Map<Key, BiConsumer<RegistryCache, List<RegistryEntry>>> REGISTRIES = new HashMap<>();
|
private static final Map<Key, BiConsumer<RegistryCache, List<RegistryEntry>>> REGISTRIES = new HashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@ -89,14 +89,14 @@ public final class RegistryCache {
|
|||||||
|
|
||||||
// Load from MCProtocolLib's classloader
|
// Load from MCProtocolLib's classloader
|
||||||
NbtMap tag = MinecraftProtocol.loadNetworkCodec();
|
NbtMap tag = MinecraftProtocol.loadNetworkCodec();
|
||||||
Map<Key, Map<String, NbtMap>> defaults = new HashMap<>();
|
Map<Key, Map<Key, NbtMap>> defaults = new HashMap<>();
|
||||||
// Don't create a keySet - no need to create the cached object in HashMap if we don't use it again
|
// Don't create a keySet - no need to create the cached object in HashMap if we don't use it again
|
||||||
REGISTRIES.forEach((key, $) -> {
|
REGISTRIES.forEach((key, $) -> {
|
||||||
List<NbtMap> rawValues = tag.getCompound(key.asString())
|
List<NbtMap> rawValues = tag.getCompound(key.asString())
|
||||||
.getList("value", NbtType.COMPOUND);
|
.getList("value", NbtType.COMPOUND);
|
||||||
Map<String, NbtMap> values = new HashMap<>();
|
Map<Key, NbtMap> values = new HashMap<>();
|
||||||
for (NbtMap value : rawValues) {
|
for (NbtMap value : rawValues) {
|
||||||
String name = value.getString("name");
|
Key name = MinecraftKey.key(value.getString("name"));
|
||||||
values.put(name, value.getCompound("element"));
|
values.put(name, value.getCompound("element"));
|
||||||
}
|
}
|
||||||
// Can make these maps immutable and as efficient as possible after initialization
|
// Can make these maps immutable and as efficient as possible after initialization
|
||||||
@ -152,7 +152,7 @@ public final class RegistryCache {
|
|||||||
private static <T> void register(String registry, Function<RegistryCache, JavaRegistry<T>> localCacheFunction, BiFunction<GeyserSession, RegistryEntry, T> reader) {
|
private static <T> void register(String registry, Function<RegistryCache, JavaRegistry<T>> localCacheFunction, BiFunction<GeyserSession, RegistryEntry, T> reader) {
|
||||||
Key key = MinecraftKey.key(registry);
|
Key key = MinecraftKey.key(registry);
|
||||||
REGISTRIES.put(key, (registryCache, entries) -> {
|
REGISTRIES.put(key, (registryCache, entries) -> {
|
||||||
Map<String, NbtMap> localRegistry = null;
|
Map<Key, NbtMap> localRegistry = null;
|
||||||
JavaRegistry<T> localCache = localCacheFunction.apply(registryCache);
|
JavaRegistry<T> localCache = localCacheFunction.apply(registryCache);
|
||||||
// Clear each local cache every time a new registry entry is given to us
|
// Clear each local cache every time a new registry entry is given to us
|
||||||
// (e.g. proxy server switches)
|
// (e.g. proxy server switches)
|
||||||
|
@ -39,7 +39,6 @@ public class JavaClientboundRecipesTranslator extends PacketTranslator<Clientbou
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translate(GeyserSession session, ClientboundRecipePacket packet) {
|
public void translate(GeyserSession session, ClientboundRecipePacket packet) {
|
||||||
System.out.println(packet);
|
|
||||||
UnlockedRecipesPacket recipesPacket = new UnlockedRecipesPacket();
|
UnlockedRecipesPacket recipesPacket = new UnlockedRecipesPacket();
|
||||||
switch (packet.getAction()) {
|
switch (packet.getAction()) {
|
||||||
case INIT -> {
|
case INIT -> {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren