@@ -5,28 +5,44 @@ This page shows a full example of a very complex altar recipe with all available
55``` js
66ServerEvents .recipes (event => {
77 event .recipes .summoningrituals
8- .altar (" stick" )
9- .itemInputs ([" cobblestone" , " #c:glass_blocks" , " 3x #c:ingots" ])
8+ .altar (" #c:ingots" )
9+ .itemInputs ([
10+ " 2x cobblestone" ,
11+ Item .of (" stone" , 4 ),
12+ Ingredient .of (" dirt" , 2 ),
13+ " #c:glass_blocks" ,
14+ " 3x #c:ingots/iron" ,
15+ ])
1016 .entityInputs ([
1117 " 3x minecraft:elder_guardian" ,
1218 " phantom" ,
13- " silverfish" ,
14- " 3x cow" ,
1519 " minecraft:wither" ,
16- SummoningEntity .input (" cat" ).tooltip (" Meow" ),
20+ SummoningEntity .input (" 2x silverfish" ),
21+ SummoningEntity .input (" cat" , 3 ).tooltip (" Meow" ),
22+ SummoningEntity .input (" zombie" )
23+ .data ({
24+ HandItems: [
25+ {
26+ id: " minecraft:diamond_sword" ,
27+ Count: 1 ,
28+ tag: { ench: [{ id: 16 , lvl: 1 }] },
29+ },
30+ ],
31+ })
32+ .tooltip (" Needs any sword" )
33+ .validator (e => e .mainHandItem .id .contains (" sword" )),
1734 ])
1835 .itemOutputs ([
19- " apple" ,
20- " carrot" ,
36+ " 3x carrot" ,
37+ Item .of (" iron_sword" ),
38+ Item .of (" potato" , 4 ),
2139 SummoningItem .of (" 3x diamond" ),
22- SummoningItem .of (" emerald" ).offset ([1 , 2 , 2 ]).spread ([4 , 2 , 4 ]),
40+ SummoningItem .of (" emerald" , 6 ).offset ([1 , 2 , 2 ]).spread ([4 , 2 , 4 ]),
2341 ])
2442 .entityOutputs ([
2543 " bat" ,
26- " ender_dragon" ,
27- " 4x creeper" ,
28- SummoningEntity .output (" fox" , 2 ),
29- SummoningEntity .output (" blaze" , 2 )
44+ SummoningEntity .output (" fox" , 3 ),
45+ SummoningEntity .output (" 2x blaze" )
3046 .data ({
3147 Health: 50 ,
3248 attributes: [{ id: " generic.max_health" , base: 50 }],
@@ -43,26 +59,69 @@ ServerEvents.recipes(event => {
4359 },
4460 ],
4561 })
46- .tooltip (" Has Sword lol" ),
47- SummoningEntity .output (" ghast" )
48- .offset ([1 , 2 , 2 ])
49- .spread ([4 , 2 , 4 ])
50- .data ({
51- Health: 50 ,
52- attributes: [{ id: " generic.max_health" , base: 50 }],
53- }),
62+ .tooltip (" Has a Sword" ),
63+ SummoningEntity .output (" ghast" ).offset ([1 , 2 , 2 ]).spread ([4 , 2 , 4 ]),
5464 ])
55- .commands ([" say Foo " , " /say Bar " ] )
65+ .commands ([" say Hi " , " /say Hello " ], [ " Broadcasts a greeting! " ], false )
5666 .sacrificeZone ([3 , 3 , 3 ])
5767 .conditions (conditions =>
5868 conditions
5969 .biomes ([" minecraft:plains" , " minecraft:desert" ])
70+ .blockBelow (" furnace" , { lit: true })
6071 .dimension (" minecraft:overworld" )
61- .maxHeight (30 )
62- .setOpenSky (true )
72+ .facing (Direction .NORTH )
73+ .height (0 , 30 )
74+ .minLightLevel (5 )
75+ .setOpenSky (false )
76+ .setSmoked (true )
6377 .structures (" #minecraft:mineshaft" )
64- .time (" night" )
78+ .time (SummoningTime .NIGHT )
79+ .setWaterlogged (true )
6580 .weather (w => w .setThundering (true ))
6681 )
82+ .id (" kubejs:forbidden_ritual" )
83+ })
84+
85+ SummoningRituals .start (event => {
86+ const { level , pos , recipeInfo , player } = event
87+
88+ // check for a specific recipe
89+ if (recipeInfo .recipeId .toString () !== " kubejs:forbidden_ritual" ) {
90+ return
91+ }
92+
93+ // cancel the ritual if one of the entity inputs has less than their max health
94+ for (let entity of recipeInfo .inputEntities ) {
95+ if (entity .health < entity .maxHealth ) {
96+ if (player) {
97+ player .tell (" Ritual cancelled: Entity health too low" )
98+ }
99+ event .cancel ()
100+ }
101+ }
102+ })
103+
104+ SummoningRituals .complete (event => {
105+ const { level , pos , recipeInfo , player } = event
106+
107+ // check for a specific recipe
108+ if (recipeInfo .recipeId .toString () !== " kubejs:forbidden_ritual" ) {
109+ return
110+ }
111+
112+ // if an item output is a sword, enchant it with sharpness 3
113+ for (let itemEntity of recipeInfo .outputItems ) {
114+ if (itemEntity .item .id .contains (" sword" )) {
115+ itemEntity .item .enchant (" minecraft:sharpness" , 3 )
116+ }
117+ }
67118})
68119```
120+
121+ ![ ] ( /../img/recipe.png )
122+ ![ ] ( /../img/initiator.png )
123+ ![ ] ( /../img/cat_tooltip.png )
124+ ![ ] ( /../img/zombie_tooltip.png )
125+ ![ ] ( /../img/blaze_tooltip.png )
126+ ![ ] ( /../img/commands.png )
127+ ![ ] ( /../img/conditions.png )
0 commit comments