mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-11-21 22:36:18 +01:00
Fix smithing recipes on 1.21.1
This commit is contained in:
parent
e645935533
commit
fd58c729d8
2 changed files with 13 additions and 1 deletions
|
@ -31,6 +31,7 @@ import org.geysermc.geyser.inventory.Inventory;
|
|||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.translator.inventory.InventoryTranslator;
|
||||
import org.geysermc.geyser.translator.inventory.PlayerInventoryTranslator;
|
||||
import org.geysermc.geyser.translator.inventory.SmithingInventoryTranslator;
|
||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||
import org.geysermc.geyser.translator.protocol.Translator;
|
||||
import org.geysermc.geyser.util.InventoryUtils;
|
||||
|
@ -74,6 +75,17 @@ public class JavaContainerSetContentTranslator extends PacketTranslator<Clientbo
|
|||
|
||||
session.getPlayerInventory().setCursor(GeyserItemStack.from(packet.getCarriedItem()), session);
|
||||
InventoryUtils.updateCursor(session);
|
||||
|
||||
if (session.getInventoryTranslator() instanceof SmithingInventoryTranslator) {
|
||||
// On 1.21.1, the recipe output is sometimes only updated here.
|
||||
// This can be replicated with shift-clicking the last item into the smithing table.
|
||||
// It seems that something in Via 5.1.1 causes 1.21.3 clients - even Java ones -
|
||||
// to make the server send a slot update.
|
||||
// That plus shift-clicking means that the state ID becomes outdated and forces
|
||||
// a complete inventory update.
|
||||
JavaContainerSetSlotTranslator.updateSmithingTableOutput(session, SmithingInventoryTranslator.OUTPUT,
|
||||
packet.getItems()[SmithingInventoryTranslator.OUTPUT], inventory);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateInventory(GeyserSession session, Inventory inventory, int containerId) {
|
||||
|
|
|
@ -224,7 +224,7 @@ public class JavaContainerSetSlotTranslator extends PacketTranslator<Clientbound
|
|||
}, 150, TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
||||
private static void updateSmithingTableOutput(GeyserSession session, int slot, ItemStack output, Inventory inventory) {
|
||||
static void updateSmithingTableOutput(GeyserSession session, int slot, ItemStack output, Inventory inventory) {
|
||||
if (slot != SmithingInventoryTranslator.OUTPUT) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue