/setworldspawn moves the world spawn, not the player's respawn point
SetWorldSpawnCommand sets the level's spawn and its angle; a player without a bed or anchor respawns there (it used to set the player's own spawn point, so other players and later deaths kept the old one). The angle is saved in level.dat's spawn (yaw, pitch), and a guest whose saved respawn point is the world spawn follows it when it moves. lan_e2e `worldspawn`: /setworldspawn 24 blocks east, then the host and the guest die and respawn there. Fixes #1310. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+48
-2
@@ -131,6 +131,8 @@ address. The script then checks, from both sides, what a guest's game used to ge
|
||||
get off by sneaking; the other side sees the animal move.
|
||||
- lightning: a bolt summoned beside the host, then the guest: both sides get the bolt and flash the
|
||||
sky (on its server thread the host's window is a client of it too).
|
||||
- worldspawn: the host moves the world spawn (`setworldspawn`): the host and the guest, with no bed,
|
||||
respawn there (#1310).
|
||||
- flight: a player in creative double-taps jump and flies, stays up, and stops flying in survival:
|
||||
the guest, and on the server thread the host's window too, take what may fly from the
|
||||
server's abilities (ClientPacketListener.handlePlayerAbilities).
|
||||
@@ -172,7 +174,7 @@ ROOT = Path(__file__).resolve().parents[1]
|
||||
GUEST_NAME = 'Guest'
|
||||
# The host plays single player on its server thread (--server-thread).
|
||||
SERVER_THREAD = False
|
||||
CHECKS = ['tab', 'self', 'armour', 'nametags', 'walls', 'chest', 'crafting', 'sign', 'damage', 'mobs', 'hazards', 'pvp', 'arrows', 'kills', 'hurt', 'respawn', 'containers', 'feedback', 'titles', 'chat', 'commands', 'recipes', 'machines', 'brewing', 'loom', 'stonecutter', 'grindstone', 'anvil', 'smithing', 'enchanting', 'beacon', 'crafter', 'lectern', 'cartography', 'trials', 'clicks', 'sleep', 'predict', 'push', 'eat', 'eating', 'xp', 'objects', 'projectiles', 'worn', 'blast', 'barter', 'deflect', 'fireball', 'light', 'time', 'swings', 'cracks', 'plates', 'effects', 'portals', 'distance', 'growth', 'flight', 'ladder', 'boats', 'minecarts', 'frames', 'lightning', 'riding', 'mounts']
|
||||
CHECKS = ['tab', 'self', 'armour', 'nametags', 'walls', 'chest', 'crafting', 'sign', 'damage', 'mobs', 'hazards', 'pvp', 'arrows', 'kills', 'hurt', 'respawn', 'containers', 'feedback', 'titles', 'chat', 'commands', 'recipes', 'machines', 'brewing', 'loom', 'stonecutter', 'grindstone', 'anvil', 'smithing', 'enchanting', 'beacon', 'crafter', 'lectern', 'cartography', 'trials', 'clicks', 'sleep', 'predict', 'push', 'eat', 'eating', 'xp', 'objects', 'projectiles', 'worn', 'blast', 'barter', 'deflect', 'fireball', 'light', 'time', 'swings', 'cracks', 'plates', 'effects', 'portals', 'distance', 'growth', 'flight', 'ladder', 'boats', 'minecarts', 'frames', 'lightning', 'riding', 'mounts', 'worldspawn']
|
||||
|
||||
|
||||
class Game:
|
||||
@@ -2297,6 +2299,49 @@ def check_flight(host, guest, out):
|
||||
|
||||
|
||||
|
||||
def respawn_when_ready(game):
|
||||
"""Press Respawn once the death screen lets it (DeathScreen's 20-tick delay, counted from when
|
||||
the screen opens)."""
|
||||
for _ in range(20):
|
||||
try:
|
||||
return game.raw('respawn')
|
||||
except Failed as e:
|
||||
if 'not active yet' not in str(e):
|
||||
raise
|
||||
game.wait(10)
|
||||
return game.raw('respawn')
|
||||
|
||||
|
||||
def check_world_spawn(host, guest, out):
|
||||
"""`setworldspawn` moves the world spawn: the host and the guest, with no bed of their own,
|
||||
respawn there once killed (#1310)."""
|
||||
hx, hy, hz = (int(v // 1) for v in pos_of(host))
|
||||
sx, sz = hx + 24, hz
|
||||
host('command', command='gamerule respawn_radius 0')
|
||||
host('command', command=f'fill {sx - 2} {hy - 1} {sz - 2} {sx + 2} {hy - 1} {sz + 2} minecraft:stone')
|
||||
host('command', command=f'fill {sx - 2} {hy} {sz - 2} {sx + 2} {hy + 3} {sz + 2} minecraft:air')
|
||||
seen = {}
|
||||
try:
|
||||
host('command', command=f'setworldspawn {sx} {hy} {sz}')
|
||||
for game in (host, guest):
|
||||
game('command', command='gamemode survival')
|
||||
game('command', command='kill @s')
|
||||
game.wait(20)
|
||||
respawn_when_ready(game)
|
||||
game.wait(60)
|
||||
seen[game.name] = [round(v, 2) for v in pos_of(game)]
|
||||
game.shot(out, 'world-spawn')
|
||||
finally:
|
||||
host('command', command=f'setworldspawn {hx} {hy} {hz}')
|
||||
host('command', command='gamerule respawn_radius 10')
|
||||
for game in (host, guest):
|
||||
game('command', command=f'tp @s {hx + 0.5} {hy} {hz + 0.5}')
|
||||
guest.wait(20)
|
||||
for name, at in seen.items():
|
||||
assert abs(at[0] - (sx + 0.5)) < 1 and abs(at[2] - (sz + 0.5)) < 1, f'{name}: {seen}, spawn {sx} {sz}'
|
||||
return seen
|
||||
|
||||
|
||||
def check_ladder(host, guest, out):
|
||||
"""#1255: climbing down a ladder doesn't hurt where the guest lands."""
|
||||
x, y, z = (int(v // 1) for v in pos_of(guest))
|
||||
@@ -3075,7 +3120,8 @@ CHECK_FNS = {'tab': check_tab, 'self': check_self, 'armour': check_armour, 'name
|
||||
'xp': check_xp, 'objects': check_objects, 'projectiles': check_projectiles, 'blast': check_blast,
|
||||
'light': check_light, 'plates': check_plates,
|
||||
'swings': check_swings, 'cracks': check_cracks,
|
||||
'time': check_time, 'growth': check_growth, 'flight': check_flight, 'fireball': check_fireball, 'deflect': check_deflect, 'barter': check_barter, 'worn': check_worn, 'kills': check_kills, 'arrows': check_arrows, 'predict': check_predict, 'ladder': check_ladder, 'boats': check_boats, 'minecarts': check_minecarts, 'frames': check_frames, 'lightning': check_lightning, 'riding': check_riding, 'mounts': check_mounts}
|
||||
'time': check_time, 'growth': check_growth, 'flight': check_flight, 'fireball': check_fireball, 'deflect': check_deflect, 'barter': check_barter, 'worn': check_worn, 'kills': check_kills, 'arrows': check_arrows, 'predict': check_predict, 'ladder': check_ladder, 'boats': check_boats, 'minecarts': check_minecarts, 'frames': check_frames, 'lightning': check_lightning, 'riding': check_riding, 'mounts': check_mounts,
|
||||
'worldspawn': check_world_spawn}
|
||||
|
||||
|
||||
def run(ctl, out, resources, checks):
|
||||
|
||||
Reference in New Issue
Block a user