From cdab1ce5ec32d69c29f5119cb1cc7703177ac21f Mon Sep 17 00:00:00 2001 From: AJ Ferguson Date: Sat, 7 Dec 2019 14:56:00 -0900 Subject: [PATCH] Translate window properties Furnace and brewing stand --- .../BrewingStandInventoryTranslator.java | 17 +++++++++++++---- .../inventory/FurnaceInventoryTranslator.java | 13 ++++++++----- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/BrewingStandInventoryTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/BrewingStandInventoryTranslator.java index e6089cb81..91f9d3270 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/BrewingStandInventoryTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/BrewingStandInventoryTranslator.java @@ -36,22 +36,31 @@ public class BrewingStandInventoryTranslator extends BlockInventoryTranslator { super(5, 117 << 4, ContainerType.BREWING_STAND); } + @Override + public void openInventory(GeyserSession session, Inventory inventory) { + super.openInventory(session, inventory); + ContainerSetDataPacket dataPacket = new ContainerSetDataPacket(); + dataPacket.setWindowId((byte) inventory.getId()); + dataPacket.setProperty(ContainerSetDataPacket.BREWING_STAND_FUEL_TOTAL); + dataPacket.setValue(20); + session.getUpstream().sendPacket(dataPacket); + } + @Override public void updateProperty(GeyserSession session, Inventory inventory, int key, int value) { - //bedrock protocol library is currently missing property mappings for windows. ContainerSetDataPacket dataPacket = new ContainerSetDataPacket(); dataPacket.setWindowId((byte) inventory.getId()); switch (key) { case 0: - dataPacket.setProperty(ContainerSetDataPacket.Property.BREWING_STAND_BREW_TIME); + dataPacket.setProperty(ContainerSetDataPacket.BREWING_STAND_BREW_TIME); break; case 1: - dataPacket.setProperty(ContainerSetDataPacket.Property.BREWING_STAND_FUEL_AMOUNT); + dataPacket.setProperty(ContainerSetDataPacket.BREWING_STAND_FUEL_AMOUNT); break; default: return; } - dataPacket.setValue((short) value); + dataPacket.setValue(value); session.getUpstream().sendPacket(dataPacket); } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/FurnaceInventoryTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/FurnaceInventoryTranslator.java index 95d785623..12a634ffd 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/FurnaceInventoryTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/FurnaceInventoryTranslator.java @@ -25,6 +25,7 @@ package org.geysermc.connector.network.translators.inventory; +import com.github.steveice10.mc.protocol.data.game.window.WindowType; import com.nukkitx.protocol.bedrock.data.ContainerType; import com.nukkitx.protocol.bedrock.packet.ContainerSetDataPacket; import org.geysermc.connector.inventory.Inventory; @@ -37,23 +38,25 @@ public class FurnaceInventoryTranslator extends BlockInventoryTranslator { @Override public void updateProperty(GeyserSession session, Inventory inventory, int key, int value) { - //bedrock protocol library is currently missing property mappings for windows. only the furnace arrow will update for now ContainerSetDataPacket dataPacket = new ContainerSetDataPacket(); dataPacket.setWindowId((byte) inventory.getId()); switch (key) { case 0: - dataPacket.setProperty(ContainerSetDataPacket.Property.FURNACE_LIT_TIME); + dataPacket.setProperty(ContainerSetDataPacket.FURNACE_LIT_TIME); break; case 1: - dataPacket.setProperty(ContainerSetDataPacket.Property.FURNACE_LIT_DURATION); + dataPacket.setProperty(ContainerSetDataPacket.FURNACE_LIT_DURATION); break; case 2: - dataPacket.setProperty(ContainerSetDataPacket.Property.FURNACE_TICK_COUNT); + dataPacket.setProperty(ContainerSetDataPacket.FURNACE_TICK_COUNT); + if (inventory.getWindowType() == WindowType.BLAST_FURNACE || inventory.getWindowType() == WindowType.SMOKER) { + value *= 2; + } break; default: return; } - dataPacket.setValue((short) value); + dataPacket.setValue(value); session.getUpstream().sendPacket(dataPacket); }