0

I have an adventure map with restocking chests. The cycle I have them on are activated by a daylight sensor which is connected to a series of command blocks. The following will be my command example:

Redstone trail leads to first command block with the command:

/blockdata -54 135 191 {Items:[]}

Restone trail continues to next command block after a redstone repeater delay. The next command is:

 /setblock -54 135 191 minecraft:air 0 destroy

Restone circuit finishes at a final command block after yet another redstone repeater delay. The final command is:

 /setblock -54 135 191 chest 0 replace
{LootTable:"mctools:chests/overworld lvl 1"}

(this is a custom loot table I created)

Also, here is a visual of my circuit. The current flows from right to left: enter image description here

So, what happens is the chest that was previously placed has its items destroyed, then the chest itself is destroyed, and finally a new chest with new loot is placed. This is what I want. The problem here is that this only works when my character is relatively close to the chest targeted when the commands are activated. If I back away, and then come back, the loot that was in the chest before the new chest was placed is all over the ground! I want the items to be destroyed not on the ground. It appears /blockdata ~ ~ ~ {Items:[]} doesn't work if the player is a distance away from the targeted chest. Like the items won't delete at a distance. Please explain this problem and how to fix it.

  • Oh god what are you doing? You should, at all costs, avoid redstone in your command blocks whenever possible! You don't need the daylight detectors (check the time with a command block) and you certainly don't need the repeaters. In fact, you should probably be doing this within functions now. – MBraedley Jul 17 '17 at 23:27
  • And actually, this might be a better way of checking the time. – MBraedley Jul 17 '17 at 23:44
  • 1
    If he's doing a very simple task and wants to run it once per day, this is completely ok. – Fabian Röling Jul 18 '17 at 5:36
1

When the oldBlockHandlingValue on the /setblock command is destroy, the block will drop itself and its contents (Unless gamerules prohibit it). However, if you use replace instead, the chest will drop neither itself nor its contents.

Also, using redstone with command blocks is an excellent way to start learning command blocks. You'll eventually want to learn about chain and repeating command blocks and functions, and certainly use functions for anything large scale, but using just normal command blocks for small things, learning and experimenting is fine.

  • Do you also have an idea about why blockdata stops working? I know that block entities only render close to the player, but isn't this only client side? – Fabian Röling Jul 18 '17 at 5:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy