3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-04 23:30:17 +01:00

Update inventory if request was rejected

Dieser Commit ist enthalten in:
AJ Ferguson 2021-01-13 19:59:11 -09:00
Ursprung 4ee3143fe9
Commit 95703d2ea7

Datei anzeigen

@ -151,28 +151,39 @@ public abstract class InventoryTranslator {
}
public void translateRequests(GeyserSession session, Inventory inventory, List<ItemStackRequestPacket.Request> requests) {
boolean refresh = false;
ItemStackResponsePacket responsePacket = new ItemStackResponsePacket();
for (ItemStackRequestPacket.Request request : requests) {
ItemStackResponsePacket.Response response;
if (request.getActions().length > 0) {
StackRequestActionData firstAction = request.getActions()[0];
if (shouldHandleRequestFirst(firstAction, inventory)) {
// Some special request that shouldn't be processed normally
responsePacket.getEntries().add(translateSpecialRequest(session, inventory, request));
response = translateSpecialRequest(session, inventory, request);
} else if (firstAction.getType() == StackRequestActionType.CRAFT_RECIPE) {
responsePacket.getEntries().add(translateCraftingRequest(session, inventory, request));
response = translateCraftingRequest(session, inventory, request);
} else if (firstAction.getType() == StackRequestActionType.CRAFT_RECIPE_AUTO) {
responsePacket.getEntries().add(translateAutoCraftingRequest(session, inventory, request));
response = translateAutoCraftingRequest(session, inventory, request);
} else if (firstAction.getType() == StackRequestActionType.CRAFT_CREATIVE) {
// This is also used for pulling items out of creative
responsePacket.getEntries().add(translateCreativeRequest(session, inventory, request));
response = translateCreativeRequest(session, inventory, request);
} else {
responsePacket.getEntries().add(translateRequest(session, inventory, request));
response = translateRequest(session, inventory, request);
}
} else {
responsePacket.getEntries().add(rejectRequest(request));
response = rejectRequest(request);
}
if (response.getResult() == ItemStackResponsePacket.ResponseStatus.ERROR) {
refresh = true;
}
responsePacket.getEntries().add(response);
}
session.sendUpstreamPacket(responsePacket);
if (refresh) {
InventoryUtils.updateCursor(session);
updateInventory(session, inventory);
}
}
public ItemStackResponsePacket.Response translateRequest(GeyserSession session, Inventory inventory, ItemStackRequestPacket.Request request) {