TransWikia.com

How can I allow placement of certain blocks in Minecraft adventure mode?

Arqade Asked by crgsqdmn on April 25, 2021

I’m making an adventure map in Minecraft and give the player a shovel that can break leaves, grass, and dirt. What I want to do is allow the player to place the blocks that he or she broke. Is this possible?

8 Answers

It is done using the CanPlaceOn tag:

For one tag: {CanPlaceOn:["minecraft:planks"]}

For multiple tags: {CanPlaceOn:["minecraft:planks","minecraft:stone"]}

So the command would look like:

/give APlayerName minecraft:stone 1 0 {CanPlaceOn:["minecraft:planks"]}

Answered by stopit25 on April 25, 2021

Using the Can Place On tag will work.
First, set this command:

{CanPlaceOn:[""]}

Fill in the brackets with an Minecraft Item Name:

{CanPlaceOn:["minecraft:Wool"]}

add an new bracket with an new Item Name to add more tags:

{CanPlaceOn:["minecraft:Wool","minecraft:sponge"]}

If you want an item to be able to break objects in adventure mode, use the Can Destroy command tag:

{CanDestroy:[""]}

and pretty much repeat the steps above:

{CanDestroy:["minecraft:dirt","minecraft:sand"]}

Answered by Rikri on April 25, 2021

I dont think you can do it for blocks that drop normally, but you can set up a trade system so your players can exchange the blocks they pick up for the same blocks that have the addition of being placeable

The trade system could be an NPC with a custom trade for the specific block, selling the block with the addition of being placeable, or even a filter system using hoppers that power a command block to give a player the block they put in with the placeable addition

I would supply code but I'm still a little new to this, I hope you can work it out!

Answered by Linkeyboy on April 25, 2021

You should use the CanDestroy tag for the shovel. This tag lets an item destroy whatever items listed and ONLY those items.

First, let's start with the /give command. For the shovel, it would be pretty simple:

/give @a minecraft:iron_shovel 1 0

Then, you would add the CanDestroy tag after that, which looks like this:

{CanDestroy:[""]}

To get it to work, you just put the name of the block you want between the "". For example, if you wanted to break specifically grass, it would look like this:

{CanDestroy:["minecraft:grass"]}

You can also extend the tag with commas, so you can select a group of blocks broken, and it will only break blocks in that group. To break grass, dirt, and leaves, it would look like this:

{CanDestroy:["minecraft:grass","minecraft:dirt","minecraft:leaves"]}

The tag is starting to look pretty long, but luckily, we don't need to do any more!

Now, all we need to do is attach the tag to the command:

/give @a minecraft:iron_shovel 1 0 {CanDestroy:["minecraft:grass","minecraft:dirt","minecraft:leaves"]}

And that's it! That command will give you an iron shovel that can only break grass, dirt, and leaves. If you wanted, you could also give the shovel the Unbreakable tag too, which makes it never take damage when in use. That would look like this:

/give @a minecraft:iron_shovel 1 0 {CanDestroy:["minecraft:grass","minecraft:dirt","minecraft:leaves"],Unbreakable:1}

Now, for placing the blocks. In adventure mode, there's no way to make a block be placed on any block. You could try to run a clock that checks for blocks in your inventory, and then replace those with blocks with the CanPlaceOn tag to place those on specific blocks, but that's pretty complicated. Placing down blocks with a CanPlaceOn tag won't work either, cause the tags go away when you break that block. So unfortunately, I don't think theres a solution to your problem..

Answered by Sir Chiggy on April 25, 2021

This if fairly easy to do, but the command required is very long.

The way you should do this, as other answers have already pointed out, is by putting CanPlaceOn tags onto the item. There's no easy way to do this once the items are already in the player's inventory, so instead you should do it for the dropped item entities with /data.

CanPlaceOn is also fairly annoying in that you need to name every single block you want to be able to place the block onto. I used the block name table from the Minecraft wiki, and wrote a script to convert the names into the right format.

Overall, the command you need to run on a fast clock is:

