Leaping Salmon

Introduction

Look out, salmon are leaping dangerously high! We must create ponds for them to land in!

Step 1

We’ll use a Trident to cause salmon to make giant leaps into the sky. Add a ||player:on item used|| to your code and set the item type to Trident.

player.onItemInteracted(TRIDENT, function () {

})

Step 2

We want multiple fish to spawn for each Trident use, so insert a ||loops:repeat|| loop into the ||player:on item used|| block and set the repeat number to 6.

player.onItemInteracted(TRIDENT, function () {
    for (let i = 0; i < 6; i++) {
    }
})

Step 3

Now it’s time to spawn the salmon. Put a ||mobs:spawn|| into the ||loops:repeat|| loop and set the animal type to Salmon.

player.onItemInteracted(TRIDENT, function () {
    for (let i = 0; i < 6; i++) {
        mobs.spawn(SALMON, pos(0, 0, 0))
    }
})

Step 4

We’ll make it so the salmon spawn into a random location so that it’s harder to catch them. Put a ||positions: pick random position|| into the ||mobs:spawn||. Set the from position to ~-6 ~60 ~-6 and the to position to ~6 ~60 ~6. That’ll make them spawn high in the sky!

player.onItemInteracted(TRIDENT, function () {
    for (let i = 0; i < 6; i++) {
        mobs.spawn(SALMON, randpos(
                pos(-6, 60, -6),
                pos(6, 60, 6)
            ))
    }
})

Step 5

We’ve just made it so the salmon leap extremely high! We should create a pond to catch them so they don’t get injured when they land. Add a second ||player:on item used|| to your code, and set the item to Kelp.

player.onItemInteracted(TRIDENT, function () {
    for (let i = 0; i < 6; i++) {
        mobs.spawn(SALMON, randpos(
            pos(-6, 60, -6),
            pos(6, 60, 6)
        ))
    }
})
player.onItemInteracted(KELP, function () {

})

Step 6

Put in a ||blocks:fill|| into the ||player:on item used|| that’s set for Kelp. The falling fish need to land in water, so set the fill block type to Water.

player.onItemInteracted(TRIDENT, function () {
    for (let i = 0; i < 6; i++) {
        mobs.spawn(SALMON, randpos(
            pos(-6, 60, -6),
            pos(6, 60, 6)
        ))
    }
})
player.onItemInteracted(KELP, function () {
    blocks.fill(
        WATER,
        pos(0, 0, 0),
        pos(0, 0, 0),
        FillOperation.Replace
    )
})

Step 7

Finally, we must change the size of our pond so the fish can land right into it. In the ||blocks:fill||, set the from position to ~-2 ~-1 ~-2 and the to position to ~2 ~-1 ~2. This creates a 5 x 5 shallow pool of water around the player.

player.onItemInteracted(TRIDENT, function () {
    for (let i = 0; i < 6; i++) {
        mobs.spawn(SALMON, randpos(
            pos(-6, 60, -6),
            pos(6, 60, 6)
        ))
    }
})
player.onItemInteracted(KELP, function () {
    blocks.fill(
        WATER,
        pos(-2, -1, -2),
        pos(2, -1, 2),
        FillOperation.Replace
    )
})

Step 8

You’re all done! Go in-game and add a Trident and some Kelp to your equipment. Use the Trident to make salmon leap high in the sky. Then, quickly equip the Kelp and use it to create a pond underneath the fish so they can land safely. You’ll have to react quickly!