Minecraft – How to make Minecart Chests unmovable

minecraft-commandsminecraft-java-edition

I'm tying to make hidden chests in Minecraft. I found this code:

/summon MinecartChest ~ ~-1 ~.05 {CustomName:"Hidden Chest"}

Which summons a Minecart Chest In the block beneath [whoever's using the command]. So when you right click on it, it opens the Minecart Chest, with the name "Hidden Chest".

But there's a problem: If you go really close to the block (in particular, step on top of it), the Minecart is inside of the block moves downwards thus making it impossible to open it without breaking blocks.
I wonder if there's any way to prevent this?

Can I make it with the NoAI NBT tag?
I tried to spawn a skeleton without an AI, and then I couldn't move it.
But, when I tried to summon the Minecart Chest without AI, but it didn't work.
(Of course, Minecarts have no AI in the first place).

Best Answer

Try summoning a Minecart Chest riding placeholder entity.

/summon MinecartChest ~ ~-1 ~ {CustomName:"Hidden Chest",Riding:{id:Chicken,Invulnerable:1,NoAI:1,Silent:1,Age:-2147483648,ActiveEffects:[{Id:14,Amplifier:0,Duration:2147483647,ShowParticles:0b}]}}

Note: This command is too long to paste into chat, use command block instead.


Added information about Invincibility - See Making mobs invincible (David Toh's solution for more details) and http://minecraft.gamepedia.com/Chunk_format#Entity_format.