From f47cf32d903c2822da814f17c33e0e6c5f2de851 Mon Sep 17 00:00:00 2001 From: DoctorMacc Date: Sat, 19 Dec 2020 19:19:44 -0500 Subject: [PATCH] Make my life tolerable --- .../translators/inventory/InventoryTranslator.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/InventoryTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/InventoryTranslator.java index 35bbb2cdd..52fb6e96c 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/InventoryTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/InventoryTranslator.java @@ -136,6 +136,10 @@ public abstract class InventoryTranslator { case PLACE: { TransferStackRequestActionData transferAction = (TransferStackRequestActionData) action; if (!(checkNetId(session, inventory, transferAction.getSource()) && checkNetId(session, inventory, transferAction.getDestination()))) { + if (session.getGameMode().equals(GameMode.CREATIVE) && transferAction.getSource().getContainer() == ContainerSlotType.CRAFTING_INPUT && + transferAction.getSource().getSlot() >= 28 && transferAction.getSource().getSlot() <= 31) { + return rejectRequest(request, false); + } session.getConnector().getLogger().error("DEBUG: About to reject request."); session.getConnector().getLogger().error("Source: " + transferAction.getSource().toString() + " Result: " + checkNetId(session, inventory, transferAction.getSource())); session.getConnector().getLogger().error("Destination: " + transferAction.getDestination().toString() + " Result: " + checkNetId(session, inventory, transferAction.getDestination())); @@ -504,7 +508,14 @@ public abstract class InventoryTranslator { } public static ItemStackResponsePacket.Response rejectRequest(ItemStackRequestPacket.Request request) { - new Throwable("DEBUGGING: ItemStackRequest rejected").printStackTrace(); //TODO: temporary debugging + return rejectRequest(request, true); + } + + public static ItemStackResponsePacket.Response rejectRequest(ItemStackRequestPacket.Request request, boolean throwError) { + if (throwError) { + // Currently for debugging, but might be worth it to keep in the future if something goes terribly wrong. + new Throwable("DEBUGGING: ItemStackRequest rejected").printStackTrace(); + } return new ItemStackResponsePacket.Response(ItemStackResponsePacket.ResponseStatus.ERROR, request.getRequestId(), Collections.emptyList()); }