mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-23 06:50:26 +01:00
Goat horns
This commit is contained in:
parent
9217414c8c
commit
f47754be03
2 changed files with 5 additions and 28 deletions
|
@ -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.DataComponents;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.item.component.Instrument;
|
import org.geysermc.mcprotocollib.protocol.data.game.item.component.Instrument;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GoatHornItem extends Item {
|
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) {
|
public GoatHornItem(String javaIdentifier, Builder builder) {
|
||||||
super(javaIdentifier, builder);
|
super(javaIdentifier, builder);
|
||||||
}
|
}
|
||||||
|
@ -60,19 +47,8 @@ public class GoatHornItem extends Item {
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
Holder<Instrument> instrument = components.get(DataComponentType.INSTRUMENT);
|
Holder<Instrument> instrument = components.get(DataComponentType.INSTRUMENT);
|
||||||
// TODO registry
|
if (instrument != null && instrument.isId()) {
|
||||||
if (instrument != null) {
|
builder.damage(instrument.id());
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,8 @@ public final class ItemTranslator {
|
||||||
|
|
||||||
NbtMap nbt = data.getTag();
|
NbtMap nbt = data.getTag();
|
||||||
if (nbt != null && !nbt.isEmpty()) {
|
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);
|
javaItem.translateNbtToJava(nbt, components, bedrockItem);
|
||||||
if (!components.getDataComponents().isEmpty()) {
|
if (!components.getDataComponents().isEmpty()) {
|
||||||
itemStack.setComponents(components);
|
itemStack.setComponents(components);
|
||||||
|
@ -394,7 +395,7 @@ public final class ItemTranslator {
|
||||||
customName = components.get(DataComponentType.ITEM_NAME);
|
customName = components.get(DataComponentType.ITEM_NAME);
|
||||||
}
|
}
|
||||||
if (customName != null) {
|
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());
|
return MessageTranslator.convertMessage(customName, session.locale());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue