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
This commit is contained in:
Camotoy 2020-04-25 18:29:26 -04:00 committed by GitHub
parent 74f869beb5
commit 36708da1d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -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;