I accidentally came across some strange locking behavior in vanilla Minecraft. It works per-container so some can be made locked and others not. It works for all tile entity containers except for chests and jukeboxes (It kinda works for chests, but instead of not letting you open it, it just crashes the game).
All you need to lock a container is a simple NBT editor that can edit the tags of blocks placed in the world.
You just edit the the coordinates in the root directory of the block to different coordinates. Try to make the coordinates be somewhere that you will probably not place any bocks. Ill get back to this later.
When you try to open a locked container by right clicking it, nothing happens and the selection screen doesn't open. Locked droppers and dispensers can still shoot items out with a redstone signal. You can lock both non-burning furnaces and burning furnaces, but when a locked furnace is supposed to stop burning (if it isn't a custom one that burns forever) it creates a glitchy furnace with no mouth in the specified coordinates and if there is already a tile entity in that spot, it crashes the game, and perhaps even corrupts the world if you aren't lucky. It keeps burning even after the other furnace is created.
Items can be put into the containers and taken out with hoppers and droppers, and it doesn't seem to affect whether the container is locked or not.
Locked containers can be broken by hand and the items will pop out without any problem.
Things this could be useful are:
- Decorational furnaces and dispensers
-Dispensers that shoot projectiles that you can't collect from and disable
-A way to crash the game automatically with redstone and hoppers:
Hopper items into a locked furnace and start smelting them and set up a non-furnace tile entity in the spot of the coordinates and wait for the furnace to stop smelting.