Goat horns

This commit is contained in:
Camotoy 2024-04-27 15:49:19 -04:00
parent 9217414c8c
commit f47754be03
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F
2 changed files with 5 additions and 28 deletions

View file

@ -35,20 +35,7 @@ import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponen
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.Instrument;
import java.util.List;
public class GoatHornItem extends Item {
private static final List<String> INSTRUMENTS = List.of(
"ponder_goat_horn",
"sing_goat_horn",
"seek_goat_horn",
"feel_goat_horn",
"admire_goat_horn",
"call_goat_horn",
"yearn_goat_horn",
"dream_goat_horn" // Called "Resist" on Bedrock 1.19.0 due to https://bugs.mojang.com/browse/MCPE-155059
);
public GoatHornItem(String javaIdentifier, Builder builder) {
super(javaIdentifier, builder);
}
@ -60,19 +47,8 @@ public class GoatHornItem extends Item {
return builder;
}
Holder<Instrument> instrument = components.get(DataComponentType.INSTRUMENT);
// TODO registry
if (instrument != null) {
// Drop the Minecraft namespace if applicable
// if (instrument.startsWith("minecraft:")) {
// instrument = instrument.substring("minecraft:".length());
// }
//
// int damage = INSTRUMENTS.indexOf(instrument);
// if (damage == -1) {
// damage = 0;
// GeyserImpl.getInstance().getLogger().debug("Unknown goat horn instrument: " + instrumentTag.getValue());
// }
// builder.damage(damage);
if (instrument != null && instrument.isId()) {
builder.damage(instrument.id());
}
return builder;
}

View file

@ -93,7 +93,8 @@ public final class ItemTranslator {
NbtMap nbt = data.getTag();
if (nbt != null && !nbt.isEmpty()) {
DataComponents components = new DataComponents(new HashMap<>());
// translateToJava may have added components
DataComponents components = itemStack.getComponents() == null ? new DataComponents(new HashMap<>()) : itemStack.getComponents();
javaItem.translateNbtToJava(nbt, components, bedrockItem);
if (!components.getDataComponents().isEmpty()) {
itemStack.setComponents(components);
@ -394,7 +395,7 @@ public final class ItemTranslator {
customName = components.get(DataComponentType.ITEM_NAME);
}
if (customName != null) {
// Get the translated name and prefix it with a reset char TODO test
// Get the translated name and prefix it with a reset char
return MessageTranslator.convertMessage(customName, session.locale());
}
}