• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
  • Minecraft 1.16.220 Update + Bug/Crash Fixes
    Added MCPE 1.16.220 version and fixed crashes for multiple plugins. You can view the full changelist here.
  • Forum Updates - 4/11/2021
    Various changes have been made to the forums and a few categories. You can view the full changelist here.

Auto-close doors

Warning!
Hello , there have been no replies in this thread for more than 30 days.
Please make sure you have a valid reason before you reply to this thread or you may face moderation action.

madhon

MadCommands Dev
#1
Use this procedure as a touch even trigger to have door automatically close 1 second after opening.
Should work with all kinds of doors, even trapdoors.



Limitation: the door will close silently as MadCommands currently does not support sounds at the time I am writing this.

To create the command, simply copy and paste this to RCON (in the game you have to add forward slash to the beginning of each line):

Code:
cmd create closedoor
cmd edit closedoor 1 # Close door 1 second after opening (touch event trigger handler)
cmd edit closedoor 2 let %ll% = %args%[3]
cmd edit closedoor 3 let %xx% = %args%[4]
cmd edit closedoor 4 let %yy% = %args%[5]
cmd edit closedoor 5 let %zz% = %args%[6]
cmd edit closedoor 6 let %block% = blockinfo(%ll%, %xx%, %yy%, %zz%)
cmd edit closedoor 7 if \"door\" notin lowercase(%block%[\"name\"]) then exit
cmd edit closedoor 8 if (%block%[\"variant\"] < 8) or (\"trap\" in lowercase(%block%[\"name\"])) then goto 11
cmd edit closedoor 9 let %yy% = %yy% - 1
cmd edit closedoor 10 let %block% = blockinfo(%ll%, %xx%, %yy%, %zz%)
cmd edit closedoor 11 let %variant% = %block%[\"variant\"]
cmd edit closedoor 12 if %variant% > 7 then let %variant% = %variant% - 8
cmd edit closedoor 13 if %variant% > 3 then let %variant% = %variant% - 4
cmd edit closedoor 14 if %block%[\"variant\"] > 7 then let %variant% = %variant% + 8
cmd edit closedoor 15 let %door% = %block%[\"id\"]
cmd edit closedoor 16 sleep 1
cmd edit closedoor 17 block %ll% %xx% %yy% %zz% %door%:%variant%
If you have new commands disabled by default, don't forget to enable it:

Code:
cmd enable closedoor
Do not register the procedure as a new command, unless you want to use it to close door at specified position manually.

Now simply set this to be used as a touch event trigger:

Code:
cmd trigger touch closedoor
If you already have a touch event trigger and don't want to remove it, you can add these lines to it to call closedoor after your own trigger:

Code:
let %params% = join(%args%[1+], \" \")
/cmd run closedoor touch %params%