mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Fix crafting output not updating sometimes (#4692)
* Only cancel crafting grid future if slot == 0 * Add some comments
This commit is contained in:
parent
cb0488a271
commit
3570caae25
1 changed files with 8 additions and 4 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue