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 1/4] 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 98089ff277d..f7681f68936 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.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 void translate(ServerEntityStatusPacket packet, GeyserSession session) { EntityEventPacket entityEventPacket = new EntityEventPacket(); entityEventPacket.setRuntimeEntityId(entity.getGeyserId()); switch (packet.getStatus()) { + // EntityEventType.HURT sends extra data depending on the type of damage. However this appears to have no visual changes + case LIVING_BURN: case LIVING_DROWN: - entityEventPacket.setData(9); case LIVING_HURT: case LIVING_HURT_SWEET_BERRY_BUSH: entityEventPacket.setType(EntityEventType.HURT); @@ -88,7 +90,11 @@ public void translate(ServerEntityStatusPacket packet, GeyserSession session) { entityEventPacket.setType(EntityEventType.CONSUME_TOTEM); break; case SHEEP_GRAZE_OR_TNT_CART_EXPLODE: - entityEventPacket.setType(EntityEventType.PRIME_TNT_MINECART); + if (entity.getEntityType() == EntityType.SHEEP) { + entityEventPacket.setType(EntityEventType.EAT_GRASS); + } else { + entityEventPacket.setType(EntityEventType.PRIME_TNT_MINECART); + } break; case IRON_GOLEM_HOLD_POPPY: entityEventPacket.setType(EntityEventType.GOLEM_FLOWER_OFFER); From ad9184ad134eab9e8e1674a3cd78b181855d1443 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+DoctorMacc@users.noreply.github.com> Date: Wed, 22 Jul 2020 14:52:12 -0400 Subject: [PATCH 2/4] 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 c696479aa10..07aaaa19d64 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 void translateActions(GeyserSession session, Inventory inventory, List Date: Thu, 23 Jul 2020 14:37:14 -0400 Subject: [PATCH 3/4] 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 c7047a1e47b..f8e4eb6d07d 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 void translate(InventoryTransactionPacket packet, GeyserSession session) } // Handled in ITEM_USE - if (packet.getItemInHand() != null && packet.getItemInHand().getId() == ItemRegistry.BUCKET.getJavaId()) { + if (packet.getItemInHand() != null && packet.getItemInHand().getId() == ItemRegistry.BUCKET.getBedrockId()) { break; } From 5b1116b15a19f0b98568c95de03af4d59a40082a Mon Sep 17 00:00:00 2001 From: AJ Ferguson Date: Fri, 24 Jul 2020 11:42:15 -0800 Subject: [PATCH 4/4] Creative items (#1013) --- .../network/session/GeyserSession.java | 4 +-- .../translators/item/ItemRegistry.java | 28 +++++++++---------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java index d9aab3593f8..b861f64c437 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java @@ -234,9 +234,7 @@ public void connect(RemoteServer remoteServer) { upstream.sendPacket(entityPacket); CreativeContentPacket creativePacket = new CreativeContentPacket(); - for (int i = 0; i < ItemRegistry.CREATIVE_ITEMS.length; i++) { - creativePacket.getEntries().put(i + 1, ItemRegistry.CREATIVE_ITEMS[i]); - } + creativePacket.setContents(ItemRegistry.CREATIVE_ITEMS); upstream.sendPacket(creativePacket); PlayStatusPacket playStatusPacket = new PlayStatusPacket(); diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemRegistry.java b/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemRegistry.java index 33f640f1c67..142f1451167 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemRegistry.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemRegistry.java @@ -163,23 +163,23 @@ public static void init() { throw new AssertionError(LanguageUtils.getLocaleStringLog("geyser.toolbox.fail.creative"), e); } + int netId = 1; List creativeItems = new ArrayList<>(); for (JsonNode itemNode : creativeItemEntries) { - short damage = 0; - if (itemNode.has("damage")) { - damage = itemNode.get("damage").numberValue().shortValue(); - } - if (itemNode.has("nbt_b64")) { - byte[] bytes = Base64.getDecoder().decode(itemNode.get("nbt_b64").asText()); - ByteArrayInputStream bais = new ByteArrayInputStream(bytes); - try { - NbtMap tag = (NbtMap) NbtUtils.createReaderLE(bais).readTag(); - creativeItems.add(ItemData.of(itemNode.get("id").asInt(), damage, 1, tag)); - } catch (IOException e) { - e.printStackTrace(); + try { + short damage = 0; + NbtMap tag = null; + if (itemNode.has("damage")) { + damage = itemNode.get("damage").numberValue().shortValue(); } - } else { - creativeItems.add(ItemData.of(itemNode.get("id").asInt(), damage, 1)); + if (itemNode.has("nbt_b64")) { + byte[] bytes = Base64.getDecoder().decode(itemNode.get("nbt_b64").asText()); + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); + tag = (NbtMap) NbtUtils.createReaderLE(bais).readTag(); + } + creativeItems.add(ItemData.fromNet(netId++, itemNode.get("id").asInt(), damage, 1, tag)); + } catch (IOException e) { + e.printStackTrace(); } } CREATIVE_ITEMS = creativeItems.toArray(new ItemData[0]);