From 30c007d04bb755111ed18bc7fc1152cc454aaaed Mon Sep 17 00:00:00 2001 From: rtm516 Date: Tue, 21 Jul 2020 18:17:55 +0100 Subject: [PATCH 1/5] Fix buckets not working on mobile (#767) Desktop clients send an extra item use packet for buckets whereas mobile clients dont send the second use packet causing the issue as a ClientPlayerUseItemPacket doesn't get sent to the Java server. Buckets on mobile may still be glitchy as the player must be directly facing the block they want to place liquid on. --- ...BedrockInventoryTransactionTranslator.java | 20 ++++++++++++------- .../translators/item/ItemRegistry.java | 9 +++++++-- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInventoryTransactionTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInventoryTransactionTranslator.java index d4168709f..c7047a1e4 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInventoryTransactionTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInventoryTransactionTranslator.java @@ -36,12 +36,11 @@ import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlaye import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerInteractEntityPacket; import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPlaceBlockPacket; import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerUseItemPacket; -import com.nukkitx.math.vector.Vector3i; import com.nukkitx.math.vector.Vector3f; +import com.nukkitx.math.vector.Vector3i; import com.nukkitx.protocol.bedrock.data.LevelEventType; -import com.nukkitx.protocol.bedrock.packet.LevelEventPacket; import com.nukkitx.protocol.bedrock.packet.InventoryTransactionPacket; - +import com.nukkitx.protocol.bedrock.packet.LevelEventPacket; import org.geysermc.connector.entity.Entity; import org.geysermc.connector.entity.ItemFrameEntity; import org.geysermc.connector.entity.living.merchant.AbstractMerchantEntity; @@ -98,11 +97,11 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator ITEMS = new ArrayList<>(); public static final Int2ObjectMap ITEM_ENTRIES = new Int2ObjectOpenHashMap<>(); - // Shield ID, used in Entity.java - public static ItemEntry SHIELD; // Boat ID, used in BedrockInventoryTransactionTranslator.java public static ItemEntry BOAT; + // Gold ID, used in BedrockInventoryTransactionTranslator.java + public static ItemEntry BUCKET; // Gold ID, used in PiglinEntity.java public static ItemEntry GOLD; + // Shield ID, used in Entity.java + public static ItemEntry SHIELD; public static int BARRIER_INDEX = 0; @@ -138,6 +140,9 @@ public class ItemRegistry { case "minecraft:shield": SHIELD = ITEM_ENTRIES.get(itemIndex); break; + case "minecraft:bucket": + BUCKET = ITEM_ENTRIES.get(itemIndex); + break; default: break; } From 765efe8a33b6939d750af847ce9f6944e530940b Mon Sep 17 00:00:00 2001 From: ForceUpdate1 Date: Tue, 21 Jul 2020 22:01:55 +0200 Subject: [PATCH 2/5] Fix anvil item rename (#992) * fix anvil item rename * fix anvil item rename --- .../inventory/AnvilInventoryTranslator.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/AnvilInventoryTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/AnvilInventoryTranslator.java index d0d3db882..c696479aa 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/AnvilInventoryTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/AnvilInventoryTranslator.java @@ -32,6 +32,9 @@ import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientRenam import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.nukkitx.nbt.NbtMap; import com.nukkitx.protocol.bedrock.data.inventory.*; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import org.geysermc.connector.inventory.Inventory; import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.translators.inventory.updater.CursorInventoryUpdater; @@ -106,7 +109,9 @@ public class AnvilInventoryTranslator extends BlockInventoryTranslator { String rename; NbtMap tag = itemName.getTag(); if (tag != null) { - rename = tag.getCompound("display").getString("Name"); + String name = tag.getCompound("display").getString("Name"); + Component component = GsonComponentSerializer.gson().deserialize(name); + rename = LegacyComponentSerializer.legacy().serialize(component); } else { rename = ""; } @@ -138,8 +143,8 @@ public class AnvilInventoryTranslator extends BlockInventoryTranslator { CompoundTag displayTag = tag.get("display"); if (displayTag != null && displayTag.contains("Name")) { String itemName = displayTag.get("Name").getValue().toString(); - TextMessage message = (TextMessage) MessageSerializer.fromString(itemName); - rename = message.getText(); + Component component = GsonComponentSerializer.gson().deserialize(itemName); + rename = LegacyComponentSerializer.legacy().serialize(component); } else { rename = ""; } From b211b9da2e59e3e7556fb67cad8671acd2071bcf Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+DoctorMacc@users.noreply.github.com> Date: Wed, 22 Jul 2020 11:03:09 -0400 Subject: [PATCH 3/5] Update entity status mappings (#995) - Add support for LIVING_BURN entity status - Properly send sheep graze event --- .../java/entity/JavaEntityStatusTranslator.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityStatusTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityStatusTranslator.java index 98089ff27..f7681f689 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityStatusTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityStatusTranslator.java @@ -29,6 +29,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntit import com.nukkitx.protocol.bedrock.data.entity.EntityEventType; import com.nukkitx.protocol.bedrock.packet.EntityEventPacket; import org.geysermc.connector.entity.Entity; +import org.geysermc.connector.entity.type.EntityType; import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.translators.PacketTranslator; import org.geysermc.connector.network.translators.Translator; @@ -48,8 +49,9 @@ public class JavaEntityStatusTranslator extends PacketTranslator Date: Wed, 22 Jul 2020 14:52:12 -0400 Subject: [PATCH 4/5] Update Adventure-Legacy dependency (#996) --- .../translators/inventory/AnvilInventoryTranslator.java | 6 ++---- .../connector/network/translators/item/ItemTranslator.java | 2 +- .../item/translators/nbt/BasicItemTranslator.java | 4 ++-- .../java/org/geysermc/connector/utils/MessageUtils.java | 4 ++-- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/AnvilInventoryTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/AnvilInventoryTranslator.java index c696479aa..07aaaa19d 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/AnvilInventoryTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/AnvilInventoryTranslator.java @@ -26,8 +26,6 @@ package org.geysermc.connector.network.translators.inventory; import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; -import com.github.steveice10.mc.protocol.data.message.MessageSerializer; -import com.github.steveice10.mc.protocol.data.message.TextMessage; import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientRenameItemPacket; import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.nukkitx.nbt.NbtMap; @@ -111,7 +109,7 @@ public class AnvilInventoryTranslator extends BlockInventoryTranslator { if (tag != null) { String name = tag.getCompound("display").getString("Name"); Component component = GsonComponentSerializer.gson().deserialize(name); - rename = LegacyComponentSerializer.legacy().serialize(component); + rename = LegacyComponentSerializer.legacySection().serialize(component); } else { rename = ""; } @@ -144,7 +142,7 @@ public class AnvilInventoryTranslator extends BlockInventoryTranslator { if (displayTag != null && displayTag.contains("Name")) { String itemName = displayTag.get("Name").getValue().toString(); Component component = GsonComponentSerializer.gson().deserialize(itemName); - rename = LegacyComponentSerializer.legacy().serialize(component); + rename = LegacyComponentSerializer.legacySection().serialize(component); } else { rename = ""; } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemTranslator.java index 27c6c2625..e4b36efc4 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemTranslator.java @@ -162,7 +162,7 @@ public abstract class ItemTranslator { // If its not a message convert it if (!MessageUtils.isMessage(name)) { - TextComponent component = LegacyComponentSerializer.legacy().deserialize(name); + TextComponent component = LegacyComponentSerializer.legacySection().deserialize(name); name = GsonComponentSerializer.gson().serialize(component); } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/item/translators/nbt/BasicItemTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/item/translators/nbt/BasicItemTranslator.java index 34c7f43dc..b30031ebc 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/item/translators/nbt/BasicItemTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/item/translators/nbt/BasicItemTranslator.java @@ -108,8 +108,8 @@ public class BasicItemTranslator extends NbtItemStackTranslator { String message = tag.getValue(); if (message == null) return null; TextComponent component = (TextComponent) MessageUtils.phraseJavaMessage(message); - String legacy = LegacyComponentSerializer.legacy().serialize(component); - if (hasFormatting(LegacyComponentSerializer.legacy().deserialize(legacy))) { + String legacy = LegacyComponentSerializer.legacySection().serialize(component); + if (hasFormatting(LegacyComponentSerializer.legacySection().deserialize(legacy))) { return "§r" + legacy; } return legacy; diff --git a/connector/src/main/java/org/geysermc/connector/utils/MessageUtils.java b/connector/src/main/java/org/geysermc/connector/utils/MessageUtils.java index 90a21c345..21a5fa519 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/MessageUtils.java +++ b/connector/src/main/java/org/geysermc/connector/utils/MessageUtils.java @@ -259,7 +259,7 @@ public class MessageUtils { public static String getBedrockMessage(String message) { Component component = phraseJavaMessage(message); - return LegacyComponentSerializer.legacy().serialize(component); + return LegacyComponentSerializer.legacySection().serialize(component); } public static Component phraseJavaMessage(String message) { @@ -267,7 +267,7 @@ public class MessageUtils { } public static String getJavaMessage(String message) { - Component component = LegacyComponentSerializer.legacy().deserialize(message); + Component component = LegacyComponentSerializer.legacySection().deserialize(message); return GsonComponentSerializer.gson().serialize(component); } From b103d86ff94c0fc9003756e3a0104d133a600ad5 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+DoctorMacc@users.noreply.github.com> Date: Thu, 23 Jul 2020 14:37:14 -0400 Subject: [PATCH 5/5] Fix buckets on desktop survival (#1003) --- .../bedrock/BedrockInventoryTransactionTranslator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInventoryTransactionTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInventoryTransactionTranslator.java index c7047a1e4..f8e4eb6d0 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInventoryTransactionTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInventoryTransactionTranslator.java @@ -141,7 +141,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator