271 lines
7.8 KiB
Go
271 lines
7.8 KiB
Go
// Generated by `wit-bindgen` 0.57.1. DO NOT EDIT!
|
|
//
|
|
// This code was generated from the following packages:
|
|
// pumpkin:plugin@0.1.0
|
|
|
|
package pumpkin_plugin_boss_bar
|
|
|
|
import (
|
|
"github.com/Pumpkin-MC/pumpkin-api-go/pkg/pumpkin_plugin_player"
|
|
"github.com/Pumpkin-MC/pumpkin-api-go/pkg/pumpkin_plugin_text"
|
|
witRuntime "go.bytecodealliance.org/pkg/wit/runtime"
|
|
"runtime"
|
|
"unsafe"
|
|
)
|
|
|
|
type TextComponent = pumpkin_plugin_text.TextComponent
|
|
type Player = pumpkin_plugin_player.Player
|
|
|
|
const (
|
|
BossBarColorPink uint8 = 0
|
|
BossBarColorBlue uint8 = 1
|
|
BossBarColorRed uint8 = 2
|
|
BossBarColorGreen uint8 = 3
|
|
BossBarColorYellow uint8 = 4
|
|
BossBarColorPurple uint8 = 5
|
|
BossBarColorWhite uint8 = 6
|
|
)
|
|
|
|
// Represents the color of a boss bar.
|
|
type BossBarColor = uint8
|
|
|
|
const (
|
|
BossBarDivisionNoDivision uint8 = 0
|
|
BossBarDivisionNotches6 uint8 = 1
|
|
BossBarDivisionNotches10 uint8 = 2
|
|
BossBarDivisionNotches12 uint8 = 3
|
|
BossBarDivisionNotches20 uint8 = 4
|
|
)
|
|
|
|
// Represents the notches/divisions of a boss bar.
|
|
type BossBarDivision = uint8
|
|
|
|
// Metadata flags that can be toggled on a boss bar.
|
|
type BossBarMetadata struct {
|
|
// Darkens the sky for players who see the boss bar.
|
|
DarkenSky bool
|
|
// If true, the bar is considered a "dragon bar" (used for Ender Dragon).
|
|
DragonBar bool
|
|
// If true, fog is created around the players who see the boss bar.
|
|
CreateFog bool
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/boss-bar@0.1.0 [resource-drop]boss-bar
|
|
func resourceDropBossBar(handle int32)
|
|
|
|
// Represents a boss bar that can be shown to players.
|
|
type BossBar struct {
|
|
handle *witRuntime.Handle
|
|
}
|
|
|
|
func (self *BossBar) TakeHandle() int32 {
|
|
return self.handle.Take()
|
|
}
|
|
|
|
func (self *BossBar) SetHandle(handle int32) {
|
|
self.handle.Set(handle)
|
|
}
|
|
|
|
func (self *BossBar) Handle() int32 {
|
|
return self.handle.Use()
|
|
}
|
|
|
|
func (self *BossBar) Drop() {
|
|
handle := self.handle.TakeOrNil()
|
|
if handle != 0 {
|
|
resourceDropBossBar(handle)
|
|
}
|
|
}
|
|
|
|
func BossBarFromOwnHandle(handleValue int32) *BossBar {
|
|
handle := witRuntime.MakeHandle(handleValue)
|
|
value := &BossBar{handle}
|
|
runtime.AddCleanup(value, func(_ int) {
|
|
handleValue := handle.TakeOrNil()
|
|
if handleValue != 0 {
|
|
resourceDropBossBar(handleValue)
|
|
}
|
|
}, 0)
|
|
return value
|
|
}
|
|
|
|
func BossBarFromBorrowHandle(handleValue int32) *BossBar {
|
|
handle := witRuntime.MakeHandle(handleValue)
|
|
return &BossBar{handle}
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/boss-bar@0.1.0 [constructor]boss-bar
|
|
func wasm_import_constructor_boss_bar(arg0 int32, arg1 int32, arg2 int32) int32
|
|
|
|
func MakeBossBar(title *pumpkin_plugin_text.TextComponent, color BossBarColor, division BossBarDivision) *BossBar {
|
|
|
|
result := wasm_import_constructor_boss_bar((title).TakeHandle(), int32(color), int32(division))
|
|
return BossBarFromOwnHandle(int32(uintptr(result)))
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/boss-bar@0.1.0 [method]boss-bar.get-title
|
|
func wasm_import_method_boss_bar_get_title(arg0 int32) int32
|
|
|
|
func (self *BossBar) GetTitle() *pumpkin_plugin_text.TextComponent {
|
|
|
|
result := wasm_import_method_boss_bar_get_title((self).Handle())
|
|
return pumpkin_plugin_text.TextComponentFromOwnHandle(int32(uintptr(result)))
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/boss-bar@0.1.0 [method]boss-bar.set-title
|
|
func wasm_import_method_boss_bar_set_title(arg0 int32, arg1 int32)
|
|
|
|
func (self *BossBar) SetTitle(title *pumpkin_plugin_text.TextComponent) {
|
|
|
|
wasm_import_method_boss_bar_set_title((self).Handle(), (title).TakeHandle())
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/boss-bar@0.1.0 [method]boss-bar.get-health
|
|
func wasm_import_method_boss_bar_get_health(arg0 int32) float32
|
|
|
|
func (self *BossBar) GetHealth() float32 {
|
|
|
|
result := wasm_import_method_boss_bar_get_health((self).Handle())
|
|
return result
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/boss-bar@0.1.0 [method]boss-bar.set-health
|
|
func wasm_import_method_boss_bar_set_health(arg0 int32, arg1 float32)
|
|
|
|
func (self *BossBar) SetHealth(health float32) {
|
|
|
|
wasm_import_method_boss_bar_set_health((self).Handle(), health)
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/boss-bar@0.1.0 [method]boss-bar.get-color
|
|
func wasm_import_method_boss_bar_get_color(arg0 int32) int32
|
|
|
|
func (self *BossBar) GetColor() BossBarColor {
|
|
|
|
result := wasm_import_method_boss_bar_get_color((self).Handle())
|
|
return uint8(result)
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/boss-bar@0.1.0 [method]boss-bar.set-color
|
|
func wasm_import_method_boss_bar_set_color(arg0 int32, arg1 int32)
|
|
|
|
func (self *BossBar) SetColor(color BossBarColor) {
|
|
|
|
wasm_import_method_boss_bar_set_color((self).Handle(), int32(color))
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/boss-bar@0.1.0 [method]boss-bar.get-division
|
|
func wasm_import_method_boss_bar_get_division(arg0 int32) int32
|
|
|
|
func (self *BossBar) GetDivision() BossBarDivision {
|
|
|
|
result := wasm_import_method_boss_bar_get_division((self).Handle())
|
|
return uint8(result)
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/boss-bar@0.1.0 [method]boss-bar.set-division
|
|
func wasm_import_method_boss_bar_set_division(arg0 int32, arg1 int32)
|
|
|
|
func (self *BossBar) SetDivision(division BossBarDivision) {
|
|
|
|
wasm_import_method_boss_bar_set_division((self).Handle(), int32(division))
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/boss-bar@0.1.0 [method]boss-bar.get-metadata
|
|
func wasm_import_method_boss_bar_get_metadata(arg0 int32, arg1 uintptr)
|
|
|
|
func (self *BossBar) GetMetadata() BossBarMetadata {
|
|
pinner := &runtime.Pinner{}
|
|
defer pinner.Unpin()
|
|
|
|
returnArea := uintptr(witRuntime.Allocate(pinner, 3, 1))
|
|
wasm_import_method_boss_bar_get_metadata((self).Handle(), returnArea)
|
|
result := BossBarMetadata{(uint8(*(*uint32)(unsafe.Add(unsafe.Pointer(returnArea), 0))) != 0), (uint8(*(*uint32)(unsafe.Add(unsafe.Pointer(returnArea), 1))) != 0), (uint8(*(*uint32)(unsafe.Add(unsafe.Pointer(returnArea), 2))) != 0)}
|
|
return result
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/boss-bar@0.1.0 [method]boss-bar.set-metadata
|
|
func wasm_import_method_boss_bar_set_metadata(arg0 int32, arg1 int32, arg2 int32, arg3 int32)
|
|
|
|
func (self *BossBar) SetMetadata(metadata BossBarMetadata) {
|
|
|
|
var result int32
|
|
if (metadata).DarkenSky {
|
|
result = 1
|
|
} else {
|
|
result = 0
|
|
}
|
|
var result0 int32
|
|
if (metadata).DragonBar {
|
|
result0 = 1
|
|
} else {
|
|
result0 = 0
|
|
}
|
|
var result1 int32
|
|
if (metadata).CreateFog {
|
|
result1 = 1
|
|
} else {
|
|
result1 = 0
|
|
}
|
|
wasm_import_method_boss_bar_set_metadata((self).Handle(), result, result0, result1)
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/boss-bar@0.1.0 [method]boss-bar.add-player
|
|
func wasm_import_method_boss_bar_add_player(arg0 int32, arg1 int32)
|
|
|
|
func (self *BossBar) AddPlayer(player *pumpkin_plugin_player.Player) {
|
|
|
|
wasm_import_method_boss_bar_add_player((self).Handle(), (player).TakeHandle())
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/boss-bar@0.1.0 [method]boss-bar.remove-player
|
|
func wasm_import_method_boss_bar_remove_player(arg0 int32, arg1 int32)
|
|
|
|
func (self *BossBar) RemovePlayer(player *pumpkin_plugin_player.Player) {
|
|
|
|
wasm_import_method_boss_bar_remove_player((self).Handle(), (player).TakeHandle())
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/boss-bar@0.1.0 [method]boss-bar.get-players
|
|
func wasm_import_method_boss_bar_get_players(arg0 int32, arg1 uintptr)
|
|
|
|
func (self *BossBar) GetPlayers() []*pumpkin_plugin_player.Player {
|
|
pinner := &runtime.Pinner{}
|
|
defer pinner.Unpin()
|
|
|
|
returnArea := uintptr(witRuntime.Allocate(pinner, (2 * 4), 4))
|
|
wasm_import_method_boss_bar_get_players((self).Handle(), returnArea)
|
|
result := make([]*pumpkin_plugin_player.Player, 0, *(*uint32)(unsafe.Add(unsafe.Pointer(returnArea), 4)))
|
|
for index := 0; index < int(*(*uint32)(unsafe.Add(unsafe.Pointer(returnArea), 4))); index++ {
|
|
base := unsafe.Add(unsafe.Pointer(uintptr(*(*uint32)(unsafe.Add(unsafe.Pointer(returnArea), 0)))), index*4)
|
|
|
|
result = append(result, pumpkin_plugin_player.PlayerFromOwnHandle(int32(uintptr(*(*int32)(unsafe.Add(unsafe.Pointer(base), 0))))))
|
|
}
|
|
|
|
result0 := result
|
|
return result0
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/boss-bar@0.1.0 [method]boss-bar.remove-all
|
|
func wasm_import_method_boss_bar_remove_all(arg0 int32)
|
|
|
|
func (self *BossBar) RemoveAll() {
|
|
|
|
wasm_import_method_boss_bar_remove_all((self).Handle())
|
|
|
|
}
|