Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
6316873
Create code for refactoring tooltips, start on registry key refactor
eclipseisoffline Jul 12, 2025
c995d90
Continue work on holder support for JavaRegistryKey
eclipseisoffline Jul 12, 2025
5a09a40
Cleanup Holder usage
eclipseisoffline Jul 12, 2025
73dd0cd
Start working on writing tooltip providers
eclipseisoffline Jul 12, 2025
7a968a9
Fireworks, instrument tooltips, more stuff
eclipseisoffline Jul 12, 2025
56c6bb1
Container contents, enchantments, lore, jukebox playable tooltips
eclipseisoffline Jul 13, 2025
842c745
Map, ominous bottle, tropical fish pattern, pot decoration tooltips (…
eclipseisoffline Jul 13, 2025
cba0f15
Potion contents, suspicious stew, container loot, written book toolti…
eclipseisoffline Jul 13, 2025
1c72a92
Implement stuff in TooltipProviders, add charged projectiles tooltip
eclipseisoffline Jul 13, 2025
2cdea5a
Attribute modifiers tooltip provider, move advanced tooltips
eclipseisoffline Jul 13, 2025
8339fde
Start the switch to TooltipProviders
eclipseisoffline Jul 13, 2025
3da9c97
Make it build
eclipseisoffline Jul 13, 2025
c3eab7b
Small things
eclipseisoffline Jul 13, 2025
81fd683
Add dangerous NBT warning tooltip, load deprecated language key file
eclipseisoffline Jul 16, 2025
e270e03
Fix tests
eclipseisoffline Jul 16, 2025
d330b47
Add tooltips to items in the creative menu
eclipseisoffline Aug 1, 2025
0bb88d9
Move over item name computing from #5595
eclipseisoffline Aug 30, 2025
bba6413
Use proper item stack name computing in tooltips
eclipseisoffline Aug 30, 2025
ab9a922
Merge remote-tracking branch 'upstream/master' into tooltip-translation
eclipseisoffline Sep 17, 2025
7b25785
Switch to dangerous (block) entities loaded by util mappings
eclipseisoffline Sep 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/src/main/java/org/geysermc/geyser/GeyserImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ public void initialize() {
return;
}

MinecraftLocale.downloadDeprecations();
MinecraftLocale.ensureEN_US();
String locale = GeyserLocale.getDefaultLocale();
if (!"en_us".equals(locale)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void setPose(Pose pose) {
}

@Override
public JavaRegistryKey<BuiltInVariant> variantRegistry() {
public JavaRegistryKey<BuiltInVariant, ?> variantRegistry() {
return JavaRegistries.FROG_VARIANT;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ default void setVariantFromJavaId(int variant) {
* The registry in {@link org.geysermc.geyser.session.cache.registry.JavaRegistries} for this mob's variants. The registry can utilise the {@link VariantHolder#reader(Class, Enum)} method
* to create a reader to be used in {@link org.geysermc.geyser.session.cache.RegistryCache}.
*/
JavaRegistryKey<? extends BedrockVariant> variantRegistry();
JavaRegistryKey<? extends BedrockVariant, ?> variantRegistry();

/**
* Should set the variant for bedrock.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected Tag<Item> getFoodTag() {
}

@Override
public JavaRegistryKey<BuiltInVariant> variantRegistry() {
public JavaRegistryKey<BuiltInVariant, ?> variantRegistry() {
return JavaRegistries.CHICKEN_VARIANT;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected Tag<Item> getFoodTag() {
}

@Override
public JavaRegistryKey<BuiltInVariant> variantRegistry() {
public JavaRegistryKey<BuiltInVariant, ?> variantRegistry() {
return JavaRegistries.COW_VARIANT;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public boolean isClientControlled() {
}

@Override
public JavaRegistryKey<BuiltInVariant> variantRegistry() {
public JavaRegistryKey<BuiltInVariant, ?> variantRegistry() {
return JavaRegistries.PIG_VARIANT;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void setTameableFlags(ByteEntityMetadata entityMetadata) {
}

@Override
public JavaRegistryKey<BuiltInVariant> variantRegistry() {
public JavaRegistryKey<BuiltInVariant, ?> variantRegistry() {
return JavaRegistries.CAT_VARIANT;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void setWolfAngerTime(IntEntityMetadata entityMetadata) {
}

@Override
public JavaRegistryKey<BuiltInVariant> variantRegistry() {
public JavaRegistryKey<BuiltInVariant, ?> variantRegistry() {
return JavaRegistries.WOLF_VARIANT;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
Expand All @@ -45,6 +46,7 @@
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponentType;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponentTypes;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.WrittenBookContent;
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.EmptySlotDisplay;
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.ItemSlotDisplay;
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.ItemStackSlotDisplay;
Expand Down Expand Up @@ -173,6 +175,10 @@ public <T> T getComponentElseGet(@NonNull DataComponentType<T> type, Supplier<T>
return value == null ? supplier.get() : value;
}

public boolean hasComponent(@NonNull DataComponentType<?> type) {
return getComponent(type) != null;
}

public int getNetId() {
return isEmpty() ? 0 : netId;
}
Expand Down Expand Up @@ -248,6 +254,17 @@ public SlotDisplay asSlotDisplay() {
return new ItemStackSlotDisplay(this.getItemStack());
}

public Component getName() {
return getComponentElseGet(DataComponentTypes.CUSTOM_NAME, () -> {
WrittenBookContent book = getComponent(DataComponentTypes.WRITTEN_BOOK_CONTENT);
if (book != null) {
return Component.text(book.getTitle().getRaw());
}

return asItem().getName(this);
});
}

public int getMaxDamage() {
return getComponentElseGet(DataComponentTypes.MAX_DAMAGE, () -> 0);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2024 GeyserMC. http://geysermc.org
* Copyright (c) 2025 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -25,84 +25,36 @@

package org.geysermc.geyser.inventory.item;

import lombok.Getter;
import net.kyori.adventure.key.Key;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.util.MinecraftKey;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.cache.registry.JavaRegistries;
import org.geysermc.geyser.session.cache.registry.RegistryEntryContext;

import java.util.Locale;
public record BannerPattern(BedrockBannerPattern bedrockPattern, String translationKey) {

@Getter
public enum BannerPattern {
BASE("b"),
SQUARE_BOTTOM_LEFT("bl"),
SQUARE_BOTTOM_RIGHT("br"),
SQUARE_TOP_LEFT("tl"),
SQUARE_TOP_RIGHT("tr"),
STRIPE_BOTTOM("bs"),
STRIPE_TOP("ts"),
STRIPE_LEFT("ls"),
STRIPE_RIGHT("rs"),
STRIPE_CENTER("cs"),
STRIPE_MIDDLE("ms"),
STRIPE_DOWNRIGHT("drs"),
STRIPE_DOWNLEFT("dls"),
SMALL_STRIPES("ss"),
CROSS("cr"),
STRAIGHT_CROSS("sc"),
TRIANGLE_BOTTOM("bt"),
TRIANGLE_TOP("tt"),
TRIANGLES_BOTTOM("bts"),
TRIANGLES_TOP("tts"),
DIAGONAL_LEFT("ld"),
DIAGONAL_UP_RIGHT("rd"),
DIAGONAL_UP_LEFT("lud"),
DIAGONAL_RIGHT("rud"),
CIRCLE("mc"),
RHOMBUS("mr"),
HALF_VERTICAL("vh"),
HALF_HORIZONTAL("hh"),
HALF_VERTICAL_RIGHT("vhr"),
HALF_HORIZONTAL_BOTTOM("hhb"),
BORDER("bo"),
CURLY_BORDER("cbo"),
GRADIENT("gra"),
GRADIENT_UP("gru"),
BRICKS("bri"),
GLOBE("glb"),
CREEPER("cre"),
SKULL("sku"),
FLOWER("flo"),
MOJANG("moj"),
PIGLIN("pig"),
FLOW("flw"),
GUSTER("gus");

private static final BannerPattern[] VALUES = values();

private final Key javaIdentifier;
private final String bedrockIdentifier;

BannerPattern(String bedrockIdentifier) {
this.javaIdentifier = MinecraftKey.key(this.name().toLowerCase(Locale.ROOT));
this.bedrockIdentifier = bedrockIdentifier;
public static BannerPattern read(RegistryEntryContext context) {
String translationKey = context.data().getString("translation_key");
// getByJavaIdentifier defaults to BASE
return new BannerPattern(BedrockBannerPattern.getByJavaIdentifier(context.id()), translationKey);
}

public static BannerPattern getByJavaIdentifier(Key key) {
for (BannerPattern bannerPattern : VALUES) {
if (bannerPattern.javaIdentifier.equals(key)) {
return bannerPattern;
}
/**
* @return the corresponding registered {@link BannerPattern} for the given {@link BedrockBannerPattern}, or null if none exists
*/
public static BannerPattern fromBedrockPattern(GeyserSession session, @Nullable BedrockBannerPattern bedrockPattern) {
if (bedrockPattern == null) {
return null;
}
return BASE; // Default fallback
}

public static @Nullable BannerPattern getByBedrockIdentifier(String bedrockIdentifier) {
for (BannerPattern bannerPattern : VALUES) {
if (bannerPattern.bedrockIdentifier.equals(bedrockIdentifier)) {
return bannerPattern;
for (BannerPattern javaPattern : session.getRegistryCache().registry(JavaRegistries.BANNER_PATTERN).values()) {
if (javaPattern.bedrockPattern == bedrockPattern) {
return javaPattern;
}
}
return null;
}

public static int findNetworkId(GeyserSession session, BedrockBannerPattern bedrockPattern) {
return JavaRegistries.BANNER_PATTERN.networkId(session, fromBedrockPattern(session, bedrockPattern));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
* Copyright (c) 2019-2024 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/

package org.geysermc.geyser.inventory.item;

import lombok.Getter;
import net.kyori.adventure.key.Key;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.util.MinecraftKey;

import java.util.Locale;

@Getter
public enum BedrockBannerPattern {
BASE("b"),
SQUARE_BOTTOM_LEFT("bl"),
SQUARE_BOTTOM_RIGHT("br"),
SQUARE_TOP_LEFT("tl"),
SQUARE_TOP_RIGHT("tr"),
STRIPE_BOTTOM("bs"),
STRIPE_TOP("ts"),
STRIPE_LEFT("ls"),
STRIPE_RIGHT("rs"),
STRIPE_CENTER("cs"),
STRIPE_MIDDLE("ms"),
STRIPE_DOWNRIGHT("drs"),
STRIPE_DOWNLEFT("dls"),
SMALL_STRIPES("ss"),
CROSS("cr"),
STRAIGHT_CROSS("sc"),
TRIANGLE_BOTTOM("bt"),
TRIANGLE_TOP("tt"),
TRIANGLES_BOTTOM("bts"),
TRIANGLES_TOP("tts"),
DIAGONAL_LEFT("ld"),
DIAGONAL_UP_RIGHT("rd"),
DIAGONAL_UP_LEFT("lud"),
DIAGONAL_RIGHT("rud"),
CIRCLE("mc"),
RHOMBUS("mr"),
HALF_VERTICAL("vh"),
HALF_HORIZONTAL("hh"),
HALF_VERTICAL_RIGHT("vhr"),
HALF_HORIZONTAL_BOTTOM("hhb"),
BORDER("bo"),
CURLY_BORDER("cbo"),
GRADIENT("gra"),
GRADIENT_UP("gru"),
BRICKS("bri"),
GLOBE("glb"),
CREEPER("cre"),
SKULL("sku"),
FLOWER("flo"),
MOJANG("moj"),
PIGLIN("pig"),
FLOW("flw"),
GUSTER("gus");

private static final BedrockBannerPattern[] VALUES = values();

private final Key javaIdentifier;
private final String bedrockIdentifier;

BedrockBannerPattern(String bedrockIdentifier) {
this.javaIdentifier = MinecraftKey.key(this.name().toLowerCase(Locale.ROOT));
this.bedrockIdentifier = bedrockIdentifier;
}

public static BedrockBannerPattern getByJavaIdentifier(Key key) {
for (BedrockBannerPattern bannerPattern : VALUES) {
if (bannerPattern.javaIdentifier.equals(key)) {
return bannerPattern;
}
}
return BASE; // Default fallback
}

public static @Nullable BedrockBannerPattern getByBedrockIdentifier(String bedrockIdentifier) {
for (BedrockBannerPattern bannerPattern : VALUES) {
if (bannerPattern.bedrockIdentifier.equals(bedrockIdentifier)) {
return bannerPattern;
}
}
return null;
}
}
Loading