Skip to content

Commit 8730292

Browse files
committed
Add gravestone popup to teleport and spawn Michael
1 parent 938d00e commit 8730292

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

scripts/addons/michael/michael.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
1-
import { VECTOR3_ZERO } from "@minecraft/math";
2-
import { Dimension, StartupEvent, world, World } from "@minecraft/server";
1+
import { VECTOR3_UP, VECTOR3_ZERO } from "@minecraft/math";
2+
import { Dimension, StartupEvent, VanillaEntityIdentifier, world, World } from "@minecraft/server";
33
import { V3 } from "../../math/vectorUtils";
4+
import { ActionFormData } from "@minecraft/server-ui";
45

56
const MichaelDimID = "whynot:michael_dimension"
67
let michaelDim: Dimension
78
export function main() {
89
michaelDim = world.getDimension(MichaelDimID)
9-
world.getAllPlayers()[0].teleport(VECTOR3_ZERO, {dimension: michaelDim})
1010
world.structureManager.place("whynot:michael_structure", michaelDim, V3.make(-1, 0, -4))
11-
11+
michaelDim.getEntities({type: "whynot:michael_zombie"}).forEach(entity => entity.remove())
12+
michaelDim.spawnEntity("whynot:michael_zombie" as VanillaEntityIdentifier, V3.make(22, 1, 0))
13+
world.afterEvents.playerInteractWithBlock.subscribe(ev => {
14+
if (ev.block.typeId != "whynot:gravestone") return
15+
const form = new ActionFormData()
16+
form.title("Gravestone")
17+
form.body("Here lies the king of pop, do you accept his challenge?")
18+
form.button("Yes")
19+
form.button("Yes")
20+
form.show(ev.player).finally(() => {
21+
ev.player.teleport(VECTOR3_UP, {dimension: michaelDim})
22+
})
23+
})
1224

1325
}
1426
export function startup(ev: StartupEvent) {

0 commit comments

Comments
 (0)