Date: 2020/06/27 23:51:06 UTC-07:00
Type: Denizen Script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#Script: 1.0.6
#Author: Icecapade
#Date 2020-06-28
IcecapadeCrates_Config:
type: data
#Show Tripwires (does not affect existing crates)
show_tripwire: true
chests:
lightChestName: <green>Light
mediumChestName: <yellow>Medium
heavyChestName: <red>Heavy
#In that list diamonds have a chance of 2%, iron_ingots 8% and dirt has a chance of 30%. The remaining 60% have no result.
#Works also with decimals. Start with the lowest value.
#Format "<chance>: <item>"
lightChestItems:
2: <item[diamond]>
10: <item[iron_ingot]>
40: <item[dirt].with[quantity=12]>
mediumChestItems:
0.01: <item[diamond_block].with[quantity=64]>
1.25: <item[beacon]>
25: <item[iron_ingot].with[quantity=8]>
heavyChestItems:
10: "<item[diamond_sword].with[enchantments=sharpness,4|fire_aspect,1;display_name=<aqua>Fire Sword]>"
IcecapadeCrates_Command:
type: command
debug: false
name: crates
description: Creates Crates
usage: /crates [Light/Medium/Heavy] (key) <<>#<>>
aliases:
- crate
permission: icecapade.crates
permission message: <&3>You need the permission <&b><permission> <&3>to use that command!
tab complete:
- choose <context.args.size>:
- case 0:
- determine <list[light|medium|heavy]>
- case 1:
- if "!<context.raw_args.ends_with[ ]>":
- determine <list[light|medium|heavy].filter[starts_with[<context.args.first>]]>
- else:
- determine key
- case 2:
- if "!<context.raw_args.ends_with[ ]>":
- determine key
script:
- choose <context.args.first||null>:
- case light medium heavy:
- if <context.args.get[2]||false> == key && <context.args.get[3].is_integer||true>:
- give IcecapadeCrates_Key<context.args.first> q:<context.args.get[3]||8>
- narrate "<&3>You received <&b><context.args.get[3]||8>x <context.args.first.to_titlecase> keys"
- else:
- give IcecapadeCrates_Chest<context.args.first>
- narrate "<&3>You received a <&b><context.args.first.to_titlecase> crate<&3>."
- default:
- narrate "<&3>Syntax: <&b>/crates [Light/Medium/Heavy] (key) (<<>#<>>)"
IcecapadeCrates_CrateHandler:
type: world
debug: false
events:
on player right clicks armor_stand with:IcecapadeCrates_Key*:
- determine passively cancelled
- choose <context.entity.flag[crate].first||null>:
- case light medium heavy:
- if <context.item.nbt[crate]> == <context.entity.flag[crate].first>:
- run IcecapadeCrates_Task def:<context.entity.flag[crate].first>|<context.entity.flag[crate].last>
on player right clicks ender_chest with:IcecapadeCrates_Key*:
- determine passively cancelled
- foreach <list[light|medium|heavy]> as:type:
- if <server.flag[crates.<[type]>].get_sub_items[1].contains[<context.location>]||false> && <context.item.nbt[crate]> == <[type]>:
- run IcecapadeCrates_Task def:<[type]>|<context.location>
- stop
on player breaks ender_chest:
- foreach <list[light|medium|heavy]> as:type:
- if <server.flag[crates.<[type]>].get_sub_items[1].contains[<context.location>]||false>:
- if <player.has_permission[icecapade.crates]>:
- define entry <server.flag[crates.<[type]>].get[<server.flag[crates.<[type]>].find_partial[<context.location>]>]>
- flag <[entry].after[/].as_list.first> crate:!
- flag <[entry].after[/].as_list.last> crate:!
- remove <[entry].after[/]>
- flag server crates.<[type]>:<-:<[entry]>
- stop
- else:
- determine cancelled
on player places IcecapadeCrates_Chest* permission:icecapade.crates:
- define type <context.item_in_hand.nbt[crate].strip_color>
- spawn armor_stand[gravity=false;visible=false;armor_pose=head|0,0,0] <context.location.add[0.5,-0.7,0.5].with_yaw[<player.location.direction[<context.location>].yaw.round_to_precision[90]>].forward_flat[0.25]> save:<[type]>
- spawn armor_stand[gravity=false;visible=false;custom_name=<script[IcecapadeCrates_Config].data_key[chests.<[type]>ChestName].parsed>;custom_name_visible=true] <context.location.add[0.5,-0.5,0.5]> save:name
- if <script[IcecapadeCrates_Config].data_key[show_tripwire]>:
- equip <entry[<[type]>].spawned_entity> head:<item[tripwire_hook].with[enchantments=durability,1]>
- flag server crates.<[type]>:->:<context.location>/<entry[<[type]>].spawned_entity>|<entry[name].spawned_entity>
- flag <entry[<[type]>].spawned_entity> crate:!|:<[type]>|<context.location>
- flag <entry[name].spawned_entity> crate:!|:<[type]>|<context.location>
IcecapadeCrates_Task:
type: task
debug: false
definitions: type|chest
script:
- choose <[type]>:
- case light medium heavy:
- define chance <util.random.decimal[0].to[100]>
- wait 1t
- take iteminhand
- define loot <script[IcecapadeCrates_Config].data_key[chests.<[type]>ChestItems].get_subset[<script[IcecapadeCrates_Config].data_key[chests.<[type]>ChestItems].list_keys.numerical>]>
- foreach <[loot].list_keys>:
- if <[chance]> <= <[value]>:
- repeat 3:
- firework <player.location.find.surface_blocks.within[4].random> random primary:<list[green|blue|yellow|aqua|white|orange].random[2]> fade:<list[green|blue|yellow|aqua|white|orange].random[2]> power:1
- animatechest <[chest]> sound:false
- playsound <player.location> sound:ENTITY_PLAYER_LEVELUP
- define item <[loot].list_values.get[<[loop_index]>].parsed>
- give <[item]>
- narrate "<green>Congrats! <white>You won <gold><[item].quantity>x <&r><[item].display||<blue><[item].material.translated_name>>"
- wait 1s
- animatechest <[chest]> close sound:false
- stop
- narrate "<red>No Result"
IcecapadeCrates_ChestLight:
type: item
material: ender_chest
display name: <green>Light Crate
lore:
- <&r>Place it to create a <green>Light Crate.
mechanisms:
nbt:
- crate/Light
IcecapadeCrates_ChestMedium:
type: item
material: ender_chest
display name: <yellow>Medium Crate
lore:
- <&r>Place it to create a <yellow>Medium Crate.
mechanisms:
nbt:
- crate/Medium
IcecapadeCrates_ChestHeavy:
type: item
material: ender_chest
display name: <red>Heavy Crate
lore:
- <&r>Place it to create a <red>Heavy Crate.
mechanisms:
nbt:
- crate/Heavy
IcecapadeCrates_KeyLight:
type: item
material: tripwire_hook
display name: <green>Light Key
lore:
- <&r>You can open a <green>Light Crate<&r> with it.
enchantments:
- durability:1
mechanisms:
nbt:
- crate/light
hides:
- ENCHANTS
IcecapadeCrates_KeyMedium:
type: item
material: tripwire_hook
display name: <yellow>Medium Key
lore:
- <&r>You can open a <yellow>Medium Crate<&r> with it.
enchantments:
- durability:1
mechanisms:
nbt:
- crate/medium
hides:
- ENCHANTS
IcecapadeCrates_KeyHeavy:
type: item
material: tripwire_hook
display name: <red>Heavy Key
lore:
- <&r>You can open a <red>Heavy Crate<&r> with it.
enchantments:
- durability:1
mechanisms:
nbt:
- crate/heavy
hides:
- ENCHANTS