https://github.com/fwcd/swift-minecraft-pi
Minecraft Pi Edition API Library for Swift
https://github.com/fwcd/swift-minecraft-pi
Last synced: 2 months ago
JSON representation
Minecraft Pi Edition API Library for Swift
- Host: GitHub
- URL: https://github.com/fwcd/swift-minecraft-pi
- Owner: fwcd
- License: mit
- Created: 2021-05-16T02:37:48.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-05-16T18:42:45.000Z (almost 5 years ago)
- Last Synced: 2026-02-15T16:40:08.966Z (3 months ago)
- Language: Swift
- Homepage:
- Size: 35.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Minecraft Pi API for Swift
[](https://github.com/fwcd/swift-minecraft-pi/actions/workflows/linux.yml)
A small library that interfaces with the Minecraft Pi Edition API and lets you place blocks, query the player's position and more in the Minecraft world.
It also provides a great environment for learning how to program Swift on a Raspberry Pi.
## Example
```swift
import MinecraftPi
// Connect to the running Minecraft Pi instance
let mc = try! Minecraft.connect()
// Post a message to the in-game-chat
mc.chat.post("Hello world!")
// Fetch the player's block position
let pos = mc.player.tile
// Place a few blocks
mc.world.setBlock(at: pos + Vec3(x: 10), to: .wood)
mc.world.setBlocks(between: pos + Vec3(x: 11), and: pos + Vec3(x: 14, y: 1), to: .glass)
```