Trapped Chest Opening Replication

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

GuacamoleGuy

New Member
Apr 21, 2018
7
0
0
One of my core plugins prevents trapped chests from being opened normally with sounds and the chest opening animation altogether. I'm trying to create a workaround to this issue, though the aforementioned plugin also prevents Skript from detecting the opening of trapped chests.

code_language.skript:
on inventory open:
    if event-inventory's display name contains "Chest":
        loop blocks in front of the player's eyes:
            if loop-block is a trapped chest:
                play "BLOCK_CHEST_OPEN" to player at volume 3
                play chest open animation at loop-block for all players

on inventory close:
    if event-inventory's display name contains "Chest":
        loop blocks in front of the player's eyes:
            if loop-block is a trapped chest:
                play "BLOCK_CHEST_CLOSE" to player at volume 3
                play chest close animation at loop-block for all players

My current solution has three known flaws:
- Multiple trapped chests can appear to be opened if more than one is in the player's line of sight
- Sounds are only played to the player opening the trapped chest
- Chest will not close if the player's line of sight changes after opening the trapped chest

Current Addons:
Skellett, skRayFall
 
instead of doing this:
code_language.skript:
loop blocks in front of the player's eyes:
            if loop-block is a trapped chest:
maybe try something like "if target block is___" and use target block for things instead of loop block?
[doublepost=1524348215,1524348021][/doublepost]Here's a cleaner version of what I was thinking
code_language.skript:
on inventory open:
    if targeted block is trapped chest:
        play "BLOCK_CHEST_OPEN" to player at volume 3
        play chest open animation at event-block for all players
[doublepost=1524348468][/doublepost]if that doesn't work, try "on right-click on a chest" instead of "on inventory open"
 
instead of doing this:
code_language.skript:
loop blocks in front of the player's eyes:
            if loop-block is a trapped chest:
maybe try something like "if target block is___" and use target block for things instead of loop block?
[doublepost=1524348215,1524348021][/doublepost]Here's a cleaner version of what I was thinking
code_language.skript:
on inventory open:
    if targeted block is trapped chest:
        play "BLOCK_CHEST_OPEN" to player at volume 3
        play chest open animation at event-block for all players
[doublepost=1524348468][/doublepost]if that doesn't work, try "on right-click on a chest" instead of "on inventory open"
After replacing "event-block" with "target block," your version did solve the thing where multiple chests could be opened. The other two problems I listed remain though. I appreciate the help! :emoji_slight_smile:
 
Glad to help

Okay try something like this. I set a temporary location of the chest for the player. So when they close, it'll play the animation at that location and then delete that location. Its probably not the best way to do this, but this might just work. Im not 100% sure if that sound part will work though
code_language.skript:
on inventory open:
    if targeted block is trapped chest:
        loop all players in radius 10 around player:
            play "BLOCK_CHEST_OPEN" to loop-player at volume 3
        play chest open animation at event-block for all players
        set {currentchest.%player%} to location of targeted block

on inventory close:
    if {currentchest.%player%} is set:
        play chest close animation at {currentchest.%player%} for all players
        loop all players in radius 10 around player:
            play "BLOCK_CHEST_CLOSE" to loop-player at volume 3
        delete {currentchest.%player%}
 
Glad to help

Okay try something like this. I set a temporary location of the chest for the player. So when they close, it'll play the animation at that location and then delete that location. Its probably not the best way to do this, but this might just work. Im not 100% sure if that sound part will work though
code_language.skript:
on inventory open:
    if targeted block is trapped chest:
        loop all players in radius 10 around player:
            play "BLOCK_CHEST_OPEN" to loop-player at volume 3
        play chest open animation at event-block for all players
        set {currentchest.%player%} to location of targeted block

on inventory close:
    if {currentchest.%player%} is set:
        play chest close animation at {currentchest.%player%} for all players
        loop all players in radius 10 around player:
            play "BLOCK_CHEST_CLOSE" to loop-player at volume 3
        delete {currentchest.%player%}
The sound part works, chest closing animation part doesn't. No errors, so I'm not sure why it isn't working (looks like it should).

Also, because this method is relying on the targeted block, the Skript won't work for chests being opened through water.
 
hmm.... that is odd, youre right it does look like it should work, ill keep brainstorming.
ok, instead of targeted block, you could try event block, since the event block would be the chest itself
 
Well EFF YOU EVENT BLOCK....
oh dear, ok, hm.... back to the thinking board
 
Yeeeep.

"Can't compare 'event block' with an item type" - Even if we fixed this, the plugin I'm using stops the trapped chest opening event entirely so using the event block wouldn't work.
 
side note... your core plugin that is disabling that function, couldn't you disable it?
 
side note... your core plugin that is disabling that function, couldn't you disable it?
Disabling the plugin would let trapped chests work normally, but having the plugin is definitely necessary for what I'm trying to accomplish. The plugin's author is currently inactive so I can't contact him about it, hence why I'm trying to find a workaround with Skript :/
 
I would suggest disabling that feature and then writing a skript to block trapped chests (I’ve done that, it’s easy) with players without permission
 
Status
Not open for further replies.