|
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"; |
3 | 3 | import { V3 } from "../../math/vectorUtils"; |
| 4 | +import { ActionFormData } from "@minecraft/server-ui"; |
4 | 5 |
|
5 | 6 | const MichaelDimID = "whynot:michael_dimension" |
6 | 7 | let michaelDim: Dimension |
7 | 8 | export function main() { |
8 | 9 | michaelDim = world.getDimension(MichaelDimID) |
9 | | - world.getAllPlayers()[0].teleport(VECTOR3_ZERO, {dimension: michaelDim}) |
10 | 10 | 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 | + }) |
12 | 24 |
|
13 | 25 | } |
14 | 26 | export function startup(ev: StartupEvent) { |
|
0 commit comments