3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-10-05 01:11:08 +02:00

debug stick changes

Dieser Commit ist enthalten in:
onebeastchris 2024-06-13 19:10:13 +02:00
Ursprung deb25d7147
Commit 9656f95233
4 geänderte Dateien mit 65 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -1204,7 +1204,7 @@ public final class Items {
public static final Item SHULKER_SHELL = register(new Item("shulker_shell", builder()));
public static final Item IRON_NUGGET = register(new Item("iron_nugget", builder()));
public static final Item KNOWLEDGE_BOOK = register(new Item("knowledge_book", builder().stackSize(1)));
public static final Item DEBUG_STICK = register(new Item("debug_stick", builder().stackSize(1)));
public static final Item DEBUG_STICK = register(new DebugStickItem("debug_stick", builder().stackSize(1)));
public static final Item MUSIC_DISC_13 = register(new Item("music_disc_13", builder().stackSize(1)));
public static final Item MUSIC_DISC_CAT = register(new Item("music_disc_cat", builder().stackSize(1)));
public static final Item MUSIC_DISC_BLOCKS = register(new Item("music_disc_blocks", builder().stackSize(1)));

Datei anzeigen

@ -0,0 +1,59 @@
/*
* Copyright (c) 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.item.type;
import org.cloudburstmc.nbt.NbtMap;
import org.cloudburstmc.nbt.NbtMapBuilder;
import org.cloudburstmc.nbt.NbtType;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.text.ChatColor;
import org.geysermc.geyser.text.MinecraftLocale;
import org.geysermc.geyser.translator.item.BedrockItemBuilder;
import java.util.ArrayList;
public class DebugStickItem extends Item {
public DebugStickItem(String javaIdentifier, Builder builder) {
super(javaIdentifier, builder);
}
@Override
public NbtMap build(GeyserSession session, BedrockItemBuilder builder) {
NbtMapBuilder nbt = builder.getOrCreateNbt();
// No enchantments -> no glint! Let's add it.
if (!nbt.containsKey("ench")) {
nbt.putList("ench", NbtType.COMPOUND, new ArrayList<>());
}
// Custom name
if (builder.getCustomName() == null) {
builder.setCustomName(ChatColor.DARK_PURPLE + MinecraftLocale.getLocaleString("item.minecraft.debug_stick", session.locale()));
}
return builder.build();
}
}

Datei anzeigen

@ -112,6 +112,10 @@ public class Item {
return builder;
}
public NbtMap build(GeyserSession session, BedrockItemBuilder builder) {
return builder.build();
}
public @NonNull GeyserItemStack translateToJava(@NonNull ItemData itemData, @NonNull ItemMapping mapping, @NonNull ItemMappings mappings) {
return GeyserItemStack.of(javaId, itemData.getCount());
}

Datei anzeigen

@ -163,7 +163,7 @@ public final class ItemTranslator {
ItemData.Builder builder = javaItem.translateToBedrock(count, components, bedrockItem, session.getItemMappings());
// Finalize the Bedrock NBT
builder.tag(nbtBuilder.build());
builder.tag(javaItem.build(session, nbtBuilder));
if (bedrockItem.isBlock()) {
CustomBlockData customBlockData = BlockRegistries.CUSTOM_BLOCK_ITEM_OVERRIDES.getOrDefault(
bedrockItem.getJavaItem().javaIdentifier(), null);