3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-20 06:50:09 +01:00

Initial, incomplete pass at Java 1.20.5

Dieser Commit ist enthalten in:
Camotoy 2024-04-19 19:21:44 -04:00
Ursprung 2471de100b
Commit 099e968bde
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
54 geänderte Dateien mit 285 neuen und 234 gelöschten Zeilen

Datei anzeigen

@ -26,7 +26,7 @@
package org.geysermc.geyser.entity.type; package org.geysermc.geyser.entity.type;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag; import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.Tag; import com.github.steveice10.opennbt.tag.builtin.Tag;

Datei anzeigen

@ -26,7 +26,7 @@
package org.geysermc.geyser.entity.type; package org.geysermc.geyser.entity.type;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import org.cloudburstmc.math.vector.Vector3f; import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.math.vector.Vector3i; import org.cloudburstmc.math.vector.Vector3i;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType; import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType;
@ -37,7 +37,7 @@ import org.cloudburstmc.protocol.bedrock.packet.EntityEventPacket;
import org.geysermc.geyser.entity.EntityDefinition; import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.level.block.BlockStateValues; import org.geysermc.geyser.level.block.BlockStateValues;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.inventory.item.ItemTranslator; import org.geysermc.geyser.translator.item.ItemTranslator;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;

Datei anzeigen

@ -26,7 +26,7 @@
package org.geysermc.geyser.entity.type; package org.geysermc.geyser.entity.type;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.object.Direction; import com.github.steveice10.mc.protocol.data.game.entity.object.Direction;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
@ -42,7 +42,7 @@ import org.cloudburstmc.protocol.bedrock.packet.UpdateBlockPacket;
import lombok.Getter; import lombok.Getter;
import org.geysermc.geyser.entity.EntityDefinition; import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.inventory.item.ItemTranslator; import org.geysermc.geyser.translator.item.ItemTranslator;
import org.geysermc.geyser.util.InteractionResult; import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InventoryUtils; import org.geysermc.geyser.util.InventoryUtils;

Datei anzeigen

@ -26,7 +26,7 @@
package org.geysermc.geyser.entity.type; package org.geysermc.geyser.entity.type;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import org.cloudburstmc.math.vector.Vector3f; import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag; import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition; import org.geysermc.geyser.entity.EntityDefinition;

Datei anzeigen

@ -26,7 +26,7 @@
package org.geysermc.geyser.entity.type; package org.geysermc.geyser.entity.type;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.opennbt.tag.builtin.StringTag; import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag; import com.github.steveice10.opennbt.tag.builtin.Tag;
import org.cloudburstmc.math.vector.Vector3f; import org.cloudburstmc.math.vector.Vector3f;

Datei anzeigen

@ -25,7 +25,8 @@
package org.geysermc.geyser.inventory; package org.geysermc.geyser.inventory;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentPatch;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Data; import lombok.Data;
@ -34,12 +35,13 @@ import lombok.Getter;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData; import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.item.Items; import org.geysermc.geyser.item.Items;
import org.geysermc.geyser.item.type.Item; import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.registry.Registries; import org.geysermc.geyser.registry.Registries;
import org.geysermc.geyser.registry.type.ItemMapping; import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.inventory.item.ItemTranslator; import org.geysermc.geyser.translator.item.ItemTranslator;
@Data @Data
public class GeyserItemStack { public class GeyserItemStack {
@ -47,26 +49,26 @@ public class GeyserItemStack {
private final int javaId; private final int javaId;
private int amount; private int amount;
private CompoundTag nbt; private DataComponentPatch components;
private int netId; private int netId;
@Getter(AccessLevel.NONE) @Getter(AccessLevel.NONE)
@EqualsAndHashCode.Exclude @EqualsAndHashCode.Exclude
private Item item; private Item item;
private GeyserItemStack(int javaId, int amount, CompoundTag nbt) { private GeyserItemStack(int javaId, int amount, DataComponentPatch components) {
this(javaId, amount, nbt, 1); this(javaId, amount, components, 1);
} }
private GeyserItemStack(int javaId, int amount, CompoundTag nbt, int netId) { private GeyserItemStack(int javaId, int amount, DataComponentPatch components, int netId) {
this.javaId = javaId; this.javaId = javaId;
this.amount = amount; this.amount = amount;
this.nbt = nbt; this.components = components;
this.netId = netId; this.netId = netId;
} }
public static @NonNull GeyserItemStack from(@Nullable ItemStack itemStack) { public static @NonNull GeyserItemStack from(@Nullable ItemStack itemStack) {
return itemStack == null ? EMPTY : new GeyserItemStack(itemStack.getId(), itemStack.getAmount(), itemStack.getNbt()); return itemStack == null ? EMPTY : new GeyserItemStack(itemStack.getId(), itemStack.getAmount(), itemStack.getDataComponentPatch());
} }
public int getJavaId() { public int getJavaId() {
@ -78,7 +80,12 @@ public class GeyserItemStack {
} }
public @Nullable CompoundTag getNbt() { public @Nullable CompoundTag getNbt() {
return isEmpty() ? null : nbt; Thread.dumpStack();
return null;
}
public @Nullable DataComponentPatch getComponents() {
return isEmpty() ? null : components;
} }
public int getNetId() { public int getNetId() {
@ -98,14 +105,14 @@ public class GeyserItemStack {
} }
public @Nullable ItemStack getItemStack(int newAmount) { public @Nullable ItemStack getItemStack(int newAmount) {
return isEmpty() ? null : new ItemStack(javaId, newAmount, nbt); return isEmpty() ? null : new ItemStack(javaId, newAmount, components);
} }
public ItemData getItemData(GeyserSession session) { public ItemData getItemData(GeyserSession session) {
if (isEmpty()) { if (isEmpty()) {
return ItemData.AIR; return ItemData.AIR;
} }
ItemData.Builder itemData = ItemTranslator.translateToBedrock(session, javaId, amount, nbt); ItemData.Builder itemData = ItemTranslator.translateToBedrock(session, javaId, amount, components);
itemData.netId(getNetId()); itemData.netId(getNetId());
itemData.usingNetId(true); itemData.usingNetId(true);
return itemData.build(); return itemData.build();
@ -131,6 +138,6 @@ public class GeyserItemStack {
} }
public GeyserItemStack copy(int newAmount) { public GeyserItemStack copy(int newAmount) {
return isEmpty() ? EMPTY : new GeyserItemStack(javaId, newAmount, nbt == null ? null : nbt.clone(), netId); return isEmpty() ? EMPTY : new GeyserItemStack(javaId, newAmount, components == null ? null : components.clone(), netId);
} }
} }

Datei anzeigen

@ -38,7 +38,7 @@ import org.cloudburstmc.protocol.bedrock.data.definitions.ItemDefinition;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.item.Items; import org.geysermc.geyser.item.Items;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.inventory.item.ItemTranslator; import org.geysermc.geyser.translator.item.ItemTranslator;
import org.jetbrains.annotations.Range; import org.jetbrains.annotations.Range;
import java.util.Arrays; import java.util.Arrays;

Datei anzeigen

@ -25,7 +25,7 @@
package org.geysermc.geyser.inventory.click; package org.geysermc.geyser.inventory.click;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.mc.protocol.data.game.inventory.ContainerActionType; import com.github.steveice10.mc.protocol.data.game.inventory.ContainerActionType;
import com.github.steveice10.mc.protocol.data.game.inventory.ContainerType; import com.github.steveice10.mc.protocol.data.game.inventory.ContainerType;
import com.github.steveice10.mc.protocol.data.game.inventory.MoveToHotbarAction; import com.github.steveice10.mc.protocol.data.game.inventory.MoveToHotbarAction;

Datei anzeigen

@ -25,7 +25,7 @@
package org.geysermc.geyser.inventory.recipe; package org.geysermc.geyser.inventory.recipe;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient; import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient;
import com.github.steveice10.mc.protocol.data.game.recipe.data.ShapedRecipeData; import com.github.steveice10.mc.protocol.data.game.recipe.data.ShapedRecipeData;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;

Datei anzeigen

@ -25,7 +25,7 @@
package org.geysermc.geyser.inventory.recipe; package org.geysermc.geyser.inventory.recipe;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient; import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient;
import com.github.steveice10.mc.protocol.data.game.recipe.data.ShapelessRecipeData; import com.github.steveice10.mc.protocol.data.game.recipe.data.ShapelessRecipeData;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;

Datei anzeigen

@ -25,7 +25,7 @@
package org.geysermc.geyser.inventory.recipe; package org.geysermc.geyser.inventory.recipe;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
/** /**

Datei anzeigen

@ -25,9 +25,11 @@
package org.geysermc.geyser.item.type; package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentPatch;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag; import com.github.steveice10.opennbt.tag.builtin.StringTag;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.nbt.NbtMapBuilder;
import org.geysermc.geyser.item.ArmorMaterial; import org.geysermc.geyser.item.ArmorMaterial;
import org.geysermc.geyser.registry.type.ItemMapping; import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
@ -41,8 +43,8 @@ public class ArmorItem extends Item {
} }
@Override @Override
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) { public void translateComponentsToBedrock(@NonNull GeyserSession session, @NonNull DataComponentPatch components, @NonNull NbtMapBuilder builder) {
super.translateNbtToBedrock(session, tag); super.translateComponentsToBedrock(session, components, builder);
if (tag.get("Trim") instanceof CompoundTag trim) { if (tag.get("Trim") instanceof CompoundTag trim) {
StringTag material = trim.remove("material"); StringTag material = trim.remove("material");

Datei anzeigen

@ -25,7 +25,9 @@
package org.geysermc.geyser.item.type; package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentType;
import com.github.steveice10.mc.protocol.data.game.item.component.PotionContents;
import com.github.steveice10.opennbt.tag.builtin.StringTag; import com.github.steveice10.opennbt.tag.builtin.StringTag;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData; import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
@ -44,9 +46,9 @@ public class ArrowItem extends Item {
TippedArrowPotion tippedArrowPotion = TippedArrowPotion.getByBedrockId(itemData.getDamage()); TippedArrowPotion tippedArrowPotion = TippedArrowPotion.getByBedrockId(itemData.getDamage());
ItemStack itemStack = super.translateToJava(itemData, mapping, mappings); ItemStack itemStack = super.translateToJava(itemData, mapping, mappings);
if (tippedArrowPotion != null) { if (tippedArrowPotion != null) {
itemStack = Items.TIPPED_ARROW.newItemStack(itemStack.getAmount(), itemStack.getNbt()); itemStack = Items.TIPPED_ARROW.newItemStack(itemStack.getAmount(), itemStack.getDataComponentPatch());
StringTag potionTag = new StringTag("Potion", tippedArrowPotion.getJavaIdentifier()); StringTag potionTag = new StringTag("Potion", tippedArrowPotion.getJavaIdentifier());
itemStack.getNbt().put(potionTag); itemStack.getDataComponentPatch().put(DataComponentType.POTION_CONTENTS, new PotionContents());
} }
return itemStack; return itemStack;
} }

Datei anzeigen

@ -25,10 +25,11 @@
package org.geysermc.geyser.item.type; package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentPatch;
import com.github.steveice10.opennbt.tag.builtin.ByteTag; import com.github.steveice10.opennbt.tag.builtin.ByteTag;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag; import com.github.steveice10.opennbt.tag.builtin.StringTag;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.nbt.NbtMapBuilder;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.text.MinecraftLocale; import org.geysermc.geyser.text.MinecraftLocale;
@ -38,8 +39,8 @@ public class AxolotlBucketItem extends Item {
} }
@Override @Override
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) { public void translateComponentsToBedrock(@NonNull GeyserSession session, @NonNull DataComponentPatch components, @NonNull NbtMapBuilder builder) {
super.translateNbtToBedrock(session, tag); super.translateComponentsToBedrock(session, components, builder);
// Bedrock Edition displays the properties of the axolotl. Java does not. // Bedrock Edition displays the properties of the axolotl. Java does not.
// To work around this, set the custom name to the Axolotl translation and it's displayed correctly // To work around this, set the custom name to the Axolotl translation and it's displayed correctly

Datei anzeigen

@ -25,6 +25,7 @@
package org.geysermc.geyser.item.type; package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentPatch;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag; import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag; import com.github.steveice10.opennbt.tag.builtin.ListTag;
@ -32,6 +33,7 @@ import com.github.steveice10.opennbt.tag.builtin.Tag;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.nbt.NbtList; import org.cloudburstmc.nbt.NbtList;
import org.cloudburstmc.nbt.NbtMap; import org.cloudburstmc.nbt.NbtMap;
import org.cloudburstmc.nbt.NbtMapBuilder;
import org.cloudburstmc.nbt.NbtType; import org.cloudburstmc.nbt.NbtType;
import org.geysermc.geyser.registry.type.ItemMapping; import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
@ -120,8 +122,8 @@ public class BannerItem extends BlockItem {
} }
@Override @Override
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) { public void translateComponentsToBedrock(@NonNull GeyserSession session, @NonNull DataComponentPatch components, @NonNull NbtMapBuilder builder) {
super.translateNbtToBedrock(session, tag); super.translateComponentsToBedrock(session, components, builder);
CompoundTag blockEntityTag = tag.remove("BlockEntityTag"); CompoundTag blockEntityTag = tag.remove("BlockEntityTag");
if (blockEntityTag != null && blockEntityTag.get("Patterns") instanceof ListTag patterns) { if (blockEntityTag != null && blockEntityTag.get("Patterns") instanceof ListTag patterns) {

Datei anzeigen

@ -25,8 +25,9 @@
package org.geysermc.geyser.item.type; package org.geysermc.geyser.item.type;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentPatch;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.nbt.NbtMapBuilder;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
public class ChestItem extends BlockItem { public class ChestItem extends BlockItem {
@ -36,8 +37,8 @@ public class ChestItem extends BlockItem {
} }
@Override @Override
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) { public void translateComponentsToBedrock(@NonNull GeyserSession session, @NonNull DataComponentPatch components, @NonNull NbtMapBuilder builder) {
super.translateNbtToBedrock(session, tag); super.translateComponentsToBedrock(session, components, builder);
// Strip the BlockEntityTag from the chests contents // Strip the BlockEntityTag from the chests contents
// sent to the client. The client does not parse this // sent to the client. The client does not parse this

Datei anzeigen

@ -25,12 +25,14 @@
package org.geysermc.geyser.item.type; package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentPatch;
import com.github.steveice10.opennbt.tag.builtin.ByteTag; import com.github.steveice10.opennbt.tag.builtin.ByteTag;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag; import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.Tag; import com.github.steveice10.opennbt.tag.builtin.Tag;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.nbt.NbtMapBuilder;
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData; import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
import org.geysermc.geyser.registry.type.ItemMapping; import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.registry.type.ItemMappings; import org.geysermc.geyser.registry.type.ItemMappings;
@ -58,8 +60,8 @@ public class CompassItem extends Item {
} }
@Override @Override
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) { public void translateComponentsToBedrock(@NonNull GeyserSession session, @NonNull DataComponentPatch components, @NonNull NbtMapBuilder builder) {
super.translateNbtToBedrock(session, tag); super.translateComponentsToBedrock(session, components, builder);
Tag lodestoneTag = tag.get("LodestoneTracked"); Tag lodestoneTag = tag.get("LodestoneTracked");
if (lodestoneTag instanceof ByteTag) { if (lodestoneTag instanceof ByteTag) {

Datei anzeigen

@ -25,14 +25,16 @@
package org.geysermc.geyser.item.type; package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentPatch;
import com.github.steveice10.opennbt.tag.builtin.*; import com.github.steveice10.opennbt.tag.builtin.*;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.nbt.NbtMapBuilder;
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData; import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
import org.geysermc.geyser.registry.type.ItemMapping; import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.inventory.item.ItemTranslator; import org.geysermc.geyser.translator.item.ItemTranslator;
public class CrossbowItem extends Item { public class CrossbowItem extends Item {
public CrossbowItem(String javaIdentifier, Builder builder) { public CrossbowItem(String javaIdentifier, Builder builder) {
@ -40,8 +42,8 @@ public class CrossbowItem extends Item {
} }
@Override @Override
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) { public void translateComponentsToBedrock(@NonNull GeyserSession session, @NonNull DataComponentPatch components, @NonNull NbtMapBuilder builder) {
super.translateNbtToBedrock(session, tag); super.translateComponentsToBedrock(session, components, builder);
ListTag chargedProjectiles = tag.get("ChargedProjectiles"); ListTag chargedProjectiles = tag.get("ChargedProjectiles");
if (chargedProjectiles != null) { if (chargedProjectiles != null) {

Datei anzeigen

@ -25,9 +25,11 @@
package org.geysermc.geyser.item.type; package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentPatch;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag; import com.github.steveice10.opennbt.tag.builtin.ListTag;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.nbt.NbtMapBuilder;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
public class DecoratedPotItem extends BlockItem { public class DecoratedPotItem extends BlockItem {
@ -37,8 +39,8 @@ public class DecoratedPotItem extends BlockItem {
} }
@Override @Override
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) { public void translateComponentsToBedrock(@NonNull GeyserSession session, @NonNull DataComponentPatch components, @NonNull NbtMapBuilder builder) {
super.translateNbtToBedrock(session, tag); super.translateComponentsToBedrock(session, components, builder);
if (tag.remove("BlockEntityTag") instanceof CompoundTag blockEntityTag) { if (tag.remove("BlockEntityTag") instanceof CompoundTag blockEntityTag) {
if (blockEntityTag.remove("sherds") instanceof ListTag sherds) { if (blockEntityTag.remove("sherds") instanceof ListTag sherds) {

Datei anzeigen

@ -25,8 +25,10 @@
package org.geysermc.geyser.item.type; package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentPatch;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.nbt.NbtMapBuilder;
import org.geysermc.geyser.item.ArmorMaterial; import org.geysermc.geyser.item.ArmorMaterial;
import org.geysermc.geyser.item.DyeableLeatherItem; import org.geysermc.geyser.item.DyeableLeatherItem;
import org.geysermc.geyser.registry.type.ItemMapping; import org.geysermc.geyser.registry.type.ItemMapping;
@ -38,8 +40,8 @@ public class DyeableArmorItem extends ArmorItem implements DyeableLeatherItem {
} }
@Override @Override
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) { public void translateComponentsToBedrock(@NonNull GeyserSession session, @NonNull DataComponentPatch components, @NonNull NbtMapBuilder builder) {
super.translateNbtToBedrock(session, tag); super.translateComponentsToBedrock(session, components, builder);
DyeableLeatherItem.translateNbtToBedrock(tag); DyeableLeatherItem.translateNbtToBedrock(tag);
} }

Datei anzeigen

@ -25,8 +25,10 @@
package org.geysermc.geyser.item.type; package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentPatch;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.nbt.NbtMapBuilder;
import org.geysermc.geyser.item.DyeableLeatherItem; import org.geysermc.geyser.item.DyeableLeatherItem;
import org.geysermc.geyser.registry.type.ItemMapping; import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
@ -37,8 +39,8 @@ public class DyeableHorseArmorItem extends Item implements DyeableLeatherItem {
} }
@Override @Override
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) { public void translateComponentsToBedrock(@NonNull GeyserSession session, @NonNull DataComponentPatch components, @NonNull NbtMapBuilder builder) {
super.translateNbtToBedrock(session, tag); super.translateComponentsToBedrock(session, components, builder);
DyeableLeatherItem.translateNbtToBedrock(tag); DyeableLeatherItem.translateNbtToBedrock(tag);
} }

Datei anzeigen

@ -25,10 +25,12 @@
package org.geysermc.geyser.item.type; package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentPatch;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag; import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.Tag; import com.github.steveice10.opennbt.tag.builtin.Tag;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.nbt.NbtMapBuilder;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import java.util.ArrayList; import java.util.ArrayList;
@ -40,8 +42,8 @@ public class EnchantedBookItem extends Item {
} }
@Override @Override
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) { public void translateComponentsToBedrock(@NonNull GeyserSession session, @NonNull DataComponentPatch components, @NonNull NbtMapBuilder builder) {
super.translateNbtToBedrock(session, tag); super.translateComponentsToBedrock(session, components, builder);
List<Tag> newTags = new ArrayList<>(); List<Tag> newTags = new ArrayList<>();
Tag enchantmentTag = tag.remove("StoredEnchantments"); Tag enchantmentTag = tag.remove("StoredEnchantments");

Datei anzeigen

@ -25,7 +25,7 @@
package org.geysermc.geyser.item.type; package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.Tag; import com.github.steveice10.opennbt.tag.builtin.Tag;
import org.cloudburstmc.nbt.NbtMap; import org.cloudburstmc.nbt.NbtMap;

Datei anzeigen

@ -25,8 +25,10 @@
package org.geysermc.geyser.item.type; package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentPatch;
import com.github.steveice10.opennbt.tag.builtin.*; import com.github.steveice10.opennbt.tag.builtin.*;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.nbt.NbtMapBuilder;
import org.geysermc.geyser.level.FireworkColor; import org.geysermc.geyser.level.FireworkColor;
import org.geysermc.geyser.registry.type.ItemMapping; import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
@ -38,8 +40,8 @@ public class FireworkRocketItem extends Item {
} }
@Override @Override
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) { public void translateComponentsToBedrock(@NonNull GeyserSession session, @NonNull DataComponentPatch components, @NonNull NbtMapBuilder builder) {
super.translateNbtToBedrock(session, tag); super.translateComponentsToBedrock(session, components, builder);
CompoundTag fireworks = tag.get("Fireworks"); CompoundTag fireworks = tag.get("Fireworks");
if (fireworks == null) { if (fireworks == null) {

Datei anzeigen

@ -25,11 +25,13 @@
package org.geysermc.geyser.item.type; package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentPatch;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.IntArrayTag; import com.github.steveice10.opennbt.tag.builtin.IntArrayTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag; import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.Tag; import com.github.steveice10.opennbt.tag.builtin.Tag;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.nbt.NbtMapBuilder;
import org.geysermc.geyser.registry.type.ItemMapping; import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
@ -39,8 +41,8 @@ public class FireworkStarItem extends Item {
} }
@Override @Override
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) { public void translateComponentsToBedrock(@NonNull GeyserSession session, @NonNull DataComponentPatch components, @NonNull NbtMapBuilder builder) {
super.translateNbtToBedrock(session, tag); super.translateComponentsToBedrock(session, components, builder);
Tag explosion = tag.remove("Explosion"); Tag explosion = tag.remove("Explosion");
if (explosion instanceof CompoundTag) { if (explosion instanceof CompoundTag) {

Datei anzeigen

@ -25,10 +25,11 @@
package org.geysermc.geyser.item.type; package org.geysermc.geyser.item.type;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentPatch;
import com.github.steveice10.opennbt.tag.builtin.IntTag; import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.Tag; import com.github.steveice10.opennbt.tag.builtin.Tag;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.nbt.NbtMapBuilder;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
public class FishingRodItem extends Item { public class FishingRodItem extends Item {
@ -37,8 +38,8 @@ public class FishingRodItem extends Item {
} }
@Override @Override
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) { public void translateComponentsToBedrock(@NonNull GeyserSession session, @NonNull DataComponentPatch components, @NonNull NbtMapBuilder builder) {
super.translateNbtToBedrock(session, tag); super.translateComponentsToBedrock(session, components, builder);
// Fix damage inconsistency // Fix damage inconsistency
Tag damage = tag.get("Damage"); Tag damage = tag.get("Damage");

Datei anzeigen

@ -25,7 +25,7 @@
package org.geysermc.geyser.item.type; package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.opennbt.tag.builtin.StringTag; import com.github.steveice10.opennbt.tag.builtin.StringTag;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData; import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;

Datei anzeigen

@ -26,10 +26,18 @@
package org.geysermc.geyser.item.type; package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.Identifier; import com.github.steveice10.mc.protocol.data.game.Identifier;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentPatch;
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentType;
import com.github.steveice10.mc.protocol.data.game.item.component.ItemEnchantments;
import com.github.steveice10.opennbt.tag.builtin.*; import com.github.steveice10.opennbt.tag.builtin.*;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.nbt.NbtList;
import org.cloudburstmc.nbt.NbtMap;
import org.cloudburstmc.nbt.NbtMapBuilder;
import org.cloudburstmc.nbt.NbtType;
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData; import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.inventory.item.Enchantment; import org.geysermc.geyser.inventory.item.Enchantment;
@ -38,7 +46,7 @@ import org.geysermc.geyser.registry.type.ItemMappings;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.text.ChatColor; import org.geysermc.geyser.text.ChatColor;
import org.geysermc.geyser.text.MinecraftLocale; import org.geysermc.geyser.text.MinecraftLocale;
import org.geysermc.geyser.translator.inventory.item.ItemTranslator; import org.geysermc.geyser.translator.item.ItemTranslator;
import org.geysermc.geyser.translator.text.MessageTranslator; import org.geysermc.geyser.translator.text.MessageTranslator;
import org.geysermc.geyser.util.InventoryUtils; import org.geysermc.geyser.util.InventoryUtils;
@ -107,7 +115,7 @@ public class Item {
public @NonNull ItemStack translateToJava(@NonNull ItemData itemData, @NonNull ItemMapping mapping, @NonNull ItemMappings mappings) { public @NonNull ItemStack translateToJava(@NonNull ItemData itemData, @NonNull ItemMapping mapping, @NonNull ItemMappings mappings) {
if (itemData.getTag() == null) { if (itemData.getTag() == null) {
return new ItemStack(javaId, itemData.getCount(), new CompoundTag("")); return new ItemStack(javaId, itemData.getCount(), null);
} }
return new ItemStack(javaId, itemData.getCount(), ItemTranslator.translateToJavaNBT("", itemData.getTag())); return new ItemStack(javaId, itemData.getCount(), ItemTranslator.translateToJavaNBT("", itemData.getTag()));
} }
@ -117,22 +125,31 @@ public class Item {
} }
/** /**
* Takes NBT from Java Edition and converts any value that Bedrock parses differently. * Takes components from Java Edition and map them into Bedrock.
*/ */
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) { public void translateComponentsToBedrock(@NonNull GeyserSession session, @NonNull DataComponentPatch components, @NonNull NbtMapBuilder builder) {
if (tag.get("display") instanceof CompoundTag displayTag) { // // Basing off of ItemStack#getHoverName as of 1.20.5. VERIFY??
if (displayTag.get("Lore") instanceof ListTag listTag) { // Component customName = components.get(DataComponentType.CUSTOM_NAME);
List<Tag> lore = new ArrayList<>(); // if (customName == null) {
for (Tag subTag : listTag.getValue()) { // customName = components.get(DataComponentType.ITEM_NAME);
if (!(subTag instanceof StringTag)) continue; // }
lore.add(new StringTag("", MessageTranslator.convertMessageLenient(((StringTag) subTag).getValue(), session.locale()))); // if (customName != null) {
} //
displayTag.put(new ListTag("Lore", lore)); // }
List<Component> loreComponents = components.get(DataComponentType.LORE);
if (loreComponents != null) {
List<String> lore = new ArrayList<>();
for (Component loreComponent : loreComponents) {
lore.add(MessageTranslator.convertMessage(loreComponent, session.locale()));
} }
builder.putList("Lore", NbtType.STRING, lore);
} }
List<Tag> newTags = new ArrayList<>(); List<Tag> newTags = new ArrayList<>();
Tag enchantmentTag = tag.remove("Enchantments"); ItemEnchantments enchantments = components.get(DataComponentType.ENCHANTMENTS);
if (enchantments != null) {
}
if (enchantmentTag instanceof ListTag listTag) { if (enchantmentTag instanceof ListTag listTag) {
for (Tag subTag : listTag.getValue()) { for (Tag subTag : listTag.getValue()) {
if (!(subTag instanceof CompoundTag)) continue; if (!(subTag instanceof CompoundTag)) continue;
@ -211,10 +228,7 @@ public class Item {
} }
} }
protected final @Nullable CompoundTag remapEnchantment(GeyserSession session, CompoundTag tag, CompoundTag rootTag) { protected final @Nullable NbtMap remapEnchantment(GeyserSession session, ItemEnchantments, NbtMapBuilder rootBuilder) {
Tag javaEnchId = tag.get("id");
if (!(javaEnchId instanceof StringTag))
return null;
Enchantment enchantment = Enchantment.getByJavaIdentifier(((StringTag) javaEnchId).getValue()); Enchantment enchantment = Enchantment.getByJavaIdentifier(((StringTag) javaEnchId).getValue());
if (enchantment == null) { if (enchantment == null) {
@ -231,11 +245,10 @@ public class Item {
Tag javaEnchLvl = tag.get("lvl"); Tag javaEnchLvl = tag.get("lvl");
CompoundTag bedrockTag = new CompoundTag(""); NbtMapBuilder builder = NbtMap.builder();
bedrockTag.put(new ShortTag("id", (short) enchantment.ordinal())); builder.putShort("id", (short) enchantment.ordinal());
// If the tag cannot parse, Java Edition 1.18.2 sets to 0 builder.putShort("lvl", );
bedrockTag.put(new ShortTag("lvl", javaEnchLvl != null && javaEnchLvl.getValue() instanceof Number lvl ? lvl.shortValue() : (short) 0)); return builder.build();
return bedrockTag;
} }
private void addSweeping(GeyserSession session, CompoundTag itemTag, int level) { private void addSweeping(GeyserSession session, CompoundTag itemTag, int level) {
@ -258,8 +271,8 @@ public class Item {
/* Translation methods end */ /* Translation methods end */
public ItemStack newItemStack(int count, CompoundTag tag) { public ItemStack newItemStack(int count, DataComponentPatch components) {
return new ItemStack(this.javaId, count, tag); return new ItemStack(this.javaId, count, components);
} }
public void setJavaId(int javaId) { // TODO like this? public void setJavaId(int javaId) { // TODO like this?

Datei anzeigen

@ -25,8 +25,10 @@
package org.geysermc.geyser.item.type; package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentPatch;
import com.github.steveice10.opennbt.tag.builtin.*; import com.github.steveice10.opennbt.tag.builtin.*;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.nbt.NbtMapBuilder;
import org.geysermc.geyser.registry.type.ItemMapping; import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
@ -36,8 +38,8 @@ public class MapItem extends Item {
} }
@Override @Override
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) { public void translateComponentsToBedrock(@NonNull GeyserSession session, @NonNull DataComponentPatch components, @NonNull NbtMapBuilder builder) {
super.translateNbtToBedrock(session, tag); super.translateComponentsToBedrock(session, components, builder);
Tag mapId = tag.remove("map"); Tag mapId = tag.remove("map");
if (mapId == null || !(mapId.getValue() instanceof Number number)) return; if (mapId == null || !(mapId.getValue() instanceof Number number)) return;

Datei anzeigen

@ -25,10 +25,12 @@
package org.geysermc.geyser.item.type; package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentPatch;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag; import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag; import com.github.steveice10.opennbt.tag.builtin.Tag;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.nbt.NbtMapBuilder;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.text.ChatColor; import org.geysermc.geyser.text.ChatColor;
import org.geysermc.geyser.text.MinecraftLocale; import org.geysermc.geyser.text.MinecraftLocale;
@ -40,8 +42,8 @@ public class PlayerHeadItem extends Item {
} }
@Override @Override
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) { public void translateComponentsToBedrock(@NonNull GeyserSession session, @NonNull DataComponentPatch components, @NonNull NbtMapBuilder builder) {
super.translateNbtToBedrock(session, tag); super.translateComponentsToBedrock(session, components, builder);
CompoundTag displayTag; CompoundTag displayTag;
if (tag.get("display") instanceof CompoundTag existingDisplayTag) { if (tag.get("display") instanceof CompoundTag existingDisplayTag) {

Datei anzeigen

@ -25,7 +25,9 @@
package org.geysermc.geyser.item.type; package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentType;
import com.github.steveice10.mc.protocol.data.game.item.component.PotionContents;
import com.github.steveice10.opennbt.tag.builtin.StringTag; import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag; import com.github.steveice10.opennbt.tag.builtin.Tag;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
@ -35,8 +37,8 @@ import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.inventory.item.Potion; import org.geysermc.geyser.inventory.item.Potion;
import org.geysermc.geyser.registry.type.ItemMapping; import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.registry.type.ItemMappings; import org.geysermc.geyser.registry.type.ItemMappings;
import org.geysermc.geyser.translator.inventory.item.CustomItemTranslator; import org.geysermc.geyser.translator.item.CustomItemTranslator;
import org.geysermc.geyser.translator.inventory.item.ItemTranslator; import org.geysermc.geyser.translator.item.ItemTranslator;
public class PotionItem extends Item { public class PotionItem extends Item {
public PotionItem(String javaIdentifier, Builder builder) { public PotionItem(String javaIdentifier, Builder builder) {
@ -45,10 +47,10 @@ public class PotionItem extends Item {
@Override @Override
public ItemData.Builder translateToBedrock(ItemStack itemStack, ItemMapping mapping, ItemMappings mappings) { public ItemData.Builder translateToBedrock(ItemStack itemStack, ItemMapping mapping, ItemMappings mappings) {
if (itemStack.getNbt() == null) return super.translateToBedrock(itemStack, mapping, mappings); if (itemStack.getDataComponentPatch() == null) return super.translateToBedrock(itemStack, mapping, mappings);
Tag potionTag = itemStack.getNbt().get("Potion"); PotionContents potionContents = itemStack.getDataComponentPatch().get(DataComponentType.POTION_CONTENTS);
if (potionTag instanceof StringTag) { if (potionContents != null) {
ItemDefinition customItemDefinition = CustomItemTranslator.getCustomItem(itemStack.getNbt(), mapping); ItemDefinition customItemDefinition = CustomItemTranslator.getCustomItem(itemStack.getDataComponentPatch(), mapping);
if (customItemDefinition == null) { if (customItemDefinition == null) {
Potion potion = Potion.getByJavaIdentifier(((StringTag) potionTag).getValue()); Potion potion = Potion.getByJavaIdentifier(((StringTag) potionTag).getValue());
if (potion != null) { if (potion != null) {

Datei anzeigen

@ -25,11 +25,13 @@
package org.geysermc.geyser.item.type; package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentPatch;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag; import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag; import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.Tag; import com.github.steveice10.opennbt.tag.builtin.Tag;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.nbt.NbtMapBuilder;
import org.geysermc.geyser.item.components.ToolTier; import org.geysermc.geyser.item.components.ToolTier;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
@ -39,8 +41,8 @@ public class ShieldItem extends Item {
} }
@Override @Override
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) { public void translateComponentsToBedrock(@NonNull GeyserSession session, @NonNull DataComponentPatch components, @NonNull NbtMapBuilder builder) {
super.translateNbtToBedrock(session, tag); super.translateComponentsToBedrock(session, components, builder);
if (tag.remove("BlockEntityTag") instanceof CompoundTag blockEntityTag) { if (tag.remove("BlockEntityTag") instanceof CompoundTag blockEntityTag) {
if (blockEntityTag.get("Patterns") instanceof ListTag patterns) { if (blockEntityTag.get("Patterns") instanceof ListTag patterns) {

Datei anzeigen

@ -26,68 +26,61 @@
package org.geysermc.geyser.item.type; package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.Identifier; import com.github.steveice10.mc.protocol.data.game.Identifier;
import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentPatch;
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentType;
import com.github.steveice10.opennbt.tag.builtin.*; import com.github.steveice10.opennbt.tag.builtin.*;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.nbt.NbtMap;
import org.cloudburstmc.nbt.NbtMapBuilder;
import org.cloudburstmc.nbt.NbtType;
import org.geysermc.geyser.item.Items;
import org.geysermc.geyser.registry.type.ItemMapping; import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.inventory.item.ItemTranslator; import org.geysermc.geyser.translator.item.ItemTranslator;
import org.geysermc.geyser.util.MathUtils; import org.geysermc.geyser.util.MathUtils;
import java.util.ArrayList;
import java.util.List;
public class ShulkerBoxItem extends BlockItem { public class ShulkerBoxItem extends BlockItem {
public ShulkerBoxItem(String javaIdentifier, Builder builder) { public ShulkerBoxItem(String javaIdentifier, Builder builder) {
super(javaIdentifier, builder); super(javaIdentifier, builder);
} }
@Override @Override
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) { public void translateComponentsToBedrock(@NonNull GeyserSession session, @NonNull DataComponentPatch components, @NonNull NbtMapBuilder builder) {
super.translateNbtToBedrock(session, tag); super.translateComponentsToBedrock(session, components, builder);
CompoundTag blockEntityTag = tag.get("BlockEntityTag"); List<ItemStack> contents = components.get(DataComponentType.CONTAINER);
if (blockEntityTag == null) { if (contents == null || contents.isEmpty()) {
// Empty shulker box // Empty shulker box
return; return;
} }
if (blockEntityTag.get("Items") == null) return; List<NbtMap> itemsList = new ArrayList<>();
ListTag itemsList = new ListTag("Items"); for (int slot = 0; slot < contents.size(); slot++) {
for (Tag item : (ListTag) blockEntityTag.get("Items")) { ItemStack item = contents.get(slot);
CompoundTag itemData = (CompoundTag) item; // Information about the item if (item.getId() == Items.AIR_ID) {
CompoundTag boxItemTag = new CompoundTag(""); // Final item tag to add to the list
boxItemTag.put(new ByteTag("Slot", (byte) (MathUtils.getNbtByte(itemData.get("Slot").getValue()) & 255)));
boxItemTag.put(new ByteTag("WasPickedUp", (byte) 0)); // ???
ItemMapping boxMapping = session.getItemMappings().getMapping(Identifier.formalize(((StringTag) itemData.get("id")).getValue()));
if (boxMapping == null) {
// If invalid ID
continue; continue;
} }
NbtMapBuilder boxItemNbt = NbtMap.builder(); // Final item tag to add to the list
boxItemNbt.putByte("Slot", (byte) slot);
boxItemNbt.putByte("WasPickedUp", (byte) 0); // ???
boxItemTag.put(new StringTag("Name", boxMapping.getBedrockIdentifier())); ItemMapping boxMapping = session.getItemMappings().getMapping(item.getId());
boxItemTag.put(new ShortTag("Damage", (short) boxMapping.getBedrockData()));
boxItemTag.put(new ByteTag("Count", MathUtils.getNbtByte(itemData.get("Count").getValue()))); boxItemNbt.putString("Name", boxMapping.getBedrockIdentifier());
boxItemNbt.putShort("Damage", (short) boxMapping.getBedrockData());
boxItemNbt.putByte("Count", (byte) item.getAmount());
// Only the display name is what we have interest in, so just translate that if relevant // Only the display name is what we have interest in, so just translate that if relevant
CompoundTag displayTag = itemData.get("tag"); DataComponentPatch boxComponents = item.getDataComponentPatch();
if (displayTag == null && boxMapping.hasTranslation()) { if (boxComponents != null) {
displayTag = new CompoundTag("tag"); boxItemNbt.put(ItemTranslator.translateDisplayProperties(session, displayTag, boxMapping, '7'));
}
if (displayTag != null) {
boxItemTag.put(ItemTranslator.translateDisplayProperties(session, displayTag, boxMapping, '7'));
} }
itemsList.add(boxItemTag); itemsList.add(boxItemNbt.build());
} }
tag.put(itemsList); builder.putList("Items", NbtType.COMPOUND, itemsList);
// Strip the BlockEntityTag from the chests contents
// sent to the client. The client does not parse this
// or use it for anything, as this tag is fully
// server-side, so we remove it to reduce bandwidth and
// solve potential issues with very large tags.
// There was a problem in the past where this would strip
// NBT data in creative mode, however with the new server
// authoritative inventories, this is no longer a concern.
tag.remove("BlockEntityTag");
} }
@Override @Override

Datei anzeigen

@ -25,7 +25,7 @@
package org.geysermc.geyser.item.type; package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.opennbt.tag.builtin.StringTag; import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag; import com.github.steveice10.opennbt.tag.builtin.Tag;
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData; import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
@ -33,7 +33,7 @@ import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.inventory.item.TippedArrowPotion; import org.geysermc.geyser.inventory.item.TippedArrowPotion;
import org.geysermc.geyser.registry.type.ItemMapping; import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.registry.type.ItemMappings; import org.geysermc.geyser.registry.type.ItemMappings;
import org.geysermc.geyser.translator.inventory.item.ItemTranslator; import org.geysermc.geyser.translator.item.ItemTranslator;
public class TippedArrowItem extends ArrowItem { public class TippedArrowItem extends ArrowItem {
public TippedArrowItem(String javaIdentifier, Builder builder) { public TippedArrowItem(String javaIdentifier, Builder builder) {

Datei anzeigen

@ -25,12 +25,14 @@
package org.geysermc.geyser.item.type; package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentPatch;
import com.github.steveice10.opennbt.tag.builtin.*; import com.github.steveice10.opennbt.tag.builtin.*;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.Style; import net.kyori.adventure.text.format.Style;
import net.kyori.adventure.text.format.TextDecoration; import net.kyori.adventure.text.format.TextDecoration;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.nbt.NbtMapBuilder;
import org.geysermc.geyser.entity.type.living.animal.TropicalFishEntity; import org.geysermc.geyser.entity.type.living.animal.TropicalFishEntity;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.text.MinecraftLocale; import org.geysermc.geyser.text.MinecraftLocale;
@ -47,8 +49,8 @@ public class TropicalFishBucketItem extends Item {
} }
@Override @Override
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) { public void translateComponentsToBedrock(@NonNull GeyserSession session, @NonNull DataComponentPatch components, @NonNull NbtMapBuilder builder) {
super.translateNbtToBedrock(session, tag); super.translateComponentsToBedrock(session, components, builder);
// Prevent name from appearing as "Bucket of" // Prevent name from appearing as "Bucket of"
tag.put(new ByteTag("AppendCustomName", (byte) 1)); tag.put(new ByteTag("AppendCustomName", (byte) 1));

Datei anzeigen

@ -25,11 +25,13 @@
package org.geysermc.geyser.item.type; package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentPatch;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag; import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag; import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag; import com.github.steveice10.opennbt.tag.builtin.Tag;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.nbt.NbtMapBuilder;
import org.geysermc.geyser.registry.type.ItemMapping; import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.text.MessageTranslator; import org.geysermc.geyser.translator.text.MessageTranslator;
@ -43,8 +45,8 @@ public class WritableBookItem extends Item {
} }
@Override @Override
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) { public void translateComponentsToBedrock(@NonNull GeyserSession session, @NonNull DataComponentPatch components, @NonNull NbtMapBuilder builder) {
super.translateNbtToBedrock(session, tag); super.translateComponentsToBedrock(session, components, builder);
ListTag pagesTag = tag.remove("pages"); ListTag pagesTag = tag.remove("pages");
if (pagesTag == null) { if (pagesTag == null) {

Datei anzeigen

@ -25,6 +25,7 @@
package org.geysermc.geyser.item.type; package org.geysermc.geyser.item.type;
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentPatch;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag; import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag; import com.github.steveice10.opennbt.tag.builtin.StringTag;
@ -32,6 +33,7 @@ import com.github.steveice10.opennbt.tag.builtin.Tag;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.nbt.NbtMapBuilder;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.text.MessageTranslator; import org.geysermc.geyser.translator.text.MessageTranslator;
@ -48,13 +50,13 @@ public class WrittenBookItem extends WritableBookItem {
} }
@Override @Override
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) { public void translateComponentsToBedrock(@NonNull GeyserSession session, @NonNull DataComponentPatch components, @NonNull NbtMapBuilder builder) {
boolean isValid = isValidWrittenBook(tag); boolean isValid = isValidWrittenBook(tag);
if (!isValid) { if (!isValid) {
tag.remove("pages"); tag.remove("pages");
} }
super.translateNbtToBedrock(session, tag); super.translateComponentsToBedrock(session, components, builder);
if (!isValid) { if (!isValid) {
CompoundTag invalidTagPage = new CompoundTag(""); CompoundTag invalidTagPage = new CompoundTag("");

Datei anzeigen

@ -26,7 +26,7 @@
package org.geysermc.geyser.registry.populator; package org.geysermc.geyser.registry.populator;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient; import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient;
import com.github.steveice10.mc.protocol.data.game.recipe.RecipeType; import com.github.steveice10.mc.protocol.data.game.recipe.RecipeType;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
@ -48,7 +48,7 @@ import org.geysermc.geyser.registry.Registries;
import org.geysermc.geyser.registry.type.ItemMapping; import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.registry.type.ItemMappings; import org.geysermc.geyser.registry.type.ItemMappings;
import org.geysermc.geyser.text.GeyserLocale; import org.geysermc.geyser.text.GeyserLocale;
import org.geysermc.geyser.translator.inventory.item.ItemTranslator; import org.geysermc.geyser.translator.item.ItemTranslator;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;

Datei anzeigen

@ -25,7 +25,7 @@
package org.geysermc.geyser.registry.type; package org.geysermc.geyser.registry.type;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectMap; import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
import lombok.Builder; import lombok.Builder;

Datei anzeigen

@ -25,7 +25,7 @@
package org.geysermc.geyser.translator.inventory; package org.geysermc.geyser.translator.inventory;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.mc.protocol.data.game.inventory.ContainerType; import com.github.steveice10.mc.protocol.data.game.inventory.ContainerType;
import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient; import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient;
import com.github.steveice10.opennbt.tag.builtin.IntTag; import com.github.steveice10.opennbt.tag.builtin.IntTag;

Datei anzeigen

@ -25,7 +25,7 @@
package org.geysermc.geyser.translator.inventory; package org.geysermc.geyser.translator.inventory;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode; import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
import com.github.steveice10.mc.protocol.data.game.inventory.ContainerType; import com.github.steveice10.mc.protocol.data.game.inventory.ContainerType;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundSetCreativeModeSlotPacket; import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundSetCreativeModeSlotPacket;
@ -53,7 +53,7 @@ import org.geysermc.geyser.item.Items;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.skin.FakeHeadProvider; import org.geysermc.geyser.skin.FakeHeadProvider;
import org.geysermc.geyser.text.GeyserLocale; import org.geysermc.geyser.text.GeyserLocale;
import org.geysermc.geyser.translator.inventory.item.ItemTranslator; import org.geysermc.geyser.translator.item.ItemTranslator;
import org.geysermc.geyser.util.InventoryUtils; import org.geysermc.geyser.util.InventoryUtils;
import java.util.Arrays; import java.util.Arrays;

Datei anzeigen

@ -25,7 +25,7 @@
package org.geysermc.geyser.translator.inventory; package org.geysermc.geyser.translator.inventory;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.mc.protocol.data.game.inventory.ContainerType; import com.github.steveice10.mc.protocol.data.game.inventory.ContainerType;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundContainerButtonClickPacket; import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundContainerButtonClickPacket;
import org.cloudburstmc.protocol.bedrock.data.inventory.ContainerSlotType; import org.cloudburstmc.protocol.bedrock.data.inventory.ContainerSlotType;

Datei anzeigen

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org * Copyright (c) 2019-2024 GeyserMC. http://geysermc.org
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@ -23,11 +23,10 @@
* @link https://github.com/GeyserMC/Geyser * @link https://github.com/GeyserMC/Geyser
*/ */
package org.geysermc.geyser.translator.inventory.item; package org.geysermc.geyser.translator.item;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentPatch;
import com.github.steveice10.opennbt.tag.builtin.IntTag; import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentType;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import it.unimi.dsi.fastutil.Pair; import it.unimi.dsi.fastutil.Pair;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.protocol.bedrock.data.definitions.ItemDefinition; import org.cloudburstmc.protocol.bedrock.data.definitions.ItemDefinition;
@ -44,8 +43,8 @@ import java.util.OptionalInt;
public final class CustomItemTranslator { public final class CustomItemTranslator {
@Nullable @Nullable
public static ItemDefinition getCustomItem(CompoundTag nbt, ItemMapping mapping) { public static ItemDefinition getCustomItem(DataComponentPatch components, ItemMapping mapping) {
if (nbt == null) { if (components == null) {
return null; return null;
} }
List<Pair<CustomItemOptions, ItemDefinition>> customMappings = mapping.getCustomItemOptions(); List<Pair<CustomItemOptions, ItemDefinition>> customMappings = mapping.getCustomItemOptions();
@ -53,10 +52,11 @@ public final class CustomItemTranslator {
return null; return null;
} }
int customModelData = nbt.get("CustomModelData") instanceof IntTag customModelDataTag ? customModelDataTag.getValue() : 0; // TODO getOrDefault
int customModelData = components.get(DataComponentType.CUSTOM_MODEL_DATA);
boolean checkDamage = mapping.getJavaItem().maxDamage() > 0; boolean checkDamage = mapping.getJavaItem().maxDamage() > 0;
int damage = !checkDamage ? 0 : nbt.get("Damage") instanceof IntTag damageTag ? damageTag.getValue() : 0; int damage = !checkDamage ? 0 : components.get(DataComponentType.DAMAGE);
boolean unbreakable = checkDamage && !isDamaged(nbt, damage); boolean unbreakable = checkDamage && !isDamaged(components, damage);
for (Pair<CustomItemOptions, ItemDefinition> mappingTypes : customMappings) { for (Pair<CustomItemOptions, ItemDefinition> mappingTypes : customMappings) {
CustomItemOptions options = mappingTypes.key(); CustomItemOptions options = mappingTypes.key();
@ -105,15 +105,15 @@ public final class CustomItemTranslator {
/* These two functions are based off their Mojmap equivalents from 1.19.2 */ /* These two functions are based off their Mojmap equivalents from 1.19.2 */
private static boolean isDamaged(CompoundTag nbt, int damage) { private static boolean isDamaged(DataComponentPatch components, int damage) {
return isDamagableItem(nbt) && damage > 0; return isDamagableItem(components) && damage > 0;
} }
private static boolean isDamagableItem(CompoundTag nbt) { private static boolean isDamagableItem(DataComponentPatch components) {
// mapping.getMaxDamage > 0 should also be checked (return false if not true) but we already check prior to this function // mapping.getMaxDamage > 0 should also be checked (return false if not true) but we already check prior to this function
Tag unbreakableTag = nbt.get("Unbreakable"); Boolean unbreakable = components.get(DataComponentType.UNBREAKABLE);
// Tag must either not be present or be set to false // Tag must either not be present or be set to false
return unbreakableTag == null || !(unbreakableTag.getValue() instanceof Number number) || number.byteValue() == 0; return unbreakable == null || !unbreakable;
} }
private CustomItemTranslator() { private CustomItemTranslator() {

Datei anzeigen

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org * Copyright (c) 2019-2024 GeyserMC. http://geysermc.org
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@ -23,11 +23,15 @@
* @link https://github.com/GeyserMC/Geyser * @link https://github.com/GeyserMC/Geyser
*/ */
package org.geysermc.geyser.translator.inventory.item; package org.geysermc.geyser.translator.item;
import com.github.steveice10.mc.protocol.data.game.Identifier; import com.github.steveice10.mc.protocol.data.game.Identifier;
import com.github.steveice10.mc.protocol.data.game.entity.attribute.ModifierOperation; import com.github.steveice10.mc.protocol.data.game.entity.attribute.ModifierOperation;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.mc.protocol.data.game.item.component.AdventureModePredicate;
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentPatch;
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentType;
import com.github.steveice10.mc.protocol.data.game.item.component.ItemAttributeModifiers;
import com.github.steveice10.opennbt.tag.builtin.ByteArrayTag; import com.github.steveice10.opennbt.tag.builtin.ByteArrayTag;
import com.github.steveice10.opennbt.tag.builtin.ByteTag; import com.github.steveice10.opennbt.tag.builtin.ByteTag;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
@ -133,20 +137,20 @@ public final class ItemTranslator {
.build(); .build();
} }
private static ItemData.@NonNull Builder translateToBedrock(GeyserSession session, Item javaItem, ItemMapping bedrockItem, int count, CompoundTag tag) { private static ItemData.@NonNull Builder translateToBedrock(GeyserSession session, Item javaItem, ItemMapping bedrockItem, int count, DataComponentPatch components) {
CompoundTag nbt = tag != null ? tag.clone() : null; NbtMapBuilder builder = NbtMap.builder();
if (nbt != null) { if (components != null) {
javaItem.translateNbtToBedrock(session, nbt); javaItem.translateComponentsToBedrock(session, components, builder);
} }
nbt = translateDisplayProperties(session, nbt, bedrockItem); translateDisplayProperties(session, components, bedrockItem);
if (nbt != null) { if (components != null) {
Tag hideFlags = nbt.get("HideFlags"); ItemAttributeModifiers attributeModifiers = components.get(DataComponentType.ATTRIBUTE_MODIFIERS);
if (hideFlags == null || !hasFlagPresent(hideFlags, HIDE_ATTRIBUTES_FLAG)) { if (attributeModifiers != null && attributeModifiers.isShowInTooltip()) {
// only add if the hide attribute modifiers flag is not present // only add if attribute modifiers do not indicate to hide them
addAttributeLore(nbt, session.locale()); addAttributeLore(attributeModifiers, builder, session.locale());
} }
} }
@ -173,10 +177,10 @@ public final class ItemTranslator {
translateCustomItem(nbt, builder, bedrockItem); translateCustomItem(nbt, builder, bedrockItem);
if (nbt != null) { if (components != null) {
// Translate the canDestroy and canPlaceOn Java NBT // Translate the canDestroy and canPlaceOn Java NBT
ListTag canDestroy = nbt.get("CanDestroy"); AdventureModePredicate canDestroy = components.get(DataComponentType.CAN_BREAK);
ListTag canPlaceOn = nbt.get("CanPlaceOn"); AdventureModePredicate canPlaceOn = components.get(DataComponentType.CAN_PLACE_ON);
String[] canBreak = getCanModify(canDestroy); String[] canBreak = getCanModify(canDestroy);
String[] canPlace = getCanModify(canPlaceOn); String[] canPlace = getCanModify(canPlaceOn);
if (canBreak != null) { if (canBreak != null) {
@ -197,13 +201,8 @@ public final class ItemTranslator {
* @param nbt the NBT of the ItemStack * @param nbt the NBT of the ItemStack
* @param language the locale of the player * @param language the locale of the player
*/ */
private static void addAttributeLore(CompoundTag nbt, String language) { private static void addAttributeLore(ItemAttributeModifiers modifiers, NbtMapBuilder builder, String language) {
ListTag attributeModifiers = nbt.get("AttributeModifiers"); CompoundTag displayTag = builder.get("display");
if (attributeModifiers == null) {
return; // nothing to convert to lore
}
CompoundTag displayTag = nbt.get("display");
if (displayTag == null) { if (displayTag == null) {
displayTag = new CompoundTag("display"); displayTag = new CompoundTag("display");
} }
@ -214,25 +213,23 @@ public final class ItemTranslator {
// maps each slot to the modifiers applied when in such slot // maps each slot to the modifiers applied when in such slot
Map<String, List<StringTag>> slotsToModifiers = new HashMap<>(); Map<String, List<StringTag>> slotsToModifiers = new HashMap<>();
for (Tag modifier : attributeModifiers) { for (ItemAttributeModifiers.Entry entry : modifiers.getModifiers()) {
CompoundTag modifierTag = (CompoundTag) modifier;
// convert the modifier tag to a lore entry // convert the modifier tag to a lore entry
String loreEntry = attributeToLore(modifierTag, language); String loreEntry = attributeToLore(entry.getModifier(), language);
if (loreEntry == null) { if (loreEntry == null) {
continue; // invalid or failed continue; // invalid or failed
} }
StringTag loreTag = new StringTag("", loreEntry); StringTag loreTag = new StringTag("", loreEntry);
StringTag slotTag = modifierTag.get("Slot"); ItemAttributeModifiers.EquipmentSlotGroup slotGroup = entry.getSlot();
if (slotTag == null) { if (slotGroup == ItemAttributeModifiers.EquipmentSlotGroup.ANY) {
// modifier applies to all slots implicitly // modifier applies to all slots implicitly
for (String slot : ALL_SLOTS) { for (String slot : ALL_SLOTS) {
slotsToModifiers.computeIfAbsent(slot, s -> new ArrayList<>()).add(loreTag); slotsToModifiers.computeIfAbsent(slot, s -> new ArrayList<>()).add(loreTag);
} }
} else { } else {
// modifier applies to only the specified slot // modifier applies to only the specified slot
slotsToModifiers.computeIfAbsent(slotTag.getValue(), s -> new ArrayList<>()).add(loreTag); slotsToModifiers.computeIfAbsent(slotGroup, s -> new ArrayList<>()).add(loreTag);
} }
} }
@ -262,31 +259,23 @@ public final class ItemTranslator {
} }
@Nullable @Nullable
private static String attributeToLore(CompoundTag modifier, String language) { private static String attributeToLore(ItemAttributeModifiers.AttributeModifier modifier, String language) {
Tag amountTag = modifier.get("Amount"); double amount = modifier.getAmount();
if (amountTag == null || !(amountTag.getValue() instanceof Number number)) {
return null;
}
double amount = number.doubleValue();
if (amount == 0) { if (amount == 0) {
return null; return null;
} }
if (!(modifier.get("AttributeName") instanceof StringTag nameTag)) { String name = modifier.getName().replace("minecraft:", "");
return null; // the namespace does not need to be present, but if it is, the java client ignores it as of pre-1.20.5
}
String name = nameTag.getValue().replace("minecraft:", "");
// the namespace does not need to be present, but if it is, the java client ignores it
String operationTotal; String operationTotal;
Tag operationTag = modifier.get("Operation"); ModifierOperation operation = modifier.getOperation();
ModifierOperation operation; if (operation == ModifierOperation.ADD) {
if (operationTag == null || (operation = ModifierOperation.from((int) operationTag.getValue())) == ModifierOperation.ADD) {
if (name.equals("generic.knockback_resistance")) { if (name.equals("generic.knockback_resistance")) {
amount *= 10; amount *= 10;
} }
operationTotal = ATTRIBUTE_FORMAT.format(amount); operationTotal = ATTRIBUTE_FORMAT.format(amount);
} else if (operation == ModifierOperation.ADD_MULTIPLIED || operation == ModifierOperation.MULTIPLY) { } else if (operation == ModifierOperation.ADD_MULTIPLIED_BASE || operation == ModifierOperation.ADD_MULTIPLIED_TOTAL) {
operationTotal = ATTRIBUTE_FORMAT.format(amount * 100) + "%"; operationTotal = ATTRIBUTE_FORMAT.format(amount * 100) + "%";
} else { } else {
GeyserImpl.getInstance().getLogger().warning("Unhandled ModifierOperation while adding item attributes: " + operation); GeyserImpl.getInstance().getLogger().warning("Unhandled ModifierOperation while adding item attributes: " + operation);
@ -363,12 +352,22 @@ public final class ItemTranslator {
* @param canModifyJava the list of items in Java * @param canModifyJava the list of items in Java
* @return the new list of items in Bedrock * @return the new list of items in Bedrock
*/ */
private static String @Nullable [] getCanModify(ListTag canModifyJava) { // TODO this is now more complicated in 1.20.5. Yippee!
if (canModifyJava != null && canModifyJava.size() > 0) { private static String @Nullable [] getCanModify(@Nullable AdventureModePredicate canModifyJava) {
String[] canModifyBedrock = new String[canModifyJava.size()]; if (canModifyJava == null) {
return null;
}
List<AdventureModePredicate.BlockPredicate> predicates = canModifyJava.getPredicates();
if (predicates.size() > 0) {
String[] canModifyBedrock = new String[predicates.size()];
for (int i = 0; i < canModifyBedrock.length; i++) { for (int i = 0; i < canModifyBedrock.length; i++) {
// Get the Java identifier of the block that can be placed // Get the Java identifier of the block that can be placed
String block = Identifier.formalize(((StringTag) canModifyJava.get(i)).getValue()); String location = predicates.get(i).getLocation();
if (location == null) {
canModifyBedrock[i] = ""; // So it'll serialize
continue; // ???
}
String block = Identifier.formalize(location);
// Get the Bedrock identifier of the item and replace it. // Get the Bedrock identifier of the item and replace it.
// This will unfortunately be limited - for example, beds and banners will be translated weirdly // This will unfortunately be limited - for example, beds and banners will be translated weirdly
canModifyBedrock[i] = BlockRegistries.JAVA_TO_BEDROCK_IDENTIFIERS.getOrDefault(block, block).replace("minecraft:", ""); canModifyBedrock[i] = BlockRegistries.JAVA_TO_BEDROCK_IDENTIFIERS.getOrDefault(block, block).replace("minecraft:", "");
@ -403,7 +402,7 @@ public final class ItemTranslator {
} }
} }
ItemDefinition definition = CustomItemTranslator.getCustomItem(itemStack.getNbt(), mapping); ItemDefinition definition = CustomItemTranslator.getCustomItem(itemStack, mapping);
if (definition == null) { if (definition == null) {
// No custom item // No custom item
return itemDefinition; return itemDefinition;

Datei anzeigen

@ -25,7 +25,7 @@
package org.geysermc.geyser.translator.protocol.bedrock; package org.geysermc.geyser.translator.protocol.bedrock;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag; import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag; import com.github.steveice10.opennbt.tag.builtin.StringTag;

Datei anzeigen

@ -25,7 +25,7 @@
package org.geysermc.geyser.translator.protocol.bedrock; package org.geysermc.geyser.translator.protocol.bedrock;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundEditBookPacket; import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundEditBookPacket;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag; import com.github.steveice10.opennbt.tag.builtin.ListTag;

Datei anzeigen

@ -25,7 +25,7 @@
package org.geysermc.geyser.translator.protocol.bedrock; package org.geysermc.geyser.translator.protocol.bedrock;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.mc.protocol.data.game.entity.object.Direction; import com.github.steveice10.mc.protocol.data.game.entity.object.Direction;
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode; import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
@ -70,7 +70,7 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.cache.SkullCache; import org.geysermc.geyser.session.cache.SkullCache;
import org.geysermc.geyser.skin.FakeHeadProvider; import org.geysermc.geyser.skin.FakeHeadProvider;
import org.geysermc.geyser.translator.inventory.InventoryTranslator; import org.geysermc.geyser.translator.inventory.InventoryTranslator;
import org.geysermc.geyser.translator.inventory.item.ItemTranslator; import org.geysermc.geyser.translator.item.ItemTranslator;
import org.geysermc.geyser.translator.protocol.PacketTranslator; import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator; import org.geysermc.geyser.translator.protocol.Translator;
import org.geysermc.geyser.util.BlockUtils; import org.geysermc.geyser.util.BlockUtils;

Datei anzeigen

@ -52,7 +52,7 @@ import org.geysermc.geyser.registry.type.BlockMapping;
import org.geysermc.geyser.registry.type.ItemMapping; import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.cache.SkullCache; import org.geysermc.geyser.session.cache.SkullCache;
import org.geysermc.geyser.translator.inventory.item.CustomItemTranslator; import org.geysermc.geyser.translator.item.CustomItemTranslator;
import org.geysermc.geyser.translator.protocol.PacketTranslator; import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator; import org.geysermc.geyser.translator.protocol.Translator;
import org.geysermc.geyser.util.BlockUtils; import org.geysermc.geyser.util.BlockUtils;

Datei anzeigen

@ -25,7 +25,7 @@
package org.geysermc.geyser.translator.protocol.java; package org.geysermc.geyser.translator.protocol.java;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient; import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient;
import com.github.steveice10.mc.protocol.data.game.recipe.Recipe; import com.github.steveice10.mc.protocol.data.game.recipe.Recipe;
import com.github.steveice10.mc.protocol.data.game.recipe.RecipeType; import com.github.steveice10.mc.protocol.data.game.recipe.RecipeType;
@ -56,7 +56,7 @@ import org.geysermc.geyser.inventory.recipe.TrimRecipe;
import org.geysermc.geyser.registry.Registries; import org.geysermc.geyser.registry.Registries;
import org.geysermc.geyser.registry.type.ItemMapping; import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.inventory.item.ItemTranslator; import org.geysermc.geyser.translator.item.ItemTranslator;
import org.geysermc.geyser.translator.protocol.PacketTranslator; import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator; import org.geysermc.geyser.translator.protocol.Translator;
import org.geysermc.geyser.util.InventoryUtils; import org.geysermc.geyser.util.InventoryUtils;

Datei anzeigen

@ -26,7 +26,7 @@
package org.geysermc.geyser.translator.protocol.java.entity; package org.geysermc.geyser.translator.protocol.java.entity;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Equipment; import com.github.steveice10.mc.protocol.data.game.entity.metadata.Equipment;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundSetEquipmentPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundSetEquipmentPacket;
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData; import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
import org.geysermc.geyser.entity.type.Entity; import org.geysermc.geyser.entity.type.Entity;
@ -35,7 +35,7 @@ import org.geysermc.geyser.entity.type.player.PlayerEntity;
import org.geysermc.geyser.item.Items; import org.geysermc.geyser.item.Items;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.skin.FakeHeadProvider; import org.geysermc.geyser.skin.FakeHeadProvider;
import org.geysermc.geyser.translator.inventory.item.ItemTranslator; import org.geysermc.geyser.translator.item.ItemTranslator;
import org.geysermc.geyser.translator.protocol.PacketTranslator; import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator; import org.geysermc.geyser.translator.protocol.Translator;

Datei anzeigen

@ -25,7 +25,7 @@
package org.geysermc.geyser.translator.protocol.java.inventory; package org.geysermc.geyser.translator.protocol.java.inventory;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient; import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.inventory.ClientboundContainerSetSlotPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.inventory.ClientboundContainerSetSlotPacket;
import org.cloudburstmc.protocol.bedrock.data.inventory.ContainerId; import org.cloudburstmc.protocol.bedrock.data.inventory.ContainerId;
@ -41,7 +41,7 @@ import org.geysermc.geyser.inventory.recipe.GeyserShapedRecipe;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.inventory.InventoryTranslator; import org.geysermc.geyser.translator.inventory.InventoryTranslator;
import org.geysermc.geyser.translator.inventory.PlayerInventoryTranslator; import org.geysermc.geyser.translator.inventory.PlayerInventoryTranslator;
import org.geysermc.geyser.translator.inventory.item.ItemTranslator; import org.geysermc.geyser.translator.item.ItemTranslator;
import org.geysermc.geyser.translator.protocol.PacketTranslator; import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator; import org.geysermc.geyser.translator.protocol.Translator;
import org.geysermc.geyser.util.InventoryUtils; import org.geysermc.geyser.util.InventoryUtils;

Datei anzeigen

@ -25,7 +25,7 @@
package org.geysermc.geyser.translator.protocol.java.inventory; package org.geysermc.geyser.translator.protocol.java.inventory;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.mc.protocol.data.game.inventory.VillagerTrade; import com.github.steveice10.mc.protocol.data.game.inventory.VillagerTrade;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.inventory.ClientboundMerchantOffersPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.inventory.ClientboundMerchantOffersPacket;
import org.cloudburstmc.nbt.NbtMap; import org.cloudburstmc.nbt.NbtMap;
@ -41,7 +41,7 @@ import org.geysermc.geyser.inventory.MerchantContainer;
import org.geysermc.geyser.registry.Registries; import org.geysermc.geyser.registry.Registries;
import org.geysermc.geyser.registry.type.ItemMapping; import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.inventory.item.ItemTranslator; import org.geysermc.geyser.translator.item.ItemTranslator;
import org.geysermc.geyser.translator.protocol.PacketTranslator; import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator; import org.geysermc.geyser.translator.protocol.Translator;
import org.geysermc.geyser.util.InventoryUtils; import org.geysermc.geyser.util.InventoryUtils;

Datei anzeigen

@ -25,7 +25,7 @@
package org.geysermc.geyser.translator.protocol.java.level; package org.geysermc.geyser.translator.protocol.java.level;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.mc.protocol.data.game.level.particle.BlockParticleData; import com.github.steveice10.mc.protocol.data.game.level.particle.BlockParticleData;
import com.github.steveice10.mc.protocol.data.game.level.particle.DustParticleData; import com.github.steveice10.mc.protocol.data.game.level.particle.DustParticleData;
import com.github.steveice10.mc.protocol.data.game.level.particle.FallingDustParticleData; import com.github.steveice10.mc.protocol.data.game.level.particle.FallingDustParticleData;
@ -49,7 +49,7 @@ import org.geysermc.geyser.entity.type.Entity;
import org.geysermc.geyser.registry.Registries; import org.geysermc.geyser.registry.Registries;
import org.geysermc.geyser.registry.type.ParticleMapping; import org.geysermc.geyser.registry.type.ParticleMapping;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.inventory.item.ItemTranslator; import org.geysermc.geyser.translator.item.ItemTranslator;
import org.geysermc.geyser.translator.protocol.PacketTranslator; import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator; import org.geysermc.geyser.translator.protocol.Translator;
import org.geysermc.geyser.util.DimensionUtils; import org.geysermc.geyser.util.DimensionUtils;

Datei anzeigen

@ -25,7 +25,7 @@
package org.geysermc.geyser.util; package org.geysermc.geyser.util;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode; import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient; import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundPickItemPacket; import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundPickItemPacket;