Skip to content

Commit

Permalink
Merge branch 'feature/inventory-updates' into bleeding
Browse files Browse the repository at this point in the history
  • Loading branch information
bundabrg committed Jul 26, 2020
2 parents 64d64e7 + 6034bef commit 7f205e8
Showing 1 changed file with 19 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,23 @@ 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 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);
}
Expand Down Expand Up @@ -106,10 +113,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 7f205e8

Please sign in to comment.