From d03f56e7e89a6ed679cd0963fddbb4731fa397b5 Mon Sep 17 00:00:00 2001 From: bundabrg Date: Sun, 26 Jul 2020 11:06:06 +0800 Subject: [PATCH] Fix Merchant Inventory Transaction (#1017) --- .../MerchantInventoryTranslator.java | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/MerchantInventoryTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/MerchantInventoryTranslator.java index 37c84e28..64061739 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/MerchantInventoryTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/MerchantInventoryTranslator.java @@ -60,15 +60,23 @@ public class MerchantInventoryTranslator extends BaseInventoryTranslator { @Override public int bedrockSlotToJava(InventoryActionData action) { - if (action.getSource().getContainerId() == ContainerId.UI) { - switch (action.getSlot()) { - case 4: - return 0; - case 5: - return 1; - case 50: - return 2; - } + switch (action.getSource().getContainerId()) { + case ContainerId.UI: + switch (action.getSlot()) { + case 4: + return 0; + case 5: + return 1; + case 50: + return 2; + } + break; + case -28: // Trading 1? + return 0; + case -29: // Trading 2? + return 1; + case -30: // Trading Output? + return 2; } return super.bedrockSlotToJava(action); } @@ -109,10 +117,8 @@ public class MerchantInventoryTranslator extends BaseInventoryTranslator { @Override public void translateActions(GeyserSession session, Inventory inventory, List actions) { - for (InventoryActionData action : actions) { - if (action.getSource().getType() == InventorySource.Type.NON_IMPLEMENTED_TODO) { - return; - } + if (actions.stream().anyMatch(a -> a.getSource().getContainerId() == -31)) { + return; } super.translateActions(session, inventory, actions);