Hey there!
I've been working on a script to supply lootcrates every so often on a number of set locations. everything works perfectly except that when a person clicks the enderchest, it also OPENS it instead of just give the items to the player. Can someone help me so it doesn't OPEN the enderchest but still gives the items, this is what I have right now:
And there's a second problem, whenever I place a random enderchest, it treats it as if it was a spawned in one, like it also gives rewards from it.
Kind regards,
hasanas
I've been working on a script to supply lootcrates every so often on a number of set locations. everything works perfectly except that when a person clicks the enderchest, it also OPENS it instead of just give the items to the player. Can someone help me so it doesn't OPEN the enderchest but still gives the items, this is what I have right now:
Code:
variables:
{rewards::1} = stick
{rewards::2} = diamond
{rewards::3} = apple
command /chestspawn <integer>:
usage: /chestspawn <1-5>
trigger:
arg-1 is between 1 and 5:
set {location.%arg-1%.chestspawn} to player's location
send "Chestspawn %arg-1% created."
every 1 minute:
set {_random} to a random integer between 1 and 5
set block at {location.%{_random}%.chestspawn} to ender chest
broadcast "Chest spawned at %{location.%{_random}%.chestspawn}%"
on rightclick on ender chest:
loop integers between 1 and 5:
clicked block's location is {location.%loop-number%.chestspawn}
cancel event
if {LootCrate.open} is true:
message "&cSomeone else opened this crate already" to player
stop
else:
set {LootCrate.open} to true
wait 0.5 seconds
give player a random item out of {rewards::*}
launch burst firework colored blue at clicked block timed 0.1
play mob spawner flames at the targeted block to the player
wait 0.5 seconds
set {LootCrate.open} to false
And there's a second problem, whenever I place a random enderchest, it treats it as if it was a spawned in one, like it also gives rewards from it.
Kind regards,
hasanas