2

[1.13.1] How do you execute for an opened chest?

GeoDashPro's Avatar GeoDashPro8/31/18 12:51 am
2 emeralds 6.4k 1
8/31/2018 12:49 pm
ShelLuser's Avatar ShelLuser

I'm being a little evil and trying to make Mimics in my adventure map, but there's no option to execute for an opened chest or trapped chest, or anything. I've tried:




executing if the block "trapped_chest[]" but there was only "facing, waterlogged, type" and type only had "left right single"




nothing for being opened. I also looked for a scoreboard, like "opened (block)" but that doesn't exist either. At least, I couldn't find any.




Even then, that's still not helping considering if I were to have multiple mimics, how would I even pull that off without
triggering ALL of them when opening a single chest? Unless, the chest had set coords.




Really 1.13 commands has been driving me insane and I'm getting tired of this, so please, if you know, do answer.

I will get back to you whenever I can.




Also I was not putting the commands as described, I was just describing what I was doing, I know how to use execute.
Posted by GeoDashPro's Avatar
GeoDashPro
Level 12 : Journeyman Miner
1

Create an account or sign in to comment.

1

1
08/31/2018 12:49 pm
Level 57 : Grandmaster Engineer
ShelLuser
ShelLuser's Avatar
To be honest 1.13 didn't really change all that much here.

First there is a score which you can use: minecraft.custom:minecraft.open_chest. The only issue is that this is a scoreboard statistical setting which means that it's used for statistical purposes. If you want to actually use this you'd have to make sure to set this to 0 and then detect a change in value.

I also noticed minecraft.used:minecraft.chest but that is a rather tricky criteria; it only gets triggered when a chest is being placed (which I suppose accounts for using it) but it doesn't if the chest gets opened. Which seems odd because opening a chest also accounts to using, IMO at least. But it's no problem.

Also: you can't detect chest locations and such, but that's not different from 1.12 at all. Instead focus on the player location. For example you pinpoint the location to the chest and then check if the player is in a 1 - 3 block radius around it.

SO... let's try to get this to work (I'm going along as I'm writing, I think this is an interesting question. Note to self: add like to post ;)).

/scoreboard objectives add opchests minecraft.custom:minecraft.open_chest "Opened chest(s)"

So now the only thing I have to do is to check if my score went up. First I'll set up a command to actually check for my score (I always get a bit confused here, because this did change in comparison to 1.12):

/execute if score @p opchests matches 1 run say "Player opened his first chest!"

And you'll see that this works. But Minecraft wouldn't be Minecraft if we couldn't do more :-)

You mentioned (or at least hinted in this direction) about using memes based on which chest a player was opening. We can do that! All we need is to ensure that the player is in close proximity to the right chest location:

My experimental chest :)

I'm not going to bother myself with F3 and having to find "looking at" somewhere in there, that's bothersome! I just looked at the chest (crosshair) and then used: /data get block, and then used tab completion to get the right coordinates. Now I know what we need to check for :)

SO... First I need to show off a bit and make this worth my while:

/data merge block -321 56 215 {LootTable:"minecraft:chests/desert_pyramid"}

Now the chest will have interesting goodies in it when I open it (very important!) ;)

I reset my open chest score: /scoreboard players reset @p opchests and then place a repeating command block and add our previously used command, but with an extra section:

execute if score @p[x=-321,y=56,z=215,distance=..6] opchests matches 1 run say "Player opened the chest next to me!"

(I used a range up to 6 because I'm not sure from mind anymore at what distance you can open a chest, and I don't want to having to bother myself with resetting my score to find out, too much typing ;))

Of course we need another command to make sure that this doesn't run in an endless loop. Therefor I also added a chain command block which contains:

scoreboard players reset @p[x=-321,y=56,z=215,distance=..6] opchests

And what do you know:

Chest check

So not only did you check if a chest got opened, you also specifically know which chest it was, and thus can base your memes on that.

Another way to do this is to simply use a trapped chest and dump a command block below it:



So as you can see there's actually quite a lot which you can do here :)

Hope this helps!
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome