Skip to content

Commit

Permalink
Fix Merchant Inventory Transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
bundabrg committed Jul 25, 2020
1 parent 5c13a67 commit bf7cf49
Showing 1 changed file with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

import com.nukkitx.protocol.bedrock.data.inventory.ContainerId;
import com.nukkitx.protocol.bedrock.data.inventory.InventoryActionData;
import com.nukkitx.protocol.bedrock.data.inventory.InventorySource;
import org.geysermc.connector.inventory.Inventory;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.inventory.updater.CursorInventoryUpdater;
Expand Down Expand Up @@ -60,15 +59,13 @@ public int javaSlotToBedrock(int slot) {

@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 -28: // Trading 1?
return 0;
case -29: // Trading 2?
return 1;
case -30: // Trading Output?
return 2;
}
return super.bedrockSlotToJava(action);
}
Expand Down Expand Up @@ -106,10 +103,8 @@ public void updateSlot(GeyserSession session, Inventory inventory, int slot) {

@Override
public void translateActions(GeyserSession session, Inventory inventory, List<InventoryActionData> 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);
Expand Down

0 comments on commit bf7cf49

Please sign in to comment.