Adventure mode blocks not breakable?

spongeforge-1.10.2-2107-6.0.0-BETA-1873

Testing some things in single player, and I realize that in adventure mode you can not break any blocks.
I do know you have to use the right tool and all, but can not dig dirt with shovel, nor mine coal with a pick.
Works fine in survival mode.

There is no error, you simply have 0 affect on the blocks
This is with just sponge loaded, so no protection plugins etc, and no editing of the config as yet.

Isn’t that the point of Adventure mode?

1 Like

This is intended behavior for unmodified Minecraft.

In previous versions of Minecraft, you could break a block with the corresponding tool in adventure mode. However, in 1.8, this was changed. Now, you cannot break any blocks by default. To allow a tool to break a block, add the CanDestroy NBT tag to it. Placing blocks is similar; it requires the CanPlaceOn NBT tag on the block you want to place.

See here for the full details.

5 Likes

Yes, chalk this one up to brain malfunction, is there a forum section to report that?
When I pulled up the updated docs, I sadly found that adventure mode got raped by mojang.

Used to be a nice game mode for more realistic gameplay so people weren’t mining rocks with a wooden shovel etc, letting server plugins handle the don’t break or place anything here aspect of things.

Anyways, nothing to see here, just a babbling fool who know not what he speaketh.

@wiesshund, you should be able to write a plugin where you can modify the ItemStacks to allow them to break their normal blocks. In this case, using Data API and some event listeners. It shouldn’t be too difficult.

I’m interesting in building a set of plugins that work in Adventure mode.

I’ve been looking over the Data API. Perhaps it is just me, but that API is very difficult to understand and navigate (from a newbie plugin developer). I would have expected a less fluid and more constrained API since it appears that many things the API “lets me do” will not be persisted if the server can’t understand it. I get generic APIs, but this one feels overly open.

However, I’m getting a feel for it, and could possibly just be missing the “bigger picture”.

That being said, I can find no reference to a DataManipulator or method for modifying the “CanDestroy” NBT tag on an Item Stack (or the CanPlaceOn NBT tag on a Block). I also see no way to manipulate a NBT tag directly on an item stack or block (which would allow me to work around a missing portion of the API until such an API exists).

Can you show an example of how this might be done with version 5 of the API?

The DataManipulators are BreakableData and PlaceableData. The Keys are Keys.BREAKABLE_BLOCK_TYPES and Keys.PLACEABLE_BLOCKS.

Ideally, you shouldn’t work with NBT at all. However, if you really need to, set up ForgeGradle in your Gradle build script (you can’t use Maven for this), add a dependency on SpongeForge, and cast the Sponge ItemStack to the Minecraft ItemStack.

Thanks! How would I track down the BreakableData and PlaceableData on my own in the future? (Considering the names are nothing like the NBTTags, which is likely why I missed them).

Understood about the NBTTags. Generally I don’t want to do that and would only consider it to work around a missing piece of the API. I’m coming from Spigot / Bukkit (not Forge), but am looking to convert to Sponge. Still haven’t picked between SpongeVanilla, Spigot with SpongeBukkit or Glowstone for my current project.

Thanks again, that will help me a ton!

Just look through the interfaces and see if there’s anything that might fit.

Nowadays, it’s a lot easier to use Keys instead of DataManipulators in most cases. If you want to use those, just scan through the Keys class (this is a separate file) to find it.