Skip to content

Commit

Permalink
修复了指定名称召唤时不正确显示名称的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
xBoyMinemc committed Nov 5, 2024
1 parent 551dd60 commit af4eea7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
## 增加独立的更新日志文件
## 开始实施自动构建与发布为未来做准备
## 修复了指定名称召唤时不正确显示名称的问题
8 changes: 6 additions & 2 deletions tscripts/xTerrain/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ let doMobSpawning = true
// ?

let spawnSimulatedPlayer : (location:Vector3, dimension:Dimension, pid: number )=>SimulatedPlayer
let spawnSimulatedPlayerByNameTag : (location:Vector3, dimension:Dimension, nameTag: string )=>SimulatedPlayer
let testWorldLocation : Vector3


Expand All @@ -78,8 +79,11 @@ register('我是云梦', '假人', (test:Test) => {
world.gameRules.doMobSpawning = doMobSpawning

spawnSimulatedPlayer = (location:Vector3, dimension:Dimension, pid: number ):SimulatedPlayer=>{
return spawnSimulatedPlayerByNameTag(location, dimension, `工具人-${pid}`)
}
spawnSimulatedPlayerByNameTag = (location:Vector3, dimension:Dimension, nameTag: string ):SimulatedPlayer=>{

const SimulatedPlayer = test.spawnSimulatedPlayer({ x:0, y:8, z:0 }, `工具人-${pid}`)
const SimulatedPlayer = test.spawnSimulatedPlayer({ x:0, y:8, z:0 }, nameTag)
SimulatedPlayer.addTag('init')
SimulatedPlayer.addTag(SIGN.YUME_SIM_SIGN)
SimulatedPlayer.addTag(SIGN.AUTO_RESPAWN_SIGN)
Expand Down Expand Up @@ -146,5 +150,5 @@ playerMove.subscribe(()=>{
//
// )

export { spawnSimulatedPlayer,testWorldLocation,GetPID }
export { spawnSimulatedPlayer,spawnSimulatedPlayerByNameTag,testWorldLocation,GetPID }

11 changes: 9 additions & 2 deletions tscripts/xTerrain/plugins/chatSpawn.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import type { SimulatedPlayer } from '@minecraft/server-gametest'

import { spawnSimulatedPlayer, SimulatedPlayerEnum, spawned as spawnedEvent, GetPID, initSucceed } from '../main'
import {
spawnSimulatedPlayer,
spawnSimulatedPlayerByNameTag,
SimulatedPlayerEnum,
spawned as spawnedEvent,
GetPID,
initSucceed
} from '../main'
import { commandInfo, CommandRegistry } from '../../lib/yumeCommand/CommandRegistry'
import { Dimension, Vector3, world } from '@minecraft/server'
const overworld = world.getDimension("overworld");
Expand Down Expand Up @@ -134,7 +141,7 @@ const withArgs_xyz_name = ({args,entity}:commandInfo)=>{

const PID = GetPID()
const __FlashPlayer__ = world.scoreboard.getObjective('##FlashPlayer##')
const SimulatedPlayer :SimulatedPlayer = spawnSimulatedPlayer(location,dimension ?? entity?.dimension ?? overworld,PID)
const SimulatedPlayer :SimulatedPlayer = spawnSimulatedPlayerByNameTag(location,dimension ?? entity?.dimension ?? overworld,nameTag)

SimulatedPlayerEnum[PID]=SimulatedPlayer
SimulatedPlayerEnum[SimulatedPlayer.id]=PID
Expand Down

0 comments on commit af4eea7

Please sign in to comment.