241 lines
6.6 KiB
Go
241 lines
6.6 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_gui
|
|
|
|
import (
|
|
"github.com/Pumpkin-MC/pumpkin-api-go/pkg/pumpkin_plugin_common"
|
|
"github.com/Pumpkin-MC/pumpkin-api-go/pkg/pumpkin_plugin_text"
|
|
witRuntime "go.bytecodealliance.org/pkg/wit/runtime"
|
|
witTypes "go.bytecodealliance.org/pkg/wit/types"
|
|
"unsafe"
|
|
"runtime"
|
|
)
|
|
|
|
type TextComponent = pumpkin_plugin_text.TextComponent
|
|
type ItemStack = pumpkin_plugin_common.ItemStack
|
|
type ClickType = pumpkin_plugin_common.ClickType
|
|
|
|
const (
|
|
GuiTypeGeneric9x1 uint8 = 0
|
|
GuiTypeGeneric9x2 uint8 = 1
|
|
GuiTypeGeneric9x3 uint8 = 2
|
|
GuiTypeGeneric9x4 uint8 = 3
|
|
GuiTypeGeneric9x5 uint8 = 4
|
|
GuiTypeGeneric9x6 uint8 = 5
|
|
GuiTypeGeneric3x3 uint8 = 6
|
|
GuiTypeCrafter3x3 uint8 = 7
|
|
GuiTypeAnvil uint8 = 8
|
|
GuiTypeBeacon uint8 = 9
|
|
GuiTypeBlastFurnace uint8 = 10
|
|
GuiTypeBrewingStand uint8 = 11
|
|
GuiTypeCrafting uint8 = 12
|
|
GuiTypeEnchantment uint8 = 13
|
|
GuiTypeFurnace uint8 = 14
|
|
GuiTypeGrindstone uint8 = 15
|
|
GuiTypeHopper uint8 = 16
|
|
GuiTypeLectern uint8 = 17
|
|
GuiTypeLoom uint8 = 18
|
|
GuiTypeMerchant uint8 = 19
|
|
GuiTypeShulkerBox uint8 = 20
|
|
GuiTypeSmithing uint8 = 21
|
|
GuiTypeSmoker uint8 = 22
|
|
GuiTypeCartographyTable uint8 = 23
|
|
GuiTypeStonecutter uint8 = 24
|
|
)
|
|
type GuiType = uint8
|
|
|
|
//go:wasmimport pumpkin:plugin/gui@0.1.0 [resource-drop]gui
|
|
func resourceDropGui(handle int32)
|
|
|
|
type Gui struct {
|
|
handle *witRuntime.Handle
|
|
}
|
|
|
|
func (self *Gui) TakeHandle() int32 {
|
|
return self.handle.Take()
|
|
}
|
|
|
|
func (self *Gui) SetHandle(handle int32) {
|
|
self.handle.Set(handle)
|
|
}
|
|
|
|
func (self *Gui) Handle() int32 {
|
|
return self.handle.Use()
|
|
}
|
|
|
|
func (self *Gui) Drop() {
|
|
handle := self.handle.TakeOrNil()
|
|
if handle != 0 {
|
|
resourceDropGui(handle)
|
|
}
|
|
}
|
|
|
|
func GuiFromOwnHandle(handleValue int32) *Gui {
|
|
handle := witRuntime.MakeHandle(handleValue)
|
|
value := &Gui{handle}
|
|
runtime.AddCleanup(value, func(_ int) {
|
|
handleValue := handle.TakeOrNil()
|
|
if handleValue != 0 {
|
|
resourceDropGui(handleValue)
|
|
}
|
|
}, 0)
|
|
return value
|
|
}
|
|
|
|
func GuiFromBorrowHandle(handleValue int32) *Gui {
|
|
handle := witRuntime.MakeHandle(handleValue)
|
|
return &Gui{handle}
|
|
}
|
|
|
|
|
|
//go:wasmimport pumpkin:plugin/gui@0.1.0 [constructor]gui
|
|
func wasm_import_constructor_gui(arg0 int32, arg1 int32) int32
|
|
|
|
func MakeGui(guiType GuiType, title *pumpkin_plugin_text.TextComponent) *Gui {
|
|
|
|
|
|
result := wasm_import_constructor_gui(int32(guiType), (title).TakeHandle())
|
|
return GuiFromOwnHandle(int32(uintptr(result)))
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/gui@0.1.0 [method]gui.set-item
|
|
func wasm_import_method_gui_set_item(arg0 int32, arg1 int32, arg2 uintptr, arg3 uint32, arg4 int32)
|
|
|
|
func (self *Gui) SetItem(slot uint32, item pumpkin_plugin_common.ItemStack) {
|
|
pinner := &runtime.Pinner{}
|
|
defer pinner.Unpin()
|
|
|
|
|
|
utf8 := unsafe.Pointer(unsafe.StringData((item).RegistryKey))
|
|
pinner.Pin(utf8)
|
|
wasm_import_method_gui_set_item((self).Handle(), int32(slot), uintptr(utf8), uint32(len((item).RegistryKey)), int32((item).Count))
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/gui@0.1.0 [method]gui.get-item
|
|
func wasm_import_method_gui_get_item(arg0 int32, arg1 int32, arg2 uintptr)
|
|
|
|
func (self *Gui) GetItem(slot uint32) witTypes.Option[pumpkin_plugin_common.ItemStack] {
|
|
pinner := &runtime.Pinner{}
|
|
defer pinner.Unpin()
|
|
|
|
returnArea := uintptr(witRuntime.Allocate(pinner, (4*4), 4))
|
|
wasm_import_method_gui_get_item((self).Handle(), int32(slot), returnArea)
|
|
var option witTypes.Option[pumpkin_plugin_common.ItemStack]
|
|
switch uint8(*(*uint32)(unsafe.Add(unsafe.Pointer(returnArea), 0))) {
|
|
case 0:
|
|
|
|
option = witTypes.None[pumpkin_plugin_common.ItemStack]()
|
|
case 1:
|
|
value := unsafe.String((*uint8)(unsafe.Pointer(uintptr(*(*uint32)(unsafe.Add(unsafe.Pointer(returnArea), 4))))), *(*uint32)(unsafe.Add(unsafe.Pointer(returnArea), (2*4))))
|
|
|
|
option = witTypes.Some[pumpkin_plugin_common.ItemStack](pumpkin_plugin_common.ItemStack{value, uint8(uint8(*(*uint32)(unsafe.Add(unsafe.Pointer(returnArea), (3*4)))))})
|
|
default:
|
|
panic("unreachable")
|
|
}
|
|
result := option;
|
|
return result
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/gui@0.1.0 [method]gui.get-type
|
|
func wasm_import_method_gui_get_type(arg0 int32) int32
|
|
|
|
func (self *Gui) GetType() GuiType {
|
|
|
|
|
|
result := wasm_import_method_gui_get_type((self).Handle())
|
|
return uint8(result)
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/gui@0.1.0 [method]gui.get-title
|
|
func wasm_import_method_gui_get_title(arg0 int32) int32
|
|
|
|
func (self *Gui) GetTitle() *pumpkin_plugin_text.TextComponent {
|
|
|
|
|
|
result := wasm_import_method_gui_get_title((self).Handle())
|
|
return pumpkin_plugin_text.TextComponentFromOwnHandle(int32(uintptr(result)))
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/gui@0.1.0 [method]gui.get-size
|
|
func wasm_import_method_gui_get_size(arg0 int32) int32
|
|
|
|
func (self *Gui) GetSize() uint32 {
|
|
|
|
|
|
result := wasm_import_method_gui_get_size((self).Handle())
|
|
return uint32(result)
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/gui@0.1.0 [method]gui.clear-items
|
|
func wasm_import_method_gui_clear_items(arg0 int32)
|
|
|
|
func (self *Gui) ClearItems() {
|
|
|
|
|
|
wasm_import_method_gui_clear_items((self).Handle())
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/gui@0.1.0 [method]gui.set-allow-grab-items
|
|
func wasm_import_method_gui_set_allow_grab_items(arg0 int32, arg1 int32)
|
|
|
|
func (self *Gui) SetAllowGrabItems(allow bool) {
|
|
|
|
|
|
var result int32
|
|
if allow {
|
|
result = 1
|
|
} else {
|
|
result = 0
|
|
}
|
|
wasm_import_method_gui_set_allow_grab_items((self).Handle(), result)
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/gui@0.1.0 [method]gui.get-allow-grab-items
|
|
func wasm_import_method_gui_get_allow_grab_items(arg0 int32) int32
|
|
|
|
func (self *Gui) GetAllowGrabItems() bool {
|
|
|
|
|
|
result := wasm_import_method_gui_get_allow_grab_items((self).Handle())
|
|
return (result != 0)
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/gui@0.1.0 [method]gui.set-allow-put-items
|
|
func wasm_import_method_gui_set_allow_put_items(arg0 int32, arg1 int32)
|
|
|
|
func (self *Gui) SetAllowPutItems(allow bool) {
|
|
|
|
|
|
var result int32
|
|
if allow {
|
|
result = 1
|
|
} else {
|
|
result = 0
|
|
}
|
|
wasm_import_method_gui_set_allow_put_items((self).Handle(), result)
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/gui@0.1.0 [method]gui.get-allow-put-items
|
|
func wasm_import_method_gui_get_allow_put_items(arg0 int32) int32
|
|
|
|
func (self *Gui) GetAllowPutItems() bool {
|
|
|
|
|
|
result := wasm_import_method_gui_get_allow_put_items((self).Handle())
|
|
return (result != 0)
|
|
|
|
}
|