From 36708da1d635054ac7bb060243f2d15e7b801cb4 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+DoctorMacc@users.noreply.github.com> Date: Sat, 25 Apr 2020 18:29:26 -0400 Subject: [PATCH] Add message when you try to use creative crafting table (#422) * Add message when you try to use creative crafting table * Update message; set access level --- .../translators/inventory/PlayerInventoryTranslator.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/PlayerInventoryTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/PlayerInventoryTranslator.java index c1e00d2a..4173b807 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/PlayerInventoryTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/PlayerInventoryTranslator.java @@ -31,6 +31,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientCreat import com.nukkitx.protocol.bedrock.data.*; import com.nukkitx.protocol.bedrock.packet.InventoryContentPacket; import com.nukkitx.protocol.bedrock.packet.InventorySlotPacket; +import it.unimi.dsi.fastutil.longs.LongArraySet; import org.geysermc.connector.inventory.Inventory; import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.translators.Translators; @@ -40,6 +41,9 @@ import org.geysermc.connector.utils.InventoryUtils; import java.util.List; public class PlayerInventoryTranslator extends InventoryTranslator { + + private static final LongArraySet HAS_RECEIVED_MESSAGE = new LongArraySet(); + public PlayerInventoryTranslator() { super(46); } @@ -164,6 +168,11 @@ public class PlayerInventoryTranslator extends InventoryTranslator { //crafting grid is not visible in creative mode in java edition for (InventoryActionData action : actions) { if (action.getSource().getContainerId() == ContainerId.CURSOR && (action.getSlot() >= 28 && 31 >= action.getSlot())) { + if (!HAS_RECEIVED_MESSAGE.contains(session.getPlayerEntity().getEntityId())) { + // TODO: Allow the crafting table to be used with non-standalone versions + session.sendMessage("The creative crafting table cannot be used as it's incompatible with Minecraft: Java Edition."); + HAS_RECEIVED_MESSAGE.add(session.getPlayerEntity().getEntityId()); + } updateInventory(session, inventory); InventoryUtils.updateCursor(session); return;