mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Small cleanup, remove debug statement (whoops), and fix item ID lookup
This commit is contained in:
parent
d074f50f1b
commit
d692ad9476
3 changed files with 9 additions and 7 deletions
|
|
@ -315,11 +315,11 @@ public class AnvilInventoryUpdater extends InventoryUpdater {
|
||||||
Enchantment enchantment = entry.getKey();
|
Enchantment enchantment = entry.getKey();
|
||||||
|
|
||||||
HolderSet supportedItems = enchantment.supportedItems();
|
HolderSet supportedItems = enchantment.supportedItems();
|
||||||
int[] supportedItemIds = supportedItems.resolve(key -> session.getTagCache().get(ItemTag.ALL_ITEM_TAGS.get(key)));
|
int[] supportedItemIds = supportedItems.resolve(tagId -> session.getTagCache().get(ItemTag.ALL_ITEM_TAGS.get(tagId)));
|
||||||
boolean canApply = isEnchantedBook(input) || IntStream.of(supportedItemIds).anyMatch(id -> id == input.getJavaId());
|
boolean canApply = isEnchantedBook(input) || IntStream.of(supportedItemIds).anyMatch(id -> id == input.getJavaId());
|
||||||
|
|
||||||
HolderSet exclusiveSet = enchantment.exclusiveSet();
|
HolderSet exclusiveSet = enchantment.exclusiveSet();
|
||||||
int[] incompatibleEnchantments = exclusiveSet.resolve(key -> session.getTagCache().get(EnchantmentTag.ALL_ENCHANTMENT_TAGS.get(key)));
|
int[] incompatibleEnchantments = exclusiveSet.resolve(tagId -> session.getTagCache().get(EnchantmentTag.ALL_ENCHANTMENT_TAGS.get(tagId)));
|
||||||
for (int i : incompatibleEnchantments) {
|
for (int i : incompatibleEnchantments) {
|
||||||
Enchantment incompatible = session.getRegistryCache().enchantments().byId(i);
|
Enchantment incompatible = session.getRegistryCache().enchantments().byId(i);
|
||||||
if (combinedEnchantments.containsKey(incompatible)) {
|
if (combinedEnchantments.containsKey(incompatible)) {
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,8 @@ import net.kyori.adventure.key.Key;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.nbt.NbtMap;
|
import org.cloudburstmc.nbt.NbtMap;
|
||||||
import org.geysermc.geyser.inventory.item.BedrockEnchantment;
|
import org.geysermc.geyser.inventory.item.BedrockEnchantment;
|
||||||
|
import org.geysermc.geyser.item.type.Item;
|
||||||
|
import org.geysermc.geyser.registry.Registries;
|
||||||
import org.geysermc.geyser.translator.text.MessageTranslator;
|
import org.geysermc.geyser.translator.text.MessageTranslator;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.RegistryEntry;
|
import org.geysermc.mcprotocollib.protocol.data.game.RegistryEntry;
|
||||||
|
|
||||||
|
|
@ -56,7 +58,10 @@ public record Enchantment(String identifier,
|
||||||
NbtMap data = entry.getData();
|
NbtMap data = entry.getData();
|
||||||
Set<EnchantmentComponent> effects = readEnchantmentComponents(data.getCompound("effects"));
|
Set<EnchantmentComponent> effects = readEnchantmentComponents(data.getCompound("effects"));
|
||||||
|
|
||||||
HolderSet supportedItems = readHolderSet(data.get("supported_items"), keyIdMapping);
|
HolderSet supportedItems = readHolderSet(data.get("supported_items"), itemId -> {
|
||||||
|
Item item = Registries.JAVA_ITEM_IDENTIFIERS.get(itemId.asString());
|
||||||
|
return Registries.JAVA_ITEMS.get().indexOf(item);
|
||||||
|
});
|
||||||
|
|
||||||
int maxLevel = data.getInt("max_level");
|
int maxLevel = data.getInt("max_level");
|
||||||
int anvilCost = data.getInt("anvil_cost");
|
int anvilCost = data.getInt("anvil_cost");
|
||||||
|
|
|
||||||
|
|
@ -173,10 +173,7 @@ public final class RegistryCache {
|
||||||
entry = new RegistryEntry(entry.getId(), localRegistry.get(entry.getId()));
|
entry = new RegistryEntry(entry.getId(), localRegistry.get(entry.getId()));
|
||||||
}
|
}
|
||||||
// This is what Geyser wants to keep as a value for this registry.
|
// This is what Geyser wants to keep as a value for this registry.
|
||||||
T cacheEntry = reader.apply(registryCache.session, key -> entryIdMap.getOrDefault(key, 0), entry);
|
T cacheEntry = reader.apply(registryCache.session, entryId -> entryIdMap.getOrDefault(entryId, 0), entry);
|
||||||
if (cacheEntry instanceof Enchantment) {
|
|
||||||
System.out.println(cacheEntry);
|
|
||||||
}
|
|
||||||
builder.add(i, cacheEntry);
|
builder.add(i, cacheEntry);
|
||||||
}
|
}
|
||||||
localCache.reset(builder);
|
localCache.reset(builder);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue