1
+ //Block Drop Fixes
1
2
onEvent ( "block.loot_tables" , ( event ) => {
2
3
[
3
4
[ "yttr:yttrium_block" ] ,
@@ -75,15 +76,178 @@ onEvent("block.loot_tables", (event) => {
75
76
[ "yttr:black_project_table" ] ,
76
77
[ "yttr:neodymium_slab" ] ,
77
78
[ "yttr:neodymium_block" ] ,
78
- [ "yttr:lamp" ] ,
79
- [ "yttr:fixture" ] ,
80
- [ "yttr:cage_lamp" ] ,
81
- [ "yttr:panel" ] ,
82
79
[ "yttr:aware_hopper" ] ,
83
80
[ "yttr:levitation_chamber" ] ,
84
81
[ "yttr:magtank" ] ,
85
82
[ "yttr:dsu" ] ,
86
83
] . forEach ( ( loot ) => {
87
84
event . addSimpleBlock ( loot [ 0 ] , loot [ 0 ] ) ;
88
85
} ) ;
86
+ //Lamp Blocks
87
+ const lampColors = [ //don't include colorless
88
+ "white" ,
89
+ "orange" ,
90
+ "magenta" ,
91
+ "light_blue" ,
92
+ "yellow" ,
93
+ "lime" ,
94
+ "pink" ,
95
+ "gray" ,
96
+ "light_gray" ,
97
+ "cyan" ,
98
+ "purple" ,
99
+ "blue" ,
100
+ "brown" ,
101
+ "green" ,
102
+ "red" ,
103
+ "black" ,
104
+ "teal"
105
+ ] ;
106
+ [
107
+ "yttr:lamp" ,
108
+ "yttr:fixture" ,
109
+ "yttr:cage_lamp" ,
110
+ "yttr:panel"
111
+ ] . forEach ( ( lamp ) => {
112
+ event . addJson ( lamp , {
113
+ type : "minecraft:block" ,
114
+ pools : [
115
+ {
116
+ rolls : 1 ,
117
+ bonus_rolls : 0 ,
118
+ entries : [
119
+ {
120
+ type : "minecraft:item" ,
121
+ name : lamp ,
122
+ functions : [
123
+ {
124
+ function : "minecraft:set_nbt" ,
125
+ tag : "{Inverted: false, LampColor: \"colorless\"}"
126
+ } ,
127
+ {
128
+ function : "minecraft:set_nbt" ,
129
+ tag : "{Inverted: true}" ,
130
+ conditions : [
131
+ {
132
+ block : lamp ,
133
+ condition : "minecraft:block_state_property" ,
134
+ properties : {
135
+ inverted : true
136
+ }
137
+ }
138
+ ]
139
+ }
140
+ ] . concat ( lampColors . map ( color => {
141
+ return {
142
+ function : "minecraft:set_nbt" ,
143
+ tag : `{LampColor: \"${ color } \"}` ,
144
+ conditions : [
145
+ {
146
+ block : lamp ,
147
+ condition : "minecraft:block_state_property" ,
148
+ properties : {
149
+ color : color
150
+ }
151
+ }
152
+ ]
153
+ }
154
+ } ) )
155
+ }
156
+ ] ,
157
+ conditions : [
158
+ {
159
+ condition : "minecraft:survives_explosion"
160
+ }
161
+ ]
162
+ }
163
+ ]
164
+ } )
165
+ } )
89
166
} ) ;
167
+
168
+ //Lamp Recipe Fixes
169
+ onEvent ( "recipes" , ( event ) => {
170
+
171
+ const lampTypes = [
172
+ "lamp" ,
173
+ "fixture" ,
174
+ "cage_lamp" ,
175
+ "panel"
176
+ ] ;
177
+ const lampColors = [ //don't include colorless
178
+ [ "white" , "$minecraft:white_dye" ] ,
179
+ [ "orange" , "minecraft:orange_dye" ] ,
180
+ [ "magenta" , "minecraft:white_dye" ] ,
181
+ [ "light_blue" , "minecraft:light_blue_dye" ] ,
182
+ [ "yellow" , "minecraft:yellow_dye" ] ,
183
+ [ "lime" , "minecraft:lime_dye" ] ,
184
+ [ "pink" , "minecraft:pink_dye" ] ,
185
+ [ "gray" , "minecraft:gray_dye" ] ,
186
+ [ "light_gray" , "minecraft:light_gray_dye" ] ,
187
+ [ "cyan" , "minecraft:cyan_dye" ] ,
188
+ [ "purple" , "minecraft:purple_dye" ] ,
189
+ [ "blue" , "minecraft:blue_dye" ] ,
190
+ [ "brown" , "minecraft:brown_dye" ] ,
191
+ [ "green" , "minecraft:green_dye" ] ,
192
+ [ "red" , "minecraft:red_dye" ] ,
193
+ [ "black" , "minecraft:black_dye" ] ,
194
+ [ "teal" , "yttr:yttrium_dust" ]
195
+ ] ;
196
+
197
+
198
+ //Lamp recipe fixes
199
+ lampTypes . forEach ( lamp => {
200
+ //this recipe is shaped for some reason
201
+ event . remove ( { id :`yttr:crafting/lamp/${ lamp } _invert` } ) ;
202
+ //this recipe doesn't even work
203
+ event . remove ( { id :`yttr:crafting/lamp/${ lamp } _dye` } ) ;
204
+
205
+ //recreate lamp inversion recipe as a shapeless one. Also make it not consume the redstone torch
206
+ event . shapeless (
207
+ Item . of ( `yttr:${ lamp } ` ) . withNBT ( '{Inverted:true, LampColor:\"colorless\"}' ) ,
208
+ [
209
+ `yttr:${ lamp } ` ,
210
+ 'minecraft:redstone_torch'
211
+ ]
212
+ )
213
+ . modifyResult ( ( grid , result ) => {
214
+ let item = grid . find ( Ingredient . of ( `yttr:${ lamp } ` ) . ignoreNBT ( ) ) ;
215
+
216
+ let nbt = { } ;
217
+ nbt . Inverted = ! item . nbt . Inverted ;
218
+ if ( item . nbt . LampColor ) {
219
+ nbt . LampColor = item . nbt . LampColor ;
220
+ }
221
+ return result . withNBT ( nbt ) ;
222
+ } )
223
+ . keepIngredient ( "minecraft:redstone_torch" )
224
+ . id ( `createastral:crafting/yttr/lamp/${ lamp } _invert` )
225
+
226
+ //Create lamp dyeing recipes that actually work
227
+ event . shapeless (
228
+ Item . of ( `yttr:${ lamp } ` ) . withNBT ( '{Inverted:false, LampColor:\"white\"}' ) ,
229
+ [
230
+ `yttr:${ lamp } ` ,
231
+ '#yttr:lamp_dyes'
232
+ ]
233
+ )
234
+ . modifyResult ( ( grid , result ) => {
235
+ let item = grid . find ( Ingredient . of ( `yttr:${ lamp } ` ) . ignoreNBT ( ) ) ;
236
+ let dye = grid . find ( `#yttr:lamp_dyes` ) ;
237
+
238
+ let nbt = { } ;
239
+
240
+ nbt . Inverted = ! ! item . nbt . Inverted ;
241
+
242
+ for ( let i = 0 ; i < lampColors . length ; ++ i ) {
243
+ if ( dye . getId ( ) === lampColors [ i ] [ 1 ] ) {
244
+ nbt . LampColor = lampColors [ i ] [ 0 ] ;
245
+ break ;
246
+ }
247
+ }
248
+
249
+ return result . withNBT ( nbt ) ;
250
+ } )
251
+ . id ( `createastral:crafting/yttr/lamp/${ lamp } _dye` )
252
+ } )
253
+ } )
0 commit comments