EntityEvents.spawned(e => {
const { entity } = e
if (entity.type == 'minecraft:lightning_bolt') {
if (entity.block.down == 'minecraft:lightning_rod') {
if (entity.block.down.down == 'minecraft:diorite') {
entity.block.down.down.set('it_all_started_with_a_bean:moon_stone')
}
else if (entity.block.down.down == 'minecraft:granite') {
entity.block.down.down.set('it_all_started_with_a_bean:sun_stone')
}
else if (entity.block.down.down == 'minecraft:andesite') {
entity.block.down.down.set('it_all_started_with_a_bean:star_stone')
}
}
}
})```
#Lightning Crafting
18 messages · Page 1 of 1 (latest)
??codeblock
You can write your code in a codeblock by typing it between the codeblock delimiters:
Note that these are backticks, not apostrophes
```js :arrow_left:
ServerEvents.recipes(event => {
event.smelting('minecraft:glass', '#forge:sand').xp(.1)
})
``` :arrow_left:
This example will look like this:
ServerEvents.recipes(event => {
event.smelting('minecraft:glass', '#forge:sand').xp(.1)
})
untested:
const conversionMap = {
"minecraft:andesite": "it_all_started_with_a_bean:star_stone",
"minecraft:diorite": "it_all_started_with_a_bean:moon_stone",
"minecraft:granite": "it_all_started_with_a_bean:sun_stone"
}
EntityEvents.spawned(e => {
const { entity } = e
if(entity.type != 'minecraft:lightning_bolt') return
if(entity.block.down != 'minecraft:lightning_rod') return
let conversionBlock = entity.block.down.down
conversionMap.filter((key, value) => {
if(conversionBlock == key) {
conversionBlock.set(value)
}
})
})```
by moving the ids of the original blocks and conversion blocks, its easier to expand on this and u don't have alot of if statements
also, negating the if statements on the `type` and `block.down` to allow for early returns makes the code more readable
cant you use EntityEvents.spawned('lightning_bolt', event => { instead of the if check?
const conversionMap = {
"minecraft:andesite": "it_all_started_with_a_bean:star_stone",
"minecraft:diorite": "it_all_started_with_a_bean:moon_stone",
"minecraft:granite": "it_all_started_with_a_bean:sun_stone",
}
EntityEvents.spawned("minecraft:lightning_bolt", (event) => {
const { entity } = event;
if (entity.block.down.id != 'minecraft:lightning_rod') return
const conversionBlock = entity.block.down.down
if (conversionMap[conversionBlock.id]) {
conversionBlock.set(conversionMap[conversionBlock.id])
}
})
why is your map now a list of lists
Because I am not sure if map is available .filter
i wasn't sure about that
yeah, the only issue is you can only make 1 block at a time, im thinking of trying to add conductor pylons to multiply the lightning to hit several blocks at one, but i think that would be difficult
its not as bad as the astral/zodiac crafting system in this pack tho
fix