Trying to emulate 1.7's Adventure Mode

Discussion in 'Spigot Plugin Development' started by DemonicKai, Jun 19, 2015.

  1. Greetings everyone!
    I'm working on a plugin, and I'm having difficulty trying to figure out how to properly set NMS data whenever a player tries to break a block.
    I'm trying to have 1.8 clients adventure mode function exactly like 1.7's. Where, for example, you can break wood with an axe.
    But realistically, I want more than that. I want the entire 1.7 adventure mode back. Essentially, I want the tools to be able to break the right item / block.

    Can anyone help me with this? I'm at wits-end, getting a headache over this, and ready to throw my computer out the window.

    Can anyone help me with this, and post any code that may help me get started. Like, basic block breaking with NMS. Simply having (any type of) axe break the wood material would suffice, I can go from there.

    Also, I do not want to use commandblocks, as I have them completely disabled on the server and absolutely will not turn them on.

    Thank you.
  2. on block break
    can tool break block material
    if not, cancel event.
  3. I've tried that. To no avail.

    This is my code:
    Code (Text):

    if (player.getGameMode() == GameMode.ADVENTURE)


    if (isHoldingAxe(player) && isBreakingAxe(b.getType())) {
    ((NBTTagList) nmsItem.getTag().get("canDestroy")).add(new NBTTagString("minecraft:wood"));
    ((NBTTagList) nmsItem.getTag().get("canDestroy")).add(new NBTTagString("minecraft:workbench"));

    PacketPlayOutSetSlot packet = new PacketPlayOutSetSlot(0, player.getInventory().getHeldItemSlot(), nmsItem);

    ItemStack itemStack = new ItemStack(b.getType());


    if (isHoldingPick(player) && isBreakingPick(b.getType()))

    if (player.getItemInHand().equals(Material.SHEARS) && b.getType().equals(Material.WOOL))
    But really, I don't think I'm even doing this right. I've never played around with NMS before, so I'm a tad new to NMS specifically.