/data merge @e[type=Item] {Item:{tag:{CanPlaceOn:["minecraft:air","minecraft:stone","minecraft:grass","minecraft:dirt","minecraft:cobblestone","minecraft:planks","minecraft:sapling","minecraft:bedrock","minecraft:flowing_water","minecraft:water","minecraft:flowing_lava","minecraft:lava","minecraft:sand","minecraft:gravel","minecraft:gold_ore","minecraft:iron_ore","minecraft:coal_ore","minecraft:log","minecraft:leaves","minecraft:sponge","minecraft:glass","minecraft:lapis_ore","minecraft:lapis_block","minecraft:dispenser","minecraft:sandstone","minecraft:noteblock","minecraft:golden_rail","minecraft:detector_rail","minecraft:sticky_piston","minecraft:web","minecraft:tallgrass","minecraft:deadbush","minecraft:piston","minecraft:piston_head","minecraft:wool","minecraft:piston_extension","minecraft:yellow_flower","minecraft:red_flower","minecraft:brown_mushroom","minecraft:red_mushroom","minecraft:gold_block","minecraft:iron_block","minecraft:double_stone_slab","minecraft:stone_slab","minecraft:brick_block","minecraft:tnt","minecraft:bookshelf","minecraft:mossy_cobblestone","minecraft:obsidian","minecraft:torch","minecraft:fire","minecraft:mob_spawner","minecraft:oak_stairs","minecraft:chest","minecraft:redstone_wire","minecraft:diamond_ore","minecraft:diamond_block","minecraft:crafting_table","minecraft:farmland","minecraft:furnace","minecraft:lit_furnace","minecraft:standing_sign","minecraft:ladder","minecraft:rail","minecraft:stone_stairs","minecraft:wall_sign","minecraft:lever","minecraft:stone_pressure_plate","minecraft:wooden_pressure_plate","minecraft:redstone_ore","minecraft:lit_redstone_ore","minecraft:unlit_redstone_torch","minecraft:redstone_torch","minecraft:stone_button","minecraft:snow_layer","minecraft:ice","minecraft:snow","minecraft:cactus","minecraft:clay","minecraft:jukebox","minecraft:fence","minecraft:pumpkin","minecraft:netherrack","minecraft:soul_sand","minecraft:glowstone","minecraft:portal","minecraft:lit_pumpkin","minecraft:unpowered_repeater","minecraft:powered_repeater","minecraft:stained_glass","minecraft:trapdoor","minecraft:monster_egg","minecraft:stonebrick","minecraft:brown_mushroom_block","minecraft:red_mushroom_block","minecraft:iron_bars","minecraft:glass_pane","minecraft:melon_block","minecraft:pumpkin_stem","minecraft:melon_stem","minecraft:vine","minecraft:fence_gate","minecraft:brick_stairs","minecraft:stone_brick_stairs","minecraft:mycelium","minecraft:waterlily","minecraft:nether_brick","minecraft:nether_brick_fence","minecraft:nether_brick_stairs","minecraft:enchanting_table","minecraft:end_portal","minecraft:end_portal_frame","minecraft:end_stone","minecraft:dragon_egg","minecraft:redstone_lamp","minecraft:lit_redstone_lamp","minecraft:double_wooden_slab","minecraft:wooden_slab","minecraft:cocoa","minecraft:sandstone_stairs","minecraft:emerald_ore","minecraft:ender_chest","minecraft:tripwire_hook","minecraft:tripwire","minecraft:emerald_block","minecraft:spruce_stairs","minecraft:birch_stairs","minecraft:jungle_stairs","minecraft:command_block","minecraft:beacon","minecraft:cobblestone_wall","minecraft:wooden_button","minecraft:anvil","minecraft:trapped_chest","minecraft:light_weighted_pressure_plate","minecraft:heavy_weighted_pressure_plate","minecraft:unpowered_comparator","minecraft:powered_comparator","minecraft:daylight_detector","minecraft:redstone_block","minecraft:quartz_ore","minecraft:hopper","minecraft:quartz_block","minecraft:quartz_stairs","minecraft:activator_rail","minecraft:dropper","minecraft:stained_hardened_clay","minecraft:stained_glass_pane","minecraft:log2","minecraft:log2","minecraft:acacia_stairs","minecraft:dark_oak_stairs","minecraft:slime","minecraft:barrier","minecraft:iron_trapdoor","minecraft:prismarine","minecraft:sea_lantern","minecraft:hay_block","minecraft:carpet","minecraft:hardened_clay","minecraft:coal_block","minecraft:packed_ice","minecraft:double_plant","minecraft:prismarine","minecraft:barrier","minecraft:red_sandstone","minecraft:sea_lantern","minecraft:iron_trapdoor"],HideFlags:16}}}

Answered by SirBenet on April 25, 2021

This is just a suggestion but dont be angry if it doesnt work but try to make the block u want to mine already has the tag like {CanPlaceOn:["minecraft________"]}and tag the item ure gonna mine has the tag that can be placed on the block that it needs to be placed on so that u wont have a problem on placing the blocks on the wrong block

Hope It Helped

Answered by Slayer_500 on April 25, 2021

I would make it so after a block breaks and you pick it up the item replaces itself with the same item, but with the CanPlaceOn tag. This tag would have the block(s) you would place it on. I personally have no idea how to do such a thing, but I bet someone else would have the ability to explain it, or there is a video on how to do it as well. Hope this helps.

Answered by HSHtheWarrior on April 25, 2021

You may do this command for an adventure map:

/give @s minecraft:oak_button{CanPlaceOn:["minecraft:diamond_block"]}

This gives you an oak button that is only placeable on a block of diamond.

Answered by Jack Riordan on April 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP