From a18ac29a9132ca7c81bf91509f3572a5acfad8ac Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Sun, 24 Jul 2022 19:32:22 -0400 Subject: [PATCH 1/4] Initial 1.19.1 Java support --- core/pom.xml | 6 ++--- .../geyser/session/GeyserSession.java | 10 ++++----- .../geysermc/geyser/text/ChatTypeEntry.java | 13 +++++------ .../geysermc/geyser/text/TextDecoration.java | 20 +++++++++-------- .../protocol/java/JavaCommandsTranslator.java | 4 ++-- .../protocol/java/JavaLoginTranslator.java | 22 +++---------------- .../java/JavaPlayerChatTranslator.java | 15 +++++-------- .../java/JavaSystemChatTranslator.java | 7 +----- 8 files changed, 35 insertions(+), 62 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index 5c0e58f83..cd38a0dfc 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -161,9 +161,9 @@ compile - com.github.GeyserMC - MCProtocolLib - ecc04fd + com.github.steveice10 + mcprotocollib + 1.19.1-SNAPSHOT compile diff --git a/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java b/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java index d3e1b7a7b..be3dfc2e3 100644 --- a/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java +++ b/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java @@ -123,9 +123,9 @@ import org.geysermc.geyser.session.auth.AuthType; import org.geysermc.geyser.session.auth.BedrockClientData; import org.geysermc.geyser.session.cache.*; import org.geysermc.geyser.skin.FloodgateSkinUploader; -import org.geysermc.geyser.text.ChatTypeEntry; import org.geysermc.geyser.text.GeyserLocale; import org.geysermc.geyser.text.MinecraftLocale; +import org.geysermc.geyser.text.TextDecoration; import org.geysermc.geyser.translator.inventory.InventoryTranslator; import org.geysermc.geyser.translator.text.MessageTranslator; import org.geysermc.geyser.util.ChunkUtils; @@ -341,7 +341,7 @@ public class GeyserSession implements GeyserConnection, CommandSender { */ private final Map dimensions = new Object2ObjectOpenHashMap<>(3); - private final Int2ObjectMap chatTypes = new Int2ObjectOpenHashMap<>(8); + private final Int2ObjectMap chatTypes = new Int2ObjectOpenHashMap<>(7); @Setter private int breakingBlock; @@ -564,8 +564,6 @@ public class GeyserSession implements GeyserConnection, CommandSender { this.playerEntity = new SessionPlayerEntity(this); collisionManager.updatePlayerBoundingBox(this.playerEntity.getPosition()); - ChatTypeEntry.applyDefaults(chatTypes); - this.playerInventory = new PlayerInventory(); this.openInventory = null; this.craftingRecipes = new Int2ObjectOpenHashMap<>(); @@ -1388,14 +1386,14 @@ public class GeyserSession implements GeyserConnection, CommandSender { * Sends a chat message to the Java server. */ public void sendChat(String message) { - sendDownstreamPacket(new ServerboundChatPacket(message, Instant.now().toEpochMilli(), 0L, ByteArrays.EMPTY_ARRAY, false)); + sendDownstreamPacket(new ServerboundChatPacket(message, Instant.now().toEpochMilli(), 0L, ByteArrays.EMPTY_ARRAY, false, Collections.emptyList(), null)); } /** * Sends a command to the Java server. */ public void sendCommand(String command) { - sendDownstreamPacket(new ServerboundChatCommandPacket(command, Instant.now().toEpochMilli(), 0L, Collections.emptyMap(), false)); + sendDownstreamPacket(new ServerboundChatCommandPacket(command, Instant.now().toEpochMilli(), 0L, Collections.emptyList(), false, Collections.emptyList(), null)); } public void setServerRenderDistance(int renderDistance) { diff --git a/core/src/main/java/org/geysermc/geyser/text/ChatTypeEntry.java b/core/src/main/java/org/geysermc/geyser/text/ChatTypeEntry.java index ad2514e09..c45de8f9f 100644 --- a/core/src/main/java/org/geysermc/geyser/text/ChatTypeEntry.java +++ b/core/src/main/java/org/geysermc/geyser/text/ChatTypeEntry.java @@ -34,9 +34,7 @@ import javax.annotation.Nullable; public record ChatTypeEntry(@Nonnull TextPacket.Type bedrockChatType, @Nullable TextDecoration textDecoration) { private static final ChatTypeEntry CHAT = new ChatTypeEntry(TextPacket.Type.CHAT, null); - private static final ChatTypeEntry SYSTEM = new ChatTypeEntry(TextPacket.Type.CHAT, null); - private static final ChatTypeEntry TIP = new ChatTypeEntry(TextPacket.Type.CHAT, null); - private static final ChatTypeEntry RAW = new ChatTypeEntry(TextPacket.Type.CHAT, null); + private static final ChatTypeEntry RAW = new ChatTypeEntry(TextPacket.Type.RAW, null); /** * Apply defaults to a map so it isn't empty in the event a chat message is sent before the login packet. @@ -46,12 +44,11 @@ public record ChatTypeEntry(@Nonnull TextPacket.Type bedrockChatType, @Nullable // But, the only way this happens is if a chat message is sent to us before the login packet, which is rare. // So we'll just make sure chat ends up in the right place. chatTypes.put(BuiltinChatType.CHAT.ordinal(), CHAT); - chatTypes.put(BuiltinChatType.SYSTEM.ordinal(), SYSTEM); - chatTypes.put(BuiltinChatType.GAME_INFO.ordinal(), TIP); chatTypes.put(BuiltinChatType.SAY_COMMAND.ordinal(), RAW); - chatTypes.put(BuiltinChatType.MSG_COMMAND.ordinal(), RAW); - chatTypes.put(BuiltinChatType.TEAM_MSG_COMMAND.ordinal(), RAW); + chatTypes.put(BuiltinChatType.MSG_COMMAND_INCOMING.ordinal(), RAW); + chatTypes.put(BuiltinChatType.MSG_COMMAND_OUTGOING.ordinal(), RAW); + chatTypes.put(BuiltinChatType.TEAM_MSG_COMMAND_INCOMING.ordinal(), RAW); + chatTypes.put(BuiltinChatType.TEAM_MSG_COMMAND_OUTGOING.ordinal(), RAW); chatTypes.put(BuiltinChatType.EMOTE_COMMAND.ordinal(), RAW); - chatTypes.put(BuiltinChatType.TELLRAW_COMMAND.ordinal(), RAW); } } diff --git a/core/src/main/java/org/geysermc/geyser/text/TextDecoration.java b/core/src/main/java/org/geysermc/geyser/text/TextDecoration.java index 296cacaf5..121e1b2b9 100644 --- a/core/src/main/java/org/geysermc/geyser/text/TextDecoration.java +++ b/core/src/main/java/org/geysermc/geyser/text/TextDecoration.java @@ -46,14 +46,16 @@ public final class TextDecoration { CompoundTag styleTag = tag.get("style"); Style.Builder builder = Style.style(); - StringTag color = styleTag.get("color"); - if (color != null) { - builder.color(NamedTextColor.NAMES.value(color.getValue())); - } - //TODO implement the rest - Tag italic = styleTag.get("italic"); - if (italic != null && ((Number) italic.getValue()).byteValue() == (byte) 1) { - builder.decorate(net.kyori.adventure.text.format.TextDecoration.ITALIC); + if (styleTag != null) { + StringTag color = styleTag.get("color"); + if (color != null) { + builder.color(NamedTextColor.NAMES.value(color.getValue())); + } + //TODO implement the rest + Tag italic = styleTag.get("italic"); + if (italic != null && ((Number) italic.getValue()).byteValue() == (byte) 1) { + builder.decorate(net.kyori.adventure.text.format.TextDecoration.ITALIC); + } } style = builder.build(); @@ -88,6 +90,6 @@ public final class TextDecoration { public enum Parameter { CONTENT, SENDER, - TEAM_NAME + TARGET } } diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaCommandsTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaCommandsTranslator.java index b6f7a2451..c9f192d3f 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaCommandsTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaCommandsTranslator.java @@ -131,7 +131,7 @@ public class JavaCommandsTranslator extends PacketTranslator= 1) { @@ -319,7 +319,7 @@ public class JavaCommandsTranslator extends PacketTranslator chatTypes = session.getChatTypes(); + Int2ObjectMap chatTypes = session.getChatTypes(); chatTypes.clear(); for (CompoundTag tag : JavaCodecEntry.iterateAsTag(packet.getRegistry().get("minecraft:chat_type"))) { // The ID is NOT ALWAYS THE SAME! ViaVersion as of 1.19 adds two registry entries that do NOT match vanilla. @@ -77,21 +73,9 @@ public class JavaLoginTranslator extends PacketTranslator TextPacket.Type.CHAT; - case SYSTEM -> TextPacket.Type.SYSTEM; - case GAME_INFO -> TextPacket.Type.TIP; - default -> TextPacket.Type.RAW; - } : TextPacket.Type.RAW; - chatTypes.put(id, new ChatTypeEntry(bedrockType, textDecoration)); + chatTypes.put(id, textDecoration); } // If the player is already initialized and a join game packet is sent, they diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaPlayerChatTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaPlayerChatTranslator.java index f9f4407d9..74b27d417 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaPlayerChatTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaPlayerChatTranslator.java @@ -30,7 +30,6 @@ import com.nukkitx.protocol.bedrock.packet.TextPacket; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TranslatableComponent; import org.geysermc.geyser.session.GeyserSession; -import org.geysermc.geyser.text.ChatTypeEntry; import org.geysermc.geyser.text.TextDecoration; import org.geysermc.geyser.translator.protocol.PacketTranslator; import org.geysermc.geyser.translator.protocol.Translator; @@ -45,18 +44,16 @@ public class JavaPlayerChatTranslator extends PacketTranslator parameters = decoration.parameters(); List args = new ArrayList<>(3); - if (parameters.contains(TextDecoration.Parameter.TEAM_NAME)) { - args.add(packet.getSenderTeamName()); + if (parameters.contains(TextDecoration.Parameter.TARGET)) { + args.add(packet.getTargetName()); } if (parameters.contains(TextDecoration.Parameter.SENDER)) { - args.add(packet.getSenderName()); + args.add(packet.getName()); } if (parameters.contains(TextDecoration.Parameter.CONTENT)) { args.add(message); diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaSystemChatTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaSystemChatTranslator.java index 2bc0d1442..b605dbbbc 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaSystemChatTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaSystemChatTranslator.java @@ -28,7 +28,6 @@ package org.geysermc.geyser.translator.protocol.java; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket; import com.nukkitx.protocol.bedrock.packet.TextPacket; import org.geysermc.geyser.session.GeyserSession; -import org.geysermc.geyser.text.ChatTypeEntry; import org.geysermc.geyser.translator.protocol.PacketTranslator; import org.geysermc.geyser.translator.protocol.Translator; import org.geysermc.geyser.translator.text.MessageTranslator; @@ -38,15 +37,11 @@ public class JavaSystemChatTranslator extends PacketTranslator Date: Wed, 27 Jul 2022 16:38:51 -0400 Subject: [PATCH 2/4] Compiles; bump version --- ap/pom.xml | 4 ++-- api/base/pom.xml | 2 +- api/geyser/pom.xml | 4 ++-- api/pom.xml | 2 +- bootstrap/bungeecord/pom.xml | 4 ++-- bootstrap/pom.xml | 4 ++-- bootstrap/spigot/pom.xml | 4 ++-- bootstrap/sponge/pom.xml | 4 ++-- bootstrap/standalone/pom.xml | 4 ++-- bootstrap/velocity/pom.xml | 4 ++-- common/pom.xml | 2 +- core/pom.xml | 14 +++++++------- pom.xml | 2 +- 13 files changed, 27 insertions(+), 27 deletions(-) diff --git a/ap/pom.xml b/ap/pom.xml index 1be050e51..90bb1dc73 100644 --- a/ap/pom.xml +++ b/ap/pom.xml @@ -6,9 +6,9 @@ org.geysermc geyser-parent - 2.0.5-SNAPSHOT + 2.0.6-SNAPSHOT ap - 2.0.5-SNAPSHOT + 2.0.6-SNAPSHOT \ No newline at end of file diff --git a/api/base/pom.xml b/api/base/pom.xml index ec0c8ac84..0eeb536ea 100644 --- a/api/base/pom.xml +++ b/api/base/pom.xml @@ -5,7 +5,7 @@ org.geysermc api-parent - 2.0.5-SNAPSHOT + 2.0.6-SNAPSHOT 4.0.0 diff --git a/api/geyser/pom.xml b/api/geyser/pom.xml index 6842929e6..0071668bf 100644 --- a/api/geyser/pom.xml +++ b/api/geyser/pom.xml @@ -5,7 +5,7 @@ org.geysermc api-parent - 2.0.5-SNAPSHOT + 2.0.6-SNAPSHOT 4.0.0 @@ -26,7 +26,7 @@ org.geysermc base-api - 2.0.5-SNAPSHOT + 2.0.6-SNAPSHOT compile diff --git a/api/pom.xml b/api/pom.xml index 50c7cb822..9b4816954 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -6,7 +6,7 @@ org.geysermc geyser-parent - 2.0.5-SNAPSHOT + 2.0.6-SNAPSHOT api-parent diff --git a/bootstrap/bungeecord/pom.xml b/bootstrap/bungeecord/pom.xml index cd96fe6d0..4ec01539f 100644 --- a/bootstrap/bungeecord/pom.xml +++ b/bootstrap/bungeecord/pom.xml @@ -6,7 +6,7 @@ org.geysermc bootstrap-parent - 2.0.5-SNAPSHOT + 2.0.6-SNAPSHOT bootstrap-bungeecord @@ -14,7 +14,7 @@ org.geysermc core - 2.0.5-SNAPSHOT + 2.0.6-SNAPSHOT compile diff --git a/bootstrap/pom.xml b/bootstrap/pom.xml index 99e77f5af..0da863811 100644 --- a/bootstrap/pom.xml +++ b/bootstrap/pom.xml @@ -6,7 +6,7 @@ org.geysermc geyser-parent - 2.0.5-SNAPSHOT + 2.0.6-SNAPSHOT bootstrap-parent pom @@ -34,7 +34,7 @@ org.geysermc ap - 2.0.5-SNAPSHOT + 2.0.6-SNAPSHOT provided diff --git a/bootstrap/spigot/pom.xml b/bootstrap/spigot/pom.xml index dffe9f578..25bcb23f9 100644 --- a/bootstrap/spigot/pom.xml +++ b/bootstrap/spigot/pom.xml @@ -6,7 +6,7 @@ org.geysermc bootstrap-parent - 2.0.5-SNAPSHOT + 2.0.6-SNAPSHOT bootstrap-spigot @@ -30,7 +30,7 @@ org.geysermc core - 2.0.5-SNAPSHOT + 2.0.6-SNAPSHOT compile diff --git a/bootstrap/sponge/pom.xml b/bootstrap/sponge/pom.xml index e0ea5c97d..25f709ec4 100644 --- a/bootstrap/sponge/pom.xml +++ b/bootstrap/sponge/pom.xml @@ -6,7 +6,7 @@ org.geysermc bootstrap-parent - 2.0.5-SNAPSHOT + 2.0.6-SNAPSHOT bootstrap-sponge @@ -14,7 +14,7 @@ org.geysermc core - 2.0.5-SNAPSHOT + 2.0.6-SNAPSHOT compile diff --git a/bootstrap/standalone/pom.xml b/bootstrap/standalone/pom.xml index aca72d28c..5d27c8a2a 100644 --- a/bootstrap/standalone/pom.xml +++ b/bootstrap/standalone/pom.xml @@ -6,7 +6,7 @@ org.geysermc bootstrap-parent - 2.0.5-SNAPSHOT + 2.0.6-SNAPSHOT bootstrap-standalone @@ -18,7 +18,7 @@ org.geysermc core - 2.0.5-SNAPSHOT + 2.0.6-SNAPSHOT compile diff --git a/bootstrap/velocity/pom.xml b/bootstrap/velocity/pom.xml index 62b155c97..0c530b21e 100644 --- a/bootstrap/velocity/pom.xml +++ b/bootstrap/velocity/pom.xml @@ -6,7 +6,7 @@ org.geysermc bootstrap-parent - 2.0.5-SNAPSHOT + 2.0.6-SNAPSHOT bootstrap-velocity @@ -14,7 +14,7 @@ org.geysermc core - 2.0.5-SNAPSHOT + 2.0.6-SNAPSHOT compile diff --git a/common/pom.xml b/common/pom.xml index f25943535..5326ca014 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -6,7 +6,7 @@ org.geysermc geyser-parent - 2.0.5-SNAPSHOT + 2.0.6-SNAPSHOT common diff --git a/core/pom.xml b/core/pom.xml index cd38a0dfc..b9cc75233 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -6,7 +6,7 @@ org.geysermc geyser-parent - 2.0.5-SNAPSHOT + 2.0.6-SNAPSHOT core @@ -29,19 +29,19 @@ org.geysermc ap - 2.0.5-SNAPSHOT + 2.0.6-SNAPSHOT provided org.geysermc geyser-api - 2.0.5-SNAPSHOT + 2.0.6-SNAPSHOT compile org.geysermc common - 2.0.5-SNAPSHOT + 2.0.6-SNAPSHOT compile @@ -161,9 +161,9 @@ compile - com.github.steveice10 - mcprotocollib - 1.19.1-SNAPSHOT + com.github.GeyserMC + MCProtocolLib + 54e6f9e compile diff --git a/pom.xml b/pom.xml index 70924b7a0..1d99d93e0 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.geysermc geyser-parent - 2.0.5-SNAPSHOT + 2.0.6-SNAPSHOT pom Geyser Allows for players from Minecraft Bedrock Edition to join Minecraft Java Edition servers. From c914938acb99a3ddd6c6802f58ae281d9663a52c Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Wed, 27 Jul 2022 16:55:57 -0400 Subject: [PATCH 3/4] Fix clientbound action serialization --- core/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/pom.xml b/core/pom.xml index b9cc75233..8977854cb 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -163,7 +163,7 @@ com.github.GeyserMC MCProtocolLib - 54e6f9e + 9f78bd5 compile From 4163de9314204079def6d6f519648386b0cf17bd Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Thu, 28 Jul 2022 17:45:38 -0400 Subject: [PATCH 4/4] Translate allay dancing --- .../geyser/entity/EntityDefinitions.java | 2 ++ .../entity/type/living/AllayEntity.java | 26 +++++++++++++++++-- .../inventory/item/StoredItemMappings.java | 2 ++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/geysermc/geyser/entity/EntityDefinitions.java b/core/src/main/java/org/geysermc/geyser/entity/EntityDefinitions.java index 52d9250ac..a552d0875 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/EntityDefinitions.java +++ b/core/src/main/java/org/geysermc/geyser/entity/EntityDefinitions.java @@ -453,6 +453,8 @@ public final class EntityDefinitions { ALLAY = EntityDefinition.inherited(AllayEntity::new, mobEntityBase) .type(EntityType.ALLAY) .height(0.6f).width(0.35f) + .addTranslator(MetadataType.BOOLEAN, AllayEntity::setDancing) + .addTranslator(MetadataType.BOOLEAN, AllayEntity::setCanDuplicate) .build(); BAT = EntityDefinition.inherited(BatEntity::new, mobEntityBase) .type(EntityType.BAT) diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/AllayEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/AllayEntity.java index ab444c4ab..d37a67938 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/AllayEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/AllayEntity.java @@ -25,8 +25,10 @@ package org.geysermc.geyser.entity.type.living; +import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.nukkitx.math.vector.Vector3f; +import com.nukkitx.protocol.bedrock.data.entity.EntityFlag; import org.geysermc.geyser.entity.EntityDefinition; import org.geysermc.geyser.inventory.GeyserItemStack; import org.geysermc.geyser.session.GeyserSession; @@ -37,14 +39,27 @@ import javax.annotation.Nonnull; import java.util.UUID; public class AllayEntity extends MobEntity { + private boolean canDuplicate; + public AllayEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) { super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw); } + public void setDancing(BooleanEntityMetadata entityMetadata) { + setFlag(EntityFlag.DANCING, entityMetadata.getPrimitiveValue()); + } + + public void setCanDuplicate(BooleanEntityMetadata entityMetadata) { + this.canDuplicate = entityMetadata.getPrimitiveValue(); + } + @Nonnull @Override protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { - if (!this.hand.isValid() && !itemInHand.isEmpty()) { + if (this.canDuplicate && getFlag(EntityFlag.DANCING) && isDuplicationItem(itemInHand)) { + // Maybe better as another tag? + return InteractiveTag.GIVE_ITEM_TO_ALLAY; + } else if (!this.hand.isValid() && !itemInHand.isEmpty()) { return InteractiveTag.GIVE_ITEM_TO_ALLAY; } else if (this.hand.isValid() && hand == Hand.MAIN_HAND && itemInHand.isEmpty()) { // Seems like there isn't a good tag for this yet @@ -57,7 +72,10 @@ public class AllayEntity extends MobEntity { @Nonnull @Override protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { - if (!this.hand.isValid() && !itemInHand.isEmpty()) { + if (this.canDuplicate && getFlag(EntityFlag.DANCING) && isDuplicationItem(itemInHand)) { + //TOCHECK sound + return InteractionResult.SUCCESS; + } else if (!this.hand.isValid() && !itemInHand.isEmpty()) { //TODO play sound? return InteractionResult.SUCCESS; } else if (this.hand.isValid() && hand == Hand.MAIN_HAND && itemInHand.isEmpty()) { @@ -67,4 +85,8 @@ public class AllayEntity extends MobEntity { return super.mobInteract(hand, itemInHand); } } + + private boolean isDuplicationItem(GeyserItemStack itemStack) { + return itemStack.getJavaId() == session.getItemMappings().getStoredItems().amethystShard(); + } } diff --git a/core/src/main/java/org/geysermc/geyser/inventory/item/StoredItemMappings.java b/core/src/main/java/org/geysermc/geyser/inventory/item/StoredItemMappings.java index 8f9eb415f..b50a9f7d5 100644 --- a/core/src/main/java/org/geysermc/geyser/inventory/item/StoredItemMappings.java +++ b/core/src/main/java/org/geysermc/geyser/inventory/item/StoredItemMappings.java @@ -38,6 +38,7 @@ import java.util.Map; @Getter @Accessors(fluent = true) public class StoredItemMappings { + private final int amethystShard; private final ItemMapping bamboo; private final ItemMapping banner; private final ItemMapping barrier; @@ -71,6 +72,7 @@ public class StoredItemMappings { private final ItemMapping writableBook; public StoredItemMappings(Map itemMappings) { + this.amethystShard = load(itemMappings, "amethyst_shard").getJavaId(); this.bamboo = load(itemMappings, "bamboo"); this.banner = load(itemMappings, "white_banner"); // As of 1.17.10, all banners have the same Bedrock ID this.barrier = load(itemMappings, "barrier");