-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
完成留言系统。
- Loading branch information
Showing
10 changed files
with
372 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//@ts-check | ||
import { Player, world } from "@minecraft/server"; | ||
|
||
export function deathCoordsInit(){} | ||
|
||
/**@type {Map<string, import("@minecraft/server").Vector3>}*/ | ||
const deadPlayerLocations = new Map(); | ||
|
||
world.afterEvents.entityDie.subscribe(data=>{ | ||
if(data.deadEntity.typeId === "minecraft:player"){ | ||
deadPlayerLocations.set(/**@type {Player}*/ (data.deadEntity).name, data.deadEntity.location); | ||
console.log(`${/**@type {Player}*/ (data.deadEntity).name} died at (${data.deadEntity.location.x.toFixed(0)}, ${data.deadEntity.location.y.toFixed(0)}, ${data.deadEntity.location.z.toFixed(0)}) from ${data.damageSource.cause}, ${data.damageSource.damagingEntity?.typeId}, ${data.damageSource.damagingProjectile?.typeId}`); | ||
} | ||
}); | ||
|
||
world.afterEvents.playerSpawn.subscribe(data=>{ | ||
if(!data.initialSpawn){ | ||
const location = deadPlayerLocations.get(data.player.name); | ||
deadPlayerLocations.delete(data.player.name); | ||
if(location) data.player.sendMessage(`§4§l您死在了(${location.x.toFixed(0)}, ${location.y.toFixed(0)}, ${location.z.toFixed(0)})。`); | ||
else data.player.sendMessage("§e§l您死在了没有坐标的地方!"); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.