3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-27 00:23:03 +01:00

Add delay to legacy recipe detection

Workaround for an issue which will be properly fixed later.
Dieser Commit ist enthalten in:
AJ Ferguson 2021-01-13 19:40:01 -09:00
Ursprung 5ddb189b48
Commit 4ee3143fe9
2 geänderte Dateien mit 8 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -151,6 +151,9 @@ public class GeyserSession implements CommandSender {
@Getter(AccessLevel.NONE) @Getter(AccessLevel.NONE)
private CompletableFuture<Void> inventoryFuture; private CompletableFuture<Void> inventoryFuture;
@Setter
private ScheduledFuture<?> craftingGridFuture;
/** /**
* Stores session collision * Stores session collision
*/ */

Datei anzeigen

@ -52,6 +52,7 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Objects; import java.util.Objects;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.TimeUnit;
@Translator(packet = ServerSetSlotPacket.class) @Translator(packet = ServerSetSlotPacket.class)
public class JavaSetSlotTranslator extends PacketTranslator<ServerSetSlotPacket> { public class JavaSetSlotTranslator extends PacketTranslator<ServerSetSlotPacket> {
@ -73,7 +74,10 @@ public class JavaSetSlotTranslator extends PacketTranslator<ServerSetSlotPacket>
InventoryTranslator translator = session.getInventoryTranslator(); InventoryTranslator translator = session.getInventoryTranslator();
if (translator != null) { if (translator != null) {
updateCraftingGrid(session, packet, inventory, translator); if (session.getCraftingGridFuture() != null) {
session.getCraftingGridFuture().cancel(false);
}
session.setCraftingGridFuture(session.getConnector().getGeneralThreadPool().schedule(() -> session.addInventoryTask(() -> updateCraftingGrid(session, packet, inventory, translator)), 150, TimeUnit.MILLISECONDS));
GeyserItemStack newItem = GeyserItemStack.from(packet.getItem()); GeyserItemStack newItem = GeyserItemStack.from(packet.getItem());
inventory.setItem(packet.getSlot(), newItem, session); inventory.setItem(packet.getSlot(), newItem, session);
@ -208,7 +212,6 @@ public class JavaSetSlotTranslator extends PacketTranslator<ServerSetSlotPacket>
} }
ShapedRecipeData data = new ShapedRecipeData(width, height, "", javaIngredients, packet.getItem()); ShapedRecipeData data = new ShapedRecipeData(width, height, "", javaIngredients, packet.getItem());
session.getConnector().getLogger().error(data.toString());
// Cache this recipe so we know the client has received it // Cache this recipe so we know the client has received it
session.getCraftingRecipes().put(newRecipeId, new Recipe(RecipeType.CRAFTING_SHAPED, uuid.toString(), data)); session.getCraftingRecipes().put(newRecipeId, new Recipe(RecipeType.CRAFTING_SHAPED, uuid.toString(), data));