{if (event.entity.type == mi" /> {if (event.entity.type == mi"/>

World Synthetic [Lightning Synthesis] [KJS] Kubejs Minecraft Game

Effect:

Code: (Obviously placed in server_scripts))

 Onevent ("Entity.spawnet", (event) => {

If (event.entity.type == 'Minecraft: lightning_bolt')

{{

Let x = PARSEINT (event.entity.x)

Let Y = PARSEINT (event.entity.y)

Let Z = PARSEINT (event.entity.z)

Event.server.Getentities ("@E [Type = Minecraft: Item]"). Foreach (Entity => {{{{{{

If (entity.item == "Minecraft: Sand" &&

Parseint (Entity.x) == x && PARSEINT (Entity.y) == y &&

Parseint (Entity.z) == Z)

Event.server.runcommandsilent (`Summon Minecraft: Item $ {Event.entity.x} $ {event.entity.y} $ {event.entity.z}

{Item: {id: "minecraft: grass", count: 1}, invulnerable: true} `))

})

}})

Code principle:

Detect Lightning Entity Generation and get its position;

Detect all the entities in the server, if there is a sand dropped entity if there is a sand in the Lightning entity;

Use a instruction to generate glass drops with instructions at the Lightning entity position, and set invulnerable: true to burn it without igniting the lightning;

Existing problems:

First, the function Foreach (entity => {} instruction execution function will be run three times

(Only one sand was hit by lightning, and three glass was generated.) The reason is guessed:

The minimum unit of the game is tick, and any change in the game is 1Tick as the smallest unit. In the event

1Tick = 3ms, so the incident was executed three times;

Second, the drop -off entity that is thrown together will be stacked together, and the function GetentITIES (). SIZE () The result is that the sand entity is only one;

Therefore, this method of lightning synthesis can only participate in the synthesis at a time, and many items can only be burned by the fire left by lightning;