Zombie Pig
Introduction
Did you know that pigs turn into zombies when the are hit by lightning? Let’s see it happen!
Iron shovel event
Add an event to run code when the player ||player:swings||
an iron shovel.
player.onItemInteracted(IRON_SHOVEL, function () {
})
Spawn a mob
In the event, put in code to ||mobs:spawn||
a ||mobs:pig||
5 blocks away from the player.
player.onItemInteracted(IRON_SHOVEL, function () {
// @highlight
mobs.spawn(PIG, pos(5, 0, 0))
})
Zap in the mob!
Use code to ||mobs:spawn||
a ||mobs:lightning bolt||
at the same position you spawned the pig.
player.onItemInteracted(IRON_SHOVEL, function () {
mobs.spawn(PIG, pos(5, 0, 0))
// @highlight
mobs.spawn(LIGHTNING_BOLT, pos(5, 0, 0))
})
Try it out!
Go to Minecraft and swing an iron shovel around!