Мир
Чтение и изменение world state через WorldHandle и server-owned services.
В этом разделе
Другие страницы раздела:
Блоки
WorldHandle покрывает чтение блоков, установку, разрушение и обновление свойств без прямой мутации runtime internals.
blocks-worlds.go
worldHandle, ok := ctx.Gameplay().Worlds().ByName("Overworld")if !ok { return fmt.Errorf("world not found")}pos := world.Pos{X: 10, Y: 64, Z: 10}blockState := block.New("chest"). String("minecraft:cardinal_direction", "north"). Block()current, exists, err := worldHandle.Block(pos)err = worldHandle.SetBlock(pos, blockState)err = worldHandle.UpdateProperties(pos, map[string]any{ "open_bit": true,})_ = current_ = existsЗапросы и эффекты
WorldHandle умеет искать ближайших игроков и сущности, а также отправлять server-owned sound, particle и level events.
world-effects.go
entities := worldHandle.NearbyEntities(entity.Position{X: 0, Y: 64, Z: 0}, 12, 10)players := worldHandle.PlayersNear(entity.Position{X: 0, Y: 64, Z: 0}, 12, 5)err := worldHandle.AddSound(entity.Position{X: 0, Y: 64, Z: 0}, gameplay.SoundEffect{Type: 1})err = worldHandle.AddParticle(entity.Position{X: 0, Y: 64, Z: 0}, gameplay.ParticleEffect{Type: 2001})err = worldHandle.LevelEvent(entity.Position{X: 0, Y: 64, Z: 0}, gameplay.LevelEvent{Type: 2001})_ = entities_ = players