3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-07-06 05:18:06 +02:00

Fix crafting output not updating sometimes (#4692)

* Only cancel crafting grid future if slot == 0

* Add some comments
Dieser Commit ist enthalten in:
Valaphee The Meerkat 2024-05-27 16:53:42 +02:00 committet von GitHub
Ursprung cb0488a271
Commit 3570caae25
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194

Datei anzeigen

@ -71,10 +71,6 @@ public class JavaContainerSetSlotTranslator extends PacketTranslator<Clientbound
InventoryTranslator translator = session.getInventoryTranslator(); InventoryTranslator translator = session.getInventoryTranslator();
if (translator != null) { if (translator != null) {
if (session.getCraftingGridFuture() != null) {
session.getCraftingGridFuture().cancel(false);
}
int slot = packet.getSlot(); int slot = packet.getSlot();
if (slot >= inventory.getSize()) { if (slot >= inventory.getSize()) {
GeyserLogger logger = session.getGeyser().getLogger(); GeyserLogger logger = session.getGeyser().getLogger();
@ -111,14 +107,22 @@ public class JavaContainerSetSlotTranslator extends PacketTranslator<Clientbound
* Checks for a changed output slot in the crafting grid, and ensures Bedrock sees the recipe. * Checks for a changed output slot in the crafting grid, and ensures Bedrock sees the recipe.
*/ */
private static void updateCraftingGrid(GeyserSession session, int slot, ItemStack item, Inventory inventory, InventoryTranslator translator) { private static void updateCraftingGrid(GeyserSession session, int slot, ItemStack item, Inventory inventory, InventoryTranslator translator) {
// Check if it's the crafting grid result slot.
if (slot != 0) { if (slot != 0) {
return; return;
} }
// Check if there is any crafting grid.
int gridSize = translator.getGridSize(); int gridSize = translator.getGridSize();
if (gridSize == -1) { if (gridSize == -1) {
return; return;
} }
// Only process the most recent crafting grid result, and cancel the previous one.
if (session.getCraftingGridFuture() != null) {
session.getCraftingGridFuture().cancel(false);
}
if (InventoryUtils.isEmpty(item)) { if (InventoryUtils.isEmpty(item)) {
return; return;
} }