Skip to content

Commit

Permalink
Goat horns
Browse files Browse the repository at this point in the history
  • Loading branch information
Camotoy committed Apr 27, 2024
1 parent 9217414 commit f47754b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 28 deletions.
28 changes: 2 additions & 26 deletions core/src/main/java/org/geysermc/geyser/item/type/GoatHornItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,7 @@
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);
}
Expand All @@ -60,19 +47,8 @@ public ItemData.Builder translateToBedrock(int count, DataComponents components,
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ public static ItemStack translateToJava(ItemData data, ItemMappings mappings) {

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);
Expand Down Expand Up @@ -394,7 +395,7 @@ public static String getCustomName(GeyserSession session, DataComponents compone
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());
}
}
Expand Down

0 comments on commit f47754b

Please sign in to comment.