pumpkin-api-py 0.1.0.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pumpkin_api/__init__.py +139 -0
- pumpkin_api/app.py +8 -0
- pumpkin_api/build.py +35 -0
- pumpkin_api/wit/componentize_py_async_support/__init__.py +529 -0
- pumpkin_api/wit/componentize_py_async_support/futures.py +93 -0
- pumpkin_api/wit/componentize_py_async_support/streams.py +189 -0
- pumpkin_api/wit/componentize_py_runtime.pyi +34 -0
- pumpkin_api/wit/componentize_py_types.py +19 -0
- pumpkin_api/wit/poll_loop.py +440 -0
- pumpkin_api/wit/wit_world/__init__.py +70 -0
- pumpkin_api/wit/wit_world/exports/__init__.py +19 -0
- pumpkin_api/wit/wit_world/exports/metadata.py +22 -0
- pumpkin_api/wit/wit_world/imports/__init__.py +0 -0
- pumpkin_api/wit/wit_world/imports/command.py +539 -0
- pumpkin_api/wit/wit_world/imports/common.py +213 -0
- pumpkin_api/wit/wit_world/imports/context.py +70 -0
- pumpkin_api/wit/wit_world/imports/entity.py +84 -0
- pumpkin_api/wit/wit_world/imports/event.py +434 -0
- pumpkin_api/wit/wit_world/imports/gui.py +61 -0
- pumpkin_api/wit/wit_world/imports/i18n.py +35 -0
- pumpkin_api/wit/wit_world/imports/logging.py +30 -0
- pumpkin_api/wit/wit_world/imports/permission.py +71 -0
- pumpkin_api/wit/wit_world/imports/player.py +350 -0
- pumpkin_api/wit/wit_world/imports/scheduler.py +44 -0
- pumpkin_api/wit/wit_world/imports/scoreboard.py +95 -0
- pumpkin_api/wit/wit_world/imports/server.py +75 -0
- pumpkin_api/wit/wit_world/imports/text.py +89 -0
- pumpkin_api/wit/wit_world/imports/world.py +215 -0
- pumpkin_api/wit_files/command.wit +189 -0
- pumpkin_api/wit_files/common.wit +201 -0
- pumpkin_api/wit_files/componentize_py_async_support/__init__.py +529 -0
- pumpkin_api/wit_files/componentize_py_async_support/futures.py +93 -0
- pumpkin_api/wit_files/componentize_py_async_support/streams.py +189 -0
- pumpkin_api/wit_files/componentize_py_runtime.pyi +34 -0
- pumpkin_api/wit_files/componentize_py_types.py +19 -0
- pumpkin_api/wit_files/context.wit +33 -0
- pumpkin_api/wit_files/entity.wit +36 -0
- pumpkin_api/wit_files/event.wit +311 -0
- pumpkin_api/wit_files/gui.wit +38 -0
- pumpkin_api/wit_files/i18n.wit +21 -0
- pumpkin_api/wit_files/log.wit +14 -0
- pumpkin_api/wit_files/metadata.wit +15 -0
- pumpkin_api/wit_files/permission.wit +46 -0
- pumpkin_api/wit_files/player.wit +172 -0
- pumpkin_api/wit_files/plugin.wit +61 -0
- pumpkin_api/wit_files/poll_loop.py +440 -0
- pumpkin_api/wit_files/scheduler.wit +24 -0
- pumpkin_api/wit_files/scoreboard.wit +72 -0
- pumpkin_api/wit_files/server.wit +41 -0
- pumpkin_api/wit_files/text.wit +41 -0
- pumpkin_api/wit_files/wit_world/__init__.py +70 -0
- pumpkin_api/wit_files/wit_world/exports/__init__.py +19 -0
- pumpkin_api/wit_files/wit_world/exports/metadata.py +22 -0
- pumpkin_api/wit_files/wit_world/imports/__init__.py +0 -0
- pumpkin_api/wit_files/wit_world/imports/command.py +539 -0
- pumpkin_api/wit_files/wit_world/imports/common.py +213 -0
- pumpkin_api/wit_files/wit_world/imports/context.py +70 -0
- pumpkin_api/wit_files/wit_world/imports/entity.py +84 -0
- pumpkin_api/wit_files/wit_world/imports/event.py +434 -0
- pumpkin_api/wit_files/wit_world/imports/gui.py +61 -0
- pumpkin_api/wit_files/wit_world/imports/i18n.py +35 -0
- pumpkin_api/wit_files/wit_world/imports/logging.py +30 -0
- pumpkin_api/wit_files/wit_world/imports/permission.py +71 -0
- pumpkin_api/wit_files/wit_world/imports/player.py +350 -0
- pumpkin_api/wit_files/wit_world/imports/scheduler.py +44 -0
- pumpkin_api/wit_files/wit_world/imports/scoreboard.py +95 -0
- pumpkin_api/wit_files/wit_world/imports/server.py +75 -0
- pumpkin_api/wit_files/wit_world/imports/text.py +89 -0
- pumpkin_api/wit_files/wit_world/imports/world.py +215 -0
- pumpkin_api/wit_files/world.wit +169 -0
- pumpkin_api_py-0.1.0.dev0.dist-info/METADATA +58 -0
- pumpkin_api_py-0.1.0.dev0.dist-info/RECORD +75 -0
- pumpkin_api_py-0.1.0.dev0.dist-info/WHEEL +4 -0
- pumpkin_api_py-0.1.0.dev0.dist-info/entry_points.txt +2 -0
- pumpkin_api_py-0.1.0.dev0.dist-info/licenses/LICENSE +677 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import componentize_py_runtime
|
|
2
|
+
import componentize_py_async_support
|
|
3
|
+
import weakref
|
|
4
|
+
|
|
5
|
+
from typing import TypeVar, Generic, Self, cast
|
|
6
|
+
from types import TracebackType
|
|
7
|
+
from componentize_py_async_support import _ReturnCode
|
|
8
|
+
|
|
9
|
+
class ByteStreamReader:
|
|
10
|
+
def __init__(self, type_: int, handle: int):
|
|
11
|
+
self.writer_dropped = False
|
|
12
|
+
self.type_ = type_
|
|
13
|
+
self.handle: int | None = handle
|
|
14
|
+
self.finalizer = weakref.finalize(self, componentize_py_runtime.stream_drop_readable, type_, handle)
|
|
15
|
+
|
|
16
|
+
async def read(self, max_count: int) -> bytes:
|
|
17
|
+
if self.writer_dropped:
|
|
18
|
+
return bytes()
|
|
19
|
+
|
|
20
|
+
code, values = await self._read(max_count)
|
|
21
|
+
|
|
22
|
+
if code == _ReturnCode.DROPPED:
|
|
23
|
+
self.writer_dropped = True
|
|
24
|
+
|
|
25
|
+
return values
|
|
26
|
+
|
|
27
|
+
async def _read(self, max_count: int) -> tuple[int, bytes]:
|
|
28
|
+
if self.handle is not None:
|
|
29
|
+
return cast(tuple[int, bytes], await componentize_py_async_support.await_result(
|
|
30
|
+
componentize_py_runtime.stream_read(self.type_, self.handle, max_count)
|
|
31
|
+
))
|
|
32
|
+
else:
|
|
33
|
+
raise AssertionError
|
|
34
|
+
|
|
35
|
+
def __enter__(self) -> Self:
|
|
36
|
+
return self
|
|
37
|
+
|
|
38
|
+
def __exit__(self,
|
|
39
|
+
exc_type: type[BaseException] | None,
|
|
40
|
+
exc_value: BaseException | None,
|
|
41
|
+
traceback: TracebackType | None) -> bool | None:
|
|
42
|
+
self.finalizer.detach()
|
|
43
|
+
handle = self.handle
|
|
44
|
+
self.handle = None
|
|
45
|
+
if handle is not None:
|
|
46
|
+
componentize_py_runtime.stream_drop_readable(self.type_, handle)
|
|
47
|
+
return None
|
|
48
|
+
|
|
49
|
+
class ByteStreamWriter:
|
|
50
|
+
def __init__(self, type_: int, handle: int):
|
|
51
|
+
self.reader_dropped = False
|
|
52
|
+
self.type_ = type_
|
|
53
|
+
self.handle: int | None = handle
|
|
54
|
+
self.finalizer = weakref.finalize(self, componentize_py_runtime.stream_drop_writable, type_, handle)
|
|
55
|
+
|
|
56
|
+
async def write(self, source: bytes) -> int:
|
|
57
|
+
if self.reader_dropped:
|
|
58
|
+
return 0
|
|
59
|
+
|
|
60
|
+
code, count = await self._write(source)
|
|
61
|
+
|
|
62
|
+
if code == _ReturnCode.DROPPED:
|
|
63
|
+
self.reader_dropped = True
|
|
64
|
+
|
|
65
|
+
return count
|
|
66
|
+
|
|
67
|
+
async def _write(self, source: bytes) -> tuple[int, int]:
|
|
68
|
+
if self.handle is not None:
|
|
69
|
+
return await componentize_py_async_support.await_result(
|
|
70
|
+
componentize_py_runtime.stream_write(self.type_, self.handle, source)
|
|
71
|
+
)
|
|
72
|
+
else:
|
|
73
|
+
raise AssertionError
|
|
74
|
+
|
|
75
|
+
async def write_all(self, source: bytes) -> int:
|
|
76
|
+
total = 0
|
|
77
|
+
|
|
78
|
+
while len(source) > 0 and not self.reader_dropped:
|
|
79
|
+
count = await self.write(source)
|
|
80
|
+
source = source[count:]
|
|
81
|
+
total += count
|
|
82
|
+
|
|
83
|
+
return total
|
|
84
|
+
|
|
85
|
+
def __enter__(self) -> Self:
|
|
86
|
+
return self
|
|
87
|
+
|
|
88
|
+
def __exit__(self,
|
|
89
|
+
exc_type: type[BaseException] | None,
|
|
90
|
+
exc_value: BaseException | None,
|
|
91
|
+
traceback: TracebackType | None) -> bool | None:
|
|
92
|
+
self.finalizer.detach()
|
|
93
|
+
handle = self.handle
|
|
94
|
+
self.handle = None
|
|
95
|
+
if handle is not None:
|
|
96
|
+
componentize_py_runtime.stream_drop_writable(self.type_, handle)
|
|
97
|
+
return None
|
|
98
|
+
|
|
99
|
+
T = TypeVar('T')
|
|
100
|
+
|
|
101
|
+
class StreamReader(Generic[T]):
|
|
102
|
+
def __init__(self, type_: int, handle: int):
|
|
103
|
+
self.writer_dropped = False
|
|
104
|
+
self.type_ = type_
|
|
105
|
+
self.handle: int | None = handle
|
|
106
|
+
self.finalizer = weakref.finalize(self, componentize_py_runtime.stream_drop_readable, type_, handle)
|
|
107
|
+
|
|
108
|
+
async def read(self, max_count: int) -> list[T]:
|
|
109
|
+
if self.writer_dropped:
|
|
110
|
+
return []
|
|
111
|
+
|
|
112
|
+
code, values = await self._read(max_count)
|
|
113
|
+
|
|
114
|
+
if code == _ReturnCode.DROPPED:
|
|
115
|
+
self.writer_dropped = True
|
|
116
|
+
|
|
117
|
+
return values
|
|
118
|
+
|
|
119
|
+
async def _read(self, max_count: int) -> tuple[int, list[T]]:
|
|
120
|
+
if self.handle is not None:
|
|
121
|
+
return cast(tuple[int, list[T]], await componentize_py_async_support.await_result(
|
|
122
|
+
componentize_py_runtime.stream_read(self.type_, self.handle, max_count)
|
|
123
|
+
))
|
|
124
|
+
else:
|
|
125
|
+
raise AssertionError
|
|
126
|
+
|
|
127
|
+
def __enter__(self) -> Self:
|
|
128
|
+
return self
|
|
129
|
+
|
|
130
|
+
def __exit__(self,
|
|
131
|
+
exc_type: type[BaseException] | None,
|
|
132
|
+
exc_value: BaseException | None,
|
|
133
|
+
traceback: TracebackType | None) -> bool | None:
|
|
134
|
+
self.finalizer.detach()
|
|
135
|
+
handle = self.handle
|
|
136
|
+
self.handle = None
|
|
137
|
+
if handle is not None:
|
|
138
|
+
componentize_py_runtime.stream_drop_readable(self.type_, handle)
|
|
139
|
+
return None
|
|
140
|
+
|
|
141
|
+
class StreamWriter(Generic[T]):
|
|
142
|
+
def __init__(self, type_: int, handle: int):
|
|
143
|
+
self.reader_dropped = False
|
|
144
|
+
self.type_ = type_
|
|
145
|
+
self.handle: int | None = handle
|
|
146
|
+
self.finalizer = weakref.finalize(self, componentize_py_runtime.stream_drop_writable, type_, handle)
|
|
147
|
+
|
|
148
|
+
async def write(self, source: list[T]) -> int:
|
|
149
|
+
if self.reader_dropped:
|
|
150
|
+
return 0
|
|
151
|
+
|
|
152
|
+
code, count = await self._write(source)
|
|
153
|
+
|
|
154
|
+
if code == _ReturnCode.DROPPED:
|
|
155
|
+
self.reader_dropped = True
|
|
156
|
+
|
|
157
|
+
return count
|
|
158
|
+
|
|
159
|
+
async def _write(self, source: list[T]) -> tuple[int, int]:
|
|
160
|
+
if self.handle is not None:
|
|
161
|
+
return await componentize_py_async_support.await_result(
|
|
162
|
+
componentize_py_runtime.stream_write(self.type_, self.handle, source)
|
|
163
|
+
)
|
|
164
|
+
else:
|
|
165
|
+
raise AssertionError
|
|
166
|
+
|
|
167
|
+
async def write_all(self, source: list[T]) -> int:
|
|
168
|
+
total = 0
|
|
169
|
+
|
|
170
|
+
while len(source) > 0 and not self.reader_dropped:
|
|
171
|
+
count = await self.write(source)
|
|
172
|
+
source = source[count:]
|
|
173
|
+
total += count
|
|
174
|
+
|
|
175
|
+
return total
|
|
176
|
+
|
|
177
|
+
def __enter__(self) -> Self:
|
|
178
|
+
return self
|
|
179
|
+
|
|
180
|
+
def __exit__(self,
|
|
181
|
+
exc_type: type[BaseException] | None,
|
|
182
|
+
exc_value: BaseException | None,
|
|
183
|
+
traceback: TracebackType | None) -> bool | None:
|
|
184
|
+
self.finalizer.detach()
|
|
185
|
+
handle = self.handle
|
|
186
|
+
self.handle = None
|
|
187
|
+
if handle is not None:
|
|
188
|
+
componentize_py_runtime.stream_drop_writable(self.type_, handle)
|
|
189
|
+
return None
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
from componentize_py_types import Result
|
|
3
|
+
|
|
4
|
+
def call_task_return(index: int, borrows: int, result: Any) -> None: ...
|
|
5
|
+
|
|
6
|
+
def waitable_set_drop(set: int) -> None: ...
|
|
7
|
+
|
|
8
|
+
def context_set(value: Any) -> None: ...
|
|
9
|
+
|
|
10
|
+
def context_get() -> Any: ...
|
|
11
|
+
|
|
12
|
+
def waitable_join(waitable: int, set: int) -> None: ...
|
|
13
|
+
|
|
14
|
+
def subtask_drop(task: int) -> None: ...
|
|
15
|
+
|
|
16
|
+
def waitable_set_new() -> int: ...
|
|
17
|
+
|
|
18
|
+
def promise_get_result(event: int, promise: int) -> Any: ...
|
|
19
|
+
|
|
20
|
+
def future_read(ty: int, future: int) -> Result[Any, tuple[int, int]]: ...
|
|
21
|
+
|
|
22
|
+
def future_write(ty: int, future: int, value: Any) -> Result[tuple[int, int], tuple[int, int]]: ...
|
|
23
|
+
|
|
24
|
+
def future_drop_readable(ty: int, future: int) -> None: ...
|
|
25
|
+
|
|
26
|
+
def future_drop_writable(ty: int, future: int) -> None: ...
|
|
27
|
+
|
|
28
|
+
def stream_read(ty: int, stream: int, max_count: int) -> Result[tuple[int, bytes | list[Any]], tuple[int, int]]: ...
|
|
29
|
+
|
|
30
|
+
def stream_write(ty: int, stream: int, values: bytes | list[Any]) -> Result[tuple[int, int], tuple[int, int]]: ...
|
|
31
|
+
|
|
32
|
+
def stream_drop_readable(ty: int, stream: int) -> None: ...
|
|
33
|
+
|
|
34
|
+
def stream_drop_writable(ty: int, stream: int) -> None: ...
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from typing import TypeVar, Generic, Union
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
|
|
4
|
+
S = TypeVar('S')
|
|
5
|
+
@dataclass
|
|
6
|
+
class Some(Generic[S]):
|
|
7
|
+
value: S
|
|
8
|
+
|
|
9
|
+
T = TypeVar('T')
|
|
10
|
+
@dataclass
|
|
11
|
+
class Ok(Generic[T]):
|
|
12
|
+
value: T
|
|
13
|
+
|
|
14
|
+
E = TypeVar('E')
|
|
15
|
+
@dataclass(frozen=True)
|
|
16
|
+
class Err(Generic[E], Exception):
|
|
17
|
+
value: E
|
|
18
|
+
|
|
19
|
+
Result = Union[Ok[T], Err[E]]
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/// The core context provided to a plugin during initialization and event handling.
|
|
2
|
+
interface context {
|
|
3
|
+
use server.{server};
|
|
4
|
+
use event.{event-type, event-priority};
|
|
5
|
+
use command.{command};
|
|
6
|
+
use permission.{permission};
|
|
7
|
+
|
|
8
|
+
/// A contextual handle for plugin-related operations.
|
|
9
|
+
resource context {
|
|
10
|
+
/// Registers a handler for a specific event.
|
|
11
|
+
///
|
|
12
|
+
/// * `handler-id`: Unique ID for the event handler.
|
|
13
|
+
/// * `event-type`: The type of event to listen for.
|
|
14
|
+
/// * `event-priority`: When this handler should be called relative to others.
|
|
15
|
+
/// * `blocking`: Whether the event should wait for this handler to finish.
|
|
16
|
+
register-event: func(handler-id: u32, event-type: event-type, event-priority: event-priority, blocking: bool);
|
|
17
|
+
|
|
18
|
+
/// Registers a new command.
|
|
19
|
+
///
|
|
20
|
+
/// * `command`: The command definition.
|
|
21
|
+
/// * `permission`: The required permission node to execute this command.
|
|
22
|
+
register-command: func(command: command, permission: string);
|
|
23
|
+
|
|
24
|
+
/// Registers a permission node with the server.
|
|
25
|
+
register-permission: func(permission: permission) -> result<_, string>;
|
|
26
|
+
|
|
27
|
+
/// Returns the path to the plugin's private data folder.
|
|
28
|
+
get-data-folder: func() -> string;
|
|
29
|
+
|
|
30
|
+
/// Returns the global server instance.
|
|
31
|
+
get-server: func() -> server;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
interface entity {
|
|
2
|
+
use common.{block-position};
|
|
3
|
+
|
|
4
|
+
resource block-entity {
|
|
5
|
+
resource-location: func() -> string;
|
|
6
|
+
get-position: func() -> block-position;
|
|
7
|
+
get-id: func() -> u32;
|
|
8
|
+
// write-nbt: func(nbt: nbt-compound);
|
|
9
|
+
// from-nbt: func(nbt: nbt-compound, position: block-position) -> entity;
|
|
10
|
+
// tick: func(world: simple-world);
|
|
11
|
+
// write-internal: func(nbt: nbt-compound);
|
|
12
|
+
// chunk-data-nbt: func() -> option<nbt-compound;
|
|
13
|
+
// get-inventory: func() -> option<inventory>;
|
|
14
|
+
// set-block-state: func(block-state: block-state-id);
|
|
15
|
+
// on-block-replaced: func(world: simple-world, position: block-position);
|
|
16
|
+
is-dirty: func() -> bool;
|
|
17
|
+
clear-dirty: func();
|
|
18
|
+
// to-property-delegate: func() -> option<property-delegate>;
|
|
19
|
+
// to-experience-container: func() -> option<experience-container>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
resource command-block-entity {
|
|
23
|
+
get-block-entity: func () -> block-entity;
|
|
24
|
+
last-output: func() -> string;
|
|
25
|
+
track-output: func() -> bool;
|
|
26
|
+
success-count: func() -> u32;
|
|
27
|
+
command: func() -> string;
|
|
28
|
+
auto: func() -> bool;
|
|
29
|
+
condition-met: func() -> bool;
|
|
30
|
+
powered: func() -> bool;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
variant entity {
|
|
34
|
+
command-block-entity(command-block-entity),
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
interface event {
|
|
2
|
+
use common.{block-position, game-mode, hand, item-stack, position};
|
|
3
|
+
use player.{player};
|
|
4
|
+
use text.{text-component};
|
|
5
|
+
use %world.{%world};
|
|
6
|
+
|
|
7
|
+
enum event-priority {
|
|
8
|
+
highest,
|
|
9
|
+
high,
|
|
10
|
+
normal,
|
|
11
|
+
low,
|
|
12
|
+
lowest,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
record player-join-event-data {
|
|
16
|
+
player: player,
|
|
17
|
+
join-message: text-component,
|
|
18
|
+
cancelled: bool
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
record player-leave-event-data {
|
|
22
|
+
player: player,
|
|
23
|
+
leave-message: text-component,
|
|
24
|
+
cancelled: bool
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
record player-login-event-data {
|
|
28
|
+
player: player,
|
|
29
|
+
kick-message: text-component,
|
|
30
|
+
cancelled: bool
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
record player-chat-event-data {
|
|
34
|
+
player: player,
|
|
35
|
+
message: string,
|
|
36
|
+
recipients: list<player>,
|
|
37
|
+
cancelled: bool
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
record player-command-send-event-data {
|
|
41
|
+
player: player,
|
|
42
|
+
command: string,
|
|
43
|
+
cancelled: bool
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
record player-permission-check-event-data {
|
|
47
|
+
player: player,
|
|
48
|
+
permission: string,
|
|
49
|
+
permission-result: bool
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
record player-move-event-data {
|
|
53
|
+
player: player,
|
|
54
|
+
from-position: position,
|
|
55
|
+
to-position: position,
|
|
56
|
+
cancelled: bool
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
record player-teleport-event-data {
|
|
60
|
+
player: player,
|
|
61
|
+
from-position: position,
|
|
62
|
+
to-position: position,
|
|
63
|
+
cancelled: bool
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
record player-change-world-event-data {
|
|
67
|
+
player: player,
|
|
68
|
+
previous-world: %world,
|
|
69
|
+
new-world: %world,
|
|
70
|
+
position: position,
|
|
71
|
+
yaw: f32,
|
|
72
|
+
pitch: f32,
|
|
73
|
+
cancelled: bool
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
record player-exp-change-event-data {
|
|
77
|
+
player: player,
|
|
78
|
+
amount: s32
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
record player-item-held-event-data {
|
|
82
|
+
player: player,
|
|
83
|
+
previous-slot: u8,
|
|
84
|
+
new-slot: u8,
|
|
85
|
+
cancelled: bool
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
record player-changed-main-hand-event-data {
|
|
89
|
+
player: player,
|
|
90
|
+
main-hand: hand
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
record player-gamemode-change-event-data {
|
|
94
|
+
player: player,
|
|
95
|
+
previous-gamemode: game-mode,
|
|
96
|
+
new-gamemode: game-mode,
|
|
97
|
+
cancelled: bool
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
record player-custom-payload-event-data {
|
|
101
|
+
player: player,
|
|
102
|
+
channel: string,
|
|
103
|
+
data: list<u8>
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
enum player-fish-state {
|
|
107
|
+
fishing,
|
|
108
|
+
caught-fish,
|
|
109
|
+
caught-entity,
|
|
110
|
+
in-ground,
|
|
111
|
+
failed-attempt,
|
|
112
|
+
reel-in,
|
|
113
|
+
bite,
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
record player-fish-event-data {
|
|
117
|
+
player: player,
|
|
118
|
+
caught-uuid: option<string>,
|
|
119
|
+
caught-type: string,
|
|
120
|
+
hook-uuid: string,
|
|
121
|
+
state: player-fish-state,
|
|
122
|
+
hand: hand,
|
|
123
|
+
exp-to-drop: s32,
|
|
124
|
+
cancelled: bool
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
record player-egg-throw-event-data {
|
|
128
|
+
player: player,
|
|
129
|
+
egg-uuid: string,
|
|
130
|
+
hatching: bool,
|
|
131
|
+
num-hatches: u8,
|
|
132
|
+
hatching-type: string,
|
|
133
|
+
cancelled: bool
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
enum entity-interaction-action {
|
|
137
|
+
interact,
|
|
138
|
+
attack,
|
|
139
|
+
interact-at,
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
enum interact-action {
|
|
143
|
+
left-click-block,
|
|
144
|
+
left-click-air,
|
|
145
|
+
right-click-air,
|
|
146
|
+
right-click-block,
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
record player-interact-event-data {
|
|
150
|
+
player: player,
|
|
151
|
+
action: interact-action,
|
|
152
|
+
clicked-pos: option<block-position>,
|
|
153
|
+
item: item-stack,
|
|
154
|
+
block: string,
|
|
155
|
+
cancelled: bool
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
record player-toggle-sneak-event-data {
|
|
159
|
+
player: player,
|
|
160
|
+
is-sneaking: bool,
|
|
161
|
+
cancelled: bool
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
record player-toggle-sprint-event-data {
|
|
165
|
+
player: player,
|
|
166
|
+
is-sprinting: bool,
|
|
167
|
+
cancelled: bool
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
record player-interact-unknown-entity-event-data {
|
|
171
|
+
player: player,
|
|
172
|
+
entity-id: s32,
|
|
173
|
+
action: entity-interaction-action,
|
|
174
|
+
cancelled: bool
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
record block-redstone-event-data {
|
|
178
|
+
target-world: %world,
|
|
179
|
+
state-id: u16,
|
|
180
|
+
block-position: block-position,
|
|
181
|
+
old-current: s32,
|
|
182
|
+
new-current: s32,
|
|
183
|
+
cancelled: bool
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
record block-break-event-data {
|
|
187
|
+
player: option<player>,
|
|
188
|
+
block: string,
|
|
189
|
+
block-position: block-position,
|
|
190
|
+
exp: u32,
|
|
191
|
+
should-drop: bool,
|
|
192
|
+
cancelled: bool
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
record block-burn-event-data {
|
|
196
|
+
igniting-block: string,
|
|
197
|
+
block: string,
|
|
198
|
+
cancelled: bool
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
record block-can-build-event-data {
|
|
202
|
+
block-to-build: string,
|
|
203
|
+
buildable: bool,
|
|
204
|
+
player: player,
|
|
205
|
+
block: string,
|
|
206
|
+
cancelled: bool
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
record block-grow-event-data {
|
|
210
|
+
target-world: %world,
|
|
211
|
+
old-block: string,
|
|
212
|
+
old-state-id: u16,
|
|
213
|
+
new-block: string,
|
|
214
|
+
new-state-id: u16,
|
|
215
|
+
block-position: block-position,
|
|
216
|
+
cancelled: bool
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
record block-place-event-data {
|
|
220
|
+
player: player,
|
|
221
|
+
block-placed: string,
|
|
222
|
+
block-placed-against: string,
|
|
223
|
+
block-position: block-position,
|
|
224
|
+
can-build: bool,
|
|
225
|
+
cancelled: bool
|
|
226
|
+
}
|
|
227
|
+
record server-command-event-data {
|
|
228
|
+
command: string,
|
|
229
|
+
cancelled: bool
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
record spawn-change-event-data {
|
|
233
|
+
target-world: %world,
|
|
234
|
+
previous-position: block-position,
|
|
235
|
+
previous-yaw: f32,
|
|
236
|
+
previous-pitch: f32,
|
|
237
|
+
new-position: block-position,
|
|
238
|
+
new-yaw: f32,
|
|
239
|
+
new-pitch: f32
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
record server-broadcast-event-data {
|
|
243
|
+
message: text-component,
|
|
244
|
+
sender: text-component,
|
|
245
|
+
cancelled: bool
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
enum event-type {
|
|
249
|
+
player-join-event,
|
|
250
|
+
player-leave-event,
|
|
251
|
+
player-login-event,
|
|
252
|
+
player-chat-event,
|
|
253
|
+
player-command-send-event,
|
|
254
|
+
player-permission-check-event,
|
|
255
|
+
player-move-event,
|
|
256
|
+
player-teleport-event,
|
|
257
|
+
player-change-world-event,
|
|
258
|
+
player-exp-change-event,
|
|
259
|
+
player-item-held-event,
|
|
260
|
+
player-changed-main-hand-event,
|
|
261
|
+
player-gamemode-change-event,
|
|
262
|
+
player-custom-payload-event,
|
|
263
|
+
player-fish-event,
|
|
264
|
+
player-egg-throw-event,
|
|
265
|
+
player-interact-unknown-entity-event,
|
|
266
|
+
player-interact-event,
|
|
267
|
+
player-toggle-sneak-event,
|
|
268
|
+
player-toggle-sprint-event,
|
|
269
|
+
block-redstone-event,
|
|
270
|
+
block-break-event,
|
|
271
|
+
block-burn-event,
|
|
272
|
+
block-can-build-event,
|
|
273
|
+
block-grow-event,
|
|
274
|
+
block-place-event,
|
|
275
|
+
server-command-event,
|
|
276
|
+
spawn-change-event,
|
|
277
|
+
server-broadcast-event,
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
variant event {
|
|
281
|
+
player-join-event(player-join-event-data),
|
|
282
|
+
player-leave-event(player-leave-event-data),
|
|
283
|
+
player-login-event(player-login-event-data),
|
|
284
|
+
player-chat-event(player-chat-event-data),
|
|
285
|
+
player-command-send-event(player-command-send-event-data),
|
|
286
|
+
player-permission-check-event(player-permission-check-event-data),
|
|
287
|
+
player-move-event(player-move-event-data),
|
|
288
|
+
player-teleport-event(player-teleport-event-data),
|
|
289
|
+
player-change-world-event(player-change-world-event-data),
|
|
290
|
+
player-exp-change-event(player-exp-change-event-data),
|
|
291
|
+
player-item-held-event(player-item-held-event-data),
|
|
292
|
+
player-changed-main-hand-event(player-changed-main-hand-event-data),
|
|
293
|
+
player-gamemode-change-event(player-gamemode-change-event-data),
|
|
294
|
+
player-custom-payload-event(player-custom-payload-event-data),
|
|
295
|
+
player-fish-event(player-fish-event-data),
|
|
296
|
+
player-egg-throw-event(player-egg-throw-event-data),
|
|
297
|
+
player-interact-unknown-entity-event(player-interact-unknown-entity-event-data),
|
|
298
|
+
player-interact-event(player-interact-event-data),
|
|
299
|
+
player-toggle-sneak-event(player-toggle-sneak-event-data),
|
|
300
|
+
player-toggle-sprint-event(player-toggle-sprint-event-data),
|
|
301
|
+
block-redstone-event(block-redstone-event-data),
|
|
302
|
+
block-break-event(block-break-event-data),
|
|
303
|
+
block-burn-event(block-burn-event-data),
|
|
304
|
+
block-can-build-event(block-can-build-event-data),
|
|
305
|
+
block-grow-event(block-grow-event-data),
|
|
306
|
+
block-place-event(block-place-event-data),
|
|
307
|
+
server-command-event(server-command-event-data),
|
|
308
|
+
spawn-change-event(spawn-change-event-data),
|
|
309
|
+
server-broadcast-event(server-broadcast-event-data),
|
|
310
|
+
}
|
|
311
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
interface gui {
|
|
2
|
+
use text.{text-component};
|
|
3
|
+
use common.{item-stack};
|
|
4
|
+
|
|
5
|
+
enum gui-type {
|
|
6
|
+
generic-9x1,
|
|
7
|
+
generic-9x2,
|
|
8
|
+
generic-9x3,
|
|
9
|
+
generic-9x4,
|
|
10
|
+
generic-9x5,
|
|
11
|
+
generic-9x6,
|
|
12
|
+
generic-3x3,
|
|
13
|
+
crafter-3x3,
|
|
14
|
+
anvil,
|
|
15
|
+
beacon,
|
|
16
|
+
blast-furnace,
|
|
17
|
+
brewing-stand,
|
|
18
|
+
crafting,
|
|
19
|
+
enchantment,
|
|
20
|
+
furnace,
|
|
21
|
+
grindstone,
|
|
22
|
+
hopper,
|
|
23
|
+
lectern,
|
|
24
|
+
loom,
|
|
25
|
+
merchant,
|
|
26
|
+
shulker-box,
|
|
27
|
+
smithing,
|
|
28
|
+
smoker,
|
|
29
|
+
cartography-table,
|
|
30
|
+
stonecutter,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
resource gui {
|
|
34
|
+
constructor(%type: gui-type, title: text-component);
|
|
35
|
+
set-item: func(slot: u32, item: item-stack);
|
|
36
|
+
get-item: func(slot: u32) -> option<item-stack>;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface i18n {
|
|
2
|
+
use common.{locale};
|
|
3
|
+
|
|
4
|
+
/// Retrieves a translated string from the host.
|
|
5
|
+
///
|
|
6
|
+
/// # Arguments
|
|
7
|
+
/// * `key`: The namespaced translation key (e.g. `pumpkin:my_key`).
|
|
8
|
+
/// * `locale`: The target locale.
|
|
9
|
+
///
|
|
10
|
+
/// # Returns
|
|
11
|
+
/// The localized string, falling back to English or the key itself.
|
|
12
|
+
translate: func(key: string, locale: locale) -> string;
|
|
13
|
+
|
|
14
|
+
/// Loads custom translations from a JSON string.
|
|
15
|
+
///
|
|
16
|
+
/// # Arguments
|
|
17
|
+
/// * `namespace`: The namespace to associate these keys with.
|
|
18
|
+
/// * `json`: A JSON string containing a flat map of translations.
|
|
19
|
+
/// * `locale`: The target locale for these translations.
|
|
20
|
+
load-translations: func(namespace: string, json: string, locale: locale);
|
|
21
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface logging {
|
|
2
|
+
enum level {
|
|
3
|
+
trace,
|
|
4
|
+
debug,
|
|
5
|
+
info,
|
|
6
|
+
warn,
|
|
7
|
+
error,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/// log any general purpose message
|
|
11
|
+
log: func(level: level, message: string);
|
|
12
|
+
/// This function is meant to be used by the tracing crate.
|
|
13
|
+
log-tracing: func(event: list<u8>);
|
|
14
|
+
}
|