From 28c3e929ca82ac90130b9dd9ccce73439c77519f Mon Sep 17 00:00:00 2001 From: MegalithOfficial Date: Sat, 19 Sep 2026 17:46:24 +0200 Subject: [PATCH] Add Zig bindings for the Pumpkin plugin API The bindings under src/wit are generated from the pumpkin-plugin-wit submodule by tools/gen.zig. The canonical ABI is handled at comptime in src/abi.zig, so plugins are plain wasm32-freestanding modules and only need wasm-tools to become a component. On top of that there is a small hand written layer: plugin registration, typed event handlers, declarative commands (cmd), text components from struct literals (msg) and std.log support. --- .gitignore | 3 + .gitmodules | 3 + LICENSE-APACHE | 176 + LICENSE-MIT | 21 + README.md | 77 + build.zig | 122 + build.zig.zon | 13 + example/src/main.zig | 70 + src/abi.zig | 687 ++ src/check.zig | 31 + src/cmd.zig | 146 + src/msg.zig | 83 + src/plugin.wit | 14266 ++++++++++++++++++++++ src/pumpkin.zig | 307 + src/wit.zig | 48 + src/wit/advancement.zig | 41 + src/wit/attributes.zig | 56 + src/wit/bedrock_packets.zig | 1901 +++ src/wit/biomes.zig | 70 + src/wit/block_entity.zig | 1865 +++ src/wit/boss_bar.zig | 157 + src/wit/command.zig | 434 + src/wit/common.zig | 260 + src/wit/context.zig | 104 + src/wit/damage_types.zig | 55 + src/wit/data_components.zig | 115 + src/wit/datapack.zig | 99 + src/wit/display.zig | 492 + src/wit/enchantments.zig | 133 + src/wit/entity.zig | 27 + src/wit/entity_statuses.zig | 66 + src/wit/entity_types.zig | 162 + src/wit/event.zig | 2454 ++++ src/wit/exports.zig | 217 + src/wit/forms.zig | 56 + src/wit/game_events.zig | 65 + src/wit/game_rules.zig | 68 + src/wit/gui.zig | 105 + src/wit/i18n.zig | 33 + src/wit/inventory.zig | 206 + src/wit/ipc.zig | 16 + src/wit/item_stack.zig | 239 + src/wit/java_dialogs.zig | 155 + src/wit/java_packets.zig | 2145 ++++ src/wit/logging.zig | 26 + src/wit/metadata.zig | 16 + src/wit/particles.zig | 129 + src/wit/permission.zig | 46 + src/wit/player.zig | 2193 ++++ src/wit/potions.zig | 50 + src/wit/recipe.zig | 117 + src/wit/scheduler.zig | 37 + src/wit/scoreboard.zig | 255 + src/wit/screens.zig | 29 + src/wit/server.zig | 567 + src/wit/sounds.zig | 1986 +++ src/wit/statistics.zig | 93 + src/wit/status_effect.zig | 52 + src/wit/text.zig | 231 + src/wit/uuid.zig | 30 + src/wit/world.zig | 2055 ++++ tools/gen.zig | 818 ++ tools/testdata/demo.json | 507 + tools/testdata/expected/wit.zig | 6 + tools/testdata/expected/wit/exports.zig | 59 + tools/testdata/expected/wit/guest.zig | 5 + tools/testdata/expected/wit/host.zig | 69 + tools/testdata/expected/wit/types.zig | 32 + tools/testdata/wit/demo.wit | 60 + wit | 1 + 70 files changed, 37318 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 LICENSE-APACHE create mode 100644 LICENSE-MIT create mode 100644 README.md create mode 100644 build.zig create mode 100644 build.zig.zon create mode 100644 example/src/main.zig create mode 100644 src/abi.zig create mode 100644 src/check.zig create mode 100644 src/cmd.zig create mode 100644 src/msg.zig create mode 100644 src/plugin.wit create mode 100644 src/pumpkin.zig create mode 100644 src/wit.zig create mode 100644 src/wit/advancement.zig create mode 100644 src/wit/attributes.zig create mode 100644 src/wit/bedrock_packets.zig create mode 100644 src/wit/biomes.zig create mode 100644 src/wit/block_entity.zig create mode 100644 src/wit/boss_bar.zig create mode 100644 src/wit/command.zig create mode 100644 src/wit/common.zig create mode 100644 src/wit/context.zig create mode 100644 src/wit/damage_types.zig create mode 100644 src/wit/data_components.zig create mode 100644 src/wit/datapack.zig create mode 100644 src/wit/display.zig create mode 100644 src/wit/enchantments.zig create mode 100644 src/wit/entity.zig create mode 100644 src/wit/entity_statuses.zig create mode 100644 src/wit/entity_types.zig create mode 100644 src/wit/event.zig create mode 100644 src/wit/exports.zig create mode 100644 src/wit/forms.zig create mode 100644 src/wit/game_events.zig create mode 100644 src/wit/game_rules.zig create mode 100644 src/wit/gui.zig create mode 100644 src/wit/i18n.zig create mode 100644 src/wit/inventory.zig create mode 100644 src/wit/ipc.zig create mode 100644 src/wit/item_stack.zig create mode 100644 src/wit/java_dialogs.zig create mode 100644 src/wit/java_packets.zig create mode 100644 src/wit/logging.zig create mode 100644 src/wit/metadata.zig create mode 100644 src/wit/particles.zig create mode 100644 src/wit/permission.zig create mode 100644 src/wit/player.zig create mode 100644 src/wit/potions.zig create mode 100644 src/wit/recipe.zig create mode 100644 src/wit/scheduler.zig create mode 100644 src/wit/scoreboard.zig create mode 100644 src/wit/screens.zig create mode 100644 src/wit/server.zig create mode 100644 src/wit/sounds.zig create mode 100644 src/wit/statistics.zig create mode 100644 src/wit/status_effect.zig create mode 100644 src/wit/text.zig create mode 100644 src/wit/uuid.zig create mode 100644 src/wit/world.zig create mode 100644 tools/gen.zig create mode 100644 tools/testdata/demo.json create mode 100644 tools/testdata/expected/wit.zig create mode 100644 tools/testdata/expected/wit/exports.zig create mode 100644 tools/testdata/expected/wit/guest.zig create mode 100644 tools/testdata/expected/wit/host.zig create mode 100644 tools/testdata/expected/wit/types.zig create mode 100644 tools/testdata/wit/demo.wit create mode 160000 wit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..03cb27d --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.zig-cache/ +zig-out/ +zig-pkg/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..0a4f435 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "wit"] + path = wit + url = https://github.com/Pumpkin-MC/pumpkin-plugin-wit diff --git a/LICENSE-APACHE b/LICENSE-APACHE new file mode 100644 index 0000000..c6e5ba7 --- /dev/null +++ b/LICENSE-APACHE @@ -0,0 +1,176 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or exemplary damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 0000000..36a056e --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024-2026 Pumpkin Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..2152f9b --- /dev/null +++ b/README.md @@ -0,0 +1,77 @@ +# Pumpkin API for Zig + +This package provides Zig bindings for building Pumpkin plugins using WebAssembly (Wasm) components. + +You will need [Zig](https://ziglang.org/download/) 0.16.0 and [`wasm-tools`](https://github.com/bytecodealliance/wasm-tools) in your `PATH`. + +## Quick Start + +1. Setup Your Project + +Add the package to your project: + +```sh +zig fetch --save git+https://github.com/Pumpkin-MC/pumpkin-api-zig +``` + +Create a `build.zig` for your plugin: + +```zig +const std = @import("std"); +const pumpkin_api = @import("pumpkin_api_zig"); + +pub fn build(b: *std.Build) void { + _ = pumpkin_api.addPlugin(b, b.dependency("pumpkin_api_zig", .{}), .{ + .name = "pumpkin-plugin-example", + .root_source_file = b.path("src/main.zig"), + }); +} +``` + +2. Write Your Plugin + +Create your source file (e.g. `src/main.zig`): + +```zig +const std = @import("std"); +const pumpkin = @import("pumpkin"); + +pub const std_options: std.Options = .{ .logFn = pumpkin.logFn }; + +const MyPlugin = struct { + pub const metadata: pumpkin.Metadata = .{ + .name = "pumpkin-plugin-example", + .version = "0.1.0", + .authors = &.{"You"}, + .description = "An example plugin in Zig.", + }; + + pub const events = .{ + .player_join_event = onJoin, + }; + + pub fn onLoad(_: pumpkin.Context) !void { + std.log.info("Hello from Zig!", .{}); + } + + fn onJoin(_: pumpkin.Server, ev: *pumpkin.EventData(.player_join_event)) void { + std.log.info("{s} joined", .{ev.player.getName()}); + } +}; + +comptime { + pumpkin.register(MyPlugin); +} +``` + +Everything the API returns, handles included, is only valid until the current callback returns. Call `keep()` on a handle to hold on to it, then release it with `deinit()` when you're done. + +3. Build Your Plugin + +Compile your plugin into a WebAssembly component: + +```sh +zig build +``` + +This will produce `zig-out/pumpkin-plugin-example.wasm` ready to be loaded into Pumpkin. diff --git a/build.zig b/build.zig new file mode 100644 index 0000000..01212b3 --- /dev/null +++ b/build.zig @@ -0,0 +1,122 @@ +const std = @import("std"); + +pub const PluginOptions = struct { + name: []const u8, + root_source_file: std.Build.LazyPath, + optimize: std.builtin.OptimizeMode = .ReleaseSmall, +}; + +/// Builds a plugin and installs `.wasm`, ready to be dropped into the +/// server's `plugins` folder. Needs `wasm-tools` in PATH. +/// +/// `api` is this package as the caller sees it: +/// const api = b.dependency("pumpkin_api_zig", .{}); +pub fn addPlugin(b: *std.Build, api: *std.Build.Dependency, options: PluginOptions) *std.Build.Step.InstallFile { + return addPluginFrom(b, api.builder, options); +} + +fn addPluginFrom(b: *std.Build, api: *std.Build, options: PluginOptions) *std.Build.Step.InstallFile { + const target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }); + + const pumpkin = api.createModule(.{ + .root_source_file = api.path("src/pumpkin.zig"), + .target = target, + .optimize = options.optimize, + }); + + const core = b.addExecutable(.{ + .name = options.name, + .root_module = b.createModule(.{ + .root_source_file = options.root_source_file, + .target = target, + .optimize = options.optimize, + .imports = &.{.{ .name = "pumpkin", .module = pumpkin }}, + }), + }); + core.entry = .disabled; + core.rdynamic = true; + + // Zig has no component model target, so the core module gets its WIT + // attached and is wrapped into a component afterwards. + const embed = b.addSystemCommand(&.{ "wasm-tools", "component", "embed", "--world", "plugin" }); + embed.addFileArg(api.path("src/plugin.wit")); + embed.addFileArg(core.getEmittedBin()); + embed.addArg("-o"); + const embedded = embed.addOutputFileArg("embedded.wasm"); + + const new = b.addSystemCommand(&.{ "wasm-tools", "component", "new" }); + new.addFileArg(embedded); + new.addArg("-o"); + const component = new.addOutputFileArg(b.fmt("{s}.wasm", .{options.name})); + + const install = b.addInstallFile(component, b.fmt("{s}.wasm", .{options.name})); + b.getInstallStep().dependOn(&install.step); + return install; +} + +pub fn build(b: *std.Build) void { + _ = addPluginFrom(b, b, .{ + .name = "pumpkin-plugin-example", + .root_source_file = b.path("example/src/main.zig"), + }); + + const test_step = b.step("test", "Run unit tests"); + for ([_][]const u8{ "src/abi.zig", "tools/gen.zig" }) |path| { + const tests = b.addTest(.{ + .root_module = b.createModule(.{ + .root_source_file = b.path(path), + .target = b.graph.host, + }), + }); + test_step.dependOn(&b.addRunArtifact(tests).step); + } + + const check = b.addObject(.{ + .name = "check", + .root_module = b.createModule(.{ + .root_source_file = b.path("src/check.zig"), + .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }), + .optimize = .ReleaseSmall, + }), + }); + b.step("check", "Compile every generated binding").dependOn(&check.step); + + // zig build gen: src/wit/ and src/plugin.wit from the wit submodule. + // Directory inputs aren't hashed, so these always rerun. + const dump = b.addSystemCommand(&.{ "wasm-tools", "component", "wit", "--json" }); + dump.addDirectoryArg(b.path("wit/v0.1")); + dump.has_side_effects = true; + const json = dump.captureStdOut(.{}); + + const merge = b.addSystemCommand(&.{ "wasm-tools", "component", "wit", "-o", "src/plugin.wit" }); + merge.addDirectoryArg(b.path("wit/v0.1")); + merge.setCwd(b.path(".")); + merge.has_side_effects = true; + + const generator = b.addExecutable(.{ + .name = "gen", + .root_module = b.createModule(.{ + .root_source_file = b.path("tools/gen.zig"), + .target = b.graph.host, + }), + }); + const generate = b.addRunArtifact(generator); + generate.addFileArg(json); + generate.addArg("src"); + generate.setCwd(b.path(".")); + generate.has_side_effects = true; + + const fmt = b.addFmt(.{ .paths = &.{ "src/wit", "src/wit.zig" } }); + fmt.step.dependOn(&generate.step); + fmt.step.dependOn(&merge.step); + b.step("gen", "Regenerate src/wit from wit/v0.1").dependOn(&fmt.step); + + // zig build fixtures: rewrites what the generator test compares against. + // demo.json comes from `wasm-tools component wit tools/testdata/wit --json`. + const fixtures = b.addRunArtifact(generator); + fixtures.addFileArg(b.path("tools/testdata/demo.json")); + fixtures.addArg("tools/testdata/expected"); + fixtures.setCwd(b.path(".")); + fixtures.has_side_effects = true; + b.step("fixtures", "Update the generator test snapshots").dependOn(&fixtures.step); +} diff --git a/build.zig.zon b/build.zig.zon new file mode 100644 index 0000000..8715c65 --- /dev/null +++ b/build.zig.zon @@ -0,0 +1,13 @@ +.{ + .name = .pumpkin_api_zig, + .version = "0.1.0", + .fingerprint = 0x8b5633e6f3f6f585, + .minimum_zig_version = "0.16.0", + .paths = .{ + "build.zig", + "build.zig.zon", + "src", + "LICENSE-MIT", + "LICENSE-APACHE", + }, +} diff --git a/example/src/main.zig b/example/src/main.zig new file mode 100644 index 0000000..b10a032 --- /dev/null +++ b/example/src/main.zig @@ -0,0 +1,70 @@ +const std = @import("std"); +const pumpkin = @import("pumpkin"); +const cmd = pumpkin.cmd; +const msg = pumpkin.msg; + +pub const std_options: std.Options = .{ .logFn = pumpkin.logFn }; + +const log = std.log.scoped(.example); + +const Example = struct { + pub const metadata: pumpkin.Metadata = .{ + .name = "pumpkin-plugin-example", + .version = "0.1.0", + .authors = &.{"You"}, + .description = "An example plugin in Zig.", + }; + + pub const events = .{ + .player_join_event = onJoin, + .player_chat_event = .{ onChat, pumpkin.EventOptions{ .priority = .high } }, + }; + + // /greet and /greet + pub const commands: []const cmd.Spec = &.{.{ + .names = &.{ "greet", "hi" }, + .description = "Says hello.", + .permission = "pumpkin-plugin-example:command.greet", + .run = greetSender, + .then = &.{ + .argument("targets", .players, .{ .run = greetTargets }), + }, + }}; + + pub fn onLoad(_: pumpkin.Context) !void { + log.info("Hello from Zig!", .{}); + } + + fn onJoin(_: pumpkin.Server, ev: *pumpkin.EventData(.player_join_event)) void { + log.info("{s} joined", .{ev.player.getName()}); + ev.join_message = msg.build(&.{ + .{ .text = "+ ", .color = .green, .bold = true }, + .{ .text = ev.player.getName(), .color = .yellow }, + }); + } + + fn onChat(_: pumpkin.Server, ev: *pumpkin.EventData(.player_chat_event)) void { + if (std.mem.indexOf(u8, ev.message, "spoiler") != null) ev.cancelled = true; + } + + fn greetSender(sender: cmd.Sender, _: pumpkin.Server, _: cmd.Args) cmd.Result { + sender.sendMessage(msg.build(&.{ + .{ .text = "Hello from Zig! ", .color = .gold }, + .{ .text = "[again]", .color = .gray, .click = .{ .run_command = "/greet" }, .hover = "Runs /greet" }, + })); + return cmd.ok(1); + } + + fn greetTargets(sender: cmd.Sender, _: pumpkin.Server, args: cmd.Args) cmd.Result { + const targets = cmd.get(args, "targets", .players) orelse return cmd.fail("nobody to greet"); + for (targets) |target| { + target.sendSystemMessage(msg.fmt(.aqua, "{s} says hello", .{sender.getName()}), false); + } + sender.sendMessage(msg.fmt(null, "Greeted {d} player(s).", .{targets.len})); + return cmd.ok(@intCast(targets.len)); + } +}; + +comptime { + pumpkin.register(Example); +} diff --git a/src/abi.zig b/src/abi.zig new file mode 100644 index 0000000..dcb6c13 --- /dev/null +++ b/src/abi.zig @@ -0,0 +1,687 @@ +//! Component model canonical ABI, driven by Zig types at comptime. +//! +//! WIT types map to Zig like this: +//! string, list []const u8, []const T +//! record, tuple struct, tuple +//! variant, result union(enum) +//! option ?T +//! enum enum(uN) +//! flags packed struct(uN) of bools +//! own non-exhaustive enum(u32) +//! borrow Borrowed(R), parameters only + +const std = @import("std"); +const builtin = @import("builtin"); + +pub fn Result(comptime T: type, comptime E: type) type { + return union(enum) { ok: T, err: E }; +} + +const is_wasm = builtin.cpu.arch == .wasm32; +const backing = if (is_wasm) std.heap.wasm_allocator else std.heap.page_allocator; + +var call_arena: std.heap.ArenaAllocator = .init(backing); + +/// Everything the host hands us lives here and is gone once the current export returns. +pub fn arena() std.mem.Allocator { + return call_arena.allocator(); +} + +const DropFn = *const fn (i32) callconv(.c) void; +const Tracked = struct { handle: u32, drop: DropFn }; + +/// Owned handles received during the current export, newest last. +var tracked: std.ArrayList(Tracked) = .empty; + +fn track(comptime T: type, handle: T) void { + tracked.append(backing, .{ .handle = @intFromEnum(handle), .drop = T.resource_drop }) catch @panic("OOM"); +} + +fn untrack(comptime T: type, handle: T) void { + var i = tracked.items.len; + while (i > 0) { + i -= 1; + const item = tracked.items[i]; + if (item.handle == @intFromEnum(handle) and item.drop == T.resource_drop) { + _ = tracked.orderedRemove(i); + return; + } + } +} + +/// Takes a handle out of the per-call cleanup so it can be stored across calls. +/// From then on it has to be released with `deinit`. +pub fn keep(comptime T: type, handle: T) void { + untrack(T, handle); +} + +pub fn drop(comptime T: type, handle: T) void { + untrack(T, handle); + T.resource_drop(@bitCast(@intFromEnum(handle))); +} + +/// A handle that is only lent to the callee. Plain handles are given away when lowered. +pub fn Borrowed(comptime T: type) type { + return struct { + handle: T, + + pub const wit_borrowed = {}; + }; +} + +pub fn borrow(handle: anytype) Borrowed(@TypeOf(handle)) { + return .{ .handle = handle }; +} + +fn isBorrowed(comptime T: type) bool { + return @typeInfo(T) == .@"struct" and @hasDecl(T, "wit_borrowed"); +} + +pub const Stats = struct { + /// Size of the linear memory. Wasm memory never shrinks, so this is the + /// number to watch for leaks. + memory_bytes: usize, + /// What the per-call arena holds on to between calls. + arena_bytes: usize, + /// Handles that will be released when the current call ends. + tracked_handles: usize, +}; + +pub fn stats() Stats { + return .{ + .memory_bytes = if (is_wasm) @wasmMemorySize(0) * std.wasm.page_size else 0, + .arena_bytes = call_arena.queryCapacity(), + .tracked_handles = tracked.items.len, + }; +} + +/// Drops the handles nobody kept. This calls into the host, which is not +/// allowed from a post-return function, so it can't be left to `endCall`. +fn releaseHandles() void { + while (tracked.pop()) |item| item.drop(@bitCast(item.handle)); +} + +/// Resets the arena. With an indirect result the host still reads from it +/// after the export returns, those exports call this from `cabi_post_*`. +pub fn endCall() void { + releaseHandles(); + _ = call_arena.reset(.retain_capacity); +} + +fn cabiRealloc(old: ?[*]u8, old_len: usize, alignment: usize, new_len: usize) callconv(.c) ?[*]u8 { + const a: std.mem.Alignment = .fromByteUnits(alignment); + const new = arena().rawAlloc(new_len, a, @returnAddress()) orelse @panic("OOM"); + if (old) |p| @memcpy(new[0..old_len], p[0..old_len]); + return new; +} + +comptime { + if (is_wasm) @export(&cabiRealloc, .{ .name = "cabi_realloc" }); +} + +const Core = enum { i32, i64, f32, f64 }; + +fn CoreType(comptime c: Core) type { + return switch (c) { + .i32 => i32, + .i64 => i64, + .f32 => f32, + .f64 => f64, + }; +} + +const max_flat_params = 16; + +// The event variant alone has a few hundred cases. +const branch_quota = 10_000_000; + +fn isHandle(comptime T: type) bool { + return @typeInfo(T) == .@"enum" and !@typeInfo(T).@"enum".is_exhaustive; +} + +fn Discriminant(comptime cases: usize) type { + if (cases <= 1 << 8) return u8; + if (cases <= 1 << 16) return u16; + return u32; +} + +fn caseCount(comptime T: type) comptime_int { + return switch (@typeInfo(T)) { + .optional => 2, + .@"union" => |u| u.fields.len, + .@"enum" => |e| e.fields.len, + else => unreachable, + }; +} + +/// Whether a []const T already has the canonical layout in memory. +fn isPlain(comptime T: type) bool { + return switch (@typeInfo(T)) { + .int => |i| i.bits == 8 or i.bits == 16 or i.bits == 32 or i.bits == 64, + .float => true, + else => false, + }; +} + +pub fn alignOf(comptime T: type) comptime_int { + @setEvalBranchQuota(branch_quota); + return switch (@typeInfo(T)) { + .void => 1, + .bool => 1, + .int => |i| if (i.bits == 21) 4 else @divExact(i.bits, 8), + .float => |f| @divExact(f.bits, 8), + .pointer => 4, + .@"enum" => if (isHandle(T)) 4 else @sizeOf(Discriminant(caseCount(T))), + .optional => |o| @max(1, alignOf(o.child)), + .@"union" => |u| blk: { + var a = @sizeOf(Discriminant(u.fields.len)); + for (u.fields) |f| a = @max(a, alignOf(f.type)); + break :blk a; + }, + .@"struct" => |s| blk: { + if (s.layout == .@"packed") break :blk @sizeOf(s.backing_integer.?); + if (isBorrowed(T)) break :blk 4; + var a = 1; + for (s.fields) |f| a = @max(a, alignOf(f.type)); + break :blk a; + }, + else => @compileError("no canonical ABI for " ++ @typeName(T)), + }; +} + +fn alignUp(comptime n: comptime_int, comptime a: comptime_int) comptime_int { + return @divFloor(n + a - 1, a) * a; +} + +pub fn sizeOf(comptime T: type) comptime_int { + @setEvalBranchQuota(branch_quota); + return switch (@typeInfo(T)) { + .void => 0, + .bool => 1, + .int => |i| if (i.bits == 21) 4 else @divExact(i.bits, 8), + .float => |f| @divExact(f.bits, 8), + .pointer => 8, + .@"enum" => if (isHandle(T)) 4 else @sizeOf(Discriminant(caseCount(T))), + .optional => |o| alignUp(payloadOffset(T) + sizeOf(o.child), alignOf(T)), + .@"union" => |u| blk: { + var max = 0; + for (u.fields) |f| max = @max(max, sizeOf(f.type)); + break :blk alignUp(payloadOffset(T) + max, alignOf(T)); + }, + .@"struct" => |s| blk: { + if (s.layout == .@"packed") break :blk @sizeOf(s.backing_integer.?); + if (isBorrowed(T)) break :blk 4; + var n = 0; + for (s.fields) |f| n = alignUp(n, alignOf(f.type)) + sizeOf(f.type); + break :blk alignUp(n, alignOf(T)); + }, + else => @compileError("no canonical ABI for " ++ @typeName(T)), + }; +} + +fn payloadOffset(comptime T: type) comptime_int { + @setEvalBranchQuota(branch_quota); + const disc = @sizeOf(Discriminant(caseCount(T))); + const payload_align = switch (@typeInfo(T)) { + .optional => |o| alignOf(o.child), + .@"union" => alignOf(T), + else => unreachable, + }; + return alignUp(disc, payload_align); +} + +fn fieldOffset(comptime T: type, comptime index: usize) comptime_int { + @setEvalBranchQuota(branch_quota); + var n = 0; + for (@typeInfo(T).@"struct".fields, 0..) |f, i| { + n = alignUp(n, alignOf(f.type)); + if (i == index) return n; + n += sizeOf(f.type); + } + unreachable; +} + +fn join(a: Core, b: Core) Core { + if (a == b) return a; + if ((a == .i32 and b == .f32) or (a == .f32 and b == .i32)) return .i32; + return .i64; +} + +fn flattenCases(comptime payloads: []const type) []const Core { + var out: []const Core = &.{}; + for (payloads) |P| { + const flat = flatten(P); + var merged: []const Core = &.{}; + for (0..@max(out.len, flat.len)) |i| { + const c = if (i >= out.len) flat[i] else if (i >= flat.len) out[i] else join(out[i], flat[i]); + merged = merged ++ [1]Core{c}; + } + out = merged; + } + return [1]Core{.i32} ++ out; +} + +pub fn flatten(comptime T: type) []const Core { + return comptime blk: { + @setEvalBranchQuota(branch_quota); + break :blk flattenType(T); + }; +} + +fn flattenType(comptime T: type) []const Core { + return switch (@typeInfo(T)) { + .void => &.{}, + .bool, .@"enum" => &.{.i32}, + .int => |i| if (i.bits == 64) &.{.i64} else &.{.i32}, + .float => |f| if (f.bits == 64) &.{.f64} else &.{.f32}, + .pointer => &.{ .i32, .i32 }, + .optional => |o| flattenCases(&.{ void, o.child }), + .@"union" => |u| blk: { + var payloads: []const type = &.{}; + for (u.fields) |f| payloads = payloads ++ [1]type{f.type}; + break :blk flattenCases(payloads); + }, + .@"struct" => |s| blk: { + if (s.layout == .@"packed" or isBorrowed(T)) break :blk &.{.i32}; + var out: []const Core = &.{}; + for (s.fields) |f| out = out ++ flatten(f.type); + break :blk out; + }, + else => @compileError("no canonical ABI for " ++ @typeName(T)), + }; +} + +// Flat values travel as raw bits in u64 slots, which makes the variant +// payload joins (f32 in an i32 slot, i32 in an i64 slot, ...) free. + +fn lowerSlice(comptime T: type, items: []const T, slots: []u64) void { + slots[1] = items.len; + if (items.len == 0) { + slots[0] = 0; + return; + } + if (comptime isPlain(T)) { + slots[0] = @intFromPtr(items.ptr); + return; + } + const a: std.mem.Alignment = comptime .fromByteUnits(alignOf(T)); + const buf = arena().alignedAlloc(u8, a, items.len * sizeOf(T)) catch @panic("OOM"); + for (items, 0..) |item, i| store(T, item, buf.ptr + i * sizeOf(T)); + slots[0] = @intFromPtr(buf.ptr); +} + +fn liftSlice(comptime T: type, addr: u64, len: u64) []const T { + if (len == 0) return &.{}; + const n: usize = @intCast(len); + if (comptime isPlain(T)) { + const ptr: [*]const T = @ptrFromInt(@as(usize, @intCast(addr))); + return ptr[0..n]; + } + const base: [*]const u8 = @ptrFromInt(@as(usize, @intCast(addr))); + const out = arena().alloc(T, n) catch @panic("OOM"); + for (out, 0..) |*item, i| item.* = load(T, base + i * sizeOf(T)); + return out; +} + +pub fn lowerFlat(comptime T: type, value: T, slots: []u64) void { + switch (@typeInfo(T)) { + .void => {}, + .bool => slots[0] = @intFromBool(value), + .int => |i| { + if (i.bits == 64) { + slots[0] = @bitCast(value); + } else if (i.signedness == .signed) { + slots[0] = @as(u32, @bitCast(@as(i32, value))); + } else { + slots[0] = value; + } + }, + .float => |f| slots[0] = if (f.bits == 64) @bitCast(value) else @as(u32, @bitCast(value)), + .pointer => |p| lowerSlice(p.child, value, slots), + .@"enum" => { + if (comptime isHandle(T)) untrack(T, value); + slots[0] = @intFromEnum(value); + }, + .optional => |o| { + @memset(slots[0..comptime flatten(T).len], 0); + if (value) |v| { + slots[0] = 1; + lowerFlat(o.child, v, slots[1..]); + } + }, + .@"union" => |u| { + @memset(slots[0..comptime flatten(T).len], 0); + switch (value) { + inline else => |v, tag| { + slots[0] = @intFromEnum(tag); + lowerFlat(u.fields[@intFromEnum(tag)].type, v, slots[1..]); + }, + } + }, + .@"struct" => |s| { + if (s.layout == .@"packed") { + slots[0] = @as(s.backing_integer.?, @bitCast(value)); + return; + } + if (comptime isBorrowed(T)) { + slots[0] = @intFromEnum(value.handle); + return; + } + var at: usize = 0; + inline for (s.fields) |f| { + lowerFlat(f.type, @field(value, f.name), slots[at..]); + at += comptime flatten(f.type).len; + } + }, + else => comptime unreachable, + } +} + +pub fn liftFlat(comptime T: type, slots: []const u64) T { + switch (@typeInfo(T)) { + .void => return {}, + .bool => return slots[0] != 0, + .int => |i| { + if (i.bits == 64) return @bitCast(slots[0]); + const word: u32 = @truncate(slots[0]); + if (i.signedness == .signed) return @truncate(@as(i32, @bitCast(word))); + return @truncate(word); + }, + .float => |f| { + if (f.bits == 64) return @bitCast(slots[0]); + return @bitCast(@as(u32, @truncate(slots[0]))); + }, + .pointer => |p| return liftSlice(p.child, slots[0], slots[1]), + .@"enum" => { + const value: T = @enumFromInt(slots[0]); + if (comptime isHandle(T)) track(T, value); + return value; + }, + .optional => |o| return if (slots[0] == 0) null else liftFlat(o.child, slots[1..]), + .@"union" => |u| { + inline for (u.fields, 0..) |f, i| { + if (slots[0] == i) return @unionInit(T, f.name, liftFlat(f.type, slots[1..])); + } + unreachable; + }, + .@"struct" => |s| { + if (s.layout == .@"packed") return @bitCast(@as(s.backing_integer.?, @truncate(slots[0]))); + if (comptime isBorrowed(T)) @compileError("borrowed handles can only be passed to imports"); + var out: T = undefined; + var at: usize = 0; + inline for (s.fields) |f| { + @field(out, f.name) = liftFlat(f.type, slots[at..]); + at += comptime flatten(f.type).len; + } + return out; + }, + else => comptime unreachable, + } +} + +fn put(comptime Int: type, ptr: [*]u8, value: Int) void { + std.mem.writeInt(Int, ptr[0..@sizeOf(Int)], value, .little); +} + +fn get(comptime Int: type, ptr: [*]const u8) Int { + return std.mem.readInt(Int, ptr[0..@sizeOf(Int)], .little); +} + +pub fn store(comptime T: type, value: T, ptr: [*]u8) void { + switch (@typeInfo(T)) { + .void => {}, + .bool => ptr[0] = @intFromBool(value), + .int => |i| if (i.bits == 21) put(u32, ptr, value) else put(T, ptr, value), + .float => |f| put(std.meta.Int(.unsigned, f.bits), ptr, @bitCast(value)), + .pointer => |p| { + var slots: [2]u64 = undefined; + lowerSlice(p.child, value, &slots); + put(u32, ptr, @intCast(slots[0])); + put(u32, ptr + 4, @intCast(slots[1])); + }, + .@"enum" => { + if (comptime isHandle(T)) { + untrack(T, value); + return put(u32, ptr, @intFromEnum(value)); + } + put(Discriminant(caseCount(T)), ptr, @intFromEnum(value)); + }, + .optional => |o| { + ptr[0] = @intFromBool(value != null); + if (value) |v| store(o.child, v, ptr + payloadOffset(T)); + }, + .@"union" => |u| switch (value) { + inline else => |v, tag| { + put(Discriminant(u.fields.len), ptr, @intFromEnum(tag)); + store(u.fields[@intFromEnum(tag)].type, v, ptr + payloadOffset(T)); + }, + }, + .@"struct" => |s| { + if (s.layout == .@"packed") return put(s.backing_integer.?, ptr, @bitCast(value)); + if (comptime isBorrowed(T)) return put(u32, ptr, @intFromEnum(value.handle)); + inline for (s.fields, 0..) |f, i| { + store(f.type, @field(value, f.name), ptr + fieldOffset(T, i)); + } + }, + else => comptime unreachable, + } +} + +pub fn load(comptime T: type, ptr: [*]const u8) T { + switch (@typeInfo(T)) { + .void => return {}, + .bool => return ptr[0] != 0, + .int => |i| return if (i.bits == 21) @truncate(get(u32, ptr)) else get(T, ptr), + .float => |f| return @bitCast(get(std.meta.Int(.unsigned, f.bits), ptr)), + .pointer => |p| return liftSlice(p.child, get(u32, ptr), get(u32, ptr + 4)), + .@"enum" => { + if (comptime isHandle(T)) { + const value: T = @enumFromInt(get(u32, ptr)); + track(T, value); + return value; + } + return @enumFromInt(get(Discriminant(caseCount(T)), ptr)); + }, + .optional => |o| return if (ptr[0] == 0) null else load(o.child, ptr + payloadOffset(T)), + .@"union" => |u| { + const tag = get(Discriminant(u.fields.len), ptr); + inline for (u.fields, 0..) |f, i| { + if (tag == i) return @unionInit(T, f.name, load(f.type, ptr + payloadOffset(T))); + } + unreachable; + }, + .@"struct" => |s| { + if (s.layout == .@"packed") return @bitCast(get(s.backing_integer.?, ptr)); + var out: T = undefined; + inline for (s.fields, 0..) |f, i| { + @field(out, f.name) = load(f.type, ptr + fieldOffset(T, i)); + } + return out; + }, + else => comptime unreachable, + } +} + +fn toCore(comptime C: type, slot: u64) C { + return switch (C) { + i32 => @bitCast(@as(u32, @truncate(slot))), + i64 => @bitCast(slot), + f32 => @bitCast(@as(u32, @truncate(slot))), + f64 => @bitCast(slot), + else => comptime unreachable, + }; +} + +fn fromCore(value: anytype) u64 { + return switch (@TypeOf(value)) { + i32, f32 => @as(u32, @bitCast(value)), + i64, f64 => @bitCast(value), + else => comptime unreachable, + }; +} + +fn scratch(comptime T: type) [*]u8 { + const a: std.mem.Alignment = comptime .fromByteUnits(alignOf(T)); + const buf = arena().alignedAlloc(u8, a, @max(sizeOf(T), 1)) catch @panic("OOM"); + return buf.ptr; +} + +/// The generator spells out raw signatures on its own, make sure it agrees with us. +fn checkSignature(comptime Func: type, comptime Args: type, comptime Ret: type) void { + const info = @typeInfo(Func).@"fn"; + const args = flatten(Args); + const ret = flatten(Ret); + + var expected: []const Core = if (args.len > max_flat_params) &.{.i32} else args; + if (ret.len > 1) expected = expected ++ [1]Core{.i32}; + const expected_ret = if (ret.len == 1) CoreType(ret[0]) else void; + + var ok = info.params.len == expected.len and info.return_type.? == expected_ret; + if (ok) for (info.params, expected) |p, e| { + if (p.type.? != CoreType(e)) ok = false; + }; + if (!ok) @compileError("raw signature " ++ @typeName(Func) ++ " does not match " ++ @typeName(Args) ++ " -> " ++ @typeName(Ret)); +} + +/// Calls an imported function. `func` is the raw extern with the flattened signature. +pub fn call(func: anytype, comptime Ret: type, args: anytype) Ret { + const Args = @TypeOf(args); + const Raw = std.meta.ArgsTuple(@TypeOf(func)); + const n = comptime flatten(Args).len; + const ret_flat = comptime flatten(Ret).len; + + var slots: [@max(n, 1)]u64 = undefined; + var raw: Raw = undefined; + const used = comptime if (n > max_flat_params) 1 else n; + comptime checkSignature(@TypeOf(func), Args, Ret); + if (n > max_flat_params) { + const buf = scratch(Args); + store(Args, args, buf); + raw[0] = @bitCast(@as(u32, @intFromPtr(buf))); + } else { + lowerFlat(Args, args, &slots); + inline for (0..n) |i| raw[i] = toCore(@TypeOf(raw[i]), slots[i]); + } + + if (ret_flat > 1) { + const out = scratch(Ret); + raw[used] = @bitCast(@as(u32, @intFromPtr(out))); + @call(.auto, func, raw); + return load(Ret, out); + } + if (ret_flat == 0) { + @call(.auto, func, raw); + return liftFlat(Ret, &.{}); + } + const slot = fromCore(@call(.auto, func, raw)); + return liftFlat(Ret, &.{slot}); +} + +/// Turns the raw parameters of an export back into `Args`. +pub fn liftArgs(comptime Args: type, raw: anytype) Args { + const n = comptime flatten(Args).len; + if (n > max_flat_params) { + const ptr: [*]const u8 = @ptrFromInt(@as(u32, @bitCast(raw[0]))); + return load(Args, ptr); + } + var slots: [@max(n, 1)]u64 = undefined; + inline for (0..n) |i| slots[i] = fromCore(raw[i]); + return liftFlat(Args, &slots); +} + +pub fn RawReturn(comptime Ret: type) type { + const flat = flatten(Ret); + if (flat.len == 0) return void; + if (flat.len == 1) return CoreType(flat[0]); + return i32; +} + +/// Lowers the return value of an export, the last thing an export does. +/// Handles that are part of `value` go back to the host, the rest is released. +pub fn lowerReturn(comptime Ret: type, value: Ret) RawReturn(Ret) { + defer releaseHandles(); + const flat = comptime flatten(Ret); + if (flat.len == 0) return; + if (flat.len == 1) { + var slots: [1]u64 = undefined; + lowerFlat(Ret, value, &slots); + return toCore(CoreType(flat[0]), slots[0]); + } + const out = scratch(Ret); + store(Ret, value, out); + return @bitCast(@as(u32, @intFromPtr(out))); +} + +test "layout" { + const Pos = struct { f64, f64, f64 }; + try std.testing.expectEqual(24, sizeOf(Pos)); + try std.testing.expectEqual(8, alignOf(Pos)); + + const Rec = struct { a: u8, b: u32, c: []const u8, d: ?u16 }; + try std.testing.expectEqual(4, alignOf(Rec)); + try std.testing.expectEqual(20, sizeOf(Rec)); + + const Var = union(enum) { a, b: u64, c: []const u8 }; + try std.testing.expectEqual(8, alignOf(Var)); + try std.testing.expectEqual(16, sizeOf(Var)); + try std.testing.expectEqual(2, sizeOf(?u8)); + try std.testing.expectEqual(16, sizeOf(?f64)); +} + +test "flatten" { + try std.testing.expectEqualSlices(Core, &.{ .i32, .i32 }, flatten([]const u8)); + try std.testing.expectEqualSlices(Core, &.{ .i32, .f64 }, flatten(?f64)); + try std.testing.expectEqualSlices(Core, &.{ .i32, .i32 }, flatten(Result(f32, u32))); + try std.testing.expectEqualSlices(Core, &.{ .i32, .i64, .i32 }, flatten(union(enum) { a: f64, b: []const u8, c })); +} + +test "flat round trip" { + const Rec = struct { a: i8, b: ?f32, c: Result(void, u64), d: packed struct(u8) { x: bool, y: bool, _: u6 = 0 } }; + const value: Rec = .{ .a = -3, .b = 1.5, .c = .{ .err = 1 << 40 }, .d = .{ .x = false, .y = true } }; + var slots: [flatten(Rec).len]u64 = undefined; + lowerFlat(Rec, value, &slots); + try std.testing.expectEqual(@as(u64, 0xffff_fffd), slots[0]); + try std.testing.expectEqualDeep(value, liftFlat(Rec, &slots)); +} + +test "memory round trip" { + const Rec = struct { a: u16, b: ?i64, c: union(enum) { x: f32, y: bool }, d: enum(u8) { p, q } }; + const value: Rec = .{ .a = 7, .b = -9, .c = .{ .y = true }, .d = .q }; + var buf: [sizeOf(Rec)]u8 align(8) = undefined; + store(Rec, value, &buf); + try std.testing.expectEqualDeep(value, load(Rec, &buf)); +} + +test "handle tracking" { + const Res = enum(u32) { + _, + + var dropped: [8]u32 = undefined; + var count: usize = 0; + + pub const resource_drop = &record; + + fn record(handle: i32) callconv(.c) void { + dropped[count] = @intCast(handle); + count += 1; + } + }; + const Pair = struct { a: Res, b: ?Res }; + + var slots: [flatten(Pair).len]u64 = .{ 1, 1, 2 }; + const pair = liftFlat(Pair, &slots); + const third = liftFlat(Res, &.{3}); + const fourth = liftFlat(Res, &.{4}); + try std.testing.expectEqual(4, tracked.items.len); + + // Given away, lent, kept, dropped by hand. Only `a` is left for endCall. + lowerFlat(Res, pair.b.?, &slots); + lowerFlat(Borrowed(Res), borrow(pair.a), &slots); + keep(Res, third); + drop(Res, fourth); + try std.testing.expectEqualSlices(u32, &.{4}, Res.dropped[0..Res.count]); + + lowerReturn(void, {}); + try std.testing.expectEqualSlices(u32, &.{ 4, 1 }, Res.dropped[0..Res.count]); + try std.testing.expectEqual(0, tracked.items.len); +} diff --git a/src/check.zig b/src/check.zig new file mode 100644 index 0000000..c4d3c5f --- /dev/null +++ b/src/check.zig @@ -0,0 +1,31 @@ +//! Not part of the package. Zig only analyzes what gets used, so a plugin build +//! never looks at most of src/wit. This takes the address of every generated +//! function to get all of them compiled, see `zig build check`. + +const std = @import("std"); +const wit = @import("wit.zig"); + +fn collect(comptime T: type) []const *const anyopaque { + var out: []const *const anyopaque = &.{}; + for (std.meta.declarations(T)) |decl| { + const Decl = @TypeOf(@field(T, decl.name)); + if (Decl == type) { + const Inner = @field(T, decl.name); + switch (@typeInfo(Inner)) { + .@"struct", .@"enum", .@"union" => out = out ++ collect(Inner), + else => {}, + } + } else if (@typeInfo(Decl) == .@"fn" and !@typeInfo(Decl).@"fn".is_generic) { + out = out ++ [1]*const anyopaque{@ptrCast(&@field(T, decl.name))}; + } + } + return out; +} + +const all = blk: { + @setEvalBranchQuota(10_000_000); + const list = collect(wit); + break :blk list[0..list.len].*; +}; + +export const table: [all.len]*const anyopaque = all; diff --git a/src/cmd.zig b/src/cmd.zig new file mode 100644 index 0000000..372ca53 --- /dev/null +++ b/src/cmd.zig @@ -0,0 +1,146 @@ +//! Declarative commands on top of the generated `command` interface. +//! +//! try pumpkin.cmd.register(ctx, .{ +//! .names = &.{ "greet", "hi" }, +//! .description = "Greets players.", +//! .permission = "my-plugin:command.greet", +//! .run = greetSelf, +//! .then = &.{ +//! .argument("targets", .players, .{ .run = greetTargets }), +//! }, +//! }); + +const std = @import("std"); +const abi = @import("abi.zig"); +const wit = @import("wit.zig"); + +const command = wit.command; +const Context = wit.context.Context; +const Server = wit.server.Server; +const TextComponent = wit.text.TextComponent; + +pub const Sender = command.CommandSender; +pub const Args = command.ConsumedArgs; +pub const Arg = command.Arg; +pub const ArgumentType = command.ArgumentType; +pub const Result = abi.Result(i32, command.CommandError); + +pub const Handler = fn (Sender, Server, Args) Result; +pub const Suggester = fn (Sender, Server, command.SuggestionRequest) command.CommandSuggestions; + +pub const Node = struct { + kind: union(enum) { + literal: []const u8, + argument: struct { name: []const u8, type: ArgumentType }, + }, + options: Options, + + pub const Options = struct { + run: ?*const Handler = null, + /// Only meaningful on arguments. + suggest: ?*const Suggester = null, + then: []const Node = &.{}, + }; + + pub fn literal(name: []const u8, options: Options) Node { + return .{ .kind = .{ .literal = name }, .options = options }; + } + + pub fn argument(name: []const u8, arg_type: ArgumentType, options: Options) Node { + return .{ .kind = .{ .argument = .{ .name = name, .type = arg_type } }, .options = options }; + } + + fn build(node: Node) command.CommandNode { + const built: command.CommandNode = switch (node.kind) { + .literal => |name| .literal(name), + .argument => |arg| .argument(arg.name, arg.type), + }; + if (node.options.run) |handler| built.executeWithHandlerId(@intFromPtr(handler)); + if (node.options.suggest) |suggester| built.suggestWithHandlerId(@intFromPtr(suggester)); + for (node.options.then) |child| built.then(child.build()); + return built; + } +}; + +pub const Spec = struct { + /// The command's name followed by its aliases. + names: []const []const u8, + description: []const u8 = "", + /// Has to start with ":". A node the server has never heard + /// of denies everyone, so `register` registers it as well. + permission: []const u8, + default: wit.permission.PermissionDefault = .allow, + run: ?*const Handler = null, + then: []const Node = &.{}, +}; + +pub fn register(ctx: Context, spec: Spec) error{PermissionRejected}!void { + switch (ctx.registerPermission(.{ + .node = spec.permission, + .description = spec.description, + .default = spec.default, + .children = &.{}, + })) { + .ok => {}, + .err => |message| { + std.log.err("permission {s}: {s}", .{ spec.permission, message }); + return error.PermissionRejected; + }, + } + + const root: command.Command = .init(spec.names, spec.description); + if (spec.run) |handler| root.executeWithHandlerId(@intFromPtr(handler)); + for (spec.then) |child| root.then(child.build()); + ctx.registerCommand(root, spec.permission); +} + +pub fn ok(count: i32) Result { + return .{ .ok = count }; +} + +pub fn fail(message: []const u8) Result { + return .{ .err = .{ .command_failed = .text(message) } }; +} + +/// The value of argument `name` if it was parsed as `tag`. +pub fn get(args: Args, name: []const u8, comptime tag: std.meta.Tag(Arg)) ?@FieldType(Arg, @tagName(tag)) { + const value = args.getValue(name); + return if (value == tag) @field(value, @tagName(tag)) else null; +} + +/// Any numeric argument as an integer, null when missing or out of bounds. +pub fn int(args: Args, name: []const u8) ?i64 { + return switch ((get(args, name, .num) orelse return null)) { + .ok => |number| switch (number) { + .int32 => |v| v, + .int64 => |v| v, + .float32 => |v| @intFromFloat(v), + .float64 => |v| @intFromFloat(v), + }, + .err => null, + }; +} + +pub fn float(args: Args, name: []const u8) ?f64 { + return switch ((get(args, name, .num) orelse return null)) { + .ok => |number| switch (number) { + .int32 => |v| @floatFromInt(v), + .int64 => |v| @floatFromInt(v), + .float32 => |v| v, + .float64 => |v| v, + }, + .err => null, + }; +} + +/// Suggests `values` for the word under the cursor. +pub fn suggestions(request: command.SuggestionRequest, values: []const []const u8) command.CommandSuggestions { + const out = abi.arena().alloc(command.CommandSuggestion, values.len) catch @panic("OOM"); + var n: usize = 0; + for (values) |value| { + if (!std.mem.startsWith(u8, value, request.remaining)) continue; + out[n] = .{ .value = value, .tooltip = null }; + n += 1; + } + return .{ .start = request.start, .length = @intCast(request.remaining.len), .values = out[0..n] }; +} diff --git a/src/msg.zig b/src/msg.zig new file mode 100644 index 0000000..b1a8e10 --- /dev/null +++ b/src/msg.zig @@ -0,0 +1,83 @@ +//! Text components from struct literals instead of a call per style. +//! +//! sender.sendMessage(pumpkin.msg.build(&.{ +//! .{ .text = "[Shop] ", .color = .gold, .bold = true }, +//! .{ .text = "open", .click = .{ .run_command = "/shop" }, .hover = "Opens the shop" }, +//! })); + +const std = @import("std"); +const abi = @import("abi.zig"); +const wit = @import("wit.zig"); + +const TextComponent = wit.text.TextComponent; + +pub const Color = wit.common.NamedColor; +pub const Rgb = wit.common.RgbColor; + +pub const Click = union(enum) { + open_url: []const u8, + run_command: []const u8, + suggest_command: []const u8, + copy: []const u8, + change_page: u32, +}; + +pub const Span = struct { + text: []const u8 = "", + /// A translation key, used instead of `text`. + translate: ?[]const u8 = null, + color: ?Color = null, + /// Wins over `color`. + rgb: ?Rgb = null, + bold: ?bool = null, + italic: ?bool = null, + underlined: ?bool = null, + strikethrough: ?bool = null, + obfuscated: ?bool = null, + click: ?Click = null, + /// Plain text shown on hover. + hover: ?[]const u8 = null, + /// Inserted into the chat box on shift click. + insertion: ?[]const u8 = null, + font: ?[]const u8 = null, +}; + +pub fn span(s: Span) TextComponent { + const out: TextComponent = if (s.translate) |key| .translate(key, &.{}) else .text(s.text); + + if (s.rgb) |rgb| out.colorRgb(rgb) else if (s.color) |color| out.colorNamed(color); + if (s.bold) |v| out.bold(v); + if (s.italic) |v| out.italic(v); + if (s.underlined) |v| out.underlined(v); + if (s.strikethrough) |v| out.strikethrough(v); + if (s.obfuscated) |v| out.obfuscated(v); + if (s.insertion) |v| out.insertion(v); + if (s.font) |v| out.font(v); + if (s.hover) |v| out.hoverShowText(.text(v)); + if (s.click) |click| switch (click) { + .open_url => |v| out.clickOpenUrl(v), + .run_command => |v| out.clickRunCommand(v), + .suggest_command => |v| out.clickSuggestCommand(v), + .copy => |v| out.clickCopyToClipboard(v), + .change_page => |v| out.clickChangePage(v), + }; + return out; +} + +/// One component made of `spans`, in order. +pub fn build(spans: []const Span) TextComponent { + if (spans.len == 1) return span(spans[0]); + const root: TextComponent = .text(""); + for (spans) |s| root.addChild(span(s)); + return root; +} + +pub fn plain(text: []const u8) TextComponent { + return .text(text); +} + +/// A formatted single color message, `color` may be null. +pub fn fmt(color: ?Color, comptime format: []const u8, args: anytype) TextComponent { + const text = std.fmt.allocPrint(abi.arena(), format, args) catch @panic("OOM"); + return span(.{ .text = text, .color = color }); +} diff --git a/src/plugin.wit b/src/plugin.wit new file mode 100644 index 0000000..7e3368d --- /dev/null +++ b/src/plugin.wit @@ -0,0 +1,14266 @@ +/// The main entry point for a Pumpkin plugin. +/// This world defines the exports that the plugin must provide to the host +/// and the imports that the host provides to the plugin. +package pumpkin:plugin@0.1.0; + +interface attributes { + enum attribute { + air-drag-modifier, + armor, + armor-toughness, + attack-damage, + attack-knockback, + attack-speed, + below-name-distance, + block-break-speed, + block-interaction-range, + bounciness, + burning-time, + camera-distance, + explosion-knockback-resistance, + entity-interaction-range, + fall-damage-multiplier, + flying-speed, + follow-range, + friction-modifier, + gravity, + jump-strength, + knockback-resistance, + luck, + max-absorption, + max-health, + mining-efficiency, + movement-efficiency, + movement-speed, + name-tag-distance, + oxygen-bonus, + safe-fall-distance, + scale, + sneaking-speed, + spawn-reinforcements, + step-height, + submerged-mining-speed, + sweeping-damage-ratio, + tempt-range, + water-movement-efficiency, + waypoint-transmit-range, + waypoint-receive-range, + } + + enum modifier-operation { + add, + multiply-base, + multiply-total, + } + + record attribute-modifier { + id: string, + amount: f64, + operation: modifier-operation, + } +} + +interface biomes { + enum biome { + badlands, + bamboo-jungle, + basalt-deltas, + beach, + birch-forest, + cherry-grove, + cold-ocean, + crimson-forest, + dark-forest, + deep-cold-ocean, + deep-dark, + deep-frozen-ocean, + deep-lukewarm-ocean, + deep-ocean, + desert, + dripstone-caves, + end-barrens, + end-highlands, + end-midlands, + eroded-badlands, + flower-forest, + forest, + frozen-ocean, + frozen-peaks, + frozen-river, + grove, + ice-spikes, + jagged-peaks, + jungle, + lukewarm-ocean, + lush-caves, + mangrove-swamp, + meadow, + mushroom-fields, + nether-wastes, + ocean, + old-growth-birch-forest, + old-growth-pine-taiga, + old-growth-spruce-taiga, + pale-garden, + plains, + river, + savanna, + savanna-plateau, + small-end-islands, + snowy-beach, + snowy-plains, + snowy-slopes, + snowy-taiga, + soul-sand-valley, + sparse-jungle, + stony-peaks, + stony-shore, + sulfur-caves, + sunflower-plains, + swamp, + taiga, + the-end, + the-void, + warm-ocean, + warped-forest, + windswept-forest, + windswept-gravelly-hills, + windswept-hills, + windswept-savanna, + wooded-badlands, + } +} + +/// Provides common types and utilities used across the entire plugin API. +interface common { + /// Serialized text component as a postcard byte array. + /// @deprecated Use the text-component resource from the text interface instead. + type raw-text-component = list; + + /// Represents one entry in an NBT compound tag. + record nbt-entry { + key: string, + value: u32, + } + + /// Represents a Minecraft NBT tag. + variant nbt-tag { + byte(s8), + short(s16), + int(s32), + long(s64), + float(f32), + double(f64), + byte-array(list), + string-tag(string), + list-tag(list), + compound(list), + int-array(list), + long-array(list), + } + + /// Represents a Minecraft NBT tag tree. + record nbt-tree { + root: u32, + tags: list, + } + + /// A position in the world grid (integers). + record block-pos { + x: s32, + y: s32, + z: s32, + } + + /// A precise coordinate in the world (floats). + type position = tuple; + + /// Represents the hands of a player. + enum hand { + left, + right, + } + + /// Represents the game modes available in Minecraft. + enum game-mode { + survival, + creative, + adventure, + spectator, + } + + /// The 16 base Minecraft colors. + enum named-color { + black, + dark-blue, + dark-green, + dark-aqua, + dark-red, + dark-purple, + gold, + gray, + dark-gray, + blue, + green, + aqua, + red, + light-purple, + yellow, + white, + } + + /// An RGB color represented by its red, green, and blue components. + record rgb-color { + r: u8, + g: u8, + b: u8, + } + + /// An ARGB color with alpha (transparency) channel. + record argb-color { + a: u8, + r: u8, + g: u8, + b: u8, + } + + /// Represents the type of click interaction in a GUI. + enum click-type { + left, + right, + shift-left, + shift-right, + middle, + drop, + control-drop, + double-click, + number-key, + unknown, + } + + /// Represents the various poses an entity can be in. + enum entity-pose { + standing, + fall-flying, + sleeping, + swimming, + spin-attack, + crouching, + long-jumping, + dying, + croaking, + using-tongue, + sitting, + roaring, + sniffing, + emerging, + digging, + sliding, + shooting, + inhaling, + } + + /// All Minecraft-supported locales. + enum locale { + af-za, + ar-sa, + ast-es, + az-az, + ba-ru, + bar, + be-by, + bg-bg, + br-fr, + brb, + bs-ba, + ca-es, + cs-cz, + cy-gb, + da-dk, + de-at, + de-ch, + de-de, + el-gr, + en-au, + en-ca, + en-gb, + en-nz, + en-pt, + en-ud, + en-us, + enp, + enws, + eo-uy, + es-ar, + es-cl, + es-ec, + es-es, + es-mx, + es-uy, + es-ve, + esan, + et-ee, + eu-es, + fa-ir, + fi-fi, + fil-ph, + fo-fo, + fr-ca, + fr-fr, + fra-de, + fur-it, + fy-nl, + ga-ie, + gd-gb, + gl-es, + haw-us, + he-il, + hi-in, + hr-hr, + hu-hu, + hy-am, + id-id, + ig-ng, + io-en, + is-is, + isv, + it-it, + ja-jp, + jbo-en, + ka-ge, + kk-kz, + kn-in, + ko-kr, + ksh, + kw-gb, + la-la, + lb-lu, + li-li, + lmo, + lo-la, + lol-us, + lt-lt, + lv-lv, + lzh, + mk-mk, + mn-mn, + ms-my, + mt-mt, + nah, + nds-de, + nl-be, + nl-nl, + nn-no, + no-no, + oc-fr, + ovd, + pl-pl, + pt-br, + pt-pt, + qya-aa, + ro-ro, + rpr, + ru-ru, + ry-ua, + sah-sah, + se-no, + sk-sk, + sl-si, + so-so, + sq-al, + sr-cs, + sr-sp, + sv-se, + sxu, + szl, + ta-in, + th-th, + tl-ph, + tlh-aa, + tok, + tr-tr, + tt-ru, + uk-ua, + val-es, + vec-it, + vi-vn, + yi-de, + yo-ng, + zh-cn, + zh-hk, + zh-tw, + zlm-arab, + } +} + +interface damage-types { + enum damage-type { + arrow, + bad-respawn-point, + cactus, + campfire, + cramming, + dragon-breath, + drown, + dry-out, + ender-pearl, + explosion, + fall, + falling-anvil, + falling-block, + falling-stalactite, + fireball, + fireworks, + fly-into-wall, + freeze, + generic, + generic-kill, + hot-floor, + in-fire, + in-wall, + indirect-magic, + lava, + lightning-bolt, + mace-smash, + magic, + mob-attack, + mob-attack-no-aggro, + mob-projectile, + on-fire, + out-of-world, + outside-border, + player-attack, + player-explosion, + sonic-boom, + spear, + spit, + stalagmite, + starve, + sting, + sulfur-cube-hot, + sweet-berry-bush, + thorns, + thrown, + trident, + unattributed-fireball, + wind-charge, + wither, + wither-skull, + } +} + +interface data-components { + enum data-component { + custom-data, + max-stack-size, + max-damage, + damage, + unbreakable, + use-effects, + custom-name, + minimum-attack-charge, + damage-type, + item-name, + item-model, + lore, + rarity, + enchantments, + can-place-on, + can-break, + attribute-modifiers, + custom-model-data, + tooltip-display, + repair-cost, + creative-slot-lock, + enchantment-glint-override, + intangible-projectile, + food, + consumable, + use-remainder, + use-cooldown, + damage-resistant, + tool, + weapon, + attack-range, + enchantable, + equippable, + repairable, + glider, + tooltip-style, + death-protection, + blocks-attacks, + piercing-weapon, + kinetic-weapon, + swing-animation, + additional-trade-cost, + stored-enchantments, + dye, + dyed-color, + map-color, + map-id, + map-decorations, + map-post-processing, + charged-projectiles, + bundle-contents, + potion-contents, + potion-duration-scale, + suspicious-stew-effects, + writable-book-content, + written-book-content, + trim, + debug-stick-state, + entity-data, + bucket-entity-data, + block-entity-data, + instrument, + provides-trim-material, + ominous-bottle-amplifier, + jukebox-playable, + provides-banner-patterns, + recipes, + lodestone-tracker, + firework-explosion, + fireworks, + profile, + note-block-sound, + banner-patterns, + base-color, + pot-decorations, + container, + block-state, + bees, + sulfur-cube-content, + lock, + container-loot, + break-sound, + villager-variant, + wolf-variant, + wolf-sound-variant, + wolf-collar, + fox-variant, + salmon-size, + parrot-variant, + tropical-fish-pattern, + tropical-fish-base-color, + tropical-fish-pattern-color, + mooshroom-variant, + rabbit-variant, + pig-variant, + pig-sound-variant, + cow-variant, + cow-sound-variant, + chicken-variant, + chicken-sound-variant, + zombie-nautilus-variant, + frog-variant, + horse-variant, + painting-variant, + llama-variant, + axolotl-variant, + cat-variant, + cat-sound-variant, + cat-collar, + sheep-color, + shulker-color, + } +} + +interface datapack { + /// Information about a discovered or loaded datapack. + record datapack-info { + id: string, + name: string, + description: string, + pack-format: u32, + is-enabled: bool, + recipe-count: u32, + function-count: u32, + } + + /// Position options for enabling a datapack relative to other packs. + variant enable-position { + first, + last, + before(string), + after(string), + } + + /// Global manager for inspecting and controlling server datapacks. + resource datapack-manager { + /// Returns all known datapacks (both enabled and available/disabled). + list-all-packs: func() -> list; + /// Returns only currently enabled datapacks. + list-enabled-packs: func() -> list; + /// Returns available (disabled) datapacks. + list-available-packs: func() -> list; + /// Retrieves details about a specific datapack by name or ID. + get-pack: func(name: string) -> option; + /// Checks if a datapack is currently enabled. + is-enabled: func(name: string) -> bool; + /// Enables a datapack with a specific priority position. + enable-pack: func(name: string, position: enable-position) -> result<_, string>; + /// Disables an enabled datapack. + disable-pack: func(name: string) -> result<_, string>; + /// Reloads all enabled datapacks, recipes, and function tags, + /// synchronizes recipes with online players, and triggers `#minecraft:load`. + reload: func() -> result<_, string>; + /// Executes a datapack function or function tag (e.g. "namespace:fn" or "#namespace:tag"). + /// Returns the number of commands executed. + execute-function: func(name: string) -> result; + } +} + +interface entity-statuses { + enum entity-status { + armadillo-peek, + armorstand-wobble, + body-break, + cancel-shake-wetness, + chest-break, + death, + dolphin-looking-for-treasure, + drown-particles, + eat-grass, + end-ram, + feet-break, + fireworks-explode, + fishing-rod-reel-in, + fox-eat, + full-debug-info, + guardian-attack-sound, + head-break, + honey-jump, + honey-slide, + in-love-hearts, + jump, + kinetic-hit, + legs-break, + love-hearts, + mainhand-break, + offer-flower, + offhand-break, + permission-level-admins, + permission-level-all, + permission-level-gamemasters, + permission-level-moderators, + permission-level-owners, + poof, + protected-from-death, + ravager-roared, + ravager-stunned, + reduced-debug-info, + saddle-break, + shake, + shake-wetness, + silverfish-merge-anim, + sniffer-digging-sound, + sonic-charge, + squid-anim-synch, + start-attacking, + start-ram, + stop-attacking, + stop-offer-flower, + swap-hands, + taming-failed, + taming-succeeded, + teleport, + tendrils-shiver, + tnt-prime, + trusting-failed, + trusting-succeeded, + use-item-complete, + villager-angry, + villager-happy, + villager-sweat, + witch-hat-magic, + zombie-converting, + } +} + +interface entity-types { + enum entity-type { + acacia-boat, + acacia-chest-boat, + allay, + area-effect-cloud, + armadillo, + armor-stand, + arrow, + axolotl, + bamboo-chest-raft, + bamboo-raft, + bat, + bee, + birch-boat, + birch-chest-boat, + blaze, + block-display, + bogged, + breeze, + breeze-wind-charge, + camel, + camel-husk, + cat, + cave-spider, + cherry-boat, + cherry-chest-boat, + chest-minecart, + chicken, + cod, + command-block-minecart, + copper-golem, + cow, + creaking, + creeper, + dark-oak-boat, + dark-oak-chest-boat, + dolphin, + donkey, + dragon-fireball, + drowned, + egg, + elder-guardian, + end-crystal, + ender-dragon, + ender-pearl, + enderman, + endermite, + evoker, + evoker-fangs, + experience-bottle, + experience-orb, + eye-of-ender, + falling-block, + fireball, + firework-rocket, + fishing-bobber, + fox, + frog, + furnace-minecart, + ghast, + giant, + glow-item-frame, + glow-squid, + goat, + guardian, + happy-ghast, + hoglin, + hopper-minecart, + horse, + husk, + illusioner, + interaction, + iron-golem, + item, + item-display, + item-frame, + jungle-boat, + jungle-chest-boat, + leash-knot, + lightning-bolt, + lingering-potion, + llama, + llama-spit, + magma-cube, + mangrove-boat, + mangrove-chest-boat, + mannequin, + marker, + minecart, + mooshroom, + mule, + nautilus, + oak-boat, + oak-chest-boat, + ocelot, + ominous-item-spawner, + painting, + pale-oak-boat, + pale-oak-chest-boat, + panda, + parched, + parrot, + phantom, + pig, + piglin, + piglin-brute, + pillager, + player, + polar-bear, + pufferfish, + rabbit, + ravager, + salmon, + sheep, + shulker, + shulker-bullet, + silverfish, + skeleton, + skeleton-horse, + slime, + small-fireball, + sniffer, + snow-golem, + snowball, + spawner-minecart, + spectral-arrow, + spider, + splash-potion, + spruce-boat, + spruce-chest-boat, + squid, + stray, + strider, + sulfur-cube, + tadpole, + text-display, + tnt, + tnt-minecart, + trader-llama, + trident, + tropical-fish, + turtle, + vex, + villager, + vindicator, + wandering-trader, + warden, + wind-charge, + witch, + wither, + wither-skeleton, + wither-skull, + wolf, + zoglin, + zombie, + zombie-horse, + zombie-nautilus, + zombie-villager, + zombified-piglin, + } +} + +interface game-events { + enum game-event { + block-activate, + block-attach, + block-change, + block-close, + block-deactivate, + block-destroy, + block-detach, + block-open, + block-place, + bounce, + container-close, + container-open, + drink, + eat, + elytra-glide, + entity-damage, + entity-die, + entity-dismount, + entity-interact, + entity-mount, + entity-place, + entity-action, + equip, + explode, + flap, + fluid-pickup, + fluid-place, + hit-ground, + instrument-play, + item-interact-finish, + item-interact-start, + jukebox-play, + jukebox-stop-play, + lightning-strike, + note-block-play, + prime-fuse, + projectile-land, + projectile-shoot, + sculk-sensor-tendrils-clicking, + shear, + shriek, + splash, + step, + swim, + teleport, + unequip, + resonate-1, + resonate-2, + resonate-3, + resonate-4, + resonate-5, + resonate-6, + resonate-7, + resonate-8, + resonate-9, + resonate-10, + resonate-11, + resonate-12, + resonate-13, + resonate-14, + resonate-15, + } +} + +interface game-rules { + enum game-rule { + advance-time, + advance-weather, + allow-entering-nether-using-portals, + block-drops, + block-explosion-drop-decay, + command-block-output, + command-blocks-work, + drowning-damage, + elytra-movement-check, + ender-pearls-vanish-on-death, + entity-drops, + fall-damage, + fire-damage, + fire-spread-radius-around-player, + forgive-dead-players, + freeze-damage, + global-sound-events, + immediate-respawn, + keep-inventory, + lava-source-conversion, + limited-crafting, + locator-bar, + log-admin-commands, + max-block-modifications, + max-command-forks, + max-command-sequence-length, + max-entity-cramming, + max-minecart-speed, + max-snow-accumulation-height, + mob-drops, + mob-explosion-drop-decay, + mob-griefing, + natural-health-regeneration, + player-movement-check, + players-nether-portal-creative-delay, + players-nether-portal-default-delay, + players-sleeping-percentage, + projectiles-can-break-blocks, + pvp, + raids, + random-tick-speed, + reduced-debug-info, + respawn-radius, + send-command-feedback, + show-advancement-messages, + show-death-messages, + spawn-mobs, + spawn-monsters, + spawn-patrols, + spawn-phantoms, + spawn-wandering-traders, + spawn-wardens, + spawner-blocks-work, + spectators-generate-chunks, + spread-vines, + tnt-explodes, + tnt-explosion-drop-decay, + universal-anger, + water-source-conversion, + } + + variant game-rule-value { + int(s32), + %bool(bool), + } +} + +interface i18n { + use common.{locale}; + + /// Retrieves a translated string from the host. + /// + /// # Arguments + /// * `key`: The namespaced translation key (e.g. `pumpkin:my_key`). + /// * `locale`: The target locale. + /// + /// # Returns + /// The localized string, falling back to English or the key itself. + translate: func(key: string, locale: locale) -> string; + + /// Loads custom translations from a JSON string. + /// + /// # Arguments + /// * `namespace`: The namespace to associate these keys with. + /// * `json`: A JSON string containing a flat map of translations. + /// * `locale`: The target locale for these translations. + load-translations: func(namespace: string, json: string, locale: locale); +} + +interface ipc { + type plugin-id = string; + + type ipc-message = list; + + /// Sends a message to the specified plugin, synchronously receiving a response (or an error). + send-ipc-message: func(recipient: plugin-id, message: ipc-message) -> result>; +} + +interface logging { + enum level { + trace, + debug, + info, + warn, + error, + } + + /// log any general purpose message + log: func(level: level, message: string); + + /// This function is meant to be used by the tracing crate. + log-tracing: func(event: list); +} + +/// Plugin metadata describing the plugin and its compatibility. +interface metadata { + record plugin-metadata { + /// Name of the plugin. + name: string, + /// Plugin version (semver). + version: string, + /// Plugin authors. + authors: list, + /// Short description of the plugin. + description: string, + /// Plugin dependencies. + dependencies: list, + /// Permissions requested by the plugin. + permissions: list, + } + + get-metadata: func() -> plugin-metadata; +} + +interface particles { + enum particle { + angry-villager, + block, + block-marker, + bubble, + sulfur-bubbles, + noxious-gas, + noxious-gas-cloud, + geyser, + geyser-base, + geyser-poof, + geyser-plume, + cloud, + copper-fire-flame, + crit, + damage-indicator, + dragon-breath, + dripping-lava, + falling-lava, + landing-lava, + dripping-water, + falling-water, + dust, + dust-color-transition, + effect, + elder-guardian, + enchanted-hit, + enchant, + end-rod, + entity-effect, + explosion-emitter, + explosion, + gust, + small-gust, + gust-emitter-large, + gust-emitter-small, + sonic-boom, + falling-dust, + firework, + fishing, + flame, + infested, + cherry-leaves, + pale-oak-leaves, + tinted-leaves, + sculk-soul, + sculk-charge, + sculk-charge-pop, + soul-fire-flame, + soul, + flash, + happy-villager, + composter, + heart, + instant-effect, + item, + vibration, + trail, + pause-mob-growth, + reset-mob-growth, + item-slime, + item-cobweb, + item-snowball, + large-smoke, + lava, + mycelium, + note, + poof, + portal, + rain, + smoke, + white-smoke, + sneeze, + spit, + squid-ink, + sweep-attack, + totem-of-undying, + underwater, + splash, + witch, + bubble-pop, + current-down, + bubble-column-up, + nautilus, + dolphin, + campfire-cosy-smoke, + campfire-signal-smoke, + dripping-honey, + falling-honey, + landing-honey, + falling-nectar, + falling-spore-blossom, + ash, + crimson-spore, + warped-spore, + spore-blossom-air, + dripping-obsidian-tear, + falling-obsidian-tear, + landing-obsidian-tear, + reverse-portal, + white-ash, + small-flame, + snowflake, + dripping-dripstone-lava, + falling-dripstone-lava, + dripping-dripstone-water, + falling-dripstone-water, + glow-squid-ink, + glow, + wax-on, + wax-off, + electric-spark, + scrape, + shriek, + egg-crack, + dust-plume, + trial-spawner-detection, + trial-spawner-detection-ominous, + vault-connection, + dust-pillar, + ominous-spawning, + raid-omen, + trial-omen, + block-crumble, + firefly, + sulfur-cube-goo, + } +} + +interface permission { + /// Represents the player's permission level + /// + /// Permission levels determine the player's access to commands and server operations. + /// Each numeric level corresponds to a specific role: + /// - `Zero`: `normal`: Player can use basic commands. + /// - `One`: `moderator`: Player can bypass spawn protection. + /// - `Two`: `gamemaster`: Player or executor can use more commands and player can use command blocks. + /// - `Three`: `admin`: Player or executor can use commands related to multiplayer management. + /// - `Four`: `owner`: Player or executor can use all of the commands, including commands related to server management. + enum permission-level { + zero, + one, + two, + three, + four, + } + + /// Describes the default behavior for permissions + variant permission-default { + /// Permission is not granted by default + deny, + /// Permission is granted by default + allow, + /// Permission is granted by default to operators + op(permission-level), + } + + /// A child permission entry + record permission-child { + node: string, + value: bool, + } + + /// Defines a permission node in the system + record permission { + /// The full node name (e.g., "minecraft:command.gamemode") + node: string, + /// Description of what this permission does + description: string, + /// The default value of this permission + default: permission-default, + /// Children nodes that are affected by this permission + children: list, + } +} + +interface potions { + enum potion-type { + water, + mundane, + thick, + awkward, + night-vision, + long-night-vision, + invisibility, + long-invisibility, + leaping, + long-leaping, + strong-leaping, + fire-resistance, + long-fire-resistance, + swiftness, + long-swiftness, + strong-swiftness, + slowness, + long-slowness, + strong-slowness, + turtle-master, + long-turtle-master, + strong-turtle-master, + water-breathing, + long-water-breathing, + healing, + strong-healing, + harming, + strong-harming, + poison, + long-poison, + strong-poison, + regeneration, + long-regeneration, + strong-regeneration, + strength, + long-strength, + strong-strength, + weakness, + long-weakness, + luck, + slow-falling, + long-slow-falling, + wind-charged, + weaving, + oozing, + infested, + } +} + +/// Provides functionality to schedule tasks to be executed later on the server. +interface scheduler { + /// Schedules a task to be executed once after the specified number of ticks. + /// + /// * `handler-id`: The unique ID of the handler to call when the task executes. + /// * `delay-ticks`: The number of game ticks to wait before execution (20 ticks = 1 second). + /// + /// Returns a unique task ID that can be used to cancel the task. + schedule-delayed-task: func(handler-id: u32, delay-ticks: u64) -> u32; + + /// Schedules a task to be executed repeatedly. + /// + /// * `handler-id`: The unique ID of the handler to call when the task executes. + /// * `delay-ticks`: The number of game ticks to wait before the first execution. + /// * `period-ticks`: The number of game ticks between subsequent executions. + /// + /// Returns a unique task ID that can be used to cancel the task. + schedule-repeating-task: func(handler-id: u32, delay-ticks: u64, period-ticks: u64) -> u32; + + /// Cancels a scheduled task if it hasn't finished yet. + /// + /// * `task-id`: The ID of the task to cancel. + cancel-task: func(task-id: u32); +} + +interface screens { + enum screen { + generic-9x1, + generic-9x2, + generic-9x3, + generic-9x4, + generic-9x5, + generic-9x6, + generic-3x3, + crafter-3x3, + anvil, + beacon, + blast-furnace, + brewing-stand, + crafting, + enchantment, + furnace, + grindstone, + hopper, + lectern, + loom, + merchant, + shulker-box, + smithing, + smoker, + cartography-table, + stonecutter, + } +} + +interface sounds { + enum sound-category { + master, + music, + records, + weather, + blocks, + hostile, + neutral, + players, + ambient, + voice, + ui, + } + + enum sound { + entity-allay-ambient-with-item, + entity-allay-ambient-without-item, + entity-allay-death, + entity-allay-hurt, + entity-allay-item-given, + entity-allay-item-taken, + entity-allay-item-thrown, + ambient-cave, + ambient-basalt-deltas-additions, + ambient-basalt-deltas-loop, + ambient-basalt-deltas-mood, + ambient-crimson-forest-additions, + ambient-crimson-forest-loop, + ambient-crimson-forest-mood, + ambient-nether-wastes-additions, + ambient-nether-wastes-loop, + ambient-nether-wastes-mood, + ambient-soul-sand-valley-additions, + ambient-soul-sand-valley-loop, + ambient-soul-sand-valley-mood, + ambient-warped-forest-additions, + ambient-warped-forest-loop, + ambient-warped-forest-mood, + ambient-underwater-enter, + ambient-underwater-exit, + ambient-underwater-loop, + ambient-underwater-loop-additions, + ambient-underwater-loop-additions-rare, + ambient-underwater-loop-additions-ultra-rare, + block-amethyst-block-break, + block-amethyst-block-chime, + block-amethyst-block-fall, + block-amethyst-block-hit, + block-amethyst-block-place, + block-amethyst-block-resonate, + block-amethyst-block-step, + block-amethyst-cluster-break, + block-amethyst-cluster-fall, + block-amethyst-cluster-hit, + block-amethyst-cluster-place, + block-amethyst-cluster-step, + block-ancient-debris-break, + block-ancient-debris-step, + block-ancient-debris-place, + block-ancient-debris-hit, + block-ancient-debris-fall, + block-anvil-break, + block-anvil-destroy, + block-anvil-fall, + block-anvil-hit, + block-anvil-land, + block-anvil-place, + block-anvil-step, + block-anvil-use, + entity-armadillo-eat, + entity-armadillo-hurt, + entity-armadillo-hurt-reduced, + entity-armadillo-ambient, + entity-armadillo-step, + entity-armadillo-death, + entity-armadillo-roll, + entity-armadillo-land, + entity-armadillo-scute-drop, + entity-armadillo-unroll-finish, + entity-armadillo-peek, + entity-armadillo-unroll-start, + entity-armadillo-brush, + item-armor-equip-chain, + item-armor-equip-diamond, + item-armor-equip-elytra, + item-armor-equip-generic, + item-armor-equip-gold, + item-armor-equip-iron, + item-armor-equip-leather, + item-armor-equip-copper, + item-armor-equip-netherite, + item-armor-equip-turtle, + item-armor-equip-wolf, + item-armor-unequip-wolf, + item-armor-equip-nautilus, + item-armor-unequip-nautilus, + entity-armor-stand-break, + entity-armor-stand-fall, + entity-armor-stand-hit, + entity-armor-stand-place, + entity-arrow-hit, + entity-arrow-hit-player, + entity-arrow-shoot, + item-axe-strip, + item-axe-scrape, + item-axe-wax-off, + entity-axolotl-attack, + entity-axolotl-death, + entity-axolotl-hurt, + entity-axolotl-idle-air, + entity-axolotl-idle-water, + entity-axolotl-splash, + entity-axolotl-swim, + block-azalea-break, + block-azalea-fall, + block-azalea-hit, + block-azalea-place, + block-azalea-step, + block-azalea-leaves-break, + block-azalea-leaves-fall, + block-azalea-leaves-hit, + block-azalea-leaves-place, + block-azalea-leaves-step, + entity-baby-nautilus-ambient, + entity-baby-nautilus-ambient-land, + entity-baby-nautilus-death, + entity-baby-nautilus-death-land, + entity-baby-nautilus-eat, + entity-baby-nautilus-hurt, + entity-baby-nautilus-hurt-land, + entity-nautilus-riding, + entity-baby-nautilus-swim, + block-bamboo-break, + block-bamboo-fall, + block-bamboo-hit, + block-bamboo-place, + block-bamboo-step, + block-bamboo-sapling-break, + block-bamboo-sapling-hit, + block-bamboo-sapling-place, + block-bamboo-wood-break, + block-bamboo-wood-fall, + block-bamboo-wood-hit, + block-bamboo-wood-place, + block-bamboo-wood-step, + block-bamboo-wood-door-close, + block-bamboo-wood-door-open, + block-bamboo-wood-trapdoor-close, + block-bamboo-wood-trapdoor-open, + block-bamboo-wood-button-click-off, + block-bamboo-wood-button-click-on, + block-bamboo-wood-pressure-plate-click-off, + block-bamboo-wood-pressure-plate-click-on, + block-bamboo-wood-fence-gate-close, + block-bamboo-wood-fence-gate-open, + block-barrel-close, + block-barrel-open, + block-basalt-break, + block-basalt-step, + block-basalt-place, + block-basalt-hit, + block-basalt-fall, + entity-bat-ambient, + entity-bat-death, + entity-bat-hurt, + entity-bat-loop, + entity-bat-takeoff, + block-beacon-activate, + block-beacon-ambient, + block-beacon-deactivate, + block-beacon-power-select, + entity-bee-death, + entity-bee-hurt, + entity-bee-loop-aggressive, + entity-bee-loop, + entity-bee-sting, + entity-bee-pollinate, + block-beehive-drip, + block-beehive-enter, + block-beehive-exit, + block-beehive-shear, + block-beehive-work, + block-bell-use, + block-bell-resonate, + block-big-dripleaf-break, + block-big-dripleaf-fall, + block-big-dripleaf-hit, + block-big-dripleaf-place, + block-big-dripleaf-step, + entity-blaze-ambient, + entity-blaze-burn, + entity-blaze-death, + entity-blaze-hurt, + entity-blaze-shoot, + entity-boat-paddle-land, + entity-boat-paddle-water, + entity-bogged-ambient, + entity-bogged-death, + entity-bogged-hurt, + entity-bogged-shear, + entity-bogged-step, + block-bone-block-break, + block-bone-block-fall, + block-bone-block-hit, + block-bone-block-place, + block-bone-block-step, + item-bone-meal-use, + item-book-page-turn, + item-book-put, + block-blastfurnace-fire-crackle, + item-bottle-empty, + item-bottle-fill, + item-bottle-fill-dragonbreath, + entity-breeze-charge, + entity-breeze-deflect, + entity-breeze-inhale, + entity-breeze-idle-ground, + entity-breeze-idle-air, + entity-breeze-shoot, + entity-breeze-jump, + entity-breeze-land, + entity-breeze-slide, + entity-breeze-death, + entity-breeze-hurt, + entity-breeze-whirl, + entity-breeze-wind-burst, + block-brewing-stand-brew, + item-brush-brushing-generic, + item-brush-brushing-sand, + item-brush-brushing-gravel, + item-brush-brushing-sand-complete, + item-brush-brushing-gravel-complete, + block-bubble-column-bubble-pop, + block-bubble-column-upwards-ambient, + block-bubble-column-upwards-inside, + block-bubble-column-whirlpool-ambient, + block-bubble-column-whirlpool-inside, + ui-hud-bubble-pop, + item-bucket-empty, + item-bucket-empty-axolotl, + item-bucket-empty-fish, + item-bucket-empty-lava, + item-bucket-empty-powder-snow, + item-bucket-empty-sulfur-cube, + item-bucket-empty-tadpole, + item-bucket-fill, + item-bucket-fill-axolotl, + item-bucket-fill-fish, + item-bucket-fill-lava, + item-bucket-fill-powder-snow, + item-bucket-fill-sulfur-cube, + item-bucket-fill-tadpole, + item-bundle-drop-contents, + item-bundle-insert, + item-bundle-insert-fail, + item-bundle-remove-one, + block-cactus-flower-break, + block-cactus-flower-place, + block-cake-add-candle, + block-calcite-break, + block-calcite-step, + block-calcite-place, + block-calcite-hit, + block-calcite-fall, + entity-camel-husk-ambient, + entity-camel-husk-dash, + entity-camel-husk-dash-ready, + entity-camel-husk-death, + entity-camel-husk-eat, + entity-camel-husk-hurt, + entity-camel-husk-saddle, + entity-camel-husk-sit, + entity-camel-husk-stand, + entity-camel-husk-step, + entity-camel-husk-step-sand, + entity-camel-ambient, + entity-camel-dash, + entity-camel-dash-ready, + entity-camel-death, + entity-camel-eat, + entity-camel-hurt, + entity-camel-saddle, + entity-camel-sit, + entity-camel-stand, + entity-camel-step, + entity-camel-step-sand, + block-campfire-crackle, + block-candle-ambient, + block-candle-break, + block-candle-extinguish, + block-candle-fall, + block-candle-hit, + block-candle-place, + block-candle-step, + entity-baby-cat-ambient, + entity-baby-cat-stray-ambient, + entity-baby-cat-death, + entity-baby-cat-eat, + entity-baby-cat-hiss, + entity-baby-cat-beg-for-food, + entity-baby-cat-hurt, + entity-baby-cat-purr, + entity-baby-cat-purreow, + entity-cat-ambient, + entity-cat-stray-ambient, + entity-cat-hiss, + entity-cat-hurt, + entity-cat-death, + entity-cat-eat, + entity-cat-beg-for-food, + entity-cat-purr, + entity-cat-purreow, + entity-cat-royal-ambient, + entity-cat-royal-stray-ambient, + entity-cat-royal-hiss, + entity-cat-royal-hurt, + entity-cat-royal-death, + entity-cat-royal-eat, + entity-cat-royal-beg-for-food, + entity-cat-royal-purr, + entity-cat-royal-purreow, + block-cave-vines-break, + block-cave-vines-fall, + block-cave-vines-hit, + block-cave-vines-place, + block-cave-vines-step, + block-cave-vines-pick-berries, + block-chain-break, + block-chain-fall, + block-chain-hit, + block-chain-place, + block-chain-step, + block-cherry-wood-break, + block-cherry-wood-fall, + block-cherry-wood-hit, + block-cherry-wood-place, + block-cherry-wood-step, + block-cherry-sapling-break, + block-cherry-sapling-fall, + block-cherry-sapling-hit, + block-cherry-sapling-place, + block-cherry-sapling-step, + block-cherry-leaves-break, + block-cherry-leaves-fall, + block-cherry-leaves-hit, + block-cherry-leaves-place, + block-cherry-leaves-step, + block-cherry-wood-hanging-sign-step, + block-cherry-wood-hanging-sign-break, + block-cherry-wood-hanging-sign-fall, + block-cherry-wood-hanging-sign-hit, + block-cherry-wood-hanging-sign-place, + block-cherry-wood-door-close, + block-cherry-wood-door-open, + block-cherry-wood-trapdoor-close, + block-cherry-wood-trapdoor-open, + block-cherry-wood-button-click-off, + block-cherry-wood-button-click-on, + block-cherry-wood-pressure-plate-click-off, + block-cherry-wood-pressure-plate-click-on, + block-cherry-wood-fence-gate-close, + block-cherry-wood-fence-gate-open, + block-chest-close, + block-chest-locked, + block-chest-open, + entity-baby-chicken-ambient, + entity-baby-chicken-death, + entity-chicken-egg, + entity-baby-chicken-hurt, + entity-chicken-step, + entity-baby-chicken-step, + entity-chicken-ambient, + entity-chicken-hurt, + entity-chicken-death, + entity-chicken-picky-ambient, + entity-chicken-picky-hurt, + entity-chicken-picky-death, + block-chiseled-bookshelf-break, + block-chiseled-bookshelf-fall, + block-chiseled-bookshelf-hit, + block-chiseled-bookshelf-insert, + block-chiseled-bookshelf-insert-enchanted, + block-chiseled-bookshelf-step, + block-chiseled-bookshelf-pickup, + block-chiseled-bookshelf-pickup-enchanted, + block-chiseled-bookshelf-place, + block-chorus-flower-death, + block-chorus-flower-grow, + item-chorus-fruit-teleport, + block-cobweb-break, + block-cobweb-step, + block-cobweb-place, + block-cobweb-hit, + block-cobweb-fall, + entity-cod-ambient, + entity-cod-death, + entity-cod-flop, + entity-cod-hurt, + block-comparator-click, + block-composter-empty, + block-composter-fill, + block-composter-fill-success, + block-composter-ready, + block-conduit-activate, + block-conduit-ambient, + block-conduit-ambient-short, + block-conduit-attack-target, + block-conduit-deactivate, + block-copper-bulb-break, + block-copper-bulb-step, + block-copper-bulb-place, + block-copper-bulb-hit, + block-copper-bulb-fall, + block-copper-bulb-turn-on, + block-copper-bulb-turn-off, + block-copper-break, + block-copper-step, + block-copper-place, + block-copper-hit, + block-copper-fall, + block-copper-chest-close, + block-copper-chest-open, + block-copper-chest-weathered-close, + block-copper-chest-weathered-open, + block-copper-chest-oxidized-close, + block-copper-chest-oxidized-open, + block-copper-door-close, + block-copper-door-open, + entity-copper-golem-step, + entity-copper-golem-hurt, + entity-copper-golem-death, + entity-copper-golem-weathered-step, + entity-copper-golem-weathered-hurt, + entity-copper-golem-weathered-death, + entity-copper-golem-oxidized-step, + entity-copper-golem-oxidized-hurt, + entity-copper-golem-oxidized-death, + entity-copper-golem-spin, + entity-copper-golem-weathered-spin, + entity-copper-golem-oxidized-spin, + entity-copper-golem-no-item-get, + entity-copper-golem-no-item-no-get, + entity-copper-golem-item-drop, + entity-copper-golem-item-no-drop, + entity-copper-golem-become-statue, + block-copper-golem-statue-break, + block-copper-golem-statue-place, + block-copper-golem-statue-hit, + block-copper-golem-statue-step, + block-copper-golem-statue-fall, + entity-copper-golem-spawn, + entity-copper-golem-shear, + block-copper-grate-break, + block-copper-grate-step, + block-copper-grate-place, + block-copper-grate-hit, + block-copper-grate-fall, + block-copper-trapdoor-close, + block-copper-trapdoor-open, + block-coral-block-break, + block-coral-block-fall, + block-coral-block-hit, + block-coral-block-place, + block-coral-block-step, + entity-cow-milk, + entity-cow-ambient, + entity-cow-hurt, + entity-cow-death, + entity-cow-step, + entity-cow-moody-ambient, + entity-cow-moody-hurt, + entity-cow-moody-death, + entity-cow-moody-step, + block-crafter-craft, + block-crafter-fail, + entity-creaking-ambient, + entity-creaking-activate, + entity-creaking-deactivate, + entity-creaking-attack, + entity-creaking-death, + entity-creaking-step, + entity-creaking-freeze, + entity-creaking-unfreeze, + entity-creaking-spawn, + entity-creaking-sway, + entity-creaking-twitch, + block-creaking-heart-break, + block-creaking-heart-fall, + block-creaking-heart-hit, + block-creaking-heart-hurt, + block-creaking-heart-place, + block-creaking-heart-step, + block-creaking-heart-idle, + block-creaking-heart-spawn, + entity-creeper-death, + entity-creeper-hurt, + entity-creeper-primed, + block-crop-break, + item-crop-plant, + item-crossbow-hit, + item-crossbow-loading-end, + item-crossbow-loading-middle, + item-crossbow-loading-start, + item-crossbow-quick-charge-1, + item-crossbow-quick-charge-2, + item-crossbow-quick-charge-3, + item-crossbow-shoot, + block-deadbush-idle, + block-decorated-pot-break, + block-decorated-pot-fall, + block-decorated-pot-hit, + block-decorated-pot-insert, + block-decorated-pot-insert-fail, + block-decorated-pot-step, + block-decorated-pot-place, + block-decorated-pot-shatter, + block-deepslate-bricks-break, + block-deepslate-bricks-fall, + block-deepslate-bricks-hit, + block-deepslate-bricks-place, + block-deepslate-bricks-step, + block-deepslate-break, + block-deepslate-fall, + block-deepslate-hit, + block-deepslate-place, + block-deepslate-step, + block-deepslate-tiles-break, + block-deepslate-tiles-fall, + block-deepslate-tiles-hit, + block-deepslate-tiles-place, + block-deepslate-tiles-step, + block-dispenser-dispense, + block-dispenser-fail, + block-dispenser-launch, + entity-dolphin-ambient, + entity-dolphin-ambient-water, + entity-dolphin-attack, + entity-dolphin-death, + entity-dolphin-eat, + entity-dolphin-hurt, + entity-dolphin-jump, + entity-dolphin-play, + entity-dolphin-splash, + entity-dolphin-swim, + entity-donkey-ambient, + entity-donkey-angry, + entity-donkey-chest, + entity-donkey-death, + entity-donkey-eat, + entity-donkey-hurt, + entity-donkey-jump, + block-dried-ghast-break, + block-dried-ghast-step, + block-dried-ghast-fall, + block-dried-ghast-ambient, + block-dried-ghast-ambient-water, + block-dried-ghast-place, + block-dried-ghast-place-in-water, + block-dried-ghast-transition, + block-dripstone-block-break, + block-dripstone-block-step, + block-dripstone-block-place, + block-dripstone-block-hit, + block-dripstone-block-fall, + block-dry-grass-ambient, + block-pointed-dripstone-break, + block-pointed-dripstone-step, + block-pointed-dripstone-place, + block-pointed-dripstone-hit, + block-pointed-dripstone-fall, + block-pointed-dripstone-land, + block-pointed-dripstone-drip-lava, + block-pointed-dripstone-drip-water, + block-pointed-dripstone-drip-lava-into-cauldron, + block-pointed-dripstone-drip-water-into-cauldron, + block-big-dripleaf-tilt-down, + block-big-dripleaf-tilt-up, + entity-drowned-ambient, + entity-drowned-ambient-water, + entity-drowned-death, + entity-drowned-death-water, + entity-drowned-hurt, + entity-drowned-hurt-water, + entity-drowned-shoot, + entity-drowned-step, + entity-drowned-swim, + item-dye-use, + entity-egg-throw, + entity-elder-guardian-ambient, + entity-elder-guardian-ambient-land, + entity-elder-guardian-curse, + entity-elder-guardian-death, + entity-elder-guardian-death-land, + entity-elder-guardian-flop, + entity-elder-guardian-hurt, + entity-elder-guardian-hurt-land, + item-elytra-flying, + block-enchantment-table-use, + block-ender-chest-close, + block-ender-chest-open, + entity-ender-dragon-ambient, + entity-ender-dragon-death, + entity-dragon-fireball-explode, + entity-ender-dragon-flap, + entity-ender-dragon-growl, + entity-ender-dragon-hurt, + entity-ender-dragon-shoot, + entity-ender-eye-death, + entity-ender-eye-launch, + entity-enderman-ambient, + entity-enderman-death, + entity-enderman-hurt, + entity-enderman-scream, + entity-enderman-stare, + entity-enderman-teleport, + entity-endermite-ambient, + entity-endermite-death, + entity-endermite-hurt, + entity-endermite-step, + entity-ender-pearl-throw, + block-end-gateway-spawn, + block-end-portal-frame-fill, + block-end-portal-spawn, + entity-evoker-ambient, + entity-evoker-cast-spell, + entity-evoker-celebrate, + entity-evoker-death, + entity-evoker-fangs-attack, + entity-evoker-hurt, + entity-evoker-prepare-attack, + entity-evoker-prepare-summon, + entity-evoker-prepare-wololo, + entity-experience-bottle-throw, + entity-experience-orb-pickup, + block-eyeblossom-open-long, + block-eyeblossom-open, + block-eyeblossom-close-long, + block-eyeblossom-close, + block-eyeblossom-idle, + block-fence-gate-close, + block-fence-gate-open, + item-firecharge-use, + block-firefly-bush-idle, + entity-firework-rocket-blast, + entity-firework-rocket-blast-far, + entity-firework-rocket-large-blast, + entity-firework-rocket-large-blast-far, + entity-firework-rocket-launch, + entity-firework-rocket-shoot, + entity-firework-rocket-twinkle, + entity-firework-rocket-twinkle-far, + block-fire-ambient, + block-fire-extinguish, + entity-fish-swim, + entity-fishing-bobber-retrieve, + entity-fishing-bobber-splash, + entity-fishing-bobber-throw, + item-flintandsteel-use, + block-flowering-azalea-break, + block-flowering-azalea-fall, + block-flowering-azalea-hit, + block-flowering-azalea-place, + block-flowering-azalea-step, + entity-fox-aggro, + entity-fox-ambient, + entity-fox-bite, + entity-fox-death, + entity-fox-eat, + entity-fox-hurt, + entity-fox-screech, + entity-fox-sleep, + entity-fox-sniff, + entity-fox-spit, + entity-fox-teleport, + block-suspicious-sand-break, + block-suspicious-sand-step, + block-suspicious-sand-place, + block-suspicious-sand-hit, + block-suspicious-sand-fall, + block-suspicious-gravel-break, + block-suspicious-gravel-step, + block-suspicious-gravel-place, + block-suspicious-gravel-hit, + block-suspicious-gravel-fall, + block-froglight-break, + block-froglight-fall, + block-froglight-hit, + block-froglight-place, + block-froglight-step, + block-frogspawn-step, + block-frogspawn-break, + block-frogspawn-fall, + block-frogspawn-hatch, + block-frogspawn-hit, + block-frogspawn-place, + entity-frog-ambient, + entity-frog-death, + entity-frog-eat, + entity-frog-hurt, + entity-frog-lay-spawn, + entity-frog-long-jump, + entity-frog-step, + entity-frog-tongue, + block-roots-break, + block-roots-step, + block-roots-place, + block-roots-hit, + block-roots-fall, + block-furnace-fire-crackle, + entity-generic-big-fall, + entity-generic-burn, + entity-generic-death, + entity-generic-drink, + entity-generic-eat, + entity-generic-explode, + entity-generic-extinguish-fire, + entity-generic-hurt, + entity-generic-small-fall, + entity-generic-splash, + entity-generic-swim, + entity-ghast-ambient, + entity-ghast-death, + entity-ghast-hurt, + entity-ghast-scream, + entity-ghast-shoot, + entity-ghast-warn, + entity-ghastling-ambient, + entity-ghastling-death, + entity-ghastling-hurt, + entity-ghastling-spawn, + block-gilded-blackstone-break, + block-gilded-blackstone-fall, + block-gilded-blackstone-hit, + block-gilded-blackstone-place, + block-gilded-blackstone-step, + block-glass-break, + block-glass-fall, + block-glass-hit, + block-glass-place, + block-glass-step, + item-glow-ink-sac-use, + entity-glow-item-frame-add-item, + entity-glow-item-frame-break, + entity-glow-item-frame-place, + entity-glow-item-frame-remove-item, + entity-glow-item-frame-rotate-item, + entity-glow-squid-ambient, + entity-glow-squid-death, + entity-glow-squid-hurt, + entity-glow-squid-squirt, + entity-goat-ambient, + entity-goat-death, + entity-goat-eat, + entity-goat-hurt, + entity-goat-long-jump, + entity-goat-milk, + entity-goat-prepare-ram, + entity-goat-ram-impact, + entity-goat-horn-break, + entity-goat-screaming-ambient, + entity-goat-screaming-death, + entity-goat-screaming-eat, + entity-goat-screaming-hurt, + entity-goat-screaming-long-jump, + entity-goat-screaming-milk, + entity-goat-screaming-prepare-ram, + entity-goat-screaming-ram-impact, + entity-goat-step, + item-golden-dandelion-use, + item-golden-dandelion-unuse, + block-grass-break, + block-grass-fall, + block-grass-hit, + block-grass-place, + block-grass-step, + block-gravel-break, + block-gravel-fall, + block-gravel-hit, + block-gravel-place, + block-gravel-step, + block-grindstone-use, + block-growing-plant-crop, + entity-guardian-ambient, + entity-guardian-ambient-land, + entity-guardian-attack, + entity-guardian-death, + entity-guardian-death-land, + entity-guardian-flop, + entity-guardian-hurt, + entity-guardian-hurt-land, + block-hanging-roots-break, + block-hanging-roots-fall, + block-hanging-roots-hit, + block-hanging-roots-place, + block-hanging-roots-step, + block-hanging-sign-step, + block-hanging-sign-break, + block-hanging-sign-fall, + block-hanging-sign-hit, + block-hanging-sign-place, + entity-happy-ghast-ambient, + entity-happy-ghast-death, + entity-happy-ghast-hurt, + entity-happy-ghast-riding, + block-heavy-core-break, + block-heavy-core-fall, + block-heavy-core-hit, + block-heavy-core-place, + block-heavy-core-step, + block-nether-wood-hanging-sign-step, + block-nether-wood-hanging-sign-break, + block-nether-wood-hanging-sign-fall, + block-nether-wood-hanging-sign-hit, + block-nether-wood-hanging-sign-place, + block-bamboo-wood-hanging-sign-step, + block-bamboo-wood-hanging-sign-break, + block-bamboo-wood-hanging-sign-fall, + block-bamboo-wood-hanging-sign-hit, + block-bamboo-wood-hanging-sign-place, + block-trial-spawner-break, + block-trial-spawner-step, + block-trial-spawner-place, + block-trial-spawner-hit, + block-trial-spawner-fall, + block-trial-spawner-spawn-mob, + block-trial-spawner-about-to-spawn-item, + block-trial-spawner-spawn-item, + block-trial-spawner-spawn-item-begin, + block-trial-spawner-detect-player, + block-trial-spawner-ominous-activate, + block-trial-spawner-ambient, + block-trial-spawner-ambient-ominous, + block-trial-spawner-open-shutter, + block-trial-spawner-close-shutter, + block-trial-spawner-eject-item, + entity-happy-ghast-equip, + entity-happy-ghast-unequip, + entity-happy-ghast-harness-goggles-up, + entity-happy-ghast-harness-goggles-down, + item-hoe-till, + entity-hoglin-ambient, + entity-hoglin-angry, + entity-hoglin-attack, + entity-hoglin-converted-to-zombified, + entity-hoglin-death, + entity-hoglin-hurt, + entity-hoglin-retreat, + entity-hoglin-step, + block-honey-block-break, + block-honey-block-fall, + block-honey-block-hit, + block-honey-block-place, + block-honey-block-slide, + block-honey-block-step, + item-honeycomb-wax-on, + item-honey-bottle-drink, + item-goat-horn-sound-0, + item-goat-horn-sound-1, + item-goat-horn-sound-2, + item-goat-horn-sound-3, + item-goat-horn-sound-4, + item-goat-horn-sound-5, + item-goat-horn-sound-6, + item-goat-horn-sound-7, + entity-horse-ambient, + entity-baby-horse-ambient, + entity-horse-angry, + entity-baby-horse-angry, + entity-horse-armor, + item-horse-armor-unequip, + entity-horse-breathe, + entity-baby-horse-breathe, + entity-horse-death, + entity-baby-horse-death, + entity-horse-eat, + entity-baby-horse-eat, + entity-horse-gallop, + entity-horse-hurt, + entity-baby-horse-hurt, + entity-horse-jump, + entity-horse-land, + entity-baby-horse-land, + entity-horse-saddle, + entity-horse-step, + entity-baby-horse-step, + entity-horse-step-wood, + entity-hostile-big-fall, + entity-hostile-death, + entity-hostile-hurt, + entity-hostile-small-fall, + entity-hostile-splash, + entity-hostile-swim, + entity-husk-ambient, + entity-husk-converted-to-zombie, + entity-husk-death, + entity-husk-hurt, + entity-husk-step, + entity-illusioner-ambient, + entity-illusioner-cast-spell, + entity-illusioner-death, + entity-illusioner-hurt, + entity-illusioner-mirror-move, + entity-illusioner-prepare-blindness, + entity-illusioner-prepare-mirror, + item-ink-sac-use, + block-iron-break, + block-iron-step, + block-iron-place, + block-iron-hit, + block-iron-fall, + block-iron-door-close, + block-iron-door-open, + entity-iron-golem-attack, + entity-iron-golem-damage, + entity-iron-golem-death, + entity-iron-golem-hurt, + entity-iron-golem-repair, + entity-iron-golem-step, + block-iron-trapdoor-close, + block-iron-trapdoor-open, + entity-item-frame-add-item, + entity-item-frame-break, + entity-item-frame-place, + entity-item-frame-remove-item, + entity-item-frame-rotate-item, + entity-item-break, + entity-item-pickup, + block-ladder-break, + block-ladder-fall, + block-ladder-hit, + block-ladder-place, + block-ladder-step, + block-lantern-break, + block-lantern-fall, + block-lantern-hit, + block-lantern-place, + block-lantern-step, + block-large-amethyst-bud-break, + block-large-amethyst-bud-place, + block-lava-ambient, + block-lava-extinguish, + block-lava-pop, + block-leaf-litter-break, + block-leaf-litter-step, + block-leaf-litter-place, + block-leaf-litter-hit, + block-leaf-litter-fall, + item-lead-untied, + item-lead-tied, + item-lead-break, + block-lever-click, + entity-lightning-bolt-impact, + entity-lightning-bolt-thunder, + entity-lingering-potion-throw, + entity-llama-ambient, + entity-llama-angry, + entity-llama-chest, + entity-llama-death, + entity-llama-eat, + entity-llama-hurt, + entity-llama-spit, + entity-llama-step, + entity-llama-swag, + item-llama-carpet-unequip, + entity-magma-cube-death-small, + block-lodestone-break, + block-lodestone-step, + block-lodestone-place, + block-lodestone-hit, + block-lodestone-fall, + item-lodestone-compass-lock, + item-spear-lunge-1, + item-spear-lunge-2, + item-spear-lunge-3, + item-mace-smash-air, + item-mace-smash-ground, + item-mace-smash-ground-heavy, + entity-magma-cube-death, + entity-magma-cube-hurt, + entity-magma-cube-hurt-small, + entity-magma-cube-jump, + entity-magma-cube-squish, + entity-magma-cube-squish-small, + block-mangrove-roots-break, + block-mangrove-roots-fall, + block-mangrove-roots-hit, + block-mangrove-roots-place, + block-mangrove-roots-step, + block-medium-amethyst-bud-break, + block-medium-amethyst-bud-place, + block-metal-break, + block-metal-fall, + block-metal-hit, + block-metal-place, + block-metal-pressure-plate-click-off, + block-metal-pressure-plate-click-on, + block-metal-step, + entity-minecart-inside-underwater, + entity-minecart-inside, + entity-minecart-riding, + entity-mooshroom-convert, + entity-mooshroom-eat, + entity-mooshroom-milk, + entity-mooshroom-suspicious-milk, + entity-mooshroom-shear, + block-moss-carpet-break, + block-moss-carpet-fall, + block-moss-carpet-hit, + block-moss-carpet-place, + block-moss-carpet-step, + block-pink-petals-break, + block-pink-petals-fall, + block-pink-petals-hit, + block-pink-petals-place, + block-pink-petals-step, + block-moss-break, + block-moss-fall, + block-moss-hit, + block-moss-place, + block-moss-step, + block-mud-break, + block-mud-fall, + block-mud-hit, + block-mud-place, + block-mud-step, + block-mud-bricks-break, + block-mud-bricks-fall, + block-mud-bricks-hit, + block-mud-bricks-place, + block-mud-bricks-step, + block-muddy-mangrove-roots-break, + block-muddy-mangrove-roots-fall, + block-muddy-mangrove-roots-hit, + block-muddy-mangrove-roots-place, + block-muddy-mangrove-roots-step, + entity-mule-ambient, + entity-mule-angry, + entity-mule-chest, + entity-mule-death, + entity-mule-eat, + entity-mule-hurt, + entity-mule-jump, + music-creative, + music-credits, + music-disc-5, + music-disc-11, + music-disc-13, + music-disc-blocks, + music-disc-bounce, + music-disc-cat, + music-disc-chirp, + music-disc-far, + music-disc-lava-chicken, + music-disc-mall, + music-disc-mellohi, + music-disc-pigstep, + music-disc-stal, + music-disc-strad, + music-disc-wait, + music-disc-ward, + music-disc-otherside, + music-disc-relic, + music-disc-creator, + music-disc-creator-music-box, + music-disc-precipice, + music-disc-tears, + music-dragon, + music-end, + music-game, + music-menu, + music-nether-basalt-deltas, + music-nether-crimson-forest, + music-overworld-deep-dark, + music-overworld-dripstone-caves, + music-overworld-grove, + music-overworld-jagged-peaks, + music-overworld-lush-caves, + music-overworld-swamp, + music-overworld-forest, + music-overworld-old-growth-taiga, + music-overworld-meadow, + music-overworld-cherry-grove, + music-nether-nether-wastes, + music-overworld-frozen-peaks, + music-overworld-snowy-slopes, + music-nether-soul-sand-valley, + music-overworld-stony-peaks, + music-nether-warped-forest, + music-overworld-flower-forest, + music-overworld-desert, + music-overworld-badlands, + music-overworld-jungle, + music-overworld-sparse-jungle, + music-overworld-bamboo-jungle, + music-overworld-sulfur-caves, + music-under-water, + entity-nautilus-ambient, + entity-nautilus-ambient-land, + entity-nautilus-dash, + entity-nautilus-dash-land, + entity-nautilus-dash-ready, + entity-nautilus-dash-ready-land, + entity-nautilus-death, + entity-nautilus-death-land, + entity-nautilus-eat, + entity-nautilus-hurt, + entity-nautilus-hurt-land, + entity-nautilus-swim, + block-nether-bricks-break, + block-nether-bricks-step, + block-nether-bricks-place, + block-nether-bricks-hit, + block-nether-bricks-fall, + block-nether-wart-break, + item-nether-wart-plant, + block-nether-wood-break, + block-nether-wood-fall, + block-nether-wood-hit, + block-nether-wood-place, + block-nether-wood-step, + block-nether-wood-door-close, + block-nether-wood-door-open, + block-nether-wood-trapdoor-close, + block-nether-wood-trapdoor-open, + block-nether-wood-button-click-off, + block-nether-wood-button-click-on, + block-nether-wood-pressure-plate-click-off, + block-nether-wood-pressure-plate-click-on, + block-nether-wood-fence-gate-close, + block-nether-wood-fence-gate-open, + intentionally-empty, + block-packed-mud-break, + block-packed-mud-fall, + block-packed-mud-hit, + block-packed-mud-place, + block-packed-mud-step, + block-stem-break, + block-stem-step, + block-stem-place, + block-stem-hit, + block-stem-fall, + block-nylium-break, + block-nylium-step, + block-nylium-place, + block-nylium-hit, + block-nylium-fall, + block-nether-sprouts-break, + block-nether-sprouts-step, + block-nether-sprouts-place, + block-nether-sprouts-hit, + block-nether-sprouts-fall, + block-fungus-break, + block-fungus-step, + block-fungus-place, + block-fungus-hit, + block-fungus-fall, + block-weeping-vines-break, + block-weeping-vines-step, + block-weeping-vines-place, + block-weeping-vines-hit, + block-weeping-vines-fall, + block-wart-block-break, + block-wart-block-step, + block-wart-block-place, + block-wart-block-hit, + block-wart-block-fall, + block-netherite-block-break, + block-netherite-block-step, + block-netherite-block-place, + block-netherite-block-hit, + block-netherite-block-fall, + block-netherrack-break, + block-netherrack-step, + block-netherrack-place, + block-netherrack-hit, + block-netherrack-fall, + block-note-block-basedrum, + block-note-block-bass, + block-note-block-bell, + block-note-block-chime, + block-note-block-flute, + block-note-block-guitar, + block-note-block-harp, + block-note-block-hat, + block-note-block-pling, + block-note-block-snare, + block-note-block-trumpet, + block-note-block-trumpet-exposed, + block-note-block-trumpet-oxidized, + block-note-block-trumpet-weathered, + block-note-block-xylophone, + block-note-block-iron-xylophone, + block-note-block-cow-bell, + block-note-block-didgeridoo, + block-note-block-bit, + block-note-block-banjo, + block-note-block-imitate-zombie, + block-note-block-imitate-skeleton, + block-note-block-imitate-creeper, + block-note-block-imitate-ender-dragon, + block-note-block-imitate-wither-skeleton, + block-note-block-imitate-piglin, + entity-ocelot-hurt, + entity-ocelot-ambient, + entity-ocelot-death, + item-ominous-bottle-dispose, + entity-painting-break, + entity-painting-place, + block-pale-hanging-moss-idle, + entity-panda-pre-sneeze, + entity-panda-sneeze, + entity-panda-ambient, + entity-panda-death, + entity-panda-eat, + entity-panda-step, + entity-panda-cant-breed, + entity-panda-aggressive-ambient, + entity-panda-worried-ambient, + entity-panda-hurt, + entity-panda-bite, + entity-parched-ambient, + entity-parched-death, + entity-parched-hurt, + entity-parched-step, + entity-parrot-ambient, + entity-parrot-death, + entity-parrot-eat, + entity-parrot-fly, + entity-parrot-hurt, + entity-parrot-imitate-blaze, + entity-parrot-imitate-bogged, + entity-parrot-imitate-breeze, + entity-parrot-imitate-camel-husk, + entity-parrot-imitate-creaking, + entity-parrot-imitate-creeper, + entity-parrot-imitate-drowned, + entity-parrot-imitate-elder-guardian, + entity-parrot-imitate-ender-dragon, + entity-parrot-imitate-endermite, + entity-parrot-imitate-evoker, + entity-parrot-imitate-ghast, + entity-parrot-imitate-guardian, + entity-parrot-imitate-hoglin, + entity-parrot-imitate-husk, + entity-parrot-imitate-illusioner, + entity-parrot-imitate-magma-cube, + entity-parrot-imitate-phantom, + entity-parrot-imitate-parched, + entity-parrot-imitate-piglin, + entity-parrot-imitate-piglin-brute, + entity-parrot-imitate-pillager, + entity-parrot-imitate-ravager, + entity-parrot-imitate-shulker, + entity-parrot-imitate-silverfish, + entity-parrot-imitate-skeleton, + entity-parrot-imitate-slime, + entity-parrot-imitate-spider, + entity-parrot-imitate-stray, + entity-parrot-imitate-vex, + entity-parrot-imitate-vindicator, + entity-parrot-imitate-warden, + entity-parrot-imitate-witch, + entity-parrot-imitate-wither, + entity-parrot-imitate-wither-skeleton, + entity-parrot-imitate-zoglin, + entity-parrot-imitate-zombie, + entity-parrot-imitate-zombie-horse, + entity-parrot-imitate-zombie-nautilus, + entity-parrot-imitate-zombie-villager, + entity-parrot-step, + entity-phantom-ambient, + entity-phantom-bite, + entity-phantom-death, + entity-phantom-flap, + entity-phantom-hurt, + entity-phantom-swoop, + entity-pig-saddle, + entity-pig-step, + entity-baby-pig-step, + entity-baby-pig-ambient, + entity-baby-pig-eat, + entity-baby-pig-hurt, + entity-baby-pig-death, + entity-pig-ambient, + entity-pig-hurt, + entity-pig-death, + entity-pig-eat, + entity-pig-mini-ambient, + entity-pig-mini-hurt, + entity-pig-mini-death, + entity-pig-mini-eat, + entity-pig-big-ambient, + entity-pig-big-hurt, + entity-pig-big-death, + entity-pig-big-eat, + entity-piglin-admiring-item, + entity-piglin-ambient, + entity-piglin-angry, + entity-piglin-celebrate, + entity-piglin-death, + entity-piglin-jealous, + entity-piglin-hurt, + entity-piglin-retreat, + entity-piglin-step, + entity-piglin-converted-to-zombified, + entity-piglin-brute-ambient, + entity-piglin-brute-angry, + entity-piglin-brute-death, + entity-piglin-brute-hurt, + entity-piglin-brute-step, + entity-piglin-brute-converted-to-zombified, + entity-pillager-ambient, + entity-pillager-celebrate, + entity-pillager-death, + entity-pillager-hurt, + block-piston-contract, + block-piston-extend, + entity-player-attack-crit, + entity-player-attack-knockback, + entity-player-attack-nodamage, + entity-player-attack-strong, + entity-player-attack-sweep, + entity-player-attack-weak, + entity-player-big-fall, + entity-player-breath, + entity-player-burp, + entity-player-death, + entity-player-hurt, + entity-player-hurt-drown, + entity-player-hurt-freeze, + entity-player-hurt-on-fire, + entity-player-hurt-sweet-berry-bush, + entity-player-levelup, + entity-player-small-fall, + entity-player-splash, + entity-player-splash-high-speed, + entity-player-swim, + entity-player-teleport, + entity-polar-bear-ambient, + entity-polar-bear-ambient-baby, + entity-polar-bear-death, + entity-polar-bear-hurt, + entity-polar-bear-step, + entity-polar-bear-warning, + block-polished-deepslate-break, + block-polished-deepslate-fall, + block-polished-deepslate-hit, + block-polished-deepslate-place, + block-polished-deepslate-step, + block-portal-ambient, + block-portal-travel, + block-portal-trigger, + block-powder-snow-break, + block-powder-snow-fall, + block-powder-snow-hit, + block-powder-snow-place, + block-powder-snow-step, + entity-puffer-fish-blow-out, + entity-puffer-fish-blow-up, + entity-puffer-fish-death, + entity-puffer-fish-flop, + entity-puffer-fish-hurt, + entity-puffer-fish-sting, + block-pumpkin-carve, + entity-rabbit-ambient, + entity-rabbit-attack, + entity-rabbit-death, + entity-rabbit-hurt, + entity-rabbit-jump, + event-raid-horn, + entity-ravager-ambient, + entity-ravager-attack, + entity-ravager-celebrate, + entity-ravager-death, + entity-ravager-hurt, + entity-ravager-step, + entity-ravager-stunned, + entity-ravager-roar, + block-nether-gold-ore-break, + block-nether-gold-ore-fall, + block-nether-gold-ore-hit, + block-nether-gold-ore-place, + block-nether-gold-ore-step, + block-nether-ore-break, + block-nether-ore-fall, + block-nether-ore-hit, + block-nether-ore-place, + block-nether-ore-step, + block-redstone-torch-burnout, + block-resin-break, + block-resin-fall, + block-resin-place, + block-resin-step, + block-resin-bricks-break, + block-resin-bricks-fall, + block-resin-bricks-hit, + block-resin-bricks-place, + block-resin-bricks-step, + block-respawn-anchor-ambient, + block-respawn-anchor-charge, + block-respawn-anchor-deplete, + block-respawn-anchor-set-spawn, + block-rooted-dirt-break, + block-rooted-dirt-fall, + block-rooted-dirt-hit, + block-rooted-dirt-place, + block-rooted-dirt-step, + entity-salmon-ambient, + entity-salmon-death, + entity-salmon-flop, + entity-salmon-hurt, + block-sand-break, + block-sand-fall, + block-sand-hit, + block-sand-place, + block-sand-step, + block-sand-idle, + block-scaffolding-break, + block-scaffolding-fall, + block-scaffolding-hit, + block-scaffolding-place, + block-scaffolding-step, + block-sculk-spread, + block-sculk-charge, + block-sculk-break, + block-sculk-fall, + block-sculk-hit, + block-sculk-place, + block-sculk-step, + block-sculk-catalyst-bloom, + block-sculk-catalyst-break, + block-sculk-catalyst-fall, + block-sculk-catalyst-hit, + block-sculk-catalyst-place, + block-sculk-catalyst-step, + block-sculk-sensor-clicking, + block-sculk-sensor-clicking-stop, + block-sculk-sensor-break, + block-sculk-sensor-fall, + block-sculk-sensor-hit, + block-sculk-sensor-place, + block-sculk-sensor-step, + block-sculk-shrieker-break, + block-sculk-shrieker-fall, + block-sculk-shrieker-hit, + block-sculk-shrieker-place, + block-sculk-shrieker-shriek, + block-sculk-shrieker-step, + block-sculk-vein-break, + block-sculk-vein-fall, + block-sculk-vein-hit, + block-sculk-vein-place, + block-sculk-vein-step, + entity-sheep-ambient, + entity-sheep-death, + entity-sheep-hurt, + entity-sheep-shear, + entity-sheep-step, + item-shears-snip, + block-shelf-activate, + block-shelf-break, + block-shelf-deactivate, + block-shelf-fall, + block-shelf-hit, + block-shelf-multi-swap, + block-shelf-place, + block-shelf-place-item, + block-shelf-single-swap, + block-shelf-step, + block-shelf-take-item, + item-shield-block, + item-shield-break, + block-shroomlight-break, + block-shroomlight-step, + block-shroomlight-place, + block-shroomlight-hit, + block-shroomlight-fall, + item-shovel-flatten, + entity-shulker-ambient, + block-shulker-box-close, + block-shulker-box-open, + entity-shulker-bullet-hit, + entity-shulker-bullet-hurt, + entity-shulker-close, + entity-shulker-death, + entity-shulker-hurt, + entity-shulker-hurt-closed, + entity-shulker-open, + entity-shulker-shoot, + entity-shulker-teleport, + entity-silverfish-ambient, + entity-silverfish-death, + entity-silverfish-hurt, + entity-silverfish-step, + entity-skeleton-ambient, + entity-skeleton-converted-to-stray, + entity-skeleton-death, + entity-skeleton-horse-ambient, + entity-skeleton-horse-death, + entity-skeleton-horse-hurt, + entity-skeleton-horse-swim, + entity-skeleton-horse-ambient-water, + entity-skeleton-horse-gallop-water, + entity-skeleton-horse-jump-water, + entity-skeleton-horse-step-water, + entity-skeleton-hurt, + entity-skeleton-shoot, + entity-skeleton-step, + entity-slime-attack, + entity-slime-death, + entity-slime-hurt, + entity-slime-jump, + entity-slime-squish, + block-slime-block-break, + block-slime-block-fall, + block-slime-block-hit, + block-slime-block-place, + block-slime-block-step, + block-small-amethyst-bud-break, + block-small-amethyst-bud-place, + block-small-dripleaf-break, + block-small-dripleaf-fall, + block-small-dripleaf-hit, + block-small-dripleaf-place, + block-small-dripleaf-step, + block-soul-sand-break, + block-soul-sand-step, + block-soul-sand-place, + block-soul-sand-hit, + block-soul-sand-fall, + block-soul-soil-break, + block-soul-soil-step, + block-soul-soil-place, + block-soul-soil-hit, + block-soul-soil-fall, + particle-soul-escape, + block-spawner-break, + block-spawner-fall, + block-spawner-hit, + block-spawner-place, + block-spawner-step, + item-spear-use, + item-spear-hit, + item-spear-attack, + item-spear-wood-use, + item-spear-wood-hit, + item-spear-wood-attack, + block-spore-blossom-break, + block-spore-blossom-fall, + block-spore-blossom-hit, + block-spore-blossom-place, + block-spore-blossom-step, + entity-strider-ambient, + entity-strider-happy, + entity-strider-retreat, + entity-strider-death, + entity-strider-hurt, + entity-strider-step, + entity-strider-step-lava, + entity-strider-eat, + entity-strider-saddle, + entity-slime-death-small, + entity-slime-hurt-small, + entity-slime-jump-small, + entity-slime-squish-small, + block-smithing-table-use, + block-smoker-smoke, + entity-sniffer-step, + entity-sniffer-eat, + entity-sniffer-idle, + entity-sniffer-hurt, + entity-sniffer-death, + entity-sniffer-drop-seed, + entity-sniffer-scenting, + entity-sniffer-sniffing, + entity-sniffer-searching, + entity-sniffer-digging, + entity-sniffer-digging-stop, + entity-sniffer-happy, + block-sniffer-egg-plop, + block-sniffer-egg-crack, + block-sniffer-egg-hatch, + entity-snowball-throw, + block-snow-break, + block-snow-fall, + entity-snow-golem-ambient, + entity-snow-golem-death, + entity-snow-golem-hurt, + entity-snow-golem-shoot, + entity-snow-golem-shear, + block-snow-hit, + block-snow-place, + block-snow-step, + entity-spider-ambient, + entity-spider-death, + entity-spider-hurt, + entity-spider-step, + entity-splash-potion-break, + entity-splash-potion-throw, + block-sponge-break, + block-sponge-fall, + block-sponge-hit, + block-sponge-place, + block-sponge-step, + block-sponge-absorb, + item-spyglass-use, + item-spyglass-stop-using, + entity-squid-ambient, + entity-squid-death, + entity-squid-hurt, + entity-squid-squirt, + block-stone-break, + block-stone-button-click-off, + block-stone-button-click-on, + block-stone-fall, + block-stone-hit, + block-stone-place, + block-stone-pressure-plate-click-off, + block-stone-pressure-plate-click-on, + block-stone-step, + entity-stray-ambient, + entity-stray-death, + entity-stray-hurt, + entity-stray-step, + block-sulfur-spike-break, + block-sulfur-spike-step, + block-sulfur-spike-place, + block-sulfur-spike-hit, + block-sulfur-spike-fall, + block-sulfur-spike-land, + block-sweet-berry-bush-break, + block-sweet-berry-bush-place, + block-sweet-berry-bush-pick-berries, + entity-tadpole-death, + entity-tadpole-flop, + entity-tadpole-grow-up, + entity-tadpole-hurt, + enchant-thorns-hit, + entity-tnt-primed, + item-totem-use, + item-trident-hit, + item-trident-hit-ground, + item-trident-return, + item-trident-riptide-1, + item-trident-riptide-2, + item-trident-riptide-3, + item-trident-throw, + item-trident-thunder, + block-tripwire-attach, + block-tripwire-click-off, + block-tripwire-click-on, + block-tripwire-detach, + entity-tropical-fish-ambient, + entity-tropical-fish-death, + entity-tropical-fish-flop, + entity-tropical-fish-hurt, + block-tuff-break, + block-tuff-step, + block-tuff-place, + block-tuff-hit, + block-tuff-fall, + block-tuff-bricks-break, + block-tuff-bricks-fall, + block-tuff-bricks-hit, + block-tuff-bricks-place, + block-tuff-bricks-step, + block-polished-tuff-break, + block-polished-tuff-fall, + block-polished-tuff-hit, + block-polished-tuff-place, + block-polished-tuff-step, + entity-turtle-ambient-land, + entity-turtle-death, + entity-turtle-death-baby, + entity-turtle-egg-break, + entity-turtle-egg-crack, + entity-turtle-egg-hatch, + entity-turtle-hurt, + entity-turtle-hurt-baby, + entity-turtle-lay-egg, + entity-turtle-shamble, + entity-turtle-shamble-baby, + entity-turtle-swim, + ui-button-click, + ui-loom-select-pattern, + ui-loom-take-result, + ui-cartography-table-take-result, + ui-stonecutter-take-result, + ui-stonecutter-select-recipe, + ui-toast-challenge-complete, + ui-toast-in, + ui-toast-out, + block-vault-activate, + block-vault-ambient, + block-vault-break, + block-vault-close-shutter, + block-vault-deactivate, + block-vault-eject-item, + block-vault-reject-rewarded-player, + block-vault-fall, + block-vault-hit, + block-vault-insert-item, + block-vault-insert-item-fail, + block-vault-open-shutter, + block-vault-place, + block-vault-step, + entity-vex-ambient, + entity-vex-charge, + entity-vex-death, + entity-vex-hurt, + entity-villager-ambient, + entity-villager-celebrate, + entity-villager-death, + entity-villager-hurt, + entity-villager-no, + entity-villager-trade, + entity-villager-yes, + entity-villager-work-armorer, + entity-villager-work-butcher, + entity-villager-work-cartographer, + entity-villager-work-cleric, + entity-villager-work-farmer, + entity-villager-work-fisherman, + entity-villager-work-fletcher, + entity-villager-work-leatherworker, + entity-villager-work-librarian, + entity-villager-work-mason, + entity-villager-work-shepherd, + entity-villager-work-toolsmith, + entity-villager-work-weaponsmith, + entity-vindicator-ambient, + entity-vindicator-celebrate, + entity-vindicator-death, + entity-vindicator-hurt, + block-vine-break, + block-vine-fall, + block-vine-hit, + block-vine-place, + block-vine-step, + block-lily-pad-place, + entity-wandering-trader-ambient, + entity-wandering-trader-death, + entity-wandering-trader-disappeared, + entity-wandering-trader-drink-milk, + entity-wandering-trader-drink-potion, + entity-wandering-trader-hurt, + entity-wandering-trader-no, + entity-wandering-trader-reappeared, + entity-wandering-trader-trade, + entity-wandering-trader-yes, + entity-warden-agitated, + entity-warden-ambient, + entity-warden-angry, + entity-warden-attack-impact, + entity-warden-death, + entity-warden-dig, + entity-warden-emerge, + entity-warden-heartbeat, + entity-warden-hurt, + entity-warden-listening, + entity-warden-listening-angry, + entity-warden-nearby-close, + entity-warden-nearby-closer, + entity-warden-nearby-closest, + entity-warden-roar, + entity-warden-sniff, + entity-warden-sonic-boom, + entity-warden-sonic-charge, + entity-warden-step, + entity-warden-tendril-clicks, + block-hanging-sign-waxed-interact-fail, + block-sign-waxed-interact-fail, + block-water-ambient, + weather-end-flash, + weather-rain, + weather-rain-above, + block-wet-grass-break, + block-wet-grass-fall, + block-wet-grass-hit, + block-wet-grass-place, + block-wet-grass-step, + block-wet-sponge-break, + block-wet-sponge-dries, + block-wet-sponge-fall, + block-wet-sponge-hit, + block-wet-sponge-place, + block-wet-sponge-step, + entity-wind-charge-wind-burst, + entity-wind-charge-throw, + entity-witch-ambient, + entity-witch-celebrate, + entity-witch-death, + entity-witch-drink, + entity-witch-hurt, + entity-witch-throw, + entity-wither-ambient, + entity-wither-break-block, + entity-wither-death, + entity-wither-hurt, + entity-wither-shoot, + entity-wither-skeleton-ambient, + entity-wither-skeleton-death, + entity-wither-skeleton-hurt, + entity-wither-skeleton-step, + entity-wither-spawn, + item-wolf-armor-break, + entity-baby-wolf-ambient, + item-wolf-armor-crack, + item-wolf-armor-damage, + item-wolf-armor-repair, + entity-baby-wolf-death, + entity-baby-wolf-growl, + entity-baby-wolf-hurt, + entity-baby-wolf-pant, + entity-wolf-shake, + entity-wolf-step, + entity-baby-wolf-step, + entity-baby-wolf-whine, + entity-wolf-ambient, + entity-wolf-death, + entity-wolf-growl, + entity-wolf-hurt, + entity-wolf-pant, + entity-wolf-whine, + entity-wolf-puglin-ambient, + entity-wolf-puglin-death, + entity-wolf-puglin-growl, + entity-wolf-puglin-hurt, + entity-wolf-puglin-pant, + entity-wolf-puglin-whine, + entity-wolf-sad-ambient, + entity-wolf-sad-death, + entity-wolf-sad-growl, + entity-wolf-sad-hurt, + entity-wolf-sad-pant, + entity-wolf-sad-whine, + entity-wolf-angry-ambient, + entity-wolf-angry-death, + entity-wolf-angry-growl, + entity-wolf-angry-hurt, + entity-wolf-angry-pant, + entity-wolf-angry-whine, + entity-wolf-grumpy-ambient, + entity-wolf-grumpy-death, + entity-wolf-grumpy-growl, + entity-wolf-grumpy-hurt, + entity-wolf-grumpy-pant, + entity-wolf-grumpy-whine, + entity-wolf-big-ambient, + entity-wolf-big-death, + entity-wolf-big-growl, + entity-wolf-big-hurt, + entity-wolf-big-pant, + entity-wolf-big-whine, + entity-wolf-cute-ambient, + entity-wolf-cute-death, + entity-wolf-cute-growl, + entity-wolf-cute-hurt, + entity-wolf-cute-pant, + entity-wolf-cute-whine, + block-wooden-door-close, + block-wooden-door-open, + block-wooden-trapdoor-close, + block-wooden-trapdoor-open, + block-wooden-button-click-off, + block-wooden-button-click-on, + block-wooden-pressure-plate-click-off, + block-wooden-pressure-plate-click-on, + block-wood-break, + block-wood-fall, + block-wood-hit, + block-wood-place, + block-wood-step, + block-wool-break, + block-wool-fall, + block-wool-hit, + block-wool-place, + block-wool-step, + entity-zoglin-ambient, + entity-zoglin-angry, + entity-zoglin-attack, + entity-zoglin-death, + entity-zoglin-hurt, + entity-zoglin-step, + entity-zombie-ambient, + entity-zombie-attack-wooden-door, + entity-zombie-attack-iron-door, + entity-zombie-break-wooden-door, + entity-zombie-converted-to-drowned, + entity-zombie-death, + entity-zombie-destroy-egg, + entity-zombie-horse-ambient, + entity-zombie-horse-angry, + entity-zombie-horse-death, + entity-zombie-horse-eat, + entity-zombie-horse-hurt, + entity-zombie-hurt, + entity-zombie-infect, + entity-zombie-nautilus-ambient, + entity-zombie-nautilus-ambient-land, + entity-zombie-nautilus-dash, + entity-zombie-nautilus-dash-land, + entity-zombie-nautilus-dash-ready, + entity-zombie-nautilus-dash-ready-land, + entity-zombie-nautilus-death, + entity-zombie-nautilus-death-land, + entity-zombie-nautilus-eat, + entity-zombie-nautilus-hurt, + entity-zombie-nautilus-hurt-land, + entity-zombie-nautilus-swim, + entity-zombified-piglin-ambient, + entity-zombified-piglin-angry, + entity-zombified-piglin-death, + entity-zombified-piglin-hurt, + entity-zombie-step, + entity-zombie-villager-ambient, + entity-zombie-villager-converted, + entity-zombie-villager-cure, + entity-zombie-villager-death, + entity-zombie-villager-hurt, + entity-zombie-villager-step, + event-mob-effect-bad-omen, + event-mob-effect-trial-omen, + event-mob-effect-raid-omen, + item-saddle-unequip, + item-nautilus-saddle-underwater-equip, + item-nautilus-saddle-equip, + block-sulfur-break, + block-sulfur-step, + block-sulfur-place, + block-sulfur-hit, + block-sulfur-fall, + block-potent-sulfur-break, + block-potent-sulfur-step, + block-potent-sulfur-place, + block-potent-sulfur-hit, + block-potent-sulfur-fall, + block-potent-sulfur-geyser-eruption, + block-potent-sulfur-geyser-eruption-active, + block-potent-sulfur-geyser-continuous-eruption, + block-potent-sulfur-geyser-continuous-eruption-active, + block-cinnabar-break, + block-cinnabar-step, + block-cinnabar-place, + block-cinnabar-hit, + block-cinnabar-fall, + entity-sulfur-cube-absorb, + entity-sulfur-cube-bounce, + entity-sulfur-cube-death, + entity-sulfur-cube-eject, + entity-sulfur-cube-hurt, + entity-sulfur-cube-jump, + entity-sulfur-cube-regular-hit, + entity-sulfur-cube-regular-push, + entity-sulfur-cube-bouncy-hit, + entity-sulfur-cube-bouncy-push, + entity-sulfur-cube-slow-bouncy-hit, + entity-sulfur-cube-slow-bouncy-push, + entity-sulfur-cube-slow-flat-hit, + entity-sulfur-cube-slow-flat-push, + entity-sulfur-cube-fast-flat-hit, + entity-sulfur-cube-fast-flat-push, + entity-sulfur-cube-light-hit, + entity-sulfur-cube-light-push, + entity-sulfur-cube-fast-sliding-hit, + entity-sulfur-cube-fast-sliding-push, + entity-sulfur-cube-slow-sliding-hit, + entity-sulfur-cube-slow-sliding-push, + entity-sulfur-cube-sticky-hit, + entity-sulfur-cube-sticky-push, + entity-sulfur-cube-high-resistance-hit, + entity-sulfur-cube-high-resistance-push, + entity-sulfur-cube-explosive-hit, + entity-sulfur-cube-explosive-push, + entity-sulfur-cube-hot-hit, + entity-sulfur-cube-hot-push, + entity-sulfur-cube-squish, + block-potent-sulfur-noxious-gas, + entity-small-sulfur-cube-death, + entity-small-sulfur-cube-hurt, + entity-small-sulfur-cube-jump, + entity-small-sulfur-cube-squish, + entity-small-sulfur-cube-eat, + } +} + +interface statistics { + enum statistic-category { + mined, + crafted, + used, + broken, + picked-up, + dropped, + killed, + killed-by, + custom, + } + + enum custom-statistic { + leave-game, + play-time, + total-world-time, + time-since-death, + time-since-rest, + sneak-time, + walk-one-cm, + crouch-one-cm, + sprint-one-cm, + walk-on-water-one-cm, + fall-one-cm, + climb-one-cm, + fly-one-cm, + walk-under-water-one-cm, + minecart-one-cm, + boat-one-cm, + pig-one-cm, + happy-ghast-one-cm, + horse-one-cm, + aviate-one-cm, + swim-one-cm, + strider-one-cm, + nautilus-one-cm, + jump, + drop, + damage-dealt, + damage-dealt-absorbed, + damage-dealt-resisted, + damage-taken, + damage-blocked-by-shield, + damage-absorbed, + damage-resisted, + deaths, + mob-kills, + animals-bred, + player-kills, + fish-caught, + talked-to-villager, + traded-with-villager, + eat-cake-slice, + fill-cauldron, + use-cauldron, + clean-armor, + clean-banner, + clean-shulker-box, + interact-with-brewingstand, + interact-with-beacon, + inspect-dropper, + inspect-hopper, + inspect-dispenser, + play-noteblock, + tune-noteblock, + pot-flower, + trigger-trapped-chest, + open-enderchest, + enchant-item, + play-record, + interact-with-furnace, + interact-with-crafting-table, + open-chest, + sleep-in-bed, + open-shulker-box, + open-barrel, + interact-with-blast-furnace, + interact-with-smoker, + interact-with-lectern, + interact-with-campfire, + interact-with-cartography-table, + interact-with-loom, + interact-with-stonecutter, + bell-ring, + raid-trigger, + raid-win, + interact-with-anvil, + interact-with-grindstone, + target-hit, + interact-with-smithing-table, + } +} + +interface status-effect { + enum status-effect-type { + speed, + slowness, + haste, + mining-fatigue, + strength, + instant-health, + instant-damage, + jump-boost, + nausea, + regeneration, + resistance, + fire-resistance, + water-breathing, + invisibility, + blindness, + night-vision, + hunger, + weakness, + poison, + wither, + health-boost, + absorption, + saturation, + glowing, + levitation, + luck, + unluck, + slow-falling, + conduit-power, + dolphins-grace, + bad-omen, + hero-of-the-village, + darkness, + trial-omen, + raid-omen, + wind-charged, + weaving, + oozing, + infested, + } + + record status-effect-instance { + effect-type: status-effect-type, + duration: u32, + amplifier: u8, + ambient: bool, + show-particles: bool, + show-icon: bool, + } +} + +interface text { + use common.{named-color, rgb-color, argb-color}; + + resource text-component { + /// Creates a plain text component. + text: static func(plain: string) -> text-component; + /// Creates a translation component. + translate: static func(key: string, %with: list) -> text-component; + /// Creates a translation component with a Bedrock-specific fallback key. + translate-cross: static func(java-key: string, bedrock-key: string, %with: list) -> text-component; + /// Creates an entity names / selector text component. + entity-names: static func(selector: string, separator: option) -> text-component; + /// Creates a keybind text component (e.g., "key.jump"). + keybind: static func(keybind: string) -> text-component; + /// Creates a custom translation component. + custom: static func(namespace: string, key: string, locale: string, %with: list) -> text-component; + /// Parses a legacy Minecraft formatted string (using section signs '§' by default) into a text component. + from-legacy-string: static func(input: string) -> text-component; + /// Parses a legacy formatted string using a custom color code symbol (e.g. '&' or '§'). + from-legacy-string-with-code: static func(input: string, code-symbol: char) -> text-component; + /// Parses a standard Minecraft JSON text component. + from-json: static func(json: string) -> result; + /// Serializes the text component to JSON format. + to-json: func() -> string; + add-child: func(child: text-component); + add-text: func(text: string); + get-text: func() -> string; + encode: func() -> list; + to-pretty-console: func() -> string; + /// Style + color-named: func(color: named-color); + color-rgb: func(color: rgb-color); + gradient-named: func(colors: list); + gradient: func(colors: list); + rainbow: func(); + bold: func(value: bool); + italic: func(value: bool); + underlined: func(value: bool); + strikethrough: func(value: bool); + obfuscated: func(value: bool); + /// Text inserted into chat when shift-clicked + insertion: func(text: string); + font: func(font: string); + shadow-color: func(color: argb-color); + /// Click events + click-open-url: func(url: string); + click-open-file: func(path: string); + click-run-command: func(command: string); + click-suggest-command: func(command: string); + click-change-page: func(page: u32); + click-copy-to-clipboard: func(text: string); + /// Hover events + hover-show-text: func(text: text-component); + /// Item data as SNBT string + hover-show-item: func(item: string); + hover-show-entity: func(entity-type: string, id: string, name: option); + } +} + +interface advancement { + use text.{text-component}; + + /// Frame type for an advancement. + enum frame-type { + task, + challenge, + goal, + } + + /// Display information for an advancement. + record advancement-display { + title: text-component, + description: text-component, + frame: frame-type, + show-toast: bool, + hidden: bool, + announce-to-chat: bool, + background: option, + x: f32, + y: f32, + } + + /// Detailed information about an advancement. + record advancement-info { + id: string, + parent-id: option, + criteria: list, + display: option, + } + + /// Represents progress of an advancement for a player. + record advancement-progress { + advancement-id: string, + done: bool, + awarded-criteria: list, + remaining-criteria: list, + } +} + +interface enchantments { + use text.{text-component}; + + /// Equipment slot where an enchantment is active. + enum attribute-modifier-slot { + any, + main-hand, + off-hand, + hand, + feet, + legs, + chest, + head, + armor, + body, + saddle, + } + + /// Vanilla enchantments enum. + enum enchantment { + aqua-affinity, + bane-of-arthropods, + binding-curse, + blast-protection, + breach, + channeling, + density, + depth-strider, + efficiency, + feather-falling, + fire-aspect, + fire-protection, + flame, + fortune, + frost-walker, + impaling, + infinity, + knockback, + looting, + loyalty, + luck-of-the-sea, + lunge, + lure, + mending, + multishot, + piercing, + power, + projectile-protection, + protection, + punch, + quick-charge, + respiration, + riptide, + sharpness, + silk-touch, + smite, + soul-speed, + sweeping-edge, + swift-sneak, + thorns, + unbreaking, + vanishing-curse, + wind-burst, + } + + /// Represents a custom enchantment definition. + record custom-enchantment { + /// Unique identifier for the enchantment (e.g. "my_plugin:lifesteal"). + id: string, + /// Description or display name of the enchantment. + description: text-component, + /// Maximum level of the enchantment (e.g. 1..=10). + max-level: u32, + /// Base anvil repair/combination cost multiplier. + anvil-cost: u32, + /// Tag or item pattern for supported items (e.g. "#minecraft:enchantable/weapon"). + supported-items: string, + /// Weight / rarity of the enchantment (higher = more common, default 5). + weight: u32, + /// Equipment slots where this enchantment is active. + slots: list, + /// List of exclusive/conflicting enchantment IDs. + exclusive-set: list, + } + + /// Global manager for registering and querying custom enchantments. + resource enchantment-manager { + /// Registers a new custom enchantment with the server. + register-enchantment: func(enchantment: custom-enchantment) -> result<_, string>; + /// Gets an enchantment definition by its ID. + get-enchantment: func(id: string) -> option; + /// Checks if an enchantment ID is registered. + has-enchantment: func(id: string) -> bool; + /// Returns all registered custom enchantment IDs. + get-all-enchantment-ids: func() -> list; + } +} + +interface forms { + use text.{text-component}; + + enum image-type { + url, + path, + } + + record form-image { + %type: image-type, + data: string, + } + + record simple-form-button { + text: text-component, + image: option, + } + + record simple-form { + title: text-component, + content: text-component, + buttons: list, + } + + record modal-form { + title: text-component, + content: text-component, + button1: text-component, + button2: text-component, + } + + variant custom-form-element { + label(text-component), + toggle(tuple), + slider(tuple), + /// text, min, max, step, default + step-slider(tuple, u32>), + /// text, steps, default + dropdown(tuple, u32>), + /// text, options, default + input(tuple), + } + + record custom-form { + title: text-component, + elements: list, + } + + variant form { + simple(simple-form), + modal(modal-form), + custom(custom-form), + } +} + +interface item-stack { + use attributes.{attribute, attribute-modifier}; + use data-components.{data-component}; + use enchantments.{attribute-modifier-slot, enchantment}; + use text.{text-component}; + use common.{nbt-entry, nbt-tree, nbt-tag}; + + /// Represents an enchantment and its level. + record enchantment-value { + enchantment: enchantment, + level: u32, + } + + /// Represents a custom enchantment and its level on an item stack. + record custom-enchantment-value { + enchantment-id: string, + level: u32, + } + + /// Represents an attribute modifier applied to an item stack for a specific slot. + record item-attribute-modifier { + attribute: attribute, + modifier: attribute-modifier, + slot: attribute-modifier-slot, + } + + /// Represents a data component and its serialized value. + record data-component-value { + component: data-component, + /// The serialized value of the component. + value: list, + } + + resource item-stack { + constructor(registry-key: string, count: u8); + /// Returns the unique registry key of the item (e.g., "minecraft:diamond"). + get-registry-key: func() -> string; + /// Returns the number of items in the stack. + get-count: func() -> u8; + /// Sets the number of items in the stack. + set-count: func(count: u8); + /// Returns the maximum number of items that can be in this stack. + get-max-count: func() -> u8; + /// Returns all enchantments on this item stack. + get-enchantments: func() -> list; + /// Adds an enchantment to this item stack. + add-enchantment: func(enchantment: enchantment, level: u32); + /// Removes an enchantment from this item stack. + remove-enchantment: func(enchantment: enchantment); + /// Returns all custom enchantments on this item stack. + get-custom-enchantments: func() -> list; + /// Adds a custom enchantment to this item stack. + add-custom-enchantment: func(enchantment-id: string, level: u32); + /// Removes a custom enchantment from this item stack. + remove-custom-enchantment: func(enchantment-id: string); + /// Returns the level of a custom enchantment on this item stack, if present. + get-custom-enchantment-level: func(enchantment-id: string) -> option; + /// Returns whether this item stack has a specific custom enchantment. + has-custom-enchantment: func(enchantment-id: string) -> bool; + /// Returns all attribute modifiers on this item stack. + get-attribute-modifiers: func() -> list; + /// Adds an attribute modifier to this item stack. + add-attribute-modifier: func(modifier: item-attribute-modifier); + /// Removes all attribute modifiers for a specific attribute from this item stack. + remove-attribute-modifiers: func(attribute: attribute); + /// Clears all custom attribute modifiers from this item stack. + clear-attribute-modifiers: func(); + /// Returns the lore of this item stack. + get-lore: func() -> list; + /// Sets the lore of this item stack. + set-lore: func(lore: list); + /// Adds a line to the lore of this item stack. + add-lore: func(line: text-component); + /// Returns the custom name of this item stack, if set. + get-custom-name: func() -> option; + /// Sets the custom name of this item stack. + set-custom-name: func(name: option); + /// Sets a namespaced custom data value on this item stack. + set-custom-data: func(namespace: string, key: string, value: nbt-tree); + /// Returns a namespaced custom data value from this item stack, if set. + get-custom-data: func(namespace: string, key: string) -> option; + /// Removes a namespaced custom data value from this item stack. + remove-custom-data: func(namespace: string, key: string); + /// Returns whether this item stack has a namespaced custom data value. + has-custom-data: func(namespace: string, key: string) -> bool; + /// Returns all data components on this item stack. + get-components: func() -> list; + /// Sets a data component on this item stack. + set-component: func(component: data-component, value: list); + /// Removes a data component from this item stack. + remove-component: func(component: data-component); + } +} + +interface inventory { + use item-stack.{item-stack}; + use common.{hand}; + + /// Common inventory resource used across GUIs, player inventories, and containers. + resource inventory { + /// Returns the number of slots in this inventory. + get-size: func() -> u32; + /// Returns true if all slots in this inventory are empty. + is-empty: func() -> bool; + /// Returns the item in the specified slot index, or none if empty. + get-item: func(slot: u32) -> option; + /// Sets the item in the specified slot index. + set-item: func(slot: u32, item: option); + /// Removes and returns the item in the specified slot index. + remove-item: func(slot: u32) -> option; + /// Clears all items from this inventory. + clear: func(); + /// Returns all items in this inventory as a list of slots. + get-all-items: func() -> list>; + /// Sets all items in this inventory from a list. + set-all-items: func(items: list>); + /// Counts the total number of items with the given ID in this inventory. + count-item: func(item-id: string) -> u32; + /// Checks if the inventory contains at least one item with the given ID. + contains-item: func(item-id: string) -> bool; + } + + /// Specialized player inventory handle providing access to main inventory, armor, offhand, and hotbar. + resource player-inventory { + /// Returns the generic 36-slot inventory handle (hotbar + main storage). + as-inventory: func() -> inventory; + /// Returns the item currently held in the specified hand. + get-item-in-hand: func(hand: hand) -> option; + /// Sets the item in the specified hand. + set-item-in-hand: func(hand: hand, item: option); + /// Returns the currently selected hotbar slot index (0-8). + get-selected-slot: func() -> u8; + /// Sets the currently selected hotbar slot index (0-8). + set-selected-slot: func(slot: u8); + /// Armor slot accessors + get-helmet: func() -> option; + set-helmet: func(item: option); + get-chestplate: func() -> option; + set-chestplate: func(item: option); + get-leggings: func() -> option; + set-leggings: func(item: option); + get-boots: func() -> option; + set-boots: func(item: option); + get-off-hand: func() -> option; + set-off-hand: func(item: option); + /// Clears all armor slots. + clear-armor: func(); + /// Clears the 36 main inventory slots. + clear-main: func(); + /// Clears all slots (main inventory, armor, offhand). + clear-all: func(); + } +} + +interface block-entity { + use common.{block-pos, nbt-tree}; + use item-stack.{item-stack}; + use inventory.{inventory}; + + resource block-entity { + resource-location: func() -> string; + get-position: func() -> block-pos; + get-id: func() -> u32; + is-dirty: func() -> bool; + clear-dirty: func(); + /// Sets a namespaced custom data value on this block entity. + set-custom-data: func(namespace: string, key: string, value: nbt-tree); + /// Returns a namespaced custom data value from this block entity, if set. + get-custom-data: func(namespace: string, key: string) -> option; + /// Removes a namespaced custom data value from this block entity. + remove-custom-data: func(namespace: string, key: string); + /// Returns whether this block entity has a namespaced custom data value. + has-custom-data: func(namespace: string, key: string) -> bool; + } + + resource container-block-entity { + get-block-entity: func() -> block-entity; + /// Returns the generic inventory handle for this container. + get-inventory: func() -> inventory; + get-size: func() -> u32; + is-empty: func() -> bool; + get-stack: func(slot: u32) -> option; + set-stack: func(slot: u32, stack: option); + remove-stack: func(slot: u32) -> option; + clear: func(); + } + + resource command-block-entity { + get-block-entity: func() -> block-entity; + last-output: func() -> string; + track-output: func() -> bool; + success-count: func() -> u32; + command: func() -> string; + auto: func() -> bool; + condition-met: func() -> bool; + powered: func() -> bool; + } + + enum dye-color { + white, + orange, + magenta, + light-blue, + yellow, + lime, + pink, + gray, + light-gray, + cyan, + purple, + blue, + brown, + green, + red, + black, + } + + record sign-text { + messages: list, + color: dye-color, + has-glowing-text: bool, + } + + resource sign-block-entity { + get-block-entity: func() -> block-entity; + get-front-text: func() -> sign-text; + set-front-text: func(text: sign-text); + get-back-text: func() -> sign-text; + set-back-text: func(text: sign-text); + is-waxed: func() -> bool; + set-waxed: func(waxed: bool); + } + + resource jukebox-block-entity { + get-block-entity: func() -> block-entity; + get-container: func() -> container-block-entity; + is-playing: func() -> bool; + stop-playing: func(); + start-playing: func(length-in-ticks: u64); + } + + resource chest-block-entity { + get-block-entity: func() -> block-entity; + get-container: func() -> container-block-entity; + viewer-count: func() -> u32; + } + + resource mob-spawner-block-entity { + get-block-entity: func() -> block-entity; + get-spawn-count: func() -> s32; + get-spawn-range: func() -> s32; + get-delay: func() -> s32; + } + + resource map-block-entity { + get-block-entity: func() -> block-entity; + get-map-id: func() -> s32; + set-map-id: func(map-id: s32); + get-colors: func() -> list; + set-colors: func(colors: list); + set-pixel: func(x: u32, y: u32, color: u8); + get-pixel: func(x: u32, y: u32) -> u8; + update: func(); + stream-frame: func(frame-data: list); + } + + resource hanging-sign-block-entity { + get-block-entity: func() -> block-entity; + get-front-text: func() -> sign-text; + set-front-text: func(text: sign-text); + get-back-text: func() -> sign-text; + set-back-text: func(text: sign-text); + is-waxed: func() -> bool; + set-waxed: func(waxed: bool); + } + + resource trapped-chest-block-entity { + get-block-entity: func() -> block-entity; + get-container: func() -> container-block-entity; + viewer-count: func() -> u32; + } + + resource banner-block-entity { + get-block-entity: func() -> block-entity; + get-custom-name: func() -> option; + } + + resource barrel-block-entity { + get-block-entity: func() -> block-entity; + get-container: func() -> container-block-entity; + viewer-count: func() -> u32; + } + + resource beacon-block-entity { + get-block-entity: func() -> block-entity; + get-container: func() -> container-block-entity; + get-primary-effect: func() -> s32; + get-secondary-effect: func() -> s32; + get-levels: func() -> s32; + } + + resource bed-block-entity { + get-block-entity: func() -> block-entity; + } + + resource beehive-block-entity { + get-block-entity: func() -> block-entity; + get-bee-count: func() -> u32; + } + + resource bell-block-entity { + get-block-entity: func() -> block-entity; + is-ringing: func() -> bool; + get-ring-ticks: func() -> s32; + } + + resource blasting-furnace-block-entity { + get-block-entity: func() -> block-entity; + get-container: func() -> container-block-entity; + get-cooking-time-spent: func() -> u16; + get-cooking-total-time: func() -> u16; + get-lit-time-remaining: func() -> u16; + get-lit-total-time: func() -> u16; + is-burning: func() -> bool; + } + + resource brewing-stand-block-entity { + get-block-entity: func() -> block-entity; + get-container: func() -> container-block-entity; + get-brew-time: func() -> s32; + get-fuel: func() -> s32; + } + + resource brushable-block-block-entity { + get-block-entity: func() -> block-entity; + } + + resource calibrated-sculk-sensor-block-entity { + get-block-entity: func() -> block-entity; + } + + resource campfire-block-entity { + get-block-entity: func() -> block-entity; + get-container: func() -> container-block-entity; + } + + resource chiseled-bookshelf-block-entity { + get-block-entity: func() -> block-entity; + get-container: func() -> container-block-entity; + get-last-interacted-slot: func() -> s8; + } + + resource comparator-block-entity { + get-block-entity: func() -> block-entity; + get-output-signal: func() -> u8; + } + + resource conduit-block-entity { + get-block-entity: func() -> block-entity; + } + + resource copper-golem-statue-block-entity { + get-block-entity: func() -> block-entity; + } + + resource crafter-block-entity { + get-block-entity: func() -> block-entity; + get-container: func() -> container-block-entity; + get-crafting-ticks-remaining: func() -> s32; + is-triggered: func() -> bool; + } + + resource creaking-heart-block-entity { + get-block-entity: func() -> block-entity; + get-creaking-uuid: func() -> option; + } + + resource daylight-detector-block-entity { + get-block-entity: func() -> block-entity; + } + + resource decorated-pot-block-entity { + get-block-entity: func() -> block-entity; + } + + resource dispenser-block-entity { + get-block-entity: func() -> block-entity; + get-container: func() -> container-block-entity; + } + + resource dropper-block-entity { + get-block-entity: func() -> block-entity; + get-container: func() -> container-block-entity; + } + + resource enchanting-table-block-entity { + get-block-entity: func() -> block-entity; + } + + resource end-gateway-block-entity { + get-block-entity: func() -> block-entity; + get-age: func() -> s64; + is-exact-teleport: func() -> bool; + } + + resource end-portal-block-entity { + get-block-entity: func() -> block-entity; + } + + resource ender-chest-block-entity { + get-block-entity: func() -> block-entity; + viewer-count: func() -> u32; + } + + resource furnace-block-entity { + get-block-entity: func() -> block-entity; + get-container: func() -> container-block-entity; + get-cooking-time-spent: func() -> u16; + get-cooking-total-time: func() -> u16; + get-lit-time-remaining: func() -> u16; + get-lit-total-time: func() -> u16; + is-burning: func() -> bool; + } + + resource hopper-block-entity { + get-block-entity: func() -> block-entity; + get-container: func() -> container-block-entity; + get-cooldown: func() -> s32; + } + + resource jigsaw-block-entity { + get-block-entity: func() -> block-entity; + get-name: func() -> string; + get-target: func() -> string; + get-pool: func() -> string; + get-final-state: func() -> string; + get-selection-priority: func() -> s32; + get-placement-priority: func() -> s32; + } + + resource lectern-block-entity { + get-block-entity: func() -> block-entity; + get-container: func() -> container-block-entity; + get-page: func() -> u32; + } + + resource piston-block-entity { + get-block-entity: func() -> block-entity; + get-progress: func() -> f32; + is-extending: func() -> bool; + is-source: func() -> bool; + } + + resource potent-sulfur-block-entity { + get-block-entity: func() -> block-entity; + } + + resource sculk-catalyst-block-entity { + get-block-entity: func() -> block-entity; + } + + resource sculk-sensor-block-entity { + get-block-entity: func() -> block-entity; + } + + resource sculk-shrieker-block-entity { + get-block-entity: func() -> block-entity; + get-warning-level: func() -> s32; + } + + resource shelf-block-entity { + get-block-entity: func() -> block-entity; + get-container: func() -> container-block-entity; + } + + resource shulker-box-block-entity { + get-block-entity: func() -> block-entity; + get-container: func() -> container-block-entity; + viewer-count: func() -> u32; + } + + resource skull-block-entity { + get-block-entity: func() -> block-entity; + get-note-block-sound: func() -> option; + } + + resource smoker-block-entity { + get-block-entity: func() -> block-entity; + get-container: func() -> container-block-entity; + get-cooking-time-spent: func() -> u16; + get-cooking-total-time: func() -> u16; + get-lit-time-remaining: func() -> u16; + get-lit-total-time: func() -> u16; + is-burning: func() -> bool; + } + + resource structure-block-block-entity { + get-block-entity: func() -> block-entity; + get-name: func() -> string; + get-author: func() -> string; + get-mode: func() -> string; + get-integrity: func() -> f32; + get-seed: func() -> s64; + } + + resource test-block-block-entity { + get-block-entity: func() -> block-entity; + } + + resource test-instance-block-block-entity { + get-block-entity: func() -> block-entity; + } + + resource trial-spawner-block-entity { + get-block-entity: func() -> block-entity; + } + + resource vault-block-entity { + get-block-entity: func() -> block-entity; + } + + variant block-entity-type { + command-block-entity(command-block-entity), + sign-block-entity(sign-block-entity), + hanging-sign-block-entity(hanging-sign-block-entity), + jukebox-block-entity(jukebox-block-entity), + chest-block-entity(chest-block-entity), + trapped-chest-block-entity(trapped-chest-block-entity), + mob-spawner-block-entity(mob-spawner-block-entity), + map-block-entity(map-block-entity), + banner-block-entity(banner-block-entity), + barrel-block-entity(barrel-block-entity), + beacon-block-entity(beacon-block-entity), + bed-block-entity(bed-block-entity), + beehive-block-entity(beehive-block-entity), + bell-block-entity(bell-block-entity), + blasting-furnace-block-entity(blasting-furnace-block-entity), + brewing-stand-block-entity(brewing-stand-block-entity), + brushable-block-block-entity(brushable-block-block-entity), + calibrated-sculk-sensor-block-entity(calibrated-sculk-sensor-block-entity), + campfire-block-entity(campfire-block-entity), + chiseled-bookshelf-block-entity(chiseled-bookshelf-block-entity), + comparator-block-entity(comparator-block-entity), + conduit-block-entity(conduit-block-entity), + copper-golem-statue-block-entity(copper-golem-statue-block-entity), + crafter-block-entity(crafter-block-entity), + creaking-heart-block-entity(creaking-heart-block-entity), + daylight-detector-block-entity(daylight-detector-block-entity), + decorated-pot-block-entity(decorated-pot-block-entity), + dispenser-block-entity(dispenser-block-entity), + dropper-block-entity(dropper-block-entity), + enchanting-table-block-entity(enchanting-table-block-entity), + end-gateway-block-entity(end-gateway-block-entity), + end-portal-block-entity(end-portal-block-entity), + ender-chest-block-entity(ender-chest-block-entity), + furnace-block-entity(furnace-block-entity), + hopper-block-entity(hopper-block-entity), + jigsaw-block-entity(jigsaw-block-entity), + lectern-block-entity(lectern-block-entity), + piston-block-entity(piston-block-entity), + potent-sulfur-block-entity(potent-sulfur-block-entity), + sculk-catalyst-block-entity(sculk-catalyst-block-entity), + sculk-sensor-block-entity(sculk-sensor-block-entity), + sculk-shrieker-block-entity(sculk-shrieker-block-entity), + shelf-block-entity(shelf-block-entity), + shulker-box-block-entity(shulker-box-block-entity), + skull-block-entity(skull-block-entity), + smoker-block-entity(smoker-block-entity), + structure-block-block-entity(structure-block-block-entity), + test-block-block-entity(test-block-block-entity), + test-instance-block-block-entity(test-instance-block-block-entity), + trial-spawner-block-entity(trial-spawner-block-entity), + vault-block-entity(vault-block-entity), + container-block-entity(container-block-entity), + } +} + +interface gui { + use text.{text-component}; + use common.{click-type}; + use item-stack.{item-stack}; + use screens.{screen}; + use inventory.{inventory}; + + resource gui { + constructor(%type: screen, title: text-component); + /// Returns the underlying inventory handle for this GUI. + get-inventory: func() -> inventory; + set-item: func(slot: u32, item: item-stack); + get-item: func(slot: u32) -> option; + /// Returns the type of this GUI. + get-type: func() -> screen; + /// Returns the title of this GUI. + get-title: func() -> text-component; + /// Returns the number of slots in this GUI. + get-size: func() -> u32; + /// Clears all items from the GUI. + clear-items: func(); + /// Sets whether players can grab items out of the inventory. + set-allow-grab-items: func(allow: bool); + /// Returns whether players can grab items out of the inventory. + get-allow-grab-items: func() -> bool; + /// Sets whether players can put items into the inventory from their own. + set-allow-put-items: func(allow: bool); + /// Returns whether players can put items into the inventory from their own. + get-allow-put-items: func() -> bool; + } +} + +/// Provides types and utilities for displaying rich dialogs to Java Edition players. +/// These dialogs support various layouts, body elements (text and items), +/// and interactive inputs (checkboxes, text fields, sliders). +interface java-dialogs { + use text.{text-component}; + use item-stack.{item-stack}; + + /// Represents the layout and button configuration of a dialog. + enum dialog-type { + /// A simple dialog with a single "OK" button. + notice, + /// A dialog with "Yes" and "No" buttons. + confirmation, + /// A scrollable list of custom buttons. + multi-action, + /// A list of buttons that open other registered dialogs. + dialog-list, + /// A dedicated menu for displaying server-related links. + server-links, + } + + /// Represents an element in the main content area of a dialog. + variant dialog-body { + /// A simple text message. + plain-message(text-component), + /// A visual item display. + item(item-stack), + } + + /// A checkbox input control. + record dialog-input-bool { + label: text-component, + default-value: bool, + } + + /// A text field input control. + record dialog-input-text { + label: text-component, + placeholder: text-component, + default-value: string, + } + + /// A numerical range slider input control. + record dialog-input-number-range { + label: text-component, + min-value: f32, + max-value: f32, + initial-value: f32, + step: f32, + label-format: option, + } + + /// A multiple-choice selection input control. + record dialog-input-single-option { + label: text-component, + options: list, + initial-index: u32, + } + + /// Represents an interactive input control in a dialog. + variant dialog-input { + /// A checkbox for true/false states. + %bool(dialog-input-bool), + /// A simple string input field. + text(dialog-input-text), + /// A slider for numerical input within a range. + number-range(dialog-input-number-range), + /// A multiple-choice selection button. + single-option(dialog-input-single-option), + } + + /// Defines what happens after a dialog is closed. + enum after-action { + /// Returns the player to the previous screen (e.g., keeping an inventory open). + peek, + /// Closes all open screens. + pop, + } + + /// Represents a custom server-side action. + record custom-click-action { + /// A unique identifier for the action (sent back to the server). + id: string, + /// Optional binary data to send with the action. + payload: option>, + } + + /// Represents an action triggered by a button click. + variant action { + /// Opens an external URL. + open-url(string), + /// Triggers a custom server-side callback with an ID and optional payload. + custom-click(custom-click-action), + } + + /// Represents a clickable button in a dialog. + record action-button { + text: text-component, + tooltip: option, + width: option, + action: action, + } + + /// Built-in link types recognized by the Java Edition client. + enum link-type { + bug-report, + community-guidelines, + support, + status, + feedback, + community, + website, + forums, + news, + announcements, + } + + /// The label for a link, which can be a built-in type or custom text. + variant link-label { + /// A built-in link type with a predefined icon/label. + built-in(link-type), + /// A custom text component label. + custom(text-component), + } + + /// Represents a link displayed in a Java Edition dialog. + record link { + /// The label to display for the link. + label: link-label, + /// The URL the link points to. + url: string, + } + + /// Represents a dialog shown to a Java Edition player. + record dialog { + /// The main title of the dialog. + title: text-component, + /// The layout type of the dialog. + %type: dialog-type, + /// A list of body elements to display in the main area. + body: list, + /// A list of interactive input controls. + inputs: list, + /// A list of clickable buttons (for multi-action and other types). + buttons: list, + /// A list of links (primarily for server-links type). + links: list, + /// What to do after the dialog is closed. + after-action: option, + /// Whether the player can exit the dialog using the Esc key. + can-close-with-escape: bool, + /// The text shown on buttons that link to/open this dialog. + external-title: option, + } +} + +interface recipe { + use item-stack.{item-stack}; + + /// Recipe category for the recipe book. + enum recipe-category { + building, + redstone, + equipment, + misc, + food, + blocks, + } + + /// Represents an ingredient in a recipe. + variant ingredient { + /// A specific item (e.g. "minecraft:diamond"). + item(string), + /// A tag group of items (e.g., "minecraft:logs"). + tag(string), + /// One of multiple specific items. + one-of(list), + } + + /// Represents a shaped crafting recipe. + record shaped-recipe { + /// The pattern of the recipe (e.g., ["# #", " s ", "# #"]). + pattern: list, + /// Mapping of characters in the pattern to ingredients. + key: list>, + /// The resulting item stack. + output: item-stack, + /// The recipe group (optional). + group: option, + /// The recipe category in the recipe book. + category: option, + /// Whether to show a toast notification when the recipe is unlocked. + show-notification: option, + } + + /// Represents a shapeless crafting recipe. + record shapeless-recipe { + /// The list of ingredients required. + ingredients: list, + /// The resulting item stack. + output: item-stack, + /// The recipe group (optional). + group: option, + /// The recipe category in the recipe book. + category: option, + } + + /// Represents a cooking recipe (Smelting, Blasting, Smoking, Campfire). + record cooking-recipe { + /// The ingredient to cook. + ingredient: ingredient, + /// The resulting item stack. + output: item-stack, + /// Experience points awarded. + experience: f32, + /// Cooking time in ticks. + cooking-time: u32, + /// The recipe group (optional). + group: option, + /// The recipe category in the recipe book. + category: option, + } + + /// Types of cooking stations. + enum cooking-type { + smelting, + blasting, + smoking, + campfire, + } + + /// Common interface for registering recipes. + resource recipe-manager { + /// Registers a shaped crafting recipe. + register-shaped: func(id: string, recipe: shaped-recipe); + /// Registers a shapeless crafting recipe. + register-shapeless: func(id: string, recipe: shapeless-recipe); + /// Registers a cooking recipe. + register-cooking: func(id: string, station-type: cooking-type, recipe: cooking-recipe); + } +} + +interface scoreboard { + use text.{text-component}; + use common.{named-color}; + + enum render-type { + integer, + hearts, + } + + variant number-format { + blank, + fixed(text-component), + } + + enum display-slot { + player-list, + sidebar, + below-name, + sidebar-team-black, + sidebar-team-dark-blue, + sidebar-team-dark-green, + sidebar-team-dark-aqua, + sidebar-team-dark-red, + sidebar-team-dark-purple, + sidebar-team-gold, + sidebar-team-gray, + sidebar-team-dark-gray, + sidebar-team-blue, + sidebar-team-green, + sidebar-team-aqua, + sidebar-team-red, + sidebar-team-light-purple, + sidebar-team-yellow, + sidebar-team-white, + } + + enum nametag-visibility { + always, + never, + hide-for-other-teams, + hide-for-own-team, + } + + enum collision-rule { + always, + never, + push-other-teams, + push-own-team, + } + + record team-settings { + display-name: text-component, + friendly-fire: bool, + see-friendly-invisibles: bool, + nametag-visibility: nametag-visibility, + collision-rule: collision-rule, + color: named-color, + prefix: text-component, + suffix: text-component, + } + + resource scoreboard { + add-objective: func(name: string, display-name: text-component, render-type: render-type, number-format: option); + update-objective: func(name: string, display-name: text-component, render-type: render-type, number-format: option); + remove-objective: func(name: string); + set-display-slot: func(slot: display-slot, objective-name: string); + clear-display-slot: func(slot: display-slot); + update-score: func(entity-name: string, objective-name: string, value: s32, number-format: option); + add-score: func(entity-name: string, objective-name: string, delta: s32) -> s32; + remove-score: func(entity-name: string, objective-name: string); + reset-entity-scores: func(entity-name: string); + create-team: func(name: string, settings: team-settings); + remove-team: func(name: string); + update-team: func(name: string, settings: team-settings); + add-player-to-team: func(team-name: string, player-name: string); + remove-player-from-team: func(team-name: string, player-name: string); + clear-team-players: func(team-name: string); + get-teams: func() -> list; + get-team: func(name: string) -> option; + get-team-players: func(team-name: string) -> list; + get-player-team: func(player-name: string) -> option; + } + + enum bedrock-sort-order { + ascending, + descending, + } + + enum bedrock-display-slot { + player-list, + sidebar, + below-name, + } + + resource bedrock-scoreboard { + add-objective: func(name: string, display-name: string, sort-order: bedrock-sort-order); + update-objective: func(name: string, display-name: string, sort-order: bedrock-sort-order); + remove-objective: func(name: string); + set-display-slot: func(slot: bedrock-display-slot, objective-name: string); + clear-display-slot: func(slot: bedrock-display-slot); + update-score: func(entity-name: string, objective-name: string, value: s32); + add-score: func(entity-name: string, objective-name: string, delta: s32) -> s32; + remove-score: func(entity-name: string, objective-name: string); + reset-entity-scores: func(entity-name: string); + } +} + +interface uuid { + /// A 128-bit UUID represented as two 64-bit integers. + record uuid { + high: u64, + low: u64, + } + + /// Generates a new random v4 UUID. + generate: func() -> uuid; + + /// Parses a UUID from a string. Returns none if the string is not a valid UUID. + parse: func(s: string) -> option; + + /// Converts a UUID to its standard string representation. + to-string: func(id: uuid) -> string; +} + +interface bedrock-packets { + use uuid.{uuid}; + + enum actor-event-id { + none, + jump, + hurt, + death, + start-attacking, + stop-attacking, + taming-failed, + taming-succeeded, + shake-wetness, + eat-grass, + fishhook-bubble, + fishhook-fish-pos, + fishhook-hook-time, + fishhook-tease, + squid-fleeing, + zombie-converting, + play-ambient, + spawn-alive, + start-offer-flower, + stop-offer-flower, + love-hearts, + villager-angry, + villager-happy, + witch-hat-magic, + fireworks-explode, + in-love-hearts, + silverfish-merge-animation, + guardian-attack-sound, + drink-potion, + throw-potion, + prime-tnt-cart, + prime-creeper, + air-supply, + deprecated-add-player-levels, + guardian-mining-fatigue, + agent-swing-arm, + dragon-start-death-anim, + ground-dust, + shake, + feed, + baby-age, + instant-death, + notify-trade, + leash-destroyed, + caravan-updated, + talisman-activate, + deprecated-update-structure-feature, + player-spawned-mob, + puke, + update-stack-size, + start-swimming, + balloon-pop, + treasure-hunt, + summon-agent, + finished-charging-item, + actor-grow-up, + vibration-detected, + drink-milk, + shake-wetness-stop, + kinetic-damage-dealt, + hurt-without-receiving-damage, + } + + record s-actor-event { + target-runtime-id: s64, + event-id: actor-event-id, + data: s32, + fire-at-position: option>, + } + + enum animate-action { + no-action, + swing-arm, + wake-up, + critical-hit, + magic-critical-hit, + } + + enum actor-swing-source { + none, + build, + mine, + interact, + attack, + use-item, + throw-item, + drop-item, + event, + } + + record s-animate { + action: animate-action, + target-actor-runtime-id: s64, + data: f32, + swing-source: option, + } + + record s-block-pick-request { + position: tuple, + with-data: bool, + max-slots: u8, + } + + record s-client-cache-blob-status { + miss-hashes: list, + hit-hashes: list, + } + + record s-client-cache-status { + is-cache-supported: bool, + } + + record command-origin-data { + r-type: string, + uuid: uuid, + request-id: string, + player-id: s64, + } + + record s-command-request { + command: string, + origin: command-origin-data, + is-internal: bool, + version: string, + } + + record s-container-close { + container-id: u8, + container-type: u8, + server-initiated-close: bool, + } + + record s-emote { + actor-runtime-id: s64, + emote-id: string, + emote-length-ticks: s32, + xuid: string, + platform-id: string, + %flags: u8, + } + + record s-emote-list { + runtime-id: s64, + emote-piece-ids: list, + } + + enum action { + invalid, + stop-riding, + interact-update, + npc-open, + open-inventory, + } + + record s-interact { + action: action, + target-runtime-id: s64, + position: option>, + } + + variant inventory-action-source { + container, + %world, + creative, + todo, + unknown(s32), + } + + record legacy-set-item-slot { + container-id: u8, + slots: list, + } + + record stack-request-item { + identifier: option, + metadata-value: s32, + count: s32, + block-runtime-id: s32, + extra-data: list, + } + + record item-stack-request-action-create { + result-index: u8, + } + + record item-stack-request-action-beacon-payment { + primary-effect-id: s32, + secondary-effect-id: s32, + } + + record item-stack-request-action-mine-block { + hotbar-slot: s32, + predicted-durability: s32, + stack-id: s32, + } + + record item-stack-request-action-craft-recipe { + recipe-id: s32, + repetitions: u8, + } + + record item-stack-request-action-craft-recipe-auto { + recipe-id: s32, + repetitions: u8, + } + + record item-stack-request-action-craft-creative { + creative-item-id: s32, + repetitions: u8, + } + + record item-stack-request-action-optional { + recipe-id: s32, + filter-string-index: s32, + } + + record item-stack-request-action-grindstone { + recipe-id: s32, + repair-cost: s32, + repetitions: u8, + } + + record item-stack-request-action-loom { + pattern-id: string, + repetitions: u8, + } + + record item-stack-request-action-craft-results-deprecated { + result-items: list, + times-crafted: u8, + } + + enum loading-screen-packet-type { + start-loading-screen, + end-loading-screen, + } + + record s-loading-screen { + loading-screen-packet-type: loading-screen-packet-type, + loading-screen-id: option, + } + + record s-login { + protocol-version: s32, + jwt: list, + raw-token: list, + } + + record skin-animation { + frames: f64, + image: string, + image-height: s32, + image-width: s32, + animation-type: s32, + animation-expression: s32, + } + + record persona-piece { + is-default: bool, + pack-id: string, + piece-id: string, + piece-type: string, + product-id: string, + } + + record persona-piece-tint-colour { + colours: list, + piece-type: string, + } + + record client-data { + client-random-id: s64, + device-os: s32, + device-id: string, + game-version: string, + language-code: string, + current-input-mode: s32, + default-input-mode: s32, + ui-profile: s32, + server-address: string, + device-model: string, + gui-scale: s32, + client-is-editor-capable: bool, + client-editor-connection-intent: s32, + max-view-distance: s32, + memory-tier: s32, + platform-type: s32, + graphics-mode: s32, + compatible-with-client-side-chunk-gen: bool, + platform-offline-id: string, + platform-online-id: string, + platform-user-id: string, + self-signed-id: string, + play-fab-id: string, + third-party-name: string, + third-party-name-only: bool, + skin-id: string, + skin-data: string, + skin-image-height: s32, + skin-image-width: s32, + skin-colour: string, + arm-size: string, + persona-skin: bool, + premium-skin: bool, + trusted-skin: bool, + override-skin: bool, + cape-data: string, + cape-id: string, + cape-image-height: s32, + cape-image-width: s32, + cape-on-classic-skin: bool, + skin-geometry: string, + skin-geometry-version: string, + skin-resource-patch: string, + animated-image-data: list, + skin-animation-data: string, + persona-pieces: list, + piece-tint-colours: list, + } + + record s-modal-form-response { + form-id: s32, + json-response: option, + form-cancel-reason: option, + } + + record s-packet-violation-warning { + violation-type: s32, + violation-severity: s32, + violation-packet-id: s32, + violation-context: string, + } + + enum player-action-type { + unknown, + start-destroy-block, + abort-destroy-block, + stop-destroy-block, + get-updated-block, + drop-item, + start-sleeping, + stop-sleeping, + respawn, + start-jump, + start-sprinting, + stop-sprinting, + start-sneaking, + stop-sneaking, + creative-destroy-block, + change-dimension-ack, + start-gliding, + stop-gliding, + deny-destroy-block, + crack-block, + change-skin, + updated-enchanting-seed, + start-swimming, + stop-swimming, + start-spin-attack, + stop-spin-attack, + interact-with-block, + predict-destroy-block, + continue-destroy-block, + start-item-use-on, + stop-item-use-on, + handled-teleport, + missed-swing, + start-crawling, + stop-crawling, + start-flying, + stop-flying, + client-ack-server-data, + start-using-item, + internal-update, + count, + } + + record s-player-action { + player-runtime-id: s64, + action: player-action-type, + block-position: tuple, + result-pos: tuple, + face: s32, + } + + record player-block-action { + action: s32, + block-pos: tuple, + face: s32, + } + + enum input-mode { + mouse, + touch, + game-pad, + motion-controller, + } + + enum play-mode { + normal, + teaser, + screen, + exit-level, + num-modes, + } + + enum interaction-model { + touch, + crosshair, + classic, + } + + enum input-data { + ascend, + descend, + north-jump, + jump-down, + sprint-down, + change-height, + jumping, + auto-jumping-in-water, + sneaking, + sneak-down, + up, + down, + left, + right, + up-left, + up-right, + want-up, + want-down, + want-down-slow, + want-up-slow, + sprinting, + ascend-block, + descend-block, + sneak-toggle-down, + persist-sneak, + start-sprinting, + stop-sprinting, + start-sneaking, + stop-sneaking, + start-swimming, + stop-swimming, + start-jumping, + start-gliding, + stop-gliding, + perform-item-interaction, + perform-block-actions, + perform-item-stack-request, + handled-teleport, + emoting, + missed-swing, + start-crawling, + stop-crawling, + start-flying, + stop-flying, + client-ack-server-data, + client-predicted-vehicle, + paddling-left, + paddling-right, + block-breaking-delay-enabled, + horizontal-collision, + vertical-collision, + down-left, + down-right, + start-using-item, + camera-relative-movement-enabled, + rot-controlled-by-move-direction, + start-spin-attack, + stop-spin-attack, + is-hotbar-touch-only, + jump-released-raw, + jump-pressed-raw, + jump-current-raw, + sneak-released-raw, + sneak-pressed-raw, + sneak-current-raw, + internal-update, + } + + record s-player-hotbar { + selected-slot: s32, + container-id: u8, + should-select-slot: bool, + } + + variant ability-value { + %bool(bool), + float(f32), + } + + record s-request-ability { + ability: s32, + value: ability-value, + } + + record s-request-chunk-radius { + chunk-radius: s32, + max-chunk-radius: u8, + } + + record s-request-network-settings { + client-network-version: s32, + } + + record s-resource-pack-client-response { + response: u8, + download-size: s32, + pack-ids: list, + } + + enum respawn-state { + searching-for-spawn, + ready-to-spawn, + client-ready-to-spawn, + } + + record s-respawn { + position: tuple, + state: respawn-state, + player-runtime-id: s64, + } + + record s-set-local-player-as-initialized { + player-id: s64, + } + + record s-set-player-inventory-options { + left-inventory-tab: s32, + right-inventory-tab: s32, + filtering: bool, + layout-inv: s32, + layout-craft: s32, + } + + enum text-packet-type { + raw, + chat, + translation, + popup, + jukebox-popup, + tip, + system, + whisper, + announcement, + json-whisper, + json, + json-announcement, + } + + record s-text { + needs-translation: bool, + r-type: text-packet-type, + source-name: string, + message: string, + parameters: list, + xuid: string, + platform-chat-id: string, + filtered-message: option, + } + + record synced-attribute { + attribute-name: string, + min-value: f32, + current-value: f32, + max-value: f32, + } + + record enum-data { + name: string, + values: list, + } + + record chained-subcommand-relationship { + index: s32, + value: s32, + } + + record chained-subcommand-data { + name: string, + subcommand-values: list, + } + + record param-data { + name: string, + parse-symbol: s32, + is-optional: bool, + options: u8, + } + + record overload-data { + is-chaining: bool, + parameter-data: list, + } + + record soft-enum-data { + enum-name: string, + enum-options: list, + } + + record constrained-value-data { + enum-value-symbol: s32, + enum-symbol: s32, + constraint-indices: list, + } + + record c-block-actor-data { + block-position: tuple, + actor-data-tags: string, + } + + record c-block-event { + block-position: tuple, + event-type: s32, + event-value: s32, + } + + record c-boss-event { + boss-entity-id: s64, + event-type: u8, + title: string, + filtered-title: string, + health-percentage: f32, + color: u8, + overlay: u8, + } + + record c-change-dimension { + dimension-id: s32, + position: tuple, + respawn: bool, + loading-screen-id: option, + } + + record c-chunk-radius-updated { + chunk-radius: s32, + } + + record missing-blob-data { + blob-id: s64, + blob-data: list, + } + + record c-client-cache-miss-response { + missing-blobs: list, + } + + enum build-platform { + unknown, + google, + ios, + osx, + amazon, + gear-vr, + uwp, + win32, + dedicated, + tv-os, + sony, + nx, + xbox, + windows-phone, + linux, + } + + enum game-type { + unknown, + survival, + creative, + adventure, + default, + spectator, + } + + enum player-permission-level { + visitor, + member, + operator, + custom, + } + + enum command-permission-level { + any, + game-directors, + admin, + host, + owner, + internal, + } + + record command-data { + name: string, + description: string, + %flags: s32, + permission-level: command-permission-level, + alias-enum: s32, + command-data-chained-subcommand-indexes: list, + overloads: list, + } + + record c-available-commands { + enum-values: list, + chained-subcommand-values: list, + post-fixes: list, + enum-data: list, + chained-subcommand-data: list, + commands: list, + soft-enums: list, + constraints: list, + } + + record serialized-abilities-data-serialized-layer { + serialized-layer: s32, + abilities-set: s32, + ability-value: s32, + fly-speed: f32, + vertical-fly-speed: f32, + walk-speed: f32, + } + + record serialized-abilities-data { + target-player-raw-id: s64, + player-permissions: player-permission-level, + command-permissions: command-permission-level, + layers: list, + } + + record actor-link { + ridden-unique-id: s64, + rider-unique-id: s64, + link-type: u8, + immediate: bool, + rider-initiated: bool, + vehicle-angular-velocity: f32, + } + + record c-container-open { + container-id: u8, + container-type: u8, + position: tuple, + target-entity-id: s64, + } + + record c-correct-player-move-prediction { + prediction-type: u8, + pos: tuple, + pos-delta: tuple, + rotation: tuple, + vehicle-angular-velocity: option, + on-ground: bool, + tick: s64, + } + + record item-descriptor-count { + item-identifier: string, + metadata-value: s32, + count: s32, + } + + record recipe-unlock-requirement { + context: s32, + } + + enum creative-category { + all, + construction, + nature, + equipment, + items, + item-command-only, + undefined, + } + + record c-disconnect { + reason: s32, + skip-message: bool, + message: string, + filtered-message: string, + } + + enum rule-value { + null, + } + + record game-rule { + rule-name: string, + rule-can-be-modified: bool, + rule-value: rule-value, + } + + record c-gamerules-changed { + rule-data: list, + } + + record item-data { + item-name: string, + item-id: s32, + is-component-based: bool, + item-version: s32, + component-data: list, + } + + record c-item-registry { + items: list, + } + + record item-stack-response-slot-info { + requested-slot: u8, + slot: u8, + amount: u8, + item-stack-net-id: s32, + custom-name: string, + filtered-custom-name: string, + durability-correction: s32, + } + + record c-level-event { + event-id: s32, + position: tuple, + data: s32, + } + + enum level-event { + particles-destroy-block, + block-start-break, + block-stop-break, + block-update-break, + } + + record c-level-sound-event { + sound-event: string, + position: tuple, + data: s32, + actor-identifier: string, + is-baby: bool, + is-global: bool, + actor-unique-id: s64, + fire-at-position: option>, + } + + record c-mob-effect { + target-runtime-id: s64, + event-id: u8, + effect-id: s32, + effect-amplifier: s32, + show-particles: bool, + effect-duration-ticks: s32, + tick: s64, + ambient: bool, + } + + record c-modal-form-request { + form-id: s32, + form-ui-json: string, + } + + record c-move-actor-absolute { + actor-runtime-id: s64, + header: u8, + position: tuple, + rotation-x: u8, + rotation-y: u8, + rotation-y-head: u8, + } + + record c-move-actor-delta { + entity-runtime-id: s64, + %flags: s32, + x: f32, + y: f32, + z: f32, + pitch: u8, + yaw: u8, + head-yaw: u8, + tick: s64, + } + + record c-move-player { + player-runtime-id: s64, + position: tuple, + pitch: f32, + yaw: f32, + head-yaw: f32, + mode: u8, + on-ground: bool, + riding-runtime-id: s64, + teleport-cause: s32, + teleport-source-entity-type: s32, + tick: s64, + } + + record c-network-chunk-publisher-update { + pos-for-view: tuple, + new-radius: s32, + server-build-chunk-list: list>, + } + + record c-network-settings { + compression-threshold: s32, + compression-algorithm: s32, + client-throttle-enabled: bool, + client-throttle-threshold: u8, + client-throttle-scalar: f32, + } + + enum c-play-status { + login-success, + outdated-client, + outdated-server, + player-spawn, + invalid-tenant, + edition-mismatch-edu-to-vanilla, + edition-mismatch-vanilla-to-edu, + server-full-sub-client, + editor-mismatch-editor-to-vanilla, + editor-mismatch-vanilla-to-editor, + } + + record c-player-hotbar { + selected-slot: s32, + container-id: u8, + should-select-slot: bool, + } + + record piece-tint-color { + piece-type: string, + colors: list, + } + + record skin { + skin-id: string, + play-fab-id: string, + resource-patch: list, + image-width: s32, + image-height: s32, + skin-data: list, + animations: list, + cape-width: s32, + cape-height: s32, + cape-data: list, + geometry-data: list, + animation-data: list, + geometry-data-engine-version: list, + cape-id: string, + full-id: string, + arm-size: string, + skin-color: string, + persona-pieces: list, + piece-tint-colors: list, + is-premium: bool, + is-persona: bool, + persona-cape-on-classic: bool, + is-primary-user: bool, + override-appearance: bool, + is-trusted: bool, + profile-hash: string, + } + + record player-list-entry { + uuid: uuid, + entity-unique-id: s64, + username: string, + xuid: string, + platform-chat-id: string, + build-platform: build-platform, + skin: skin, + is-teacher: bool, + is-host: bool, + is-sub-client: bool, + player-color: list, + } + + record c-player-list { + action: u8, + entries: list, + } + + record c-remove-actor { + target-actor-id: s64, + } + + record c-remove-objective { + objective-name: string, + } + + record pack-instance-id { + pack-id: string, + version: string, + sub-pack-name: string, + } + + record pack-id-version { + pack-uuid: uuid, + pack-version: string, + } + + record pack-info-data { + pack-id-version: pack-id-version, + pack-size: s64, + content-key: string, + subpack-name: string, + content-identity: string, + has-scripts: bool, + is-addon-pack: bool, + is-ray-tracing-capable: bool, + cdn-url: string, + } + + record c-resource-packs-info { + resource-pack-required: bool, + has-addon-packs: bool, + has-scripts: bool, + force-disable-vibrant-visuals: bool, + world-template-id-and-version: pack-id-version, + resource-packs: list, + } + + variant metadata-value { + byte(u8), + short(s32), + int(s32), + float(f32), + %string(string), + compound-tag, + item-pos(tuple), + int64(s64), + vec3(tuple), + } + + record property-sync-data { + int-entries-list: list>, + float-entries-list: list>, + } + + record c-add-actor { + target-actor-id: s64, + target-runtime-id: s64, + actor-type: string, + position: tuple, + velocity: tuple, + rotation: tuple, + y-head-rotation: f32, + y-body-rotation: f32, + attributes-list: list, + actor-data: string, + synced-properties: property-sync-data, + actor-links: list, + } + + record c-set-actor-data { + target-runtime-id: s64, + actor-data: string, + synced-properties: property-sync-data, + tick: s64, + } + + record c-set-actor-link { + link: actor-link, + } + + record c-set-actor-motion { + target-runtime-id: s64, + motion: tuple, + tick: s64, + } + + record c-set-difficulty { + difficulty: s32, + } + + record c-set-display-objective { + display-slot-name: string, + objective-name: string, + objective-display-name: string, + criteria-name: string, + sort-order: s32, + } + + record c-set-health { + health: s32, + } + + record c-set-player-game-type { + player-game-type: game-type, + } + + record score-entry { + scoreboard-id: s64, + objective-name: string, + score: s32, + entry-type: s32, + entity-unique-id: s64, + custom-name: string, + } + + record c-set-score { + action: s32, + entries: list, + } + + enum spawn-position-type { + player-respawn, + world-respawn, + } + + record c-set-spawn-position { + spawn-position-type: spawn-position-type, + block-position: tuple, + dimension-type: s32, + spawn-block-pos: tuple, + } + + record c-set-time { + time: s32, + } + + enum title-type { + clear, + reset, + title, + subtitle, + actionbar, + times, + title-text-object, + subtitle-text-object, + actionbar-text-object, + } + + record c-set-title { + title-type: title-type, + title-text: string, + fade-in-time: s32, + stay-time: s32, + fade-out-time: s32, + xuid: string, + platform-online-id: string, + filtered-title-message: string, + } + + record c-show-credits { + player-runtime-id: s64, + credits-state: s32, + } + + record gathering-join-info { + experience-id: uuid, + experience-name: string, + experience-world-id: uuid, + experience-world-name: string, + creator-id: string, + unknown-uuid-1: uuid, + unknown-uuid-2: uuid, + server-id: string, + } + + record store-entry-point-info { + store-id: string, + store-name: string, + } + + record presence-info { + experience-name: string, + world-name: string, + } + + record server-join-information { + gathering: option, + store-entry-point: option, + presence: option, + } + + record server-telemetry-data { + server-id: string, + scenario-id: string, + world-id: string, + owner-id: string, + } + + record experiment-toggle { + name: string, + enabled: bool, + } + + record experiments { + toggles: list, + experiments-ever-toggled: bool, + } + + record c-resource-pack-stack-packet { + texture-pack-required: bool, + texture-pack-list: list, + base-game-version: string, + experiments: experiments, + include-editor-packs: bool, + } + + enum game-publish-setting { + no-multi-play, + invite-only, + friends-only, + friends-of-friends, + public, + } + + record level-settings { + seed: s64, + spawn-biome-type: s32, + custom-biome-name: string, + dimension: s32, + generator-type: s32, + world-gamemode: game-type, + hardcore: bool, + difficulty: s32, + spawn-position: tuple, + has-achievements-disabled: bool, + editor-world-type: s32, + is-created-in-editor: bool, + is-exported-from-editor: bool, + day-cycle-stop-time: s32, + education-edition-offer: s32, + has-education-features-enabled: bool, + education-product-id: string, + rain-level: f32, + lightning-level: f32, + has-confirmed-platform-locked-content: bool, + was-multiplayer-intended: bool, + was-lan-broadcasting-intended: bool, + xbox-live-broadcast-setting: game-publish-setting, + platform-broadcast-setting: game-publish-setting, + commands-enabled: bool, + is-texture-packs-required: bool, + rule-data: list, + experiments: experiments, + bonus-chest: bool, + has-start-with-map-enabled: bool, + permission-level: u8, + server-simulation-distance: s32, + has-locked-behavior-pack: bool, + has-locked-resource-pack: bool, + is-from-locked-world-template: bool, + is-using-msa-gamertags-only: bool, + is-from-world-template: bool, + is-world-template-option-locked: bool, + is-only-spawning-v1-villagers: bool, + is-disabling-personas: bool, + is-disabling-custom-skins: bool, + emote-chat-muted: bool, + game-version: string, + limited-world-width: s32, + limited-world-height: s32, + new-nether: bool, + edu-shared-uri-button-name: string, + edu-shared-uri-link-uri: string, + override-force-experimental-gameplay-has-value: bool, + chat-restriction-level: u8, + disable-player-interactions: bool, + server-editor-connection-policy: s32, + allow-anonymous-block-drops-in-editor-worlds: bool, + } + + record c-start-game { + entity-id: s64, + runtime-entity-id: s64, + player-gamemode: game-type, + position: tuple, + pitch: f32, + yaw: f32, + level-settings: level-settings, + level-id: string, + level-name: string, + premium-world-template-id: string, + is-trial: bool, + rewind-history-size: s32, + server-authoritative-block-breaking: bool, + current-level-time: s64, + enchantment-seed: s32, + block-properties-size: s32, + multiplayer-correlation-id: string, + enable-itemstack-net-manager: bool, + server-version: string, + compound-id: u8, + compound-len: s32, + compound-end: u8, + block-registry-checksum: s64, + world-template-id: uuid, + enable-clientside-generation: bool, + blocknetwork-ids-are-hashed: bool, + server-auth-sounds: bool, + server-join-information: option, + telemetry: server-telemetry-data, + } + + record gg { + name: string, + id: u8, + len: s32, + end: u8, + } + + record c-take-item-actor { + item-runtime-id: s64, + actor-runtime-id: s64, + } + + record c-transfer { + server-address: string, + server-port: s32, + reload-world: bool, + } + + record c-update-abilities { + data: serialized-abilities-data, + } + + enum ability { + build, + mine, + doors-and-switches, + open-containers, + attack-players, + attack-mobs, + operator-commands, + teleport, + invulnerable, + flying, + may-fly, + instabuild, + lightning, + fly-speed, + walk-speed, + muted, + world-builder, + no-clip, + privileged-builder, + vertical-fly-speed, + ability-count, + } + + record attribute-modifier { + id: string, + name: string, + amount: f32, + operation: s32, + operand: s32, + is-serializable: bool, + } + + record attribute-data { + min-value: f32, + max-value: f32, + current-value: f32, + default-min-value: f32, + default-max-value: f32, + default-value: f32, + name: string, + modifiers: list, + } + + record c-update-attributes { + target-runtime-id: s64, + attribute-list: list, + tick: s64, + } + + record c-update-block { + block-position: tuple, + block-runtime-id: s32, + %flags: s32, + layer: s32, + } + + record c-update-trade { + container-id: u8, + r-type: u8, + size: s32, + trader-tier: s32, + entity-unique-id: s64, + last-trading-player: s64, + display-name: string, + use-new-trade-screen: bool, + using-economy-trade: bool, + data: string, + } + + record network-item-descriptor { + id: s32, + stack-size: s32, + aux-value: s32, + block-runtime-id: s32, + nbt-data: string, + place-on-blocks: list, + destroy-blocks: list, + shield-blocking-tick: s64, + } + + record inventory-action { + source-type: s32, + window-id: option, + source-flags: option, + inventory-slot: s32, + old-item: network-item-descriptor, + new-item: network-item-descriptor, + } + + record use-item-transaction-data { + action-type: s32, + trigger-type: u8, + block-position: tuple, + block-face: u8, + hot-bar-slot: s32, + hand: u8, + item-in-hand: network-item-descriptor, + player-position: tuple, + click-position: tuple, + block-runtime-id: s32, + client-prediction: u8, + client-cooldown-state: u8, + } + + record use-item-on-entity-transaction-data { + target-entity-runtime-id: s64, + action-type: s32, + hot-bar-slot: s32, + item-in-hand: network-item-descriptor, + player-position: tuple, + click-position: tuple, + } + + record release-item-transaction-data { + action-type: s32, + hot-bar-slot: s32, + item-in-hand: network-item-descriptor, + head-position: tuple, + } + + variant transaction-data { + normal(string), + mismatch(string), + use-item(use-item-transaction-data), + use-item-on-entity(use-item-on-entity-transaction-data), + release-item(release-item-transaction-data), + } + + record s-inventory-transaction { + legacy-request-id: s32, + legacy-set-item-slots: list, + has-value: bool, + actions: list, + transaction-type: s32, + transaction-data: transaction-data, + } + + record player-use-item-transaction-data { + action-type: s32, + trigger-type: u8, + block-position: tuple, + block-face: u8, + hot-bar-slot: s32, + item-in-hand: network-item-descriptor, + player-position: tuple, + click-position: tuple, + block-runtime-id: s32, + client-prediction: u8, + client-cooldown-state: u8, + } + + record player-inventory-action { + legacy-request-id: s32, + legacy-slots: list, + actions: list, + transaction: player-use-item-transaction-data, + } + + record bedrock-shapeless-recipe { + recipe-id: string, + input: list, + output: list, + uuid: uuid, + block: string, + priority: s32, + unlock-requirement: recipe-unlock-requirement, + recipe-network-id: s32, + } + + record bedrock-shaped-recipe { + recipe-id: string, + width: s32, + height: s32, + input: list, + output: list, + uuid: uuid, + block: string, + priority: s32, + assume-symmetry: bool, + unlock-requirement: recipe-unlock-requirement, + recipe-network-id: s32, + } + + variant bedrock-recipe { + shapeless(bedrock-shapeless-recipe), + shaped(bedrock-shaped-recipe), + } + + record c-crafting-data { + recipes: list, + clean-recipes: bool, + } + + record creative-group-info-payload { + creative-category: creative-category, + name: string, + group-icon-item: network-item-descriptor, + } + + record creative-item-entry-payload { + id: s32, + item: network-item-descriptor, + group-index: s32, + } + + record c-creative-content { + groups: list, + entries: list, + } + + record item-stack-wrapper { + id: s32, + stack-size: s32, + aux-value: s32, + block-runtime-id: s32, + nbt-data: string, + place-on-blocks: list, + destroy-blocks: list, + shield-blocking-tick: s64, + net-id: option, + } + + record c-add-item-actor { + target-actor-id: s64, + target-runtime-id: s64, + item: item-stack-wrapper, + position: tuple, + velocity: tuple, + entity-data: string, + is-from-fishing: bool, + } + + record network-item-stack-descriptor { + id: s32, + stack-size: s32, + aux-value: s32, + block-runtime-id: s32, + extra-data: list, + net-id: option, + } + + record s-mob-equipment { + entity-runtime-id: s64, + item: network-item-stack-descriptor, + slot: u8, + selected-slot: u8, + container-id: u8, + } + + record c-add-player { + uuid: uuid, + player-name: string, + target-runtime-id: s64, + platform-chat-id: string, + position: tuple, + velocity: tuple, + rotation: tuple, + y-head-rotation: f32, + carried-item: network-item-stack-descriptor, + player-game-type: game-type, + entity-data: string, + synced-properties: property-sync-data, + abilities-data: serialized-abilities-data, + actor-links: list, + device-id: string, + build-platform: build-platform, + } + + record c-mob-equipment { + target-runtime-id: s64, + item: network-item-stack-descriptor, + slot: u8, + selected-slot: u8, + container-id: u8, + } + + enum container-name { + anvil-input, + anvil-material, + anvil-result-preview, + smithing-table-input, + smithing-table-material, + smithing-table-result-preview, + armor, + level-entity, + beacon-payment, + brewing-stand-input, + brewing-stand-result, + brewing-stand-fuel, + combined-hot-bar-and-inventory, + crafting-input, + crafting-output-preview, + recipe-construction, + recipe-nature, + recipe-items, + recipe-search, + recipe-search-bar, + recipe-equipment, + recipe-book, + enchanting-input, + enchanting-material, + furnace-fuel, + furnace-ingredient, + furnace-result, + horse-equip, + hot-bar, + inventory, + shulker-box, + trade-ingredient1, + trade-ingredient2, + trade-result-preview, + offhand, + compound-creator-input, + compound-creator-output-preview, + element-constructor-output-preview, + material-reducer-input, + material-reducer-output, + lab-table-input, + loom-input, + loom-dye, + loom-material, + loom-result-preview, + blast-furnace-ingredient, + smoker-ingredient, + trade2-ingredient1, + trade2-ingredient2, + trade2-result-preview, + grindstone-input, + grindstone-additional, + grindstone-result-preview, + stonecutter-input, + stonecutter-result-preview, + cartography-input, + cartography-additional, + cartography-result-preview, + barrel, + cursor, + created-output, + smithing-table-template, + crafter-level-entity, + dynamic, + recipe-food, + recipe-blocks, + recipe-furnace-items, + } + + record full-container-name { + container-name: container-name, + dynamic-id: option, + } + + record item-stack-request-slot-info { + container-name: full-container-name, + slot-id: u8, + stack-id: s32, + } + + record item-stack-request-action-take { + count: u8, + source: item-stack-request-slot-info, + destination: item-stack-request-slot-info, + } + + record item-stack-request-action-place { + count: u8, + source: item-stack-request-slot-info, + destination: item-stack-request-slot-info, + } + + record item-stack-request-action-swap { + slot1: item-stack-request-slot-info, + slot2: item-stack-request-slot-info, + } + + record item-stack-request-action-drop { + count: u8, + source: item-stack-request-slot-info, + randomly: bool, + } + + record item-stack-request-action-destroy { + count: u8, + source: item-stack-request-slot-info, + } + + record item-stack-request-action-consume { + count: u8, + source: item-stack-request-slot-info, + } + + variant item-stack-request-action { + take(item-stack-request-action-take), + place(item-stack-request-action-place), + swap(item-stack-request-action-swap), + drop(item-stack-request-action-drop), + destroy(item-stack-request-action-destroy), + consume(item-stack-request-action-consume), + create(item-stack-request-action-create), + lab-table-combine, + beacon-payment(item-stack-request-action-beacon-payment), + mine-block(item-stack-request-action-mine-block), + craft-recipe(item-stack-request-action-craft-recipe), + craft-recipe-auto(item-stack-request-action-craft-recipe-auto), + craft-creative(item-stack-request-action-craft-creative), + optional(item-stack-request-action-optional), + grindstone(item-stack-request-action-grindstone), + loom(item-stack-request-action-loom), + craft-non-implemented, + craft-results-deprecated(item-stack-request-action-craft-results-deprecated), + } + + record item-stack-request { + request-id: s32, + actions: list, + filter-strings: list, + filter-cause: s32, + } + + record s-item-stack-request { + requests: list, + } + + record s-player-auth-input { + pitch: f32, + yaw: f32, + position: tuple, + move-vec: tuple, + head-yaw: f32, + input-data: list, + input-mode: s32, + play-mode: s32, + interaction-model: s32, + interact-pitch: f32, + interact-yaw: f32, + tick: s64, + delta: tuple, + block-actions: option>, + item-interaction: option, + item-stack-request: option, + vehicle-rotation: option>, + vehicle-unique-id: option, + analog-move: tuple, + camera-orientation: tuple, + raw-move: tuple, + } + + record c-inventory-content { + container-id: s32, + slots: list, + full-container-name: full-container-name, + storage-item: network-item-stack-descriptor, + } + + record c-inventory-slot { + container-id: s32, + slot: s32, + full-container-name: option, + storage-item: option, + item: network-item-stack-descriptor, + } + + record item-stack-response-container-info { + full-container-name: full-container-name, + slots: list, + } + + record item-stack-response-info { + %result: u8, + client-request-id: s32, + containers: list, + } + + record c-item-stack-response { + responses: list, + } + + record network-item-stack { + id: s32, + count: s32, + aux-value: s32, + block-runtime-id: s32, + extra-data: list, + } + + variant serverbound-packet { + s-actor-event(s-actor-event), + s-animate(s-animate), + s-block-pick-request(s-block-pick-request), + s-client-cache-blob-status(s-client-cache-blob-status), + s-client-cache-status(s-client-cache-status), + s-command-request(s-command-request), + s-container-close(s-container-close), + s-emote(s-emote), + s-emote-list(s-emote-list), + s-interact(s-interact), + s-inventory-transaction(s-inventory-transaction), + s-item-stack-request(s-item-stack-request), + s-loading-screen(s-loading-screen), + s-login(s-login), + s-mob-equipment(s-mob-equipment), + s-modal-form-response(s-modal-form-response), + s-packet-violation-warning(s-packet-violation-warning), + s-player-action(s-player-action), + s-player-auth-input(s-player-auth-input), + s-player-hotbar(s-player-hotbar), + s-request-ability(s-request-ability), + s-request-chunk-radius(s-request-chunk-radius), + s-request-network-settings(s-request-network-settings), + s-resource-pack-client-response(s-resource-pack-client-response), + s-respawn(s-respawn), + s-set-local-player-as-initialized(s-set-local-player-as-initialized), + s-set-player-inventory-options(s-set-player-inventory-options), + s-text(s-text), + unknown, + } + + variant clientbound-packet { + c-add-actor(c-add-actor), + c-add-item-actor(c-add-item-actor), + c-add-player(c-add-player), + c-available-commands(c-available-commands), + c-biome-definition-list, + c-block-actor-data(c-block-actor-data), + c-block-event(c-block-event), + c-boss-event(c-boss-event), + c-change-dimension(c-change-dimension), + c-chunk-radius-updated(c-chunk-radius-updated), + c-client-cache-miss-response(c-client-cache-miss-response), + c-container-open(c-container-open), + c-correct-player-move-prediction(c-correct-player-move-prediction), + c-crafting-data(c-crafting-data), + c-creative-content(c-creative-content), + c-disconnect(c-disconnect), + c-gamerules-changed(c-gamerules-changed), + c-inventory-content(c-inventory-content), + c-inventory-slot(c-inventory-slot), + c-item-registry(c-item-registry), + c-item-stack-response(c-item-stack-response), + c-jigsaw-structure-data, + c-level-event(c-level-event), + c-level-sound-event(c-level-sound-event), + c-mob-effect(c-mob-effect), + c-mob-equipment(c-mob-equipment), + c-modal-form-request(c-modal-form-request), + c-move-actor-absolute(c-move-actor-absolute), + c-move-actor-delta(c-move-actor-delta), + c-move-player(c-move-player), + c-network-chunk-publisher-update(c-network-chunk-publisher-update), + c-network-settings(c-network-settings), + c-play-status(c-play-status), + c-player-hotbar(c-player-hotbar), + c-player-list(c-player-list), + c-remove-actor(c-remove-actor), + c-remove-objective(c-remove-objective), + c-resource-pack-stack-packet(c-resource-pack-stack-packet), + c-resource-packs-info(c-resource-packs-info), + c-set-actor-data(c-set-actor-data), + c-set-actor-link(c-set-actor-link), + c-set-actor-motion(c-set-actor-motion), + c-set-difficulty(c-set-difficulty), + c-set-display-objective(c-set-display-objective), + c-set-health(c-set-health), + c-set-player-game-type(c-set-player-game-type), + c-set-score(c-set-score), + c-set-spawn-position(c-set-spawn-position), + c-set-time(c-set-time), + c-set-title(c-set-title), + c-show-credits(c-show-credits), + c-start-game(c-start-game), + c-take-item-actor(c-take-item-actor), + c-transfer(c-transfer), + c-update-abilities(c-update-abilities), + c-update-attributes(c-update-attributes), + c-update-block(c-update-block), + c-update-trade(c-update-trade), + c-voxel-shapes, + unknown, + } +} + +interface java-packets { + use uuid.{uuid}; + + record config-s-client-information-config { + locale: string, + view-distance: u8, + chat-mode: s32, + chat-colors: bool, + skin-parts: u8, + main-hand: s32, + text-filtering: bool, + server-listing: bool, + } + + record config-s-config-cookie-response { + key: string, + has-payload: bool, + payload: option>, + } + + record config-s-custom-click-action { + action-id: string, + payload: option>, + } + + record config-s-keep-alive { + keep-alive-id: s64, + } + + record config-s-known-packs { + known-packs: list, + } + + record config-s-plugin-message { + channel: string, + data: list, + } + + record config-s-config-pong { + id: s32, + } + + variant resource-pack-response-result { + download-success, + download-fail, + downloaded, + accepted, + declined, + invalid-url, + reload-failed, + discarded, + unknown(s32), + } + + record config-s-config-resource-pack { + uuid: uuid, + %result: s32, + } + + record login-s-login-cookie-response { + key: string, + payload: option>, + } + + record s-encryption-response { + shared-secret: list, + verify-token: list, + } + + record login-s-login-start { + name: string, + uuid: uuid, + } + + record login-s-login-plugin-response { + message-id: s32, + data: option>, + } + + record s-attack { + entity-id: s32, + } + + record s-block-entity-tag-query { + transaction-id: s32, + location: tuple, + } + + record s-bundle-item-selected { + slot-id: s32, + selected-item-index: s32, + } + + record s-change-difficulty { + difficulty: string, + } + + record s-change-game-mode { + game-mode: string, + } + + record s-chat-ack { + offset: s32, + } + + record s-chat-command { + command: string, + } + + record argument-signature { + name: string, + signature: list, + } + + record s-chat-command-signed { + command: string, + timestamp: s64, + salt: s64, + argument-signatures: list, + message-count: s32, + acknowledged: list, + checksum: u8, + } + + record s-chat-message { + message: string, + timestamp: s64, + salt: s64, + signature: option>, + message-count: s32, + acknowledged: list, + checksum: u8, + } + + record s-chunk-batch { + chunks-per-tick: f32, + } + + enum slot-action-type { + pickup, + quick-move, + swap, + clone, + throw, + quick-craft, + pickup-all, + } + + record s-click-slot { + sync-id: s32, + revision: s32, + slot: s32, + button: u8, + mode: slot-action-type, + length-of-array: s32, + array-of-changed-slots: list>, + carried-item: string, + } + + record s-client-command { + action-id: s32, + } + + record s-client-information-play { + locale: string, + view-distance: u8, + chat-mode: s32, + chat-colors: bool, + skin-parts: u8, + main-hand: s32, + text-filtering: bool, + server-listing: bool, + } + + record s-close-container { + window-id: s32, + } + + record s-command-suggestion { + id: s32, + command: string, + } + + record s-confirm-teleport { + teleport-id: s32, + } + + record s-container-button-click { + window-id: s32, + button-id: s32, + } + + record s-container-slot-state-changed { + slot-id: s32, + container-id: s32, + new-state: bool, + } + + record s-cookie-response { + key: string, + payload: option>, + } + + record s-custom-click-action { + action-id: string, + payload: option>, + } + + record s-custom-payload { + channel: string, + data: list, + } + + record s-debug-sample-subscription { + sample-type: s32, + } + + record s-debug-subscription-request { + sample-type: s32, + } + + record s-edit-book { + slot: s32, + pages: list, + title: option, + } + + record s-entity-tag-query { + transaction-id: s32, + entity-id: s32, + } + + record s-interact { + entity-id: s32, + r-type: s32, + target-position: option>, + hand: option, + sneaking: bool, + } + + enum action-type { + interact, + attack, + interact-at, + } + + record s-jigsaw-generate { + pos: tuple, + levels: s32, + keep-jigsaws: bool, + } + + record s-keep-alive { + keep-alive-id: s64, + } + + record s-lock-difficulty { + locked: bool, + } + + record s-move-vehicle { + x: f64, + y: f64, + z: f64, + yaw: f32, + pitch: f32, + on-ground: bool, + } + + record s-paddle-boat { + left-paddle: bool, + right-paddle: bool, + } + + record s-pick-item-from-block { + pos: tuple, + include-data: bool, + } + + record s-pick-item-from-entity { + id: s32, + include-data: bool, + } + + record s-play-ping-request { + payload: s64, + } + + record s-place-recipe { + container-id: u8, + recipe-display-id: s32, + use-max-items: bool, + } + + record s-player-abilities { + %flags: u8, + fly-speed: option, + walk-speed: option, + } + + record s-player-action { + status: s32, + position: tuple, + face: u8, + sequence: s32, + } + + enum status { + started-digging, + cancelled-digging, + finished-digging, + drop-item-stack, + drop-item, + release-item-in-use, + swap-item, + spear-jab, + } + + enum action { + start-sneaking, + stop-sneaking, + leave-bed, + start-sprinting, + stop-sprinting, + start-horse-jump, + stop-horse-jump, + open-vehicle-inventory, + start-flying-elytra, + } + + record s-player-command { + entity-id: s32, + action: action, + jump-boost: s32, + } + + record s-set-player-ground { + on-ground: bool, + } + + record s-player-input { + input: u8, + } + + record s-player-position { + position: tuple, + collision: u8, + } + + record s-player-position-rotation { + position: tuple, + yaw: f32, + pitch: f32, + collision: u8, + } + + record s-player-rotation { + yaw: f32, + pitch: f32, + ground: bool, + } + + record s-player-session { + session-id: uuid, + expires-at: s64, + public-key: list, + key-signature: list, + } + + record s-play-pong { + id: s32, + } + + record s-recipe-book-change-settings { + book-type: s32, + is-open: bool, + is-filtering: bool, + } + + record s-recipe-book-seen-recipe { + recipe-display-id: s32, + } + + record s-rename-item { + item-name: string, + } + + variant play-resource-pack-result { + download-success, + declined, + download-fail, + accepted, + downloaded, + invalid-url, + reload-failed, + discarded, + unknown(s32), + } + + record s-play-resource-pack { + uuid: uuid, + %result: s32, + } + + variant s-seen-advancement { + open-tab(string), + close-tab, + } + + record s-select-trade { + selected-slot: s32, + } + + record s-set-beacon { + primary-effect: option, + secondary-effect: option, + } + + record s-set-command-block { + pos: tuple, + command: string, + mode: s32, + %flags: u8, + } + + enum command-block-mode { + chain, + repeating, + impulse, + } + + record s-set-command-minecart { + entity-id: s32, + command: string, + track-output: bool, + } + + record s-set-creative-slot { + slot: s32, + clicked-item: string, + } + + record game-rule-entry { + game-rule-key: string, + value: string, + } + + record s-set-game-rule { + entries: list, + } + + record s-set-held-item { + slot: s32, + } + + record s-set-jigsaw-block { + pos: tuple, + name: string, + target: string, + pool: string, + final-state: string, + joint: string, + selection-priority: s32, + placement-priority: s32, + } + + record s-set-structure-block { + location: tuple, + action: s32, + mode: s32, + name: string, + offset-x: u8, + offset-y: u8, + offset-z: u8, + size-x: u8, + size-y: u8, + size-z: u8, + mirror: s32, + rotation: s32, + metadata: string, + integrity: f32, + seed: s64, + %flags: u8, + } + + enum test-block-mode { + start, + log, + fail, + accept, + } + + record s-set-test-block { + position: tuple, + mode: test-block-mode, + message: string, + } + + record s-spectate-entity { + target: uuid, + } + + record s-swing-arm { + hand: s32, + } + + record s-teleport-to-entity { + target: uuid, + } + + enum test-instance-block-action { + init, + query, + set, + reset, + save, + %export, + run, + } + + record var-int-vector3 { + x: s32, + y: s32, + z: s32, + } + + enum test-instance-block-status { + cleared, + running, + success, + failed, + } + + record test-instance-block-data { + test: option, + size: var-int-vector3, + rotation: string, + ignore-entities: bool, + status: test-instance-block-status, + error-message: option, + } + + record s-test-instance-block-action { + pos: tuple, + action: test-instance-block-action, + data: test-instance-block-data, + } + + record s-update-sign { + location: tuple, + is-front-text: bool, + line-1: string, + line-2: string, + line-3: string, + line-4: string, + } + + record s-use-item { + hand: s32, + sequence: s32, + yaw: f32, + pitch: f32, + } + + record s-use-item-on { + hand: s32, + position: tuple, + face: s32, + cursor-pos: tuple, + inside-block: bool, + is-against-world-border: bool, + sequence: s32, + } + + record status-s-status-ping-request { + payload: s64, + } + + record config-c-config-add-resource-pack { + uuid: uuid, + url: string, + hash: string, + forced: bool, + prompt-message: option, + } + + record config-c-code-of-conduct { + code-of-conduct: string, + } + + record config-c-config-disconnect { + reason: string, + } + + record config-c-cookie-request { + key: string, + } + + record config-c-config-custom-report-details { + details: list>, + } + + record config-c-feature-flags { + features: list, + } + + record config-c-known-packs { + known-packs: list, + } + + record config-c-config-ping { + id: s32, + } + + record config-c-plugin-message { + channel: string, + data: list, + } + + record config-c-registry-data { + registry-id: string, + entries: list, + } + + record config-c-config-remove-resource-pack { + uuid: option, + } + + record config-c-config-server-links { + links: list, + } + + record config-c-config-show-dialog { + dialog: string, + } + + record config-c-store-cookie { + key: string, + payload: list, + } + + record config-c-transfer { + host: string, + port: s32, + } + + record config-c-update-tags { + tags: list, + } + + record login-c-login-cookie-request { + key: string, + } + + record c-encryption-request { + server-id: string, + public-key: list, + verify-token: list, + should-authenticate: bool, + } + + record login-c-login-disconnect { + json-reason: string, + } + + record login-c-login-plugin-request { + message-id: s32, + channel: string, + data: list, + } + + record login-c-set-compression { + threshold: s32, + } + + record c-acknowledge-block-change { + sequence-id: s32, + } + + record c-action-bar { + action-bar: string, + } + + record c-add-resource-pack { + uuid: uuid, + url: string, + hash: string, + forced: bool, + prompt-message: option, + } + + record statistic { + category-id: s32, + statistic-id: s32, + value: s32, + } + + record c-award-stats { + stats: list, + } + + record c-set-block-destroy-stage { + entity-id: s32, + location: tuple, + destroy-stage: u8, + } + + record c-block-entity-data { + location: tuple, + r-type: s32, + nbt-data: list, + } + + record c-block-event { + location: tuple, + action-id: u8, + action-parameter: u8, + block-type: s32, + } + + record c-block-update { + location: tuple, + state-id: s32, + } + + record bossevent-action-add { + title: string, + health: f32, + color: s32, + division: s32, + %flags: u8, + } + + record bossevent-action-update-style { + color: s32, + dividers: s32, + } + + variant bossevent-action { + add(bossevent-action-add), + remove, + update-health(f32), + update-tile(string), + update-style(bossevent-action-update-style), + update-flags(u8), + } + + record c-boss-event { + uuid: uuid, + action: bossevent-action, + } + + record c-center-chunk { + chunk-x: s32, + chunk-z: s32, + } + + record c-change-difficulty { + difficulty: u8, + locked: bool, + } + + record c-chunk-batch-end { + batch-size: s32, + } + + record chunk-biome-entry { + chunk-x: s32, + chunk-z: s32, + data: list, + } + + record c-chunks-biomes { + chunks: list, + } + + record c-clear-title { + reset: bool, + } + + record c-close-container { + sync-id: s32, + } + + record c-combat-death { + player-id: s32, + message: string, + } + + record c-combat-end { + duration-ticks: s32, + } + + record command-suggestion { + suggestion: string, + tooltip: option, + } + + record c-command-suggestions { + id: s32, + start: s32, + length: s32, + matches: list, + } + + record proto-node-type-literal { + name: string, + is-executable: bool, + redirect-target: option, + restricted: bool, + } + + record argument-type-float { + min: option, + max: option, + } + + record argument-type-double { + min: option, + max: option, + } + + record argument-type-integer { + min: option, + max: option, + } + + record argument-type-long { + min: option, + max: option, + } + + record argument-type-entity { + %flags: u8, + } + + record argument-type-score-holder { + %flags: u8, + } + + record argument-type-time { + min: s32, + } + + record argument-type-resource-or-tag { + identifier: string, + } + + record argument-type-resource-or-tag-key { + identifier: string, + } + + record argument-type-resource { + identifier: string, + } + + record argument-type-resource-key { + identifier: string, + } + + enum string-proto-arg-behavior { + single-word, + quotable-phrase, + greedy-phrase, + } + + variant argument-type { + %bool, + float(argument-type-float), + double(argument-type-double), + integer(argument-type-integer), + long(argument-type-long), + %string(string-proto-arg-behavior), + entity(argument-type-entity), + game-profile, + block-pos, + column-pos, + vec3, + vec2, + block-state, + block-predicate, + item-stack, + item-predicate, + color, + hex-color, + component, + style, + message, + nbt-compound, + nbt-tag, + nbt-path, + objective, + objective-criteria, + operation, + particle, + angle, + rotation, + scoreboard-slot, + score-holder(argument-type-score-holder), + swizzle, + team, + item-slot, + item-slots, + resource-location, + function, + entity-anchor, + int-range, + float-range, + dimension, + gamemode, + time(argument-type-time), + resource-or-tag(argument-type-resource-or-tag), + resource-or-tag-key(argument-type-resource-or-tag-key), + %resource(argument-type-resource), + resource-key(argument-type-resource-key), + resource-selector, + template-mirror, + template-rotation, + heightmap, + loot-table, + loot-predicate, + loot-modifier, + dialog, + uuid, + } + + enum suggestion-providers { + ask-server, + all-recipes, + available-sounds, + summonable-entities, + } + + record proto-node-type-argument { + name: string, + is-executable: bool, + redirect-target: option, + parser: argument-type, + override-suggestion-type: option, + restricted: bool, + } + + variant proto-node-type { + root, + literal(proto-node-type-literal), + argument(proto-node-type-argument), + } + + record proto-node { + children: list, + node-type: proto-node-type, + } + + record c-commands { + nodes: list, + root-node-index: s32, + } + + record c-play-cookie-request { + key: string, + } + + record c-custom-chat-completions { + action: s32, + entries: list, + } + + record c-custom-payload { + channel: string, + data: list, + } + + record c-play-custom-report-details { + details: list>, + } + + record c-damage-event { + entity-id: s32, + source-type-id: s32, + source-cause-id: s32, + source-direct-id: s32, + source-position: option>, + } + + record c-debug-block-value { + pos: tuple, + name: string, + value: string, + } + + record c-debug-chunk-value { + chunk-pos: tuple, + name: string, + value: string, + } + + record c-debug-entity-value { + entity-id: s32, + name: string, + value: string, + } + + record c-debug-event { + name: string, + data: list, + } + + record c-debug-sample { + sample: list, + sample-type: s32, + } + + record c-delete-chat { + signature-id: s32, + signature: option>, + } + + record c-play-disconnect { + reason: string, + } + + record c-disguised-chat-message { + message: string, + chat-type: s32, + sender-name: string, + target-name: option, + } + + record c-display-objective { + position: s32, + score-name: string, + } + + record c-entity-animation { + entity-id: s32, + animation: u8, + } + + enum animation { + swing-main-arm, + leave-bed, + swing-offhand, + critical-effect, + magic-criticaleffect, + } + + record c-set-entity-metadata { + entity-id: s32, + metadata: list, + } + + record c-entity-position-sync { + entity-id: s32, + position: tuple, + delta: tuple, + yaw: f32, + pitch: f32, + on-ground: bool, + } + + record c-entity-sound-effect { + sound-event: string, + sound-category: s32, + entity-id: s32, + volume: f32, + pitch: f32, + seed: s64, + } + + record c-entity-status { + entity-id: s32, + entity-status: u8, + } + + record c-entity-velocity { + entity-id: s32, + velocity: string, + } + + record c-explosion { + center: tuple, + radius: f32, + block-count: s32, + knockback: option>, + particle: s32, + sound: string, + block-particles-pool-size: s32, + } + + record c-game-event { + event: u8, + value: f32, + } + + enum game-event { + no-respawn-block-available, + begin-raining, + end-raining, + change-game-mode, + win-game, + demo-event, + arrow-hit-player, + rain-level-change, + thunder-level-change, + play-pufferfish-string-sound, + play-elder-guardian-mob-appearance, + enabled-respawn-screen, + limited-crafting, + start-waiting-chunks, + } + + record c-game-rule-values { + rules: list>, + } + + record c-game-test-highlight-pos { + pos: tuple, + color: s32, + label: string, + duration-ms: s32, + } + + record c-head-rot { + entity-id: s32, + head-yaw: u8, + } + + record c-hurt-animation { + entity-id: s32, + yaw: f32, + } + + record c-initialize-world-border { + x: f64, + z: f64, + old-diameter: f64, + new-diameter: f64, + speed: s64, + portal-teleport-boundary: s32, + warning-blocks: s32, + warning-time: s32, + } + + record c-item-cooldown { + group: string, + cooldown: s32, + } + + record c-keep-alive { + keep-alive-id: s64, + } + + record c-level-event { + event: s32, + location: tuple, + data: s32, + disable-relative-volume: bool, + } + + record light-data { + trust-edges: bool, + sky-light-mask: list, + block-light-mask: list, + empty-sky-light-mask: list, + empty-block-light-mask: list, + sky-light-arrays: list>, + block-light-arrays: list>, + } + + record c-light-update { + chunk-x: s32, + chunk-z: s32, + light-data: light-data, + } + + record map-icon { + icon-type: s32, + x: u8, + z: u8, + direction: u8, + display-name: option, + } + + record map-patch { + columns: u8, + rows: u8, + x: u8, + z: u8, + data: list, + } + + record c-map-item-data { + map-id: s32, + scale: u8, + tracking-position: bool, + locked: bool, + icons: option>, + data: option, + } + + record merchant-offer { + base-cost-a: string, + output: string, + cost-b: option, + reward-exp: bool, + uses: s32, + max-uses: s32, + xp: s32, + special-price: s32, + price-multiplier: f32, + demand: s32, + } + + record c-merchant-offers { + window-id: s32, + offers: list, + villager-level: s32, + experience: s32, + is-regular-villager: bool, + can-restock: bool, + } + + record minecart-step { + position: tuple, + movement: tuple, + yaw: f32, + pitch: f32, + weight: f32, + } + + record c-move-minecart-along-track { + entity-id: s32, + steps: list, + } + + record c-move-vehicle { + x: f64, + y: f64, + z: f64, + yaw: f32, + pitch: f32, + } + + record c-multi-block-update { + chunk-section: tuple, + suppress-light-updates: bool, + updates: list, string>>, + } + + record c-open-book { + hand: s32, + } + + record c-open-mount-screen { + window-id: u8, + slot-count: s32, + entity-id: s32, + } + + record c-open-screen { + sync-id: s32, + window-type: s32, + window-title: string, + } + + record c-open-sign-editor { + location: tuple, + is-front-text: bool, + } + + record c-particle { + force-spawn: bool, + important: bool, + position: tuple, + offset: tuple, + max-speed: f32, + particle-count: s32, + particle-id: s32, + data: list, + } + + record c-play-ping { + id: s32, + } + + record c-ping-response { + payload: s64, + } + + record c-place-ghost-recipe { + window-id: u8, + recipe-id: string, + } + + record c-player-abilities { + %flags: u8, + flying-speed: f32, + field-of-view: f32, + } + + record init-chat { + session-id: uuid, + expires-at: s64, + public-key: list, + signature: list, + } + + record previous-message { + id: s32, + signature: option>, + } + + variant filter-type { + pass-through, + fully-filtered, + partially-filtered(list), + } + + record c-player-chat-message { + global-index: s32, + sender: uuid, + index: s32, + message-signature: option>, + message: string, + timestamp: s64, + salt: s64, + previous-messages: list, + unsigned-content: option, + filter-type: filter-type, + chat-type: s32, + sender-name: string, + target-name: option, + } + + record c-player-look-at { + from-anchor: s32, + target-x: f64, + target-y: f64, + target-z: f64, + entity: option>, + } + + record c-player-position { + teleport-id: s32, + position: tuple, + delta: tuple, + yaw: f32, + pitch: f32, + relatives: list, + } + + record c-remove-player-info { + players: list, + } + + record c-player-rotation { + yaw: f32, + pitch: f32, + } + + record player-spawn-data { + dimension: string, + hashed-seed: s64, + game-mode: u8, + previous-gamemode: u8, + debug: bool, + is-flat: bool, + death-dimension-name: option>>, + portal-cooldown: s32, + sealevel: s32, + } + + record c-login { + entity-id: s32, + is-hardcore: bool, + dimension-names: list, + max-players: s32, + view-distance: s32, + simulated-distance: s32, + reduced-debug-info: bool, + enabled-respawn-screen: bool, + limited-crafting: bool, + spawn-data: player-spawn-data, + online-mode: bool, + enforce-secure-chat: bool, + } + + record c-player-spawn-position { + dimension-name: string, + location: tuple, + yaw: f32, + pitch: f32, + } + + record c-projectile-power { + entity-id: s32, + x-power: f64, + y-power: f64, + z-power: f64, + } + + record c-recipe-book-add { + replace: bool, + } + + record c-recipe-book-remove { + recipes: list, + } + + record c-recipe-book-settings { + crafting-open: bool, + crafting-filtering: bool, + furnace-open: bool, + furnace-filtering: bool, + blast-furnace-open: bool, + blast-furnace-filtering: bool, + smoker-open: bool, + smoker-filtering: bool, + } + + record c-remove-entities { + entity-ids: list, + } + + record c-remove-mob-effect { + entity-id: s32, + effect-id: s32, + } + + record c-remove-resource-pack { + uuid: option, + } + + record c-reset-score { + entity-name: string, + objective-name: option, + } + + record c-respawn { + player-spawn-info: player-spawn-data, + data-kept: u8, + } + + record c-select-advancements-tab { + tab-id: option, + } + + record c-server-data { + motd: string, + icon-base64: option, + } + + record c-play-server-links { + links: list, + } + + record c-set-border-center { + x: f64, + z: f64, + } + + record c-set-border-lerp-size { + old-diameter: f64, + new-diameter: f64, + speed: s64, + } + + record c-set-border-size { + diameter: f64, + } + + record c-set-border-warning-delay { + warning-time: s32, + } + + record c-set-border-warning-distance { + warning-blocks: s32, + } + + record c-set-camera { + camera-id: s32, + } + + record c-set-chunk-cache-radius { + radius: s32, + } + + record c-set-container-content { + window-id: s32, + state-id: s32, + slot-data: list, + carried-item: string, + } + + record c-set-container-property { + window-id: s32, + property: s32, + value: s32, + } + + record c-set-container-slot { + window-id: u8, + state-id: s32, + slot: s32, + slot-data: string, + } + + record c-set-cursor-item { + stack: string, + } + + record c-set-entity-link { + attached-entity-id: s32, + holding-entity-id: s32, + leash: bool, + } + + record c-set-equipment { + entity-id: s32, + equipment: list>, + } + + record c-set-experience { + progress: f32, + level: s32, + total-experience: s32, + } + + record c-set-health { + health: f32, + food: s32, + food-saturation: f32, + } + + record c-set-selected-slot { + slot: u8, + } + + record c-set-passengers { + entity-id: s32, + passengers: list, + } + + record c-set-player-inventory { + slot: s32, + item: string, + } + + enum team-method { + create, + remove, + update, + add-players, + remove-players, + } + + record team-parameters { + display-name: string, + options: u8, + nametag-visibility: string, + collision-rule: string, + color: s32, + player-prefix: string, + player-suffix: string, + } + + record c-set-player-team { + team-name: string, + method: team-method, + parameters: option, + players: list, + } + + record c-set-simulation-distance { + simulation-distance: s32, + } + + record c-update-time { + game-time: s64, + clock-updates: list>, + } + + record c-title-text { + title: string, + } + + record c-title-animation { + fade-in-ticks: s32, + stay-ticks: s32, + fade-out-ticks: s32, + } + + record c-play-show-dialog { + dialog: string, + } + + record c-sound-effect { + sound-event: string, + sound-category: s32, + position: tuple, + volume: f32, + pitch: f32, + seed: f64, + } + + record c-spawn-entity { + entity-id: s32, + entity-uuid: uuid, + r-type: s32, + position: tuple, + velocity: string, + pitch: u8, + yaw: u8, + head-yaw: u8, + data: s32, + } + + record c-spawn-living-entity { + entity-id: s32, + entity-uuid: uuid, + r-type: s32, + position: tuple, + yaw: u8, + pitch: u8, + head-yaw: u8, + velocity: string, + metadata: option>, + } + + record c-spawn-painting { + entity-id: s32, + uuid: uuid, + title: string, + %variant: s32, + location: tuple, + direction: u8, + } + + record c-stop-sound { + sound-id: option, + category: option, + } + + record c-store-cookie { + key: string, + payload: list, + } + + record c-subtitle { + subtitle: string, + } + + record c-system-chat-message { + content: string, + overlay: bool, + } + + record c-tab-list { + header: string, + footer: string, + } + + record c-tag-query-response { + transaction-id: s32, + nbt-bytes: list, + } + + record c-take-item-entity { + entity-id: s32, + collector-entity-id: s32, + stack-amount: s32, + } + + record c-teleport-entity { + entity-id: s32, + position: tuple, + delta: tuple, + yaw: f32, + pitch: f32, + relatives: list, + on-ground: bool, + } + + record c-test-instance-block-status { + pos: tuple, + status: s32, + message: option, + } + + record c-ticking-state { + tick-rate: f32, + is-frozen: bool, + } + + record c-ticking-step { + tick-steps: s32, + } + + record c-transfer { + host: string, + port: s32, + } + + record c-unload-chunk { + x: s32, + z: s32, + } + + record c-update-advancements { + reset: bool, + added: list, + removed: list, + progress: list, + show-advancements: bool, + } + + record attribute-modifier { + id: string, + amount: f64, + operation: u8, + } + + record property { + id: s32, + value: f64, + modifiers: list, + } + + record c-login-success { + uuid: uuid, + username: string, + properties: list, + strict-error-handling: bool, + session-id: uuid, + } + + record player-action-add-player { + name: string, + properties: list, + } + + variant player-action { + add-player(player-action-add-player), + initialize-chat(option), + update-game-mode(s32), + update-listed(bool), + update-latency(s32), + update-display-name(option), + update-list-order(s32), + update-hat(bool), + } + + record player { + uuid: uuid, + actions: list, + } + + record c-player-info-update { + actions: u8, + players: list, + } + + record c-update-attributes { + entity-id: s32, + properties: list, + } + + record c-update-entity-pos { + entity-id: s32, + delta: tuple, + on-ground: bool, + } + + record c-update-entity-pos-rot { + entity-id: s32, + delta: tuple, + yaw: u8, + pitch: u8, + on-ground: bool, + } + + record c-update-entity-rot { + entity-id: s32, + yaw: u8, + pitch: u8, + on-ground: bool, + } + + record c-update-mob-effect { + entity-id: s32, + effect-id: s32, + amplifier: s32, + duration: s32, + %flags: u8, + } + + record c-update-objectives { + objective-name: string, + mode: u8, + display-name: string, + render-type: s32, + number-format: option, + } + + enum mode { + add, + remove, + update, + } + + enum render-type { + integer, + hearts, + } + + record c-update-recipes { + raw-data: list, + } + + record c-update-score { + entity-name: string, + objective-name: string, + value: s32, + display-name: option, + number-format: option, + } + + record c-update-tags-play { + tags: list, + } + + record c-use-bed { + entity-id: s32, + location: tuple, + } + + enum waypoint-operation { + track, + untrack, + update, + } + + record waypoint-target-chunk { + x: s32, + z: s32, + } + + variant waypoint-target { + position(tuple), + chunk(waypoint-target-chunk), + azimuth(f32), + empty, + } + + record waypoint-icon { + style: option, + color: s32, + } + + record tracked-waypoint { + identifier: uuid, + icon: option, + target: waypoint-target, + } + + record c-waypoint { + operation: waypoint-operation, + waypoint: tracked-waypoint, + } + + record c-world-event { + event: s32, + location: tuple, + data: s32, + disable-relative-volume: bool, + } + + record status-c-ping-response { + payload: s64, + } + + record status-c-status-response { + json-response: string, + } + + variant serverbound-packet { + config-s-accept-code-of-conduct, + config-s-acknowledge-finish-config, + config-s-client-information-config(config-s-client-information-config), + config-s-config-cookie-response(config-s-config-cookie-response), + config-s-custom-click-action(config-s-custom-click-action), + config-s-keep-alive(config-s-keep-alive), + config-s-known-packs(config-s-known-packs), + config-s-plugin-message(config-s-plugin-message), + config-s-config-pong(config-s-config-pong), + config-s-config-resource-pack(config-s-config-resource-pack), + login-s-login-cookie-response(login-s-login-cookie-response), + login-s-login-acknowledged, + login-s-login-start(login-s-login-start), + login-s-login-plugin-response(login-s-login-plugin-response), + s-attack(s-attack), + s-block-entity-tag-query(s-block-entity-tag-query), + s-bundle-item-selected(s-bundle-item-selected), + s-change-difficulty(s-change-difficulty), + s-change-game-mode(s-change-game-mode), + s-chat-ack(s-chat-ack), + s-chat-command(s-chat-command), + s-chat-command-signed(s-chat-command-signed), + s-chat-message(s-chat-message), + s-chunk-batch(s-chunk-batch), + s-click-slot(s-click-slot), + s-client-command(s-client-command), + s-client-information-play(s-client-information-play), + s-client-tick-end, + s-close-container(s-close-container), + s-command-suggestion(s-command-suggestion), + s-configuration-acknowledged, + s-container-button-click(s-container-button-click), + s-container-slot-state-changed(s-container-slot-state-changed), + s-cookie-response(s-cookie-response), + s-custom-click-action(s-custom-click-action), + s-custom-payload(s-custom-payload), + s-debug-sample-subscription(s-debug-sample-subscription), + s-debug-subscription-request(s-debug-subscription-request), + s-edit-book(s-edit-book), + s-entity-tag-query(s-entity-tag-query), + s-interact(s-interact), + s-jigsaw-generate(s-jigsaw-generate), + s-keep-alive(s-keep-alive), + s-lock-difficulty(s-lock-difficulty), + s-move-vehicle(s-move-vehicle), + s-paddle-boat(s-paddle-boat), + s-pick-item-from-block(s-pick-item-from-block), + s-pick-item-from-entity(s-pick-item-from-entity), + s-play-ping-request(s-play-ping-request), + s-place-recipe(s-place-recipe), + s-player-abilities(s-player-abilities), + s-player-action(s-player-action), + s-player-command(s-player-command), + s-set-player-ground(s-set-player-ground), + s-player-input(s-player-input), + s-player-loaded, + s-player-position(s-player-position), + s-player-position-rotation(s-player-position-rotation), + s-player-rotation(s-player-rotation), + s-player-session(s-player-session), + s-play-pong(s-play-pong), + s-recipe-book-change-settings(s-recipe-book-change-settings), + s-recipe-book-seen-recipe(s-recipe-book-seen-recipe), + s-rename-item(s-rename-item), + s-play-resource-pack(s-play-resource-pack), + s-seen-advancement(s-seen-advancement), + s-select-trade(s-select-trade), + s-set-beacon(s-set-beacon), + s-set-command-block(s-set-command-block), + s-set-command-minecart(s-set-command-minecart), + s-set-creative-slot(s-set-creative-slot), + s-set-game-rule(s-set-game-rule), + s-set-held-item(s-set-held-item), + s-set-jigsaw-block(s-set-jigsaw-block), + s-set-structure-block(s-set-structure-block), + s-set-test-block(s-set-test-block), + s-spectate-entity(s-spectate-entity), + s-swing-arm(s-swing-arm), + s-teleport-to-entity(s-teleport-to-entity), + s-test-instance-block-action(s-test-instance-block-action), + s-update-sign(s-update-sign), + s-use-item(s-use-item), + s-use-item-on(s-use-item-on), + status-s-status-ping-request(status-s-status-ping-request), + status-s-status-request, + unknown, + } + + variant clientbound-packet { + config-c-config-add-resource-pack(config-c-config-add-resource-pack), + config-c-config-clear-dialog, + config-c-code-of-conduct(config-c-code-of-conduct), + config-c-config-disconnect(config-c-config-disconnect), + config-c-cookie-request(config-c-cookie-request), + config-c-config-custom-report-details(config-c-config-custom-report-details), + config-c-feature-flags(config-c-feature-flags), + config-c-finish-config, + config-c-known-packs(config-c-known-packs), + config-c-config-ping(config-c-config-ping), + config-c-plugin-message(config-c-plugin-message), + config-c-registry-data(config-c-registry-data), + config-c-config-remove-resource-pack(config-c-config-remove-resource-pack), + config-c-config-reset-chat, + config-c-config-server-links(config-c-config-server-links), + config-c-config-show-dialog(config-c-config-show-dialog), + config-c-store-cookie(config-c-store-cookie), + config-c-transfer(config-c-transfer), + config-c-update-tags(config-c-update-tags), + login-c-login-cookie-request(login-c-login-cookie-request), + login-c-login-disconnect(login-c-login-disconnect), + login-c-login-plugin-request(login-c-login-plugin-request), + login-c-set-compression(login-c-set-compression), + c-acknowledge-block-change(c-acknowledge-block-change), + c-action-bar(c-action-bar), + c-add-resource-pack(c-add-resource-pack), + c-award-stats(c-award-stats), + c-set-block-destroy-stage(c-set-block-destroy-stage), + c-block-entity-data(c-block-entity-data), + c-block-event(c-block-event), + c-block-update(c-block-update), + c-boss-event(c-boss-event), + c-bundle-delimiter, + c-center-chunk(c-center-chunk), + c-change-difficulty(c-change-difficulty), + c-chunk-batch-end(c-chunk-batch-end), + c-chunk-batch-start, + c-chunks-biomes(c-chunks-biomes), + c-play-clear-dialog, + c-clear-title(c-clear-title), + c-close-container(c-close-container), + c-combat-death(c-combat-death), + c-combat-enter, + c-combat-end(c-combat-end), + c-command-suggestions(c-command-suggestions), + c-commands(c-commands), + c-play-cookie-request(c-play-cookie-request), + c-custom-chat-completions(c-custom-chat-completions), + c-custom-payload(c-custom-payload), + c-play-custom-report-details(c-play-custom-report-details), + c-damage-event(c-damage-event), + c-debug-block-value(c-debug-block-value), + c-debug-chunk-value(c-debug-chunk-value), + c-debug-entity-value(c-debug-entity-value), + c-debug-event(c-debug-event), + c-debug-sample(c-debug-sample), + c-delete-chat(c-delete-chat), + c-play-disconnect(c-play-disconnect), + c-disguised-chat-message(c-disguised-chat-message), + c-display-objective(c-display-objective), + c-entity-animation(c-entity-animation), + c-set-entity-metadata(c-set-entity-metadata), + c-entity-sound-effect(c-entity-sound-effect), + c-entity-status(c-entity-status), + c-entity-velocity(c-entity-velocity), + c-explosion(c-explosion), + c-game-event(c-game-event), + c-game-rule-values(c-game-rule-values), + c-game-test-highlight-pos(c-game-test-highlight-pos), + c-head-rot(c-head-rot), + c-hurt-animation(c-hurt-animation), + c-initialize-world-border(c-initialize-world-border), + c-item-cooldown(c-item-cooldown), + c-keep-alive(c-keep-alive), + c-level-event(c-level-event), + c-light-update(c-light-update), + c-login(c-login), + c-low-disk-space-warning, + c-map-item-data(c-map-item-data), + c-merchant-offers(c-merchant-offers), + c-move-minecart-along-track(c-move-minecart-along-track), + c-move-vehicle(c-move-vehicle), + c-multi-block-update(c-multi-block-update), + c-open-book(c-open-book), + c-open-mount-screen(c-open-mount-screen), + c-open-screen(c-open-screen), + c-open-sign-editor(c-open-sign-editor), + c-particle(c-particle), + c-play-ping(c-play-ping), + c-ping-response(c-ping-response), + c-place-ghost-recipe(c-place-ghost-recipe), + c-player-abilities(c-player-abilities), + c-player-chat-message(c-player-chat-message), + c-player-info-update(c-player-info-update), + c-player-look-at(c-player-look-at), + c-player-position(c-player-position), + c-remove-player-info(c-remove-player-info), + c-player-rotation(c-player-rotation), + c-player-spawn-position(c-player-spawn-position), + c-projectile-power(c-projectile-power), + c-recipe-book-add(c-recipe-book-add), + c-recipe-book-remove(c-recipe-book-remove), + c-recipe-book-settings(c-recipe-book-settings), + c-remove-entities(c-remove-entities), + c-remove-mob-effect(c-remove-mob-effect), + c-remove-resource-pack(c-remove-resource-pack), + c-reset-score(c-reset-score), + c-respawn(c-respawn), + c-select-advancements-tab(c-select-advancements-tab), + c-server-data(c-server-data), + c-play-server-links(c-play-server-links), + c-set-border-center(c-set-border-center), + c-set-border-lerp-size(c-set-border-lerp-size), + c-set-border-size(c-set-border-size), + c-set-border-warning-delay(c-set-border-warning-delay), + c-set-border-warning-distance(c-set-border-warning-distance), + c-set-camera(c-set-camera), + c-set-chunk-cache-radius(c-set-chunk-cache-radius), + c-set-container-content(c-set-container-content), + c-set-container-property(c-set-container-property), + c-set-container-slot(c-set-container-slot), + c-set-cursor-item(c-set-cursor-item), + c-set-entity-link(c-set-entity-link), + c-set-equipment(c-set-equipment), + c-set-experience(c-set-experience), + c-set-health(c-set-health), + c-set-passengers(c-set-passengers), + c-set-player-inventory(c-set-player-inventory), + c-set-player-team(c-set-player-team), + c-set-simulation-distance(c-set-simulation-distance), + c-update-time(c-update-time), + c-title-text(c-title-text), + c-title-animation(c-title-animation), + c-play-show-dialog(c-play-show-dialog), + c-sound-effect(c-sound-effect), + c-spawn-entity(c-spawn-entity), + c-spawn-living-entity(c-spawn-living-entity), + c-spawn-painting(c-spawn-painting), + c-start-configuration, + c-stop-sound(c-stop-sound), + c-store-cookie(c-store-cookie), + c-subtitle(c-subtitle), + c-tab-list(c-tab-list), + c-tag-query-response(c-tag-query-response), + c-take-item-entity(c-take-item-entity), + c-teleport-entity(c-teleport-entity), + c-test-instance-block-status(c-test-instance-block-status), + c-ticking-state(c-ticking-state), + c-ticking-step(c-ticking-step), + c-transfer(c-transfer), + c-unload-chunk(c-unload-chunk), + c-update-advancements(c-update-advancements), + c-update-attributes(c-update-attributes), + c-update-entity-pos(c-update-entity-pos), + c-update-entity-pos-rot(c-update-entity-pos-rot), + c-update-entity-rot(c-update-entity-rot), + c-update-mob-effect(c-update-mob-effect), + c-update-objectives(c-update-objectives), + c-update-recipes(c-update-recipes), + c-update-score(c-update-score), + c-use-bed(c-use-bed), + c-waypoint(c-waypoint), + c-world-event(c-world-event), + status-c-ping-response(status-c-ping-response), + status-c-status-response(status-c-status-response), + unknown, + } +} + +interface %world { + use common.{position, entity-pose, block-pos, nbt-tree}; + use block-entity.{block-entity, command-block-entity, block-entity-type}; + use text.{text-component}; + use scoreboard.{scoreboard}; + use particles.{particle}; + use sounds.{sound, sound-category}; + use entity-types.{entity-type}; + use biomes.{biome}; + use attributes.{attribute, modifier-operation, attribute-modifier}; + use item-stack.{item-stack}; + use damage-types.{damage-type}; + use game-rules.{game-rule, game-rule-value}; + use uuid.{uuid}; + + /// Equipment slots available on living entities (mobs, armor stands, players). + enum equipment-slot { + main-hand, + off-hand, + feet, + legs, + chest, + head, + body, + saddle, + } + + /// Defines how a block reacts when pushed by a piston. + enum piston-behavior { + /// Normal behavior; the block can be pushed and pulled. + normal, + /// The block is destroyed when pushed. + destroy, + /// The block cannot be pushed or pulled. + block, + /// The block is ignored by pistons. + ignore, + /// The block can only be pushed, not pulled. + push-only, + } + + /// Predefined AI goals that can be added to mob entities. + variant builtin-ai-goal { + swim, + wander-around(f32), + melee-attack(f32), + look-at-player(f32), + look-around, + escape-danger(f32), + avoid-entity(f32), + blaze-attack, + creeper-ignite, + eat-grass, + zombie-attack(f32), + } + + /// Node and terrain classification types evaluated during mob pathfinding. + enum path-node-type { + blocked, + open, + walkable, + walkable-door, + trapdoor, + powder-snow, + danger-powder-snow, + fence, + lava, + water, + water-border, + rail, + unpassable-rail, + danger-fire, + damage-fire, + danger-other, + damage-other, + door-open, + door-wood-closed, + door-iron-closed, + breach, + leaves, + sticky-honey, + cocoa, + damage-cautious, + danger-trapdoor, + } + + /// Minecraft 16 dye colors. + enum dye-color { + white, + orange, + magenta, + light-blue, + yellow, + lime, + pink, + gray, + light-gray, + cyan, + purple, + blue, + brown, + green, + red, + black, + } + + /// Villager profession identifiers. + enum villager-profession { + none, + armorer, + butcher, + cartographer, + cleric, + farmer, + fisherman, + fletcher, + leatherworker, + librarian, + mason, + nitwit, + shepherd, + toolsmith, + weaponsmith, + } + + /// Specialized data for sheep entities. + record sheep-data { + color: dye-color, + is-sheared: bool, + } + + /// Specialized data for wolf entities. + record wolf-data { + is-tamed: bool, + owner: option, + is-sitting: bool, + collar-color: dye-color, + is-angry: bool, + is-begging: bool, + } + + /// Specialized data for cat entities. + record cat-data { + is-tamed: bool, + owner: option, + is-sitting: bool, + collar-color: dye-color, + } + + /// Specialized data for villager entities. + record villager-data { + profession: villager-profession, + level: u8, + experience: u32, + } + + /// Specialized data for creeper entities. + record creeper-data { + is-powered: bool, + fuse: s32, + is-ignited: bool, + explosion-radius: u8, + } + + /// Specialized data for slime and magma cube entities. + record slime-data { + size: s32, + } + + /// Specialized data for enderman entities. + record enderman-data { + carried-block-state: option, + is-screaming: bool, + is-staring: bool, + } + + /// Specialized data for iron golem entities. + record iron-golem-data { + is-player-created: bool, + } + + /// Specialized data for fox entities. + record fox-data { + is-sitting: bool, + is-sleeping: bool, + is-crouching: bool, + } + + /// Specialized data for ageable animal mobs. + record ageable-data { + is-baby: bool, + age: s32, + in-love-ticks: s32, + } + + /// Specialized data for zombie entities. + record zombie-data { + is-baby: bool, + can-break-doors: bool, + } + + /// Defines how an explosion interacts with blocks in the world. + enum explosion-interaction { + /// No interaction with blocks. + none, + /// Blocks are destroyed and may drop loot. + block, + /// Interaction typical for mob-caused explosions. + mob, + /// Interaction typical for TNT explosions. + tnt, + /// Triggers specific block behaviors. + trigger, + } + + /// Flags used to control block updates and notifications. + flags block-flags { + /// Notifies neighbor blocks of the change. + notify-neighbors, + /// Notifies client listeners of the change. + notify-listeners, + /// Forces the block state even if it's the same. + force-state, + /// Skips dropping items when the block is removed. + skip-drops, + /// Indicates the block was moved (e.g., by a piston). + moved, + /// Skips state replacement for redstone wires. + skip-redstone-wire-state-replacement, + /// Skips the callback when a block entity is replaced. + skip-block-entity-replaced-callback, + /// Skips the callback when a block is added. + skip-block-added-callback, + } + + /// Flammability properties of a block. + record flammable { + spread-chance: u8, + burn-chance: u8, + } + + /// Musical instruments used by note blocks. + enum noteblock-instrument { + harp, + basedrum, + snare, + hat, + bass, + flute, + bell, + guitar, + chime, + xylophone, + iron-xylophone, + cow-bell, + didgeridoo, + bit, + banjo, + pling, + trumpet, + trumpet-exposed, + trumpet-oxidized, + trumpet-weathered, + zombie, + skeleton, + creeper, + dragon, + wither-skeleton, + piglin, + custom-head, + } + + /// Static definition of a Minecraft block type. + record block { + /// The internal numerical ID of the block type. + id: u16, + /// The unique namespaced ID (e.g., "minecraft:stone"). + name: string, + /// How hard the block is to break (-1.0 for unbreakable blocks). + hardness: f32, + /// Resistance to explosions. + blast-resistance: f32, + /// The color of this block when displayed on a map. + map-color: u8, + /// The friction coefficient (0.6 default, 0.98 for ice). + slipperiness: f32, + /// How much this block affects entity walk speed. + velocity-multiplier: f32, + /// How much this block affects entity jump height. + jump-velocity-multiplier: f32, + /// The item ID associated with this block in inventory/drops. + item-id: u16, + /// The default block state ID when placed without extra properties. + default-state-id: u16, + /// All valid state IDs belonging to this block type. + state-ids: list, + /// Whether this block is solid by default. + is-solid: bool, + /// Whether this block is considered air. + is-air: bool, + /// Whether this block is flammable. + is-flammable: bool, + /// Flammability details if flammable. + flammable: option, + } + + /// A simple wrapper for a block state ID. + record block-state-id { + id: u16, + } + + resource entity { + get-id: func() -> u32; + get-uuid: func() -> uuid; + get-type: func() -> entity-type; + get-position: func() -> position; + get-world: func() -> %world; + get-yaw: func() -> f32; + get-pitch: func() -> f32; + get-head-yaw: func() -> f32; + teleport: func(pos: position, world-ref: %world); + set-velocity: func(velocity: position); + get-velocity: func() -> position; + get-pose: func() -> entity-pose; + get-name: func() -> text-component; + set-custom-name: func(name: text-component); + get-custom-name: func() -> option; + set-custom-name-visible: func(visible: bool); + is-custom-name-visible: func() -> bool; + is-invulnerable: func() -> bool; + set-invulnerable: func(invulnerable: bool); + get-fire-ticks: func() -> s32; + set-fire-ticks: func(ticks: s32); + get-fall-distance: func() -> f32; + set-fall-distance: func(distance: f32); + get-ticks-lived: func() -> s32; + set-ticks-lived: func(ticks: s32); + is-sneaking: func() -> bool; + set-sneaking: func(sneaking: bool); + is-sprinting: func() -> bool; + set-sprinting: func(sprinting: bool); + is-swimming: func() -> bool; + set-swimming: func(swimming: bool); + is-invisible: func() -> bool; + set-invisible: func(invisible: bool); + is-glowing: func() -> bool; + set-glowing: func(glowing: bool); + is-fall-flying: func() -> bool; + set-fall-flying: func(fall-flying: bool); + is-silent: func() -> bool; + set-silent: func(silent: bool); + has-gravity: func() -> bool; + set-has-gravity: func(gravity: bool); + get-width: func() -> f32; + get-height: func() -> f32; + set-rotation: func(yaw: f32, pitch: f32); + is-on-ground: func() -> bool; + is-on-fire: func() -> bool; + set-on-fire: func(on-fire: bool); + has-visual-fire: func() -> bool; + set-visual-fire: func(visual-fire: bool); + get-portal-cooldown: func() -> u32; + set-portal-cooldown: func(cooldown: u32); + get-remaining-air: func() -> s32; + set-remaining-air: func(air: s32); + get-max-air: func() -> s32; + get-eye-height: func() -> f32; + get-eye-position: func() -> position; + get-nearby-entities: func(x: f64, y: f64, z: f64) -> list; + get-vehicle: func() -> option; + set-vehicle: func(vehicle: option); + get-passengers: func() -> list; + add-passenger: func(passenger: entity); + remove-passenger: func(passenger: entity); + eject-passengers: func(); + get-bounding-box: func() -> bounding-box; + is-in-water: func() -> bool; + is-in-lava: func() -> bool; + remove: func(); + /// Performs a raycast from the entity's eye position in its looking direction. + raycast: func(max-distance: f64, fluid-handling: bool) -> option; + /// Performs a ray-trace from the entity's eye position in its looking direction to find the targeted block. + ray-trace-block: func(max-distance: f64, include-fluids: bool) -> option; + /// Performs a ray-trace from the entity's eye position in its looking direction to find the targeted entity. + ray-trace-entity: func(max-distance: f64) -> option; + /// Returns the entity currently targeted in the looking direction within the specified distance. + get-target-entity: func(max-distance: f64) -> option; + /// Sets a namespaced custom data value on this entity. + set-custom-data: func(namespace: string, key: string, value: nbt-tree); + /// Returns a namespaced custom data value from this entity, if set. + get-custom-data: func(namespace: string, key: string) -> option; + /// Removes a namespaced custom data value from this entity. + remove-custom-data: func(namespace: string, key: string); + /// Returns whether this entity has a namespaced custom data value. + has-custom-data: func(namespace: string, key: string) -> bool; + /// Returns this entity as a living-entity if it has health and attributes, or none otherwise. + as-living: func() -> option; + /// Returns this entity as a mob if it is an AI-driven mob entity, or none otherwise. + as-mob: func() -> option; + /// Returns whether this entity is a living entity. + is-living: func() -> bool; + /// Returns whether this entity is an AI-driven mob. + is-mob: func() -> bool; + } + + /// Represents a living entity with health, combat stats, attributes, and equipment (mobs, players, armor stands). + resource living-entity { + /// Converts back to the base entity handle. + as-entity: func() -> entity; + /// Returns this living entity as a mob if it has AI/navigation, or none otherwise. + as-mob: func() -> option; + /// Returns whether this living entity is an AI-driven mob. + is-mob: func() -> bool; + /// Health & Combat + get-health: func() -> f32; + set-health: func(health: f32); + get-max-health: func() -> f32; + set-max-health: func(max-health: f32); + damage: func(amount: f32, damage-type: damage-type); + is-dead: func() -> bool; + get-absorption: func() -> f32; + set-absorption: func(amount: f32); + /// Attributes + get-attribute-value: func(attr: attribute) -> f64; + get-attribute-base: func(attr: attribute) -> f64; + set-attribute-base: func(attr: attribute, value: f64); + add-attribute-modifier: func(attr: attribute, modifier: attribute-modifier); + remove-attribute-modifier: func(attr: attribute, id: string); + get-attribute-modifiers: func(attr: attribute) -> list; + reset-attribute: func(attr: attribute); + reset-all-attributes: func(); + /// Equipment + get-equipment: func(slot: equipment-slot) -> option; + set-equipment: func(slot: equipment-slot, stack: option); + clear-equipment: func(); + get-age: func() -> s32; + set-age: func(age: s32); + send-system-message: func(message: text-component); + } + + /// Represents an AI-driven mob entity with goals, targeting, and pathfinding navigation (e.g. zombies, villagers). + resource mob { + /// Converts back to the base entity handle. + as-entity: func() -> entity; + /// Converts to the living-entity handle. + as-living: func() -> living-entity; + /// Goals & Targeting + add-ai-goal: func(priority: u8, goal: builtin-ai-goal); + add-custom-ai-goal: func(priority: u8, goal-id: u32); + clear-ai-goals: func(); + set-ai-disabled: func(disabled: bool); + is-ai-disabled: func() -> bool; + set-target: func(target: option); + get-target: func() -> option; + /// Pathfinding & Navigation + navigate-to-pos: func(pos: position, speed: f64) -> bool; + navigate-to-entity: func(target: entity, speed: f64) -> bool; + stop-navigation: func(); + is-navigating: func() -> bool; + has-reached-destination: func() -> bool; + set-navigation-speed: func(speed: f64); + can-reach: func(pos: position, max-distance: f32) -> bool; + set-pathfinding-malus: func(node-type: path-node-type, malus: f32); + get-pathfinding-malus: func(node-type: path-node-type) -> f32; + look-at: func(pos: position); + look-at-entity: func(target: entity); + /// Returns the specialized mob-specific data for this mob. + get-mob-data: func() -> mob-data; + /// Sets the specialized mob-specific data for this mob. + /// Returns false if the provided data variant is incompatible with this mob. + set-mob-data: func(data: mob-data) -> bool; + /// Sets the number of freeze ticks on this entity (0 to 140). + set-freeze-ticks: func(ticks: s32); + /// Returns the number of freeze ticks currently on this entity. + get-freeze-ticks: func() -> s32; + } + + /// Result of an entity ray-trace operation. + record ray-trace-entity-result { + /// The entity that was hit. + entity: entity, + /// The exact hit coordinates in world space. + hit-pos: position, + /// The distance from the ray start to the hit position. + distance: f64, + } + + resource chunk { + /// Gets the chunk's X coordinate. + get-x: func() -> s32; + /// Gets the chunk's Z coordinate. + get-z: func() -> s32; + /// Gets the block state ID at the specified position relative to the chunk. + /// X and Z must be in the range [0, 15]. + get-block-state-id: func(pos: block-pos) -> u16; + /// Gets detailed block state information at the specified position relative to the chunk. + /// X and Z must be in the range [0, 15]. + get-block-state: func(pos: block-pos) -> block-state; + /// Sets the block state at the specified position relative to the chunk. + /// X and Z must be in the range [0, 15]. + set-block-state: func(pos: block-pos, state: u16); + /// Gets the block at the specified position relative to the chunk. + /// X and Z must be in the range [0, 15]. + get-block: func(pos: block-pos) -> block; + /// Sets the block at the specified position relative to the chunk using its default state. + /// X and Z must be in the range [0, 15]. + set-block: func(pos: block-pos, block: block); + /// Sets the block by block ID at the specified position relative to the chunk using its default state. + /// X and Z must be in the range [0, 15]. + set-block-by-id: func(pos: block-pos, block-id: u16); + /// Gets the biome at the specified position relative to the chunk. + /// X and Z must be in the range [0, 15]. + get-biome: func(pos: block-pos) -> biome; + /// Gets the block entity at the specified position relative to the chunk, if any. + /// X and Z must be in the range [0, 15]. + get-block-entity: func(pos: block-pos) -> option; + /// Gets the highest non-air block Y coordinate at the specified X and Z relative to the chunk. + /// X and Z must be in the range [0, 15]. + get-top-block-y: func(x: s32, z: s32) -> s32; + /// Gets the sky light level at the specified position relative to the chunk. + /// X and Z must be in the range [0, 15]. + get-sky-light: func(pos: block-pos) -> u8; + /// Gets the block light level at the specified position relative to the chunk. + /// X and Z must be in the range [0, 15]. + get-block-light: func(pos: block-pos) -> u8; + /// Sets a namespaced custom data value on this chunk. + set-custom-data: func(namespace: string, key: string, value: nbt-tree); + /// Returns a namespaced custom data value from this chunk, if set. + get-custom-data: func(namespace: string, key: string) -> option; + /// Removes a namespaced custom data value from this chunk. + remove-custom-data: func(namespace: string, key: string); + /// Returns whether this chunk has a namespaced custom data value. + has-custom-data: func(namespace: string, key: string) -> bool; + } + + /// Represents the boundaries of a world. + resource world-border { + /// Gets the center X coordinate of the border. + get-center-x: func() -> f64; + /// Gets the center Z coordinate of the border. + get-center-z: func() -> f64; + /// Gets the center position of the border. + get-center: func() -> position; + /// Sets the center coordinates of the border. + set-center: func(x: f64, z: f64); + /// Gets the current diameter of the border. + get-diameter: func() -> f64; + /// Gets the current diameter of the border (alias for get-diameter). + get-size: func() -> f64; + /// Sets the diameter of the border, optionally with a speed (in ticks) for lerping. + set-diameter: func(diameter: f64, speed: option); + /// Sets the size of the border instantly. + set-size: func(size: f64); + /// Sets the size of the border with a transition duration in seconds. + set-size-transition: func(new-size: f64, time-seconds: u64); + /// Gets the target diameter when lerping/transitioning. + get-target-diameter: func() -> f64; + /// Gets the target transition duration/speed in ticks. + get-target-speed: func() -> s64; + /// Gets the distance from the border where warning effects start (in blocks). + get-warning-distance: func() -> s32; + /// Sets the warning distance (in blocks). + set-warning-distance: func(distance: s32); + /// Gets the time before a player hitting the border is warned (in seconds). + get-warning-delay: func() -> s32; + /// Sets the warning delay (in seconds). + set-warning-delay: func(delay: s32); + /// Gets the warning time (alias for get-warning-delay). + get-warning-time: func() -> s32; + /// Sets the warning time (alias for set-warning-delay). + set-warning-time: func(time: s32); + /// Gets the safe damage buffer distance outside the border (in blocks). + get-damage-buffer: func() -> f64; + /// Sets the safe damage buffer distance outside the border (in blocks). + set-damage-buffer: func(buffer: f64); + /// Gets the damage amount inflicted per block per second when outside the buffer. + get-damage-amount: func() -> f64; + /// Sets the damage amount inflicted per block per second when outside the buffer. + set-damage-amount: func(damage: f64); + /// Returns whether the specified coordinates are within the border. + contains: func(x: f64, z: f64) -> bool; + /// Returns whether the specified position is within the border. + contains-pos: func(pos: position) -> bool; + /// Resets the world border to vanilla default settings. + reset: func(); + } + + /// Represents an axis-aligned bounding box. + record bounding-box { + min: position, + max: position, + } + + /// Detailed information about a block's state. + record block-state { + /// The internal numerical ID of the block state. + id: u16, + /// The numerical ID of the parent block type. + block-id: u16, + /// The namespaced identifier of the parent block type. + block-name: string, + /// The light level emitted by this block (0-15). + luminance: u8, + /// How much light this block blocks. + opacity: u8, + /// The hardness of the block, determining mining speed. + hardness: f32, + /// Whether this block is considered air. + is-air: bool, + /// Whether this block is a liquid. + is-liquid: bool, + /// Whether this block is a solid. + is-solid: bool, + /// Whether this block occupies a full cube. + is-full-cube: bool, + /// How this block behaves when pushed by a piston. + piston-behavior: piston-behavior, + /// Whether this block receives random ticks. + has-random-ticks: bool, + /// Whether this block can catch fire. + burnable: bool, + /// Whether a specific tool is required to mine this block and get drops. + tool-required: bool, + /// Whether this block has transparency on its sides. + sided-transparency: bool, + /// Whether this block can be replaced by another block (e.g., grass). + replaceable: bool, + /// Whether this block is considered a solid block for redstone purposes. + is-solid-block: bool, + /// The numerical ID of the block entity type, if any. + block-entity-type: u16, + /// The instrument used for note blocks when placed on top of this block. + instrument: noteblock-instrument, + /// The collision shapes of this block. + collision-shapes: list, + /// The outline shapes of this block. + outline-shapes: list, + /// Whether the bottom side of the block is solid. + down-side-solid: bool, + /// Whether the top side of the block is solid. + up-side-solid: bool, + /// Whether the north side of the block is solid. + north-side-solid: bool, + /// Whether the south side of the block is solid. + south-side-solid: bool, + /// Whether the west side of the block is solid. + west-side-solid: bool, + /// Whether the east side of the block is solid. + east-side-solid: bool, + /// Whether the center of the bottom side is solid. + down-center-solid: bool, + /// Whether the center of the top side is solid. + up-center-solid: bool, + /// The color of this block when displayed on a map. + map-color: u8, + /// The block state's property key-value pairs (e.g. facing=north). + properties: list>, + } + + /// Represents the configured shared spawn location for a world. + record world-spawn-location { + /// The block position of the shared world spawn. + pos: block-pos, + /// The yaw players should face when spawning here. + yaw: f32, + /// The pitch players should use when spawning here. + pitch: f32, + } + + /// Represents a cardinal direction or block face. + enum block-direction { + down, + up, + north, + south, + west, + east, + } + + /// Specialized data for shulker entities. + record shulker-data { + attached-face: block-direction, + peek-amount: u8, + color: option, + } + + /// Tagged variant holding specialized data for specific mob types. + variant mob-data { + sheep(sheep-data), + wolf(wolf-data), + cat(cat-data), + villager(villager-data), + creeper(creeper-data), + slime(slime-data), + enderman(enderman-data), + iron-golem(iron-golem-data), + fox(fox-data), + ageable(ageable-data), + zombie(zombie-data), + shulker(shulker-data), + generic, + } + + /// Result of a raycast operation. + record raycast-result { + /// The block position that was hit. + pos: block-pos, + /// The face of the block that was hit. + face: block-direction, + } + + /// Detailed result of a block ray-trace operation. + record ray-trace-block-result { + /// The block position that was hit. + pos: block-pos, + /// The face of the block that was hit. + face: block-direction, + /// The exact hit coordinates in world space. + hit-pos: position, + } + + /// Represents a Minecraft world (dimension). + resource %world { + /// Returns the unique identifier of this world. + get-id: func() -> string; + /// Gets the world border associated with this world (alias for get-world-border). + get-border: func() -> world-border; + /// Gets the world border associated with this world. + get-world-border: func() -> world-border; + /// Gets the chunk at the specified chunk coordinates. + get-chunk: func(x: s32, z: s32) -> option; + /// Gets the block state ID at the specified position. + get-block-state-id: func(pos: block-pos) -> u16; + /// Gets detailed block state information at the specified position. + get-block-state: func(pos: block-pos) -> block-state; + /// Sets the block state at the specified position. + set-block-state: func(pos: block-pos, state: u16, update-flags: block-flags); + /// Gets the block type at the specified position. + get-block: func(pos: block-pos) -> block; + /// Gets the numerical block ID at the specified position. + get-block-id: func(pos: block-pos) -> u16; + /// Sets the block at the specified position using its default state. + set-block: func(pos: block-pos, block: block, update-flags: block-flags); + /// Sets the block at the specified position by numerical block ID using its default state. + set-block-by-id: func(pos: block-pos, block-id: u16, update-flags: block-flags); + /// Sets the block at the specified position by namespaced name using its default state. + /// Returns true if the block was recognized and set. + set-block-by-name: func(pos: block-pos, name: string, update-flags: block-flags) -> bool; + /// Returns the current time of day in ticks. + get-time-of-day: func() -> u64; + /// Sets the current time of day in ticks. + set-time-of-day: func(time: u64); + /// Returns the total age of the world in ticks. + get-world-age: func() -> u64; + /// Returns the dimension type (e.g., \"minecraft:overworld\"). + get-dimension: func() -> string; + /// Returns the configured shared spawn location for this world. + get-spawn-location: func() -> world-spawn-location; + /// Gets the highest non-air block Y coordinate at the specified X and Z. + get-top-block-y: func(x: s32, z: s32) -> s32; + /// Gets the highest motion-blocking block Y coordinate. + get-motion-blocking-height: func(x: s32, z: s32) -> s32; + /// Returns whether it is currently raining or snowing. + is-raining: func() -> bool; + /// Sets whether it should be raining or snowing. + set-raining: func(raining: bool); + /// Returns whether there is currently a thunderstorm. + is-thundering: func() -> bool; + /// Sets whether there should be a thunderstorm. + set-thundering: func(thundering: bool); + /// Broadcasts a system message to all players in this world. + broadcast-system-message: func(message: text-component, overlay: bool); + /// Returns the scoreboard associated with this world. + get-scoreboard: func() -> scoreboard; + /// Plays a sound at the specified position for all players in the world. + play-sound: func(sound: sound, category: sound-category, pos: position, volume: f32, pitch: f32); + /// Plays a custom resource pack sound identifier at the specified position for all players in the world. + play-custom-sound: func(sound-name: string, category: sound-category, pos: position, volume: f32, pitch: f32); + /// Spawns particles at the specified position. + spawn-particle: func(particle: particle, pos: position, offset: position, max-speed: f32, count: s32); + /// Creates an explosion at the specified position. + create-explosion: func(pos: position, power: f32, create-fire: bool, interaction: explosion-interaction); + /// Returns the sea level of this world. + get-sea-level: func() -> s32; + /// Returns the minimum Y coordinate (bottom of the world). + get-min-y: func() -> s32; + /// Returns the sky light level at the specified position. + get-sky-light: func(pos: block-pos) -> u8; + /// Sets the sky light level at the specified position. + set-sky-light: func(pos: block-pos, level: u8); + /// Returns the block light level at the specified position. + get-block-light: func(pos: block-pos) -> u8; + /// Sets the block light level at the specified position. + set-block-light: func(pos: block-pos, level: u8); + /// Returns the biome at the specified position. + get-biome: func(pos: block-pos) -> biome; + /// Spawns an entity of the specified type at the given position. + spawn-entity: func(entity-type: entity-type, pos: position) -> entity; + /// Returns a list of all entities in this world. + get-entities: func() -> list; + /// Spawns a lightning bolt at the specified position. + strike-lightning: func(pos: position, effect-only: bool); + /// Performs a raycast from start position to end position to hit blocks. + ray-trace-blocks: func(start: position, end: position) -> option; + /// Performs a raycast from start position to end position to hit blocks, with optional fluid handling. + ray-trace-block: func(start: position, end: position, include-fluids: bool) -> option; + /// Performs a raycast from start position to end position to find the closest entity hit. + ray-trace-entity: func(start: position, end: position) -> option; + /// Performs a raycast from start position to end position to find all entities hit along the ray. + ray-trace-entities: func(start: position, end: position) -> list; + /// Returns the block entity at the specified position, if any. + get-block-entity: func(pos: block-pos) -> option; + /// Returns the raw NBT bytes of the block entity at the given position, if any. + get-block-entity-nbt: func(pos: block-pos) -> option>; + /// Restores a block entity from raw NBT bytes at the given position. + /// The NBT must contain a valid "id" field (e.g. "minecraft:chest"). + set-block-entity-nbt: func(pos: block-pos, nbt-data: list) -> result<_, string>; + /// Returns the name of this world (e.g. "world", "world_nether", "arena_1"). + get-name: func() -> string; + /// Saves all chunk data, block entities, and entities for this world to disk. + save: func() -> result<_, string>; + /// Sets a custom chunk generator for this world using a registered generator ID. + set-chunk-generator: func(generator-id: u32); + /// Sets a namespaced custom data value on this world. + set-custom-data: func(namespace: string, key: string, value: nbt-tree); + /// Returns a namespaced custom data value from this world, if set. + get-custom-data: func(namespace: string, key: string) -> option; + /// Removes a namespaced custom data value from this world. + remove-custom-data: func(namespace: string, key: string); + /// Returns whether this world has a namespaced custom data value. + has-custom-data: func(namespace: string, key: string) -> bool; + /// Gets the value of a game rule in this world. + get-game-rule: func(rule: game-rule) -> game-rule-value; + /// Sets the value of a game rule in this world. + set-game-rule: func(rule: game-rule, value: game-rule-value); + } + + /// Generation phase for custom chunk generation. + enum generation-phase { + biomes, + noise, + surface, + features, + } + + /// Mutable chunk buffer representing a 16x16 column during custom world generation. + resource chunk-buffer { + /// Returns the chunk X coordinate. + get-x: func() -> s32; + /// Returns the chunk Z coordinate. + get-z: func() -> s32; + /// Returns the minimum Y coordinate for this world. + get-min-y: func() -> s32; + /// Returns the height of the chunk in blocks. + get-height: func() -> u32; + /// Sets the block state ID at local coordinates (0..16, y, 0..16). + set-block-state-id: func(x: u8, y: s32, z: u8, state-id: u16); + /// Gets the block state ID at local coordinates (0..16, y, 0..16). + get-block-state-id: func(x: u8, y: s32, z: u8) -> u16; + /// Fills an entire horizontal 16x16 layer at the given Y level with a block state ID. + fill-layer: func(y: s32, state-id: u16); + /// Fills a vertical column from min-y to max-y at local (x, z) with a block state ID. + fill-range: func(x: u8, min-y: s32, max-y: s32, z: u8, state-id: u16); + /// Fills a 3D cuboid with a block state ID. + fill-cuboid: func(min-x: u8, min-y: s32, min-z: u8, max-x: u8, max-y: s32, max-z: u8, state-id: u16); + /// Sets the biome at local coordinates (0..16, y, 0..16). + set-biome: func(x: u8, y: s32, z: u8, biome: biome); + /// Fills the entire chunk with the given biome. + fill-biome: func(biome: biome); + } + + /// A block's registry name and its property key-value pairs for a state ID. + record block-state-info { + name: string, + properties: list>, + } + + /// Resolves a block name and optional properties to a block state ID. + /// Returns none if the block name is unknown. + resolve-block-state: func(name: string, properties: list>) -> option; + + /// Resolves a block state ID back to its block name and properties. + /// Returns none if the state ID is unknown. + block-state-to-info: func(state-id: u16) -> option; + + /// Gets a block type by its numerical block ID. + get-block-by-id: func(id: u16) -> option; + + /// Gets a block type by its namespaced name (e.g., "minecraft:stone" or "stone"). + get-block-by-name: func(name: string) -> option; + + /// Gets all registered blocks. + get-all-blocks: func() -> list; + + /// Gets the names of all registered blocks. + get-all-block-names: func() -> list; + + /// Gets the total number of registered block types. + get-block-count: func() -> u32; + + /// Gets the total number of registered block states. + get-block-state-count: func() -> u32; + + /// Gets all valid block states for a block type. + get-states-for-block: func(block: block) -> list; + + /// Gets all valid block states for a numerical block ID. + get-states-for-block-id: func(block-id: u16) -> list; + + /// Gets all valid state IDs for a numerical block ID. + get-state-ids-for-block-id: func(block-id: u16) -> list; + + /// Gets property key-value pairs for a numerical block state ID. + get-block-properties: func(state-id: u16) -> list>; + + /// Gets the block type associated with a block state ID. + get-block-from-state-id: func(state-id: u16) -> option; + + /// Gets the block type associated with a block state. + get-block-from-state: func(state: block-state) -> block; + + /// Gets the default block state for a block type. + get-default-state-from-block: func(block: block) -> block-state; + + /// Gets the default block state for a numerical block ID. + get-default-state-from-block-id: func(block-id: u16) -> option; + + /// Gets the detailed block state for a numerical block state ID. + get-block-state-by-id: func(state-id: u16) -> option; +} + +interface display { + use %world.{entity}; + use text.{text-component}; + use item-stack.{item-stack}; + use uuid.{uuid}; + + /// Billboard rendering constraints for display entities. + enum billboard-mode { + fixed, + vertical, + horizontal, + center, + } + + /// Item display transformation modes for item display entities. + enum item-display-mode { + none, + thirdperson-lefthand, + thirdperson-righthand, + firstperson-lefthand, + firstperson-righthand, + head, + gui, + ground, + fixed, + } + + /// Text alignment options for text display entities. + enum text-alignment { + center, + left, + right, + } + + /// 3D single-precision vector. + record vector3f { + x: f32, + y: f32, + z: f32, + } + + /// Single-precision quaternion representing a 3D rotation. + record quaternionf { + x: f32, + y: f32, + z: f32, + w: f32, + } + + /// Transformation (translation, scale, left and right rotations) for display entities. + record display-transformation { + translation: vector3f, + scale: vector3f, + left-rotation: quaternionf, + right-rotation: quaternionf, + } + + /// Common base resource for all display entities. + resource display-entity { + from-entity: static func(entity: borrow) -> option; + get-entity: func() -> entity; + get-transformation: func() -> display-transformation; + set-transformation: func(transformation: display-transformation); + get-interpolation-duration: func() -> s32; + set-interpolation-duration: func(duration: s32); + get-interpolation-start: func() -> s32; + set-interpolation-start: func(delta-ticks: s32); + get-teleport-duration: func() -> s32; + set-teleport-duration: func(duration: s32); + get-billboard: func() -> billboard-mode; + set-billboard: func(mode: billboard-mode); + get-view-range: func() -> f32; + set-view-range: func(range: f32); + get-shadow-radius: func() -> f32; + set-shadow-radius: func(radius: f32); + get-shadow-strength: func() -> f32; + set-shadow-strength: func(strength: f32); + get-display-width: func() -> f32; + set-display-width: func(width: f32); + get-display-height: func() -> f32; + set-display-height: func(height: f32); + get-glow-color-override: func() -> s32; + set-glow-color-override: func(color: s32); + get-brightness: func() -> s32; + set-brightness: func(brightness: s32); + } + + /// Resource specifically for Block Display entities. + resource block-display-entity { + from-entity: static func(entity: borrow) -> option; + get-display: func() -> display-entity; + get-entity: func() -> entity; + get-block-state-id: func() -> u16; + set-block-state-id: func(state-id: u16); + } + + /// Resource specifically for Item Display entities. + resource item-display-entity { + from-entity: static func(entity: borrow) -> option; + get-display: func() -> display-entity; + get-entity: func() -> entity; + get-item: func() -> option; + set-item: func(item: option); + get-item-display-mode: func() -> item-display-mode; + set-item-display-mode: func(mode: item-display-mode); + } + + /// Resource specifically for Text Display entities. + resource text-display-entity { + from-entity: static func(entity: borrow) -> option; + get-display: func() -> display-entity; + get-entity: func() -> entity; + get-text: func() -> text-component; + set-text: func(text: text-component); + get-line-width: func() -> s32; + set-line-width: func(width: s32); + get-background: func() -> s32; + set-background: func(color: s32); + get-text-opacity: func() -> s8; + set-text-opacity: func(opacity: s8); + get-shadow: func() -> bool; + set-shadow: func(shadow: bool); + get-see-through: func() -> bool; + set-see-through: func(see-through: bool); + get-default-background: func() -> bool; + set-default-background: func(default-background: bool); + get-alignment: func() -> text-alignment; + set-alignment: func(alignment: text-alignment); + } + + /// Resource specifically for Interaction entities. + resource interaction-entity { + from-entity: static func(entity: borrow) -> option; + get-entity: func() -> entity; + get-width: func() -> f32; + set-width: func(width: f32); + get-height: func() -> f32; + set-height: func(height: f32); + get-response: func() -> bool; + set-response: func(response: bool); + get-last-attacker: func() -> option; + get-last-interaction: func() -> option; + } +} + +interface entity { + use %world.{entity, living-entity, mob, path-node-type, dye-color, villager-profession, mob-data, sheep-data, wolf-data, cat-data, villager-data, creeper-data, slime-data, enderman-data, iron-golem-data, fox-data, ageable-data, zombie-data, shulker-data, raycast-result, ray-trace-block-result, ray-trace-entity-result, block-direction}; +} + +/// Represents a player connected to the Minecraft server. +interface player { + use common.{hand, position, game-mode, block-pos}; + use item-stack.{item-stack}; + use %world.{%world, entity, ray-trace-block-result, ray-trace-entity-result}; + use permission.{permission-level}; + use text.{text-component}; + use gui.{gui}; + use forms.{form}; + use java-dialogs.{dialog}; + use java-packets.{clientbound-packet as java-packet}; + use bedrock-packets.{clientbound-packet as bedrock-packet}; + use uuid.{uuid}; + use status-effect.{status-effect-type, status-effect-instance}; + use scoreboard.{scoreboard, bedrock-scoreboard}; + use advancement.{advancement-progress}; + use damage-types.{damage-type}; + use statistics.{statistic-category, custom-statistic}; + use inventory.{inventory, player-inventory}; + use sounds.{sound, sound-category}; + use particles.{particle}; + use entity-statuses.{entity-status}; + + /// Represents per-player weather condition overrides. + enum player-weather { + clear, + downfall, + } + + /// Types of projectiles that can be launched by a player. + enum projectile-type { + arrow, + snowball, + egg, + ender-pearl, + splash-potion, + fireball, + small-fireball, + trident, + wind-charge, + } + + /// Types of clientbound game events. + enum client-game-event { + no-respawn-block-available, + begin-raining, + end-raining, + change-game-mode, + win-game, + demo-event, + arrow-hit-player, + rain-level-change, + thunder-level-change, + play-pufferfish-string-sound, + play-elder-guardian-mob-appearance, + enabled-respawn-screen, + limited-crafting, + start-waiting-chunks, + } + + /// Built-in known server link types displayed in the client Escape pause menu. + enum known-server-link { + bug-report, + community-guidelines, + support, + status, + feedback, + community, + website, + forums, + news, + announcements, + } + + /// Label for a server link: either a built-in standard link type or a custom text component. + variant server-link-label { + known(known-server-link), + custom(text-component), + } + + /// Represents a server link entry with a label and destination URL. + record server-link { + label: server-link-label, + url: string, + } + + /// Various abilities a player can have. + record player-abilities { + /// Whether the player is invulnerable to damage. + invulnerable: bool, + /// Whether the player is currently flying. + flying: bool, + /// Whether the player is allowed to fly. + allow-flying: bool, + /// Whether the player is in creative mode. + creative: bool, + /// Whether the player can modify the world. + allow-modify-world: bool, + /// The speed at which the player flies. + fly-speed: f32, + /// The speed at which the player walks. + walk-speed: f32, + } + + /// Represents a player's skin textures and metadata. + record player-skin { + /// The base64-encoded texture data (usually JSON containing skin/cape URLs). + value: string, + /// The optional signature for the texture data. + signature: option, + } + + /// Represents which skin parts are visible. + flags skin-parts { + cape, + jacket, + left-sleeve, + right-sleeve, + left-pants-leg, + right-pants-leg, + hat, + } + + /// Represents the various abilities a Bedrock Edition player can have. + enum bedrock-ability { + /// Whether the player can build. + build, + /// Whether the player can mine blocks. + mine, + /// Whether the player can use doors and switches. + doors-and-switches, + /// Whether the player can open containers. + open-containers, + /// Whether the player can attack other players. + attack-players, + /// Whether the player can attack mobs. + attack-mobs, + /// Whether the player can use operator commands. + operator-commands, + /// Whether the player can teleport. + teleport, + /// Whether the player is invulnerable. + invulnerable, + /// Whether the player is currently flying. + flying, + /// Whether the player is allowed to fly. + may-fly, + /// Whether the player has instant build (creative). + instabuild, + /// Whether the player can use lightning-related abilities. + lightning, + /// The speed at which the player flies. + fly-speed, + /// The speed at which the player walks. + walk-speed, + /// Whether the player is muted. + muted, + /// Whether the player is a world builder. + world-builder, + /// Whether the player has no-clip enabled. + no-clip, + /// Whether the player is a privileged builder. + privileged-builder, + /// The speed at which the player flies vertically. + vertical-fly-speed, + } + + /// Represents the various status flags a Bedrock Edition entity can have. + /// These flags control client-side rendering and behavior. + enum bedrock-status-flag { + /// Whether the entity is currently on fire. + on-fire, + /// Whether the entity is sneaking. + sneaking, + /// Whether the entity is riding another entity. + riding, + /// Whether the entity is sprinting. + sprinting, + /// Whether the entity is using an item (e.g., eating, blocking). + using-item, + /// Whether the entity is invisible. + invisible, + /// Whether the entity is tempted by an item. + tempted, + /// Whether the entity is in love (breeding). + in-love, + /// Whether the entity is saddled. + saddled, + /// Whether the entity is powered (e.g., charged creeper). + powered, + /// Whether the entity is ignited. + ignited, + /// Whether the entity is a baby. + baby, + /// Whether the entity is currently converting to another type. + converting, + /// Whether the entity is in a critical state. + critical, + /// Whether to show the entity's name tag. + show-name, + /// Whether to always show the entity's name tag. + always-show-name, + /// Whether the entity has no AI. + no-ai, + /// Whether the entity is silent. + silent, + /// Whether the entity is climbing a wall. + wall-climbing, + /// Whether the entity is climbing. + climb, + /// Whether the entity is swimming. + swim, + /// Whether the entity is flying. + fly, + /// Whether the entity is walking. + walk, + /// Whether the entity is resting. + resting, + /// Whether the entity is sitting. + sitting, + /// Whether the entity is angry. + angry, + /// Whether the entity is interested. + interested, + /// Whether the entity is charged. + charged, + /// Whether the entity is tamed. + tamed, + /// Whether the entity is orphaned. + orphaned, + /// Whether the entity is leashed. + leashed, + /// Whether the entity is sheared. + sheared, + /// Whether the entity is gliding (elytra). + gliding, + /// Whether the entity is an elder (e.g., elder guardian). + elder, + /// Whether the entity is moving. + moving, + /// Whether the entity is breathing. + breathing, + /// Whether the entity has a chest (e.g., donkey). + chested, + /// Whether the entity is stackable. + stackable, + /// Whether to show the bottom of the entity. + show-bottom, + /// Whether the entity is standing. + standing, + /// Whether the entity is shaking. + shaking, + /// Whether the entity is idling. + idling, + /// Whether the entity is casting (e.g., evoker). + casting, + /// Whether the entity is charging an attack. + charging, + /// Whether the entity is controlled by a keyboard. + keyboard-controlled, + /// Whether the entity is performing a power jump. + power-jump, + /// Whether the entity is dashing. + dash, + /// Whether the entity is lingering. + lingering, + /// Whether the entity has collision. + has-collision, + /// Whether the entity has gravity. + has-gravity, + /// Whether the entity is immune to fire. + fire-immune, + /// Whether the entity is dancing. + dancing, + /// Whether the entity is enchanted. + enchanted, + /// Whether a trident will return to the entity. + return-trident, + /// Whether the container is private. + container-private, + /// Whether the entity is transforming. + transforming, + /// Whether the entity damages nearby mobs. + damage-nearby-mobs, + /// Whether the entity is swimming. + swimming, + /// Whether the entity has been bribed. + bribed, + /// Whether the entity is pregnant. + pregnant, + /// Whether the entity is laying an egg. + laying-egg, + /// Whether a passenger can pick up the entity. + passenger-can-pick, + /// Whether the entity is transitioning to sitting. + transition-sitting, + /// Whether the entity is eating. + eating, + /// Whether the entity is laying down. + laying-down, + /// Whether the entity is sneezing. + sneezing, + /// Whether the entity is trusting. + trusting, + /// Whether the entity is rolling. + rolling, + /// Whether the entity is scared. + scared, + /// Whether the entity is in scaffolding. + in-scaffolding, + /// Whether the entity is over scaffolding. + over-scaffolding, + /// Whether the entity is descending through a block. + descend-through-block, + /// Whether the entity is blocking. + blocking, + /// Whether the entity is transitioning to blocking. + transition-blocking, + /// Whether the entity is blocked using a shield. + blocked-using-shield, + /// Whether the entity is blocked using a damaged shield. + blocked-using-damaged-shield, + /// Whether the entity is sleeping. + sleeping, + /// Whether the entity wants to wake up. + wants-to-wake, + /// Whether the entity shows interest in trading. + trade-interest, + /// Whether the entity can break doors. + door-breaker, + /// Whether the entity is breaking an obstruction. + breaking-obstruction, + /// Whether the entity can open doors. + door-opener, + /// Whether the entity is a captain (raid). + captain, + /// Whether the entity is stunned. + stunned, + /// Whether the entity is roaring. + roaring, + /// Whether the entity has a delayed attack. + delayed-attack, + /// Whether the entity is avoiding mobs. + avoiding-mobs, + /// Whether the entity is avoiding a block. + avoiding-block, + /// Whether the entity is facing a target for a ranged attack. + facing-target-to-range-attack, + /// Whether the entity is hidden when invisible. + hidden-when-invisible, + /// Whether the entity is in a UI. + in-ui, + /// Whether the entity is stalking. + stalking, + /// Whether the entity is emoting. + emoting, + /// Whether the entity is celebrating. + celebrating, + /// Whether the entity is admiring (piglin). + admiring, + /// Whether the entity is celebrating a special event. + celebrating-special, + /// Whether the entity is out of control. + out-of-control, + /// Whether the entity is performing a ram attack. + ram-attack, + /// Whether the entity is playing dead. + playing-dead, + /// Whether the entity is in an ascending block. + in-ascending-block, + /// Whether the entity is over a descending block. + over-descending-block, + /// Whether the entity is croaking (frog). + croaking, + /// Whether the entity is digesting a mob. + digest-mob, + /// Whether the entity has a jump goal. + jump-goal, + /// Whether the entity is emerging. + emerging, + /// Whether the entity is sniffing. + sniffing, + /// Whether the entity is digging. + digging, + /// Whether the entity is performing a sonic boom. + sonic-boom, + /// Whether the entity has a dash timeout. + has-dash-timeout, + /// Whether the entity is pushed towards the closest space. + push-towards-closest-space, + /// Whether the entity is scenting. + scenting, + /// Whether the entity is rising. + rising, + /// Whether the entity is feeling happy. + feeling-happy, + /// Whether the entity is searching. + searching, + /// Whether the entity is crawling. + crawling, + /// Whether the entity's body rotation is blocked. + body-rotation-blocked, + /// Whether the entity is rendered when invisible. + render-when-invisible, + /// Whether the entity's body rotation is axis-aligned. + body-rotation-axis-aligned, + /// Whether the entity is collidable. + collidable, + /// Whether the entity is air-controlled via WASD. + wasd-air-controlled, + /// Whether only the server can authorize a dismount. + does-server-auth-only-dismount, + /// Whether the body rotation always follows the head. + body-rotation-always-follows-head, + /// Whether the entity can use vertical movement actions. + can-use-vertical-movement-action, + /// Whether rotation is locked to the vehicle. + rotation-locked-to-vehicle, + } + + /// Represents a specific version of the Minecraft Java Edition protocol. + enum java-minecraft-version { + v-1-7-2, + v-1-7-6, + v-1-8, + v-1-9, + v-1-9-1, + v-1-9-2, + v-1-9-3, + v-1-10, + v-1-11, + v-1-11-1, + v-1-12, + v-1-12-1, + v-1-12-2, + v-1-13, + v-1-13-1, + v-1-13-2, + v-1-14, + v-1-14-1, + v-1-14-2, + v-1-14-3, + v-1-14-4, + v-1-15, + v-1-15-1, + v-1-15-2, + v-1-16, + v-1-16-1, + v-1-16-2, + v-1-16-3, + v-1-16-4, + v-1-17, + v-1-17-1, + v-1-18, + v-1-18-2, + v-1-19, + v-1-19-1, + v-1-19-3, + v-1-19-4, + v-1-20, + v-1-20-2, + v-1-20-3, + v-1-20-5, + v-1-21, + v-1-21-2, + v-1-21-4, + v-1-21-5, + v-1-21-6, + v-1-21-7, + v-1-21-9, + v-1-21-11, + v-26-1, + v-26-2, + unknown, + } + + /// Represents a specific version of the Minecraft Bedrock Edition protocol. + enum bedrock-minecraft-version { + v-1-21, + v-1-26-30, + unknown, + } + + /// The chat visibility settings for a player. + enum chat-mode { + /// Chat is fully enabled. + enabled, + /// Only system messages and commands are shown. + commands-only, + /// Chat is completely hidden. + hidden, + } + + /// Represents settings for a Java Edition player. + record java-player-settings { + /// The player's preferred language (e.g., \"en_us\"). + locale: string, + /// The maximum distance at which chunks are rendered. + view-distance: u8, + /// The player's chat visibility settings. + chat-mode: chat-mode, + /// Whether chat colors are enabled. + chat-colors: bool, + /// The player's skin configuration options. + skin-parts: skin-parts, + /// The player's dominant hand (left or right). + main-hand: hand, + /// Whether text filtering is enabled. + text-filtering: bool, + /// Whether the player wants to appear in the server list. + server-listing: bool, + } + + /// Represents the operating system of a Bedrock Edition client. + enum bedrock-device-os { + android, + ios, + osx, + amazon, + gear-vr, + holo-lens, + windows-10, + win-32, + dedicated, + tv-os, + playstation, + nintendo, + xbox, + windows-phone, + linux, + /// Fallback for unrecognized operating systems. + unknown, + } + + /// Represents the input mode used by a Bedrock Edition client. + enum bedrock-input-mode { + /// Unknown input mode. + unknown, + /// Mouse and keyboard. + mouse, + /// Touch screen. + touch, + /// Game controller. + game-pad, + /// Motion-based controller. + motion-controller, + } + + /// Represents the UI profile used by a Bedrock Edition client. + enum bedrock-ui-profile { + /// Classic desktop UI. + classic, + /// Pocket/Mobile optimized UI. + pocket, + /// Unknown UI profile. + unknown, + } + + /// Represents the graphics mode used by a Bedrock Edition client. + enum bedrock-graphics-mode { + simple, + fancy, + ray-traced, + unknown, + } + + /// Represents settings and client data for a Bedrock Edition player. + record bedrock-player-settings { + /// The client's specific game version string. + game-version: string, + /// The operating system of the client device. + device-os: bedrock-device-os, + /// A unique identifier for the client device. + device-id: string, + /// The model name of the client device. + device-model: string, + /// The player's preferred language code (e.g., \"en_US\"). + language-code: string, + /// The input mode currently used by the player. + current-input-mode: bedrock-input-mode, + /// The default input mode for the client device. + default-input-mode: bedrock-input-mode, + /// The UI layout profile used by the client. + ui-profile: bedrock-ui-profile, + /// The current GUI scale setting. + gui-scale: s32, + /// Whether the player is in Editor mode. + is-editor-mode: bool, + /// The maximum view distance the client supports. + max-view-distance: s32, + /// The memory tier of the client device (indicates performance level). + memory-tier: s32, + /// The graphics mode used by the client. + graphics-mode: bedrock-graphics-mode, + /// The player's unique PlayFab identifier. + playfab-id: string, + /// A random 64-bit ID generated by the client. + client-random-id: s64, + /// Platform-specific offline identifier. + platform-offline-id: string, + /// Platform-specific online identifier. + platform-online-id: string, + /// The unique ID of the player's current skin. + skin-id: string, + /// The model arm size (e.g., \"wide\" or \"slim\"). + arm-size: string, + /// Whether the player is using a Character Creator (Persona) skin. + is-persona-skin: bool, + /// Whether the skin is a premium (paid) skin. + is-premium-skin: bool, + /// Whether the skin is from a trusted source. + is-trusted-skin: bool, + } + + /// Protocol-level disconnect reasons for Minecraft Bedrock Edition. + enum bedrock-disconnect-reason { + unknown, + cant-connect-no-internet, + no-permissions, + unrecoverable-error, + third-party-blocked, + third-party-no-internet, + third-party-bad-ip, + third-party-no-server-or-server-locked, + version-mismatch, + skin-issue, + invite-session-not-found, + edu-level-settings-missing, + local-server-not-found, + legacy-disconnect, + user-leave-game-attempted, + platform-locked-skins-error, + realms-world-unassigned, + realms-server-cant-connect, + realms-server-hidden, + realms-server-disabled-beta, + realms-server-disabled, + cross-platform-disabled, + cant-connect, + session-not-found, + client-settings-incompatible-with-server, + server-full, + invalid-platform-skin, + edition-version-mismatch, + edition-mismatch, + level-newer-than-exe-version, + no-fail-occurred, + banned-skin, + timeout, + server-not-found, + outdated-server, + outdated-client, + no-premium-platform, + multiplayer-disabled, + no-wifi, + world-corruption, + no-reason, + disconnected, + invalid-player, + logged-in-other-location, + server-id-conflict, + not-allowed, + not-authenticated, + invalid-tenant, + unknown-packet, + unexpected-packet, + invalid-command-request-packet, + host-suspended, + login-packet-no-request, + login-packet-no-cert, + missing-client, + kicked, + kicked-for-exploit, + kicked-for-idle, + resource-pack-problem, + incompatible-pack, + out-of-storage, + invalid-level, + disconnect-packet, + block-mismatch, + invalid-heights, + invalid-widths, + connection-lost, + zombie-connection, + shutdown, + reason-not-set, + loading-state-timeout, + resource-pack-loading-failed, + searching-for-session-loading-screen-failed, + nether-net-protocol-version, + subsystem-status-error, + empty-auth-from-discovery, + empty-url-from-discovery, + expired-auth-from-discovery, + unknown-signal-service-sign-in-failure, + xbl-join-lobby-failure, + unspecified-client-instance-disconnection, + nether-net-session-not-found, + nether-net-create-peer-connection, + nether-net-ice, + nether-net-connect-request, + nether-net-connect-response, + nether-net-negotiation-timeout, + nether-net-inactivity-timeout, + stale-connection-being-replaced, + realms-session-not-found, + bad-packet, + nether-net-failed-to-create-offer, + nether-net-failed-to-create-answer, + nether-net-failed-to-set-local-description, + nether-net-failed-to-set-remote-description, + nether-net-negotiation-timeout-waiting-for-response, + nether-net-negotiation-timeout-waiting-for-accept, + nether-net-incoming-connection-ignored, + nether-net-signaling-parsing-failure, + nether-net-signaling-unknown-error, + nether-net-signaling-unicast-delivery-failed, + nether-net-signaling-broadcast-delivery-failed, + nether-net-signaling-generic-delivery-failed, + editor-mismatch-editor-world, + editor-mismatch-vanilla-world, + world-transfer-not-primary-client, + request-server-shutdown, + client-game-setup-cancelled, + client-game-setup-failed, + no-venue, + nether-net-signaling-signin-failed, + session-access-denied, + service-signin-issue, + nether-net-no-signaling-channel, + nether-net-not-logged-in, + nether-net-client-signaling-error, + sub-client-login-disabled, + deep-link-trying-to-open-demo-world-while-signed-in, + async-join-task-denied, + realms-timeline-required, + guest-without-host, + failed-to-join-experience, + nether-net-data-channel-closed, + discovery-environment-mismatch, + host-without-keys, + host-signed-out, + script-watchdog-exception, + script-memory-limit-exceeded, + storage-low-during-gameplay, + storage-full-during-gameplay, + level-storage-corruption, + edition-mismatch-vanilla-to-edu, + edition-mismatch-edu-to-vanilla, + editor-mismatch-editor-to-vanilla, + editor-mismatch-vanilla-to-editor, + deny-listed, + nonce-missing, + nonce-not-found, + nonce-expired, + nonce-not-valid, + host-disconnected, + editor-join-intent-policy-failure, + nether-net-identity-not-allowed, + invalid-name, + expired-token, + host-accepts-no-type-of-auth, + not-authenticated-fast-fail, + editor-not-allowed, + } + + /// Policy for tearing down the player's network connection. + enum socket-teardown-policy { + /// Send the disconnect packet and gracefully close the connection. + graceful, + /// Send the disconnect packet and close the socket immediately. + immediate-close, + /// Terminate the connection immediately without sending any disconnect packet. + drop-connection, + } + + /// Options for disconnecting a Java Edition player. + record java-kick-options { + /// The formatted text component displayed on the Java disconnect screen. + reason: text-component, + /// Whether to log the kick in the server console (default: true). + log-to-console: bool, + /// How the connection is closed (default: graceful). + teardown-policy: socket-teardown-policy, + } + + /// Options for disconnecting a Bedrock Edition player. + record bedrock-kick-options { + /// Protocol level disconnect code (default: kicked). + reason: bedrock-disconnect-reason, + /// Message displayed on the Bedrock disconnect screen (default: ""). + message: string, + /// Whether to suppress the disconnect message on the client screen (default: false). + skip-message: bool, + /// Filtered message string for safety/parental filters (default: ""). + filtered-message: string, + /// Whether to log the kick in the server console (default: true). + log-to-console: bool, + /// How the connection is closed (default: graceful). + teardown-policy: socket-teardown-policy, + } + + /// Options for banning a player. + record ban-player-options { + /// Ban reason displayed to the player and stored in the ban list. + reason: option, + /// Source or authority responsible for the ban (default: "Plugin"). + source: option, + /// Ban expiration in RFC-3339 format, if temporary. + expires-at-utc: option, + /// Ban duration in seconds from now, if temporary. + duration-seconds: option, + /// Whether to immediately kick the player if currently online (default: true). + kick-if-online: bool, + /// Whether to log the ban action to the server console (default: true). + log-to-console: bool, + } + + /// Options for banning an IP address. + record ban-ip-options { + /// Ban reason stored in the IP ban list. + reason: option, + /// Source or authority responsible for the ban (default: "Plugin"). + source: option, + /// Ban expiration in RFC-3339 format, if temporary. + expires-at-utc: option, + /// Ban duration in seconds from now, if temporary. + duration-seconds: option, + /// Whether to immediately kick all online players with this IP (default: true). + kick-matching-players: bool, + /// Whether to log the IP ban action to the server console (default: true). + log-to-console: bool, + } + + /// A handle to a player on the server. + resource player { + /// Returns the player as an entity. + as-entity: func() -> entity; + /// Returns the player's unique UUID as a string. + get-id: func() -> uuid; + /// Returns the player's username. + get-name: func() -> string; + /// Basic state + /// Returns the player's current position in the world. + get-position: func() -> position; + /// Returns the player's current yaw (horizontal rotation). + get-yaw: func() -> f32; + /// Returns the player's current pitch (vertical rotation). + get-pitch: func() -> f32; + /// Returns the world the player is currently in. + get-world: func() -> %world; + /// Returns the player's current game mode. + get-gamemode: func() -> game-mode; + /// Changes the player's game mode. Returns true if successful. + set-gamemode: func(mode: game-mode) -> bool; + /// Returns the player's locale (e.g., \"en_us\"). + get-locale: func() -> string; + /// Returns the player's current ping in milliseconds. + get-ping: func() -> u32; + /// Permissions & metadata + /// Returns the player's permission level (0-4). + get-permission-level: func() -> permission-level; + /// Sets the player's permission level. + set-permission-level: func(level: permission-level); + /// Grants or denies a specific permission node for the player. + set-permission: func(node: string, value: bool); + /// Removes an explicitly set permission node from the player. + unset-permission: func(node: string); + /// Returns `Some(true)` if granted, `Some(false)` if denied, or `None` if not set. + has-permission-set: func(node: string) -> option; + /// Checks if the player has a specific permission node. + has-permission: func(node: string) -> bool; + /// Returns the player's display name, which may include formatting. + get-display-name: func() -> text-component; + /// Sets the player's display name. + set-display-name: func(display-name: text-component); + /// Gets the player's custom tab list name. + get-tab-list-name: func() -> option; + /// Sets the player's custom tab list name. + set-tab-list-name: func(name: option); + /// Messaging & titles + /// Sends a system message to the player's chat. + send-system-message: func(text: text-component, overlay: bool); + /// Deletes a signed chat message from the player's chat window using its 256-byte signature. + delete-message-by-signature: func(signature: list); + /// Deletes a signed chat message from the player's chat window using its signature cache ID. + delete-message-by-id: func(signature-id: s32); + /// Sets the header and footer of the player's Tab list. + set-tab-list-header-footer: func(header: text-component, footer: text-component); + /// Sets the sorting order of the player in the Tab list. + set-tab-list-order: func(order: s32); + /// Sets the latency (ping) shown for the player in the Tab list. + set-tab-list-latency: func(latency: s32); + /// Sets whether the player is visible in the Tab list. + set-tab-list-listed: func(listed: bool); + /// Shows a large title on the player's screen. + show-title: func(text: text-component); + /// Shows a smaller subtitle on the player's screen. + show-subtitle: func(text: text-component); + /// Shows a message in the action bar area. + show-actionbar: func(text: text-component); + /// Sets the fade-in, stay, and fade-out times for titles. + send-title-animation: func(fade-in: s32, stay: s32, fade-out: s32); + /// Camera & Spectating + /// Sets the player's camera to view from the perspective of another entity. + /// If `entity` is `none`, the camera is reset back to the player. + set-camera: func(entity: option); + /// Sets the player's camera to view from the perspective of an entity with the given entity ID. + /// If `entity-id` is the player's own entity ID, the camera is reset back to the player. + set-camera-entity-id: func(entity-id: u32); + /// Gets the entity ID of the entity that the player's camera is currently attached to, + /// or the player's own entity ID if the camera has not been overridden. + get-camera-entity-id: func() -> u32; + /// Resets the player's camera back to their own perspective. + reset-camera: func(); + /// Audio & Particles + /// Plays a sound effect for this player at their current location. + play-sound: func(sound: sound, category: sound-category, volume: f32, pitch: f32); + /// Plays a sound effect for this player at a specific location. + play-sound-at: func(pos: position, sound: sound, category: sound-category, volume: f32, pitch: f32); + /// Stops a sound effect from playing for this player. + stop-sound: func(sound: option, category: option); + /// Plays a custom resource pack sound identifier for this player at their current location. + play-custom-sound: func(sound-name: string, category: sound-category, volume: f32, pitch: f32); + /// Plays a custom resource pack sound identifier for this player at a specific location. + play-custom-sound-at: func(pos: position, sound-name: string, category: sound-category, volume: f32, pitch: f32); + /// Stops a custom sound identifier from playing for this player. + stop-custom-sound: func(sound-name: option, category: option); + /// Spawns particles visible only to this player. + spawn-particles: func(particle: particle, pos: position, count: u32, offset: position, max-speed: f32); + /// Visuals & Client Overrides + /// Sends a temporary fake block change to the player's client without modifying the server world. + send-block-change: func(pos: block-pos, block-id: u16); + /// Resets a temporary fake block change by resending the actual world block at that position. + reset-block-change: func(pos: block-pos); + /// Sends a hurt / damage-tilt animation to the player's client (causes screen shake in the given yaw direction). + send-hurt-animation: func(yaw: f32); + /// Opens a written book interface for the player from the specified hand. + open-book: func(hand: hand); + /// Forces the sign text editor to open for the player at the specified sign block position. + open-sign-editor: func(pos: block-pos, is-front-text: bool); + /// Velocity & Physics + /// Sets the player's velocity / motion vector. + set-velocity: func(velocity: position); + /// Applies directional knockback impulse to the player. + apply-knockback: func(strength: f64, x: f64, z: f64); + /// Movement Lock & Freezing + /// Sets whether the player's movement is locked (frozen in place) for cutscenes and NPC dialogues. + set-movement-locked: func(locked: bool); + /// Returns whether the player's movement is currently locked. + is-movement-locked: func() -> bool; + /// Sets the number of freeze ticks on the player (controlling the powdered snow / frostbite screen vignette). + set-freeze-ticks: func(ticks: s32); + /// Returns the current number of freeze ticks on the player. + get-freeze-ticks: func() -> s32; + /// Sends custom server links to the player (displayed in the client Esc pause menu in 1.21+). + set-server-links: func(links: list); + /// Teleport & kick + /// Teleports the player to a position in a world. + teleport: func(position: position, yaw: option, pitch: option, %world: %world); + /// Teleports the player to another world at a specific position. + teleport-world: func(world-ref: %world, position: position, yaw: option, pitch: option); + /// Forces the player to respawn. + respawn: func(); + /// Opens a GUI for the player. + open-gui: func(gui-ref: gui); + /// Bans the player with the specified options. + ban: func(options: ban-player-options); + /// Bans the player's IP address with the specified options. + ban-ip: func(options: ban-ip-options); + /// Transfers the player to another server. + transfer: func(host: string, port: u16); + /// Status Effects + /// Gives a status effect to the player. + add-effect: func(effect: status-effect-instance); + /// Removes a status effect from the player. + remove-effect: func(effect: status-effect-type); + /// Clears all active status effects from the player. + clear-effects: func(); + /// Checks if a status effect is currently applied to the player. + has-effect: func(effect: status-effect-type) -> bool; + /// Returns the status effect instance applied to the player, if any. + get-effect: func(effect: status-effect-type) -> option; + /// Returns all status effects currently applied to the player. + get-active-effects: func() -> list; + /// Health & Damage + /// Heals the player by a specified amount. + heal: func(amount: f32); + /// Deals damage to the player by a specified amount with a damage type. + damage: func(amount: f32, damage-type: damage-type); + /// Kills the player instantly. + kill: func(); + /// Statistics + /// Gets the value of a statistic for this player in the given category and ID. + get-statistic: func(category: statistic-category, stat-id: s32) -> s32; + /// Sets the value of a statistic for this player in the given category and ID. + set-statistic: func(category: statistic-category, stat-id: s32, value: s32); + /// Increments the value of a statistic for this player in the given category and ID. + increment-statistic: func(category: statistic-category, stat-id: s32, amount: s32); + /// Gets the value of a custom statistic for this player. + get-custom-statistic: func(stat: custom-statistic) -> s32; + /// Sets the value of a custom statistic for this player. + set-custom-statistic: func(stat: custom-statistic, value: s32); + /// Increments the value of a custom statistic for this player. + increment-custom-statistic: func(stat: custom-statistic, amount: s32); + /// Sends the player's updated statistics packet to the client. + send-stats: func(); + /// Gets the team name that this player belongs to on their active scoreboard, if any. + get-team: func() -> option; + /// Cooldowns + /// Starts an item cooldown for a specific item group name. + start-cooldown: func(group: string, duration-ticks: s32); + /// Returns the cooldown progress (0.0 to 1.0) for a specific item group. + get-cooldown: func(group: string) -> f32; + /// Checks if a specific item group is currently on cooldown. + is-on-cooldown: func(group: string) -> bool; + /// Abilities & Flight + /// Sets whether the player is allowed to fly. + set-allow-flight: func(allowed: bool); + /// Sets the player's flying speed. + set-fly-speed: func(speed: f32); + /// Sets the player's walking speed. + set-walk-speed: func(speed: f32); + /// Sets whether the player is invulnerable to damage. + set-invulnerable: func(invulnerable: bool); + /// Inventory + /// Returns the player's inventory handle for managing main storage, armor, and equipment. + get-inventory: func() -> player-inventory; + /// Returns the player's ender chest inventory handle. + get-ender-chest: func() -> inventory; + /// Returns the index of the currently selected hotbar slot (0-8). + get-selected-slot: func() -> u8; + /// Returns the item currently in the specified hand. + get-item-in-hand: func(hand: hand) -> option; + /// Returns the item in the specified inventory slot. + get-inventory-item: func(slot: u8) -> option; + /// Sets the item in the specified hand. + set-item-in-hand: func(hand: hand, stack: option); + /// Sets the item in the specified inventory slot. + set-inventory-item: func(slot: u8, stack: option); + /// Ender Chest Inventory + /// Returns the item in the specified ender chest slot (0-26). + get-ender-chest-item: func(slot: u8) -> option; + /// Sets the item in the specified ender chest slot (0-26). + set-ender-chest-item: func(slot: u8, stack: option); + /// Clears all items from the player's ender chest. + clear-ender-chest: func(); + /// Opens the player's ender chest inventory screen for them. + open-ender-chest: func(); + /// Status + /// Returns the player's current health. + get-health: func() -> f32; + /// Sets the player's current health. + set-health: func(health: f32); + /// Returns the player's maximum health. + get-max-health: func() -> f32; + /// Sets the player's maximum health. + set-max-health: func(max-health: f32); + /// Returns the player's food level (0-20). + get-food-level: func() -> u8; + /// Sets the player's food level. + set-food-level: func(food-level: u8); + /// Returns the player's food saturation level. + get-saturation: func() -> f32; + /// Sets the player's food saturation level. + set-saturation: func(saturation: f32); + /// Returns the player's food exhaustion level. + get-exhaustion: func() -> f32; + /// Sets the player's food exhaustion level. + set-exhaustion: func(exhaustion: f32); + /// Returns the player's current absorption amount. + get-absorption: func() -> f32; + /// Sets the player's current absorption amount. + set-absorption: func(absorption: f32); + /// Returns the player's total experience level. + get-experience-level: func() -> s32; + /// Returns the player's progress toward the next level (0.0 to 1.0). + get-experience-progress: func() -> f32; + /// Returns the total experience points the player has. + get-experience-points: func() -> s32; + /// Sets the player's total experience level. + set-experience-level: func(level: s32); + /// Sets the player's progress toward the next level. + set-experience-progress: func(progress: f32); + /// Sets the player's total experience points. + set-experience-points: func(points: s32); + /// Adds experience levels to the player. + add-experience-levels: func(levels: s32); + /// Adds experience points to the player. + add-experience-points: func(points: s32); + /// Returns whether the player is currently flying. + is-flying: func() -> bool; + /// Sets whether the player should be flying. + set-flying: func(flying: bool); + /// Returns the player's current abilities. + get-abilities: func() -> player-abilities; + /// Updates the player's abilities. + set-abilities: func(abilities: player-abilities); + /// Returns the player's IP address. + get-ip: func() -> string; + /// Returns the player's current skin textures. + get-skin: func() -> option; + /// Updates the player's skin textures. + /// Note: this only updates the fields, it doesn't reload the skin. + set-skin: func(skin: player-skin); + /// Returns which skin parts are visible. + get-skin-parts: func() -> skin-parts; + /// Sets which skin parts are visible. + set-skin-parts: func(parts: skin-parts); + /// Per-Player Environment & Overrides + /// Overrides the time of day shown to this player. + set-player-time: func(time: u64, relative: bool); + /// Resets the player's time to sync with the server world time. + reset-player-time: func(); + /// Returns the custom time set for this player, if any. + get-player-time: func() -> option; + /// Checks if the custom player time is relative to the world time. + is-player-time-relative: func() -> bool; + /// Overrides the weather condition shown to this player. + set-player-weather: func(weather: player-weather); + /// Resets the player's weather to match the server world weather. + reset-player-weather: func(); + /// Returns the custom weather set for this player, if any. + get-player-weather: func() -> option; + /// Sets the position where the player's compass points. + set-compass-target: func(pos: position); + /// Returns the position where the player's compass currently points. + get-compass-target: func() -> position; + /// Sets the player's custom respawn / bed location. + set-respawn-location: func(pos: position); + /// Returns the player's custom respawn / bed location, if set. + get-respawn-location: func() -> option; + /// Hides another player from this player's view (vanish). + hide-player: func(other: player); + /// Shows a previously hidden player to this player. + show-player: func(other: player); + /// Checks if this player can see another specified player. + can-see: func(other: player) -> bool; + /// Checks if this player can see another specified player. + can-see-player: func(other: player) -> bool; + /// Sets the tab list ping / latency indicator in milliseconds. + set-tab-list-ping: func(latency-ms: s32); + /// Sets a client-side item cooldown overlay. + set-item-cooldown: func(item-id: string, ticks: s32); + /// Returns the remaining cooldown ticks for an item, if active. + get-item-cooldown: func(item-id: string) -> option; + /// Checks if an item is currently on cooldown. + has-item-cooldown: func(item-id: string) -> bool; + /// Performs a ray-trace from the player's eye position in looking direction to find the targeted block. + ray-trace-block: func(max-distance: f64, include-fluids: bool) -> option; + /// Performs a ray-trace from the player's eye position in looking direction to find the targeted entity. + ray-trace-entity: func(max-distance: f64) -> option; + /// Returns the entity currently targeted in the looking direction within the specified distance. + get-target-entity: func(max-distance: f64) -> option; + /// Raycasts from the player's eyes to find the block being targeted. + get-target-block: func(max-distance: u32) -> option; + /// Performs a raycast from the player's eyes to find the exact block and face being targeted. + get-target-block-exact: func(max-distance: f64, include-fluids: bool) -> option; + /// Launches a projectile from the player's eyes in their line of sight. + launch-projectile: func(%type: projectile-type) -> option; + /// Advancements + /// Returns the progress of the specified advancement for this player, if the advancement exists. + get-advancement-progress: func(advancement-id: string) -> option; + /// Awards a specific criterion of an advancement to the player. + /// Returns true if the criterion was successfully awarded (was not already completed). + award-advancement-criterion: func(advancement-id: string, criterion: string) -> bool; + /// Revokes a specific criterion of an advancement from the player. + /// Returns true if the criterion was successfully revoked (was previously completed). + revoke-advancement-criterion: func(advancement-id: string, criterion: string) -> bool; + /// Awards all criteria of the specified advancement to the player. + /// Returns true if any criterion was newly awarded. + award-advancement: func(advancement-id: string) -> bool; + /// Revokes all criteria of the specified advancement from the player. + /// Returns true if any criterion was newly revoked. + revoke-advancement: func(advancement-id: string) -> bool; + /// Checks whether the player has completed the specified advancement. + has-advancement: func(advancement-id: string) -> bool; + /// Returns a list of all advancement IDs completed by this player. + get-completed-advancements: func() -> list; + /// Returns the ID of the currently selected advancement tab for this player, if any. + get-selected-advancement-tab: func() -> option; + /// Sets the selected advancement tab for this player (must be a root advancement ID). + set-selected-advancement-tab: func(tab-id: option); + /// Returns a Java-specific player handle, if the player is connected via Java Edition. + /// + /// This allows access to Java-exclusive features like sending specific packets + /// or retrieving the client brand. + as-java: func() -> option; + /// Returns a Bedrock-specific player handle, if the player is connected via Bedrock Edition. + /// + /// This allows access to Bedrock-exclusive features like custom forms + /// or detailed device information. + as-bedrock: func() -> option; + } + + /// Represents a resource pack sent to a Java Edition player. + record java-resource-pack { + /// Unique identifier for the resource pack. + id: uuid, + /// The URL to the resource pack file. + url: string, + /// The SHA1 hash (40-character hex string) of the pack. + hash: string, + /// Whether the player is forced to accept the pack. + forced: bool, + /// Optional prompt message displayed in the pack acceptance screen. + prompt-message: option, + } + + /// Represents an individual Bedrock Edition resource pack entry. + record bedrock-resource-pack-entry { + /// Unique identifier for the Bedrock pack. + id: uuid, + /// Version string of the Bedrock pack (e.g., "1.0.0"). + version: string, + /// Size of the pack in bytes. + size: u64, + /// Download URL for remote Bedrock packs. + download-url: string, + /// Optional encryption content key for encrypted packs. + content-key: option, + /// Optional sub-pack name inside the archive. + sub-pack-name: option, + /// Optional content identifier. + content-id: option, + /// Whether the pack contains client scripts. + has-scripts: bool, + /// Whether the pack is marked as an addon pack. + addon-pack: bool, + /// Whether Ray Tracing / RTX features are enabled for the pack. + rtx-enabled: bool, + } + + /// Represents the resource packs information payload sent to Bedrock clients. + record bedrock-resource-packs-info { + /// If true, players cannot join without accepting packs. + required: bool, + /// Whether the server offers addon packs. + has-addon-packs: bool, + /// Whether any of the packs contain client scripts. + has-scripts: bool, + /// Whether vibrant visuals should be forced disabled. + is-vibrant-visuals-force-disabled: bool, + /// World template ID, if any. + world-template-id: option, + /// World template version, if any. + world-template-version: option, + /// List of resource packs to send to the player. + packs: list, + } + + /// A handle to a player connected via the Java Edition. + resource java-player { + /// Returns the Minecraft Java Edition version of the player. + get-version: func() -> java-minecraft-version; + /// Returns the brand of the player's client (e.g., \"vanilla\", \"fabric\"). + get-brand: func() -> string; + /// Returns the server address the player used to connect. + get-server-address: func() -> string; + /// Returns the player's configuration settings. + get-settings: func() -> java-player-settings; + /// Sends a Java-specific clientbound packet to the player. + send-packet: func(packet: java-packet); + /// Sends a custom payload packet (plugin message) to the player. + send-custom-payload: func(channel: string, data: list); + /// Shows a dialog to the player. + show-dialog: func(dialog: dialog); + /// Clears any currently shown dialog for the player. + clear-dialog: func(); + /// Returns the Java scoreboard handle for this player. + get-scoreboard: func() -> scoreboard; + /// Resets the player's custom Java scoreboard back to the world scoreboard. + reset-scoreboard: func(); + /// Sends a resource pack to the Java player. + send-resource-pack: func(pack: java-resource-pack); + /// Removes a specific resource pack by UUID for the Java player. + remove-resource-pack: func(id: uuid); + /// Clears all custom resource packs for the Java player. + clear-resource-packs: func(); + /// Kicks the Java player with the specified options. + kick: func(options: java-kick-options); + /// Sends a clientbound GameEvent packet to the Java player. + send-game-event: func(event: client-game-event, value: f32); + /// Sends an entity status / animation event packet to the Java player for a specific entity ID. + send-entity-status: func(entity-id: s32, status: entity-status); + } + + /// A handle to a player connected via the Bedrock Edition. + resource bedrock-player { + /// Returns the Minecraft Bedrock Edition version of the player. + get-version: func() -> bedrock-minecraft-version; + /// Returns the player's configuration settings. + get-settings: func() -> bedrock-player-settings; + /// Returns whether a specific Bedrock-only ability is enabled for the player. + get-ability: func(ability: bedrock-ability) -> bool; + /// Sets whether a specific Bedrock-only ability is enabled for the player. + set-ability: func(ability: bedrock-ability, value: bool); + /// Returns whether a specific Bedrock-only status flag is enabled for the player. + /// + /// Status flags control things like whether the player is on fire, sneaking, + /// sprinting, or has specific visual effects. + get-status-flag: func(flag: bedrock-status-flag) -> bool; + /// Sets whether a specific Bedrock-only status flag is enabled for the player. + /// + /// This can be used to manually trigger client-side visual states. + set-status-flag: func(flag: bedrock-status-flag, value: bool); + /// Sends a Bedrock-specific clientbound packet to the player. + send-packet: func(packet: bedrock-packet); + /// Opens a Bedrock custom form for the player. + open-form: func(form: form) -> u32; + /// Returns the Bedrock scoreboard handle for this player. + get-scoreboard: func() -> bedrock-scoreboard; + /// Resets the player's custom Bedrock scoreboard back to the world scoreboard. + reset-scoreboard: func(); + /// Sends resource packs information to the Bedrock player. + send-resource-packs-info: func(info: bedrock-resource-packs-info); + /// Kicks the Bedrock player with the specified options. + kick: func(options: bedrock-kick-options); + } + + /// Returns a list of all players in a specific world. + get-world-players: func(world-ref: %world) -> list; +} + +interface boss-bar { + use text.{text-component}; + use player.{player}; + + /// Represents the color of a boss bar. + enum boss-bar-color { + pink, + blue, + red, + green, + yellow, + purple, + white, + } + + /// Represents the notches/divisions of a boss bar. + enum boss-bar-division { + no-division, + notches-6, + notches-10, + notches-12, + notches-20, + } + + /// Metadata flags that can be toggled on a boss bar. + record boss-bar-metadata { + /// Darkens the sky for players who see the boss bar. + darken-sky: bool, + /// If true, the bar is considered a "dragon bar" (used for Ender Dragon). + dragon-bar: bool, + /// If true, fog is created around the players who see the boss bar. + create-fog: bool, + } + + /// Represents a boss bar that can be shown to players. + resource boss-bar { + /// Creates a new boss bar. + constructor(title: text-component, color: boss-bar-color, division: boss-bar-division); + /// Returns the title of this boss bar. + get-title: func() -> text-component; + /// Sets the title of this boss bar. + set-title: func(title: text-component); + /// Returns the health (0.0 to 1.0) of this boss bar. + get-health: func() -> f32; + /// Sets the health (0.0 to 1.0) of this boss bar. + set-health: func(health: f32); + /// Returns the color of this boss bar. + get-color: func() -> boss-bar-color; + /// Sets the color of this boss bar. + set-color: func(color: boss-bar-color); + /// Returns the division of this boss bar. + get-division: func() -> boss-bar-division; + /// Sets the division of this boss bar. + set-division: func(division: boss-bar-division); + /// Returns the currently active metadata on this boss bar. + get-metadata: func() -> boss-bar-metadata; + /// Updates the metadata on this boss bar. + set-metadata: func(metadata: boss-bar-metadata); + /// Adds a player to this boss bar, making it visible to them. + add-player: func(player: player); + /// Removes a player from this boss bar, hiding it from them. + remove-player: func(player: player); + /// Returns a list of all players currently seeing this boss bar. + get-players: func() -> list; + /// Removes this boss bar from all players and cleans it up. + remove-all: func(); + } +} + +interface event { + use common.{block-pos, game-mode, hand, position, click-type}; + use item-stack.{item-stack}; + use enchantments.{enchantment}; + use damage-types.{damage-type}; + use screens.{screen}; + use player.{player}; + use text.{text-component}; + use %world.{%world}; + use java-packets.{serverbound-packet as java-serverbound-packet, clientbound-packet as java-clientbound-packet}; + use bedrock-packets.{serverbound-packet as bedrock-serverbound-packet, clientbound-packet as bedrock-clientbound-packet}; + use uuid.{uuid}; + use java-dialogs.{dialog}; + + variant serverbound-packet { + java(java-serverbound-packet), + bedrock(bedrock-serverbound-packet), + unknown, + } + + variant clientbound-packet { + java(java-clientbound-packet), + bedrock(bedrock-clientbound-packet), + unknown, + } + + enum event-priority { + highest, + high, + normal, + low, + lowest, + } + + record player-join-event-data { + player: player, + join-message: text-component, + cancelled: bool, + } + + record player-leave-event-data { + player: player, + leave-message: text-component, + cancelled: bool, + } + + record player-login-event-data { + player: player, + kick-message: text-component, + cancelled: bool, + } + + record player-chat-event-data { + player: player, + message: string, + recipients: list, + signature: option>, + cancelled: bool, + } + + record player-command-send-event-data { + player: player, + command: string, + cancelled: bool, + } + + record player-permission-check-event-data { + player: player, + permission: string, + permission-result: bool, + } + + record player-move-event-data { + player: player, + from-position: position, + to-position: position, + cancelled: bool, + } + + record player-teleport-event-data { + player: player, + from-position: position, + to-position: position, + cancelled: bool, + } + + record player-change-world-event-data { + player: player, + previous-world: %world, + new-world: %world, + position: position, + yaw: f32, + pitch: f32, + cancelled: bool, + } + + record player-respawn-event-data { + player: player, + previous-world: %world, + respawned-world: %world, + position: position, + yaw: f32, + pitch: f32, + alive: bool, + } + + record player-exp-change-event-data { + player: player, + amount: s32, + } + + record player-item-held-event-data { + player: player, + previous-slot: u8, + new-slot: u8, + cancelled: bool, + } + + record player-changed-main-hand-event-data { + player: player, + main-hand: hand, + } + + record player-gamemode-change-event-data { + player: player, + previous-gamemode: game-mode, + new-gamemode: game-mode, + cancelled: bool, + } + + record player-custom-payload-event-data { + player: player, + channel: string, + data: list, + } + + enum player-fish-state { + fishing, + caught-fish, + caught-entity, + in-ground, + failed-attempt, + reel-in, + bite, + } + + record player-fish-event-data { + player: player, + caught-uuid: option, + caught-type: string, + hook-uuid: uuid, + state: player-fish-state, + hand: hand, + exp-to-drop: s32, + cancelled: bool, + } + + record player-egg-throw-event-data { + player: player, + egg-uuid: uuid, + hatching: bool, + num-hatches: u8, + hatching-type: string, + cancelled: bool, + } + + enum entity-interaction-action { + interact, + attack, + interact-at, + } + + enum interact-action { + left-click-block, + left-click-air, + right-click-air, + right-click-block, + } + + record player-interact-event-data { + player: player, + action: interact-action, + clicked-pos: option, + block: string, + cancelled: bool, + } + + record player-toggle-sneak-event-data { + player: player, + is-sneaking: bool, + cancelled: bool, + } + + record player-toggle-flight-event-data { + player: player, + is-flying: bool, + cancelled: bool, + } + + record player-toggle-sprint-event-data { + player: player, + is-sprinting: bool, + cancelled: bool, + } + + record player-interact-unknown-entity-event-data { + player: player, + entity-id: s32, + action: entity-interaction-action, + cancelled: bool, + } + + record inventory-click-event-data { + player: player, + window-type: option, + click-type: click-type, + slot: s16, + raw-slot: s16, + clicked-item: option, + cursor: option, + hotbar-button: s32, + cancelled: bool, + } + + record inventory-close-event-data { + player: player, + window-type: option, + } + + record block-redstone-event-data { + target-world: %world, + state-id: u16, + block-pos: block-pos, + old-current: s32, + new-current: s32, + cancelled: bool, + } + + record block-break-event-data { + player: option, + block: string, + block-pos: block-pos, + exp: u32, + should-drop: bool, + cancelled: bool, + } + + record block-burn-event-data { + igniting-block: string, + block: string, + cancelled: bool, + } + + record block-can-build-event-data { + block-to-build: string, + buildable: bool, + player: player, + block: string, + cancelled: bool, + } + + record block-grow-event-data { + target-world: %world, + old-block: string, + old-state-id: u16, + new-block: string, + new-state-id: u16, + block-pos: block-pos, + cancelled: bool, + } + + record block-place-event-data { + player: player, + block-placed: string, + block-placed-against: string, + block-pos: block-pos, + can-build: bool, + cancelled: bool, + } + + record bedrock-form-response-event-data { + player: player, + form-id: u32, + response-data: option, + } + + record dialog-click-action-event-data { + player: player, + id: string, + payload: option>, + cancelled: bool, + } + + record dialog-show-event-data { + player: player, + dialog: dialog, + cancelled: bool, + } + + record dialog-clear-event-data { + player: player, + cancelled: bool, + } + + record server-command-event-data { + command: string, + cancelled: bool, + } + + record server-list-ping-address { + host: string, + port: u16, + } + + record server-list-ping-event-data { + hostname: string, + address: server-list-ping-address, + motd: text-component, + max-players: u32, + num-players: u32, + favicon: option, + } + + enum server-load-type { + startup, + reload, + } + + record server-load-event-data { + load-type: server-load-type, + } + + record spawn-change-event-data { + target-world: %world, + previous-position: block-pos, + previous-yaw: f32, + previous-pitch: f32, + new-position: block-pos, + new-yaw: f32, + new-pitch: f32, + } + + record server-broadcast-event-data { + message: text-component, + sender: text-component, + cancelled: bool, + } + + record server-tick-start-event-data { + tick: s32, + } + + record server-tick-end-event-data { + tick: s32, + duration-nanos: s64, + } + + record packet-received-event-data { + player: player, + packet: serverbound-packet, + packet-id: s32, + raw-payload: list, + cancelled: bool, + } + + record packet-sent-event-data { + player: player, + packet: clientbound-packet, + packet-id: s32, + raw-payload: list, + cancelled: bool, + } + + record player-interact-entity-event-data { + player: player, + entity-id: s32, + action: entity-interaction-action, + sneaking: bool, + cancelled: bool, + } + + record chunk-load-event-data { + target-world: %world, + chunk-x: s32, + chunk-z: s32, + cancelled: bool, + } + + record chunk-save-event-data { + target-world: %world, + chunk-x: s32, + chunk-z: s32, + cancelled: bool, + } + + record chunk-send-event-data { + target-world: %world, + chunk-x: s32, + chunk-z: s32, + cancelled: bool, + } + + record entity-damage-event-data { + entity-id: s32, + damage: f32, + damage-type: damage-type, + cancelled: bool, + } + + record entity-death-event-data { + entity-id: s32, + dropped-exp: s32, + } + + record player-death-event-data { + player: player, + death-message: text-component, + dropped-exp: s32, + keep-inventory: bool, + cancelled: bool, + } + + record entity-spawn-event-data { + entity-id: s32, + entity-type: string, + position: position, + target-world: %world, + cancelled: bool, + } + + record entity-combust-event-data { + entity-id: s32, + duration-secs: f32, + cancelled: bool, + } + + record entity-regain-health-event-data { + entity-id: s32, + amount: f32, + cancelled: bool, + } + + record entity-air-change-event-data { + entity-id: s32, + amount: s32, + cancelled: bool, + } + + record entity-breed-event-data { + father-id: s32, + mother-id: s32, + child-id: s32, + cancelled: bool, + } + + record entity-dismount-event-data { + entity-id: s32, + dismounted-id: s32, + cancelled: bool, + } + + record entity-dye-event-data { + entity-id: s32, + color: string, + player: option, + cancelled: bool, + } + + record entity-enter-love-mode-event-data { + entity-id: s32, + human-entity-id: option, + ticks-in-love: s32, + cancelled: bool, + } + + record entity-explode-event-data { + entity-id: s32, + position: position, + yield-rate: f32, + cancelled: bool, + } + + record entity-mount-event-data { + entity-id: s32, + mounted-id: s32, + cancelled: bool, + } + + record entity-pickup-item-event-data { + entity-id: s32, + item-name: string, + count: u8, + cancelled: bool, + } + + record entity-portal-event-data { + entity-id: s32, + portal-pos: block-pos, + cancelled: bool, + } + + record entity-resurrect-event-data { + entity-id: s32, + cancelled: bool, + } + + record entity-shoot-bow-event-data { + entity-id: s32, + weapon-name: string, + force: f32, + cancelled: bool, + } + + record entity-tame-event-data { + entity-id: s32, + owner: player, + cancelled: bool, + } + + record entity-target-event-data { + entity-id: s32, + target-id: option, + cancelled: bool, + } + + record entity-teleport-event-data { + entity-id: s32, + from-position: position, + to-position: position, + cancelled: bool, + } + + record entity-toggle-glide-event-data { + entity-id: s32, + is-gliding: bool, + cancelled: bool, + } + + record entity-transform-event-data { + entity-id: s32, + new-entity-id: s32, + transform-reason: string, + cancelled: bool, + } + + record creature-spawn-event-data { + entity-id: s32, + entity-type: string, + position: position, + target-world: %world, + spawn-reason: string, + cancelled: bool, + } + + record ender-dragon-change-phase-event-data { + entity-id: s32, + current-phase: string, + new-phase: string, + cancelled: bool, + } + + record entity-break-door-event-data { + entity-id: s32, + block-pos: block-pos, + cancelled: bool, + } + + record entity-change-block-event-data { + entity-id: s32, + block-pos: block-pos, + new-block: string, + cancelled: bool, + } + + record entity-damage-by-block-event-data { + entity-id: s32, + damager-pos: option, + damage: f32, + cause: string, + cancelled: bool, + } + + record entity-damage-by-entity-event-data { + entity-id: s32, + damager-id: s32, + damage: f32, + cause: string, + cancelled: bool, + } + + record entity-drop-item-event-data { + entity-id: s32, + item-name: string, + count: u8, + cancelled: bool, + } + + record entity-enter-block-event-data { + entity-id: s32, + block-pos: block-pos, + cancelled: bool, + } + + record entity-exhaustion-event-data { + entity-id: s32, + exhaustion: f32, + cancelled: bool, + } + + record entity-interact-event-data { + entity-id: s32, + block-pos: block-pos, + cancelled: bool, + } + + record entity-knockback-event-data { + entity-id: s32, + hit-by-id: option, + knockback: position, + cancelled: bool, + } + + record entity-place-event-data { + entity-id: s32, + block-pos: block-pos, + block-name: string, + cancelled: bool, + } + + record entity-pose-change-event-data { + entity-id: s32, + pose: string, + cancelled: bool, + } + + record entity-potion-effect-event-data { + entity-id: s32, + effect-name: string, + duration: s32, + amplifier: u8, + cancelled: bool, + } + + record entity-spell-cast-event-data { + entity-id: s32, + spell: string, + cancelled: bool, + } + + record entity-target-living-entity-event-data { + entity-id: s32, + target-id: option, + reason: string, + cancelled: bool, + } + + record entity-toggle-swim-event-data { + entity-id: s32, + is-swimming: bool, + cancelled: bool, + } + + record explosion-prime-event-data { + entity-id: s32, + radius: f32, + fire: bool, + cancelled: bool, + } + + record firework-explode-event-data { + entity-id: s32, + cancelled: bool, + } + + record food-level-change-event-data { + entity-id: s32, + food-level: u8, + cancelled: bool, + } + + record item-despawn-event-data { + entity-id: s32, + cancelled: bool, + } + + record item-merge-event-data { + entity-id: s32, + target-id: s32, + cancelled: bool, + } + + record item-spawn-event-data { + entity-id: s32, + position: position, + item-name: string, + cancelled: bool, + } + + record piglin-barter-event-data { + entity-id: s32, + input-item: item-stack, + outcome: list, + cancelled: bool, + } + + record projectile-hit-event-data { + entity-id: s32, + hit-position: position, + hit-entity-id: option, + cancelled: bool, + } + + record projectile-launch-event-data { + entity-id: s32, + shooter-id: option, + cancelled: bool, + } + + record sheep-dye-wool-event-data { + entity-id: s32, + dye-color: u8, + player-id: option, + cancelled: bool, + } + + record sheep-regrow-wool-event-data { + entity-id: s32, + cancelled: bool, + } + + record slime-split-event-data { + entity-id: s32, + count: s32, + cancelled: bool, + } + + record strider-temperature-change-event-data { + entity-id: s32, + is-shivering: bool, + cancelled: bool, + } + + record villager-acquire-trade-event-data { + entity-id: s32, + recipe-index: s32, + cancelled: bool, + } + + record villager-career-change-event-data { + entity-id: s32, + profession: string, + reason: string, + cancelled: bool, + } + + record villager-replenish-trade-event-data { + entity-id: s32, + restock-quantity: s32, + cancelled: bool, + } + + record warden-anger-change-event-data { + entity-id: s32, + target-id: s32, + old-anger: s32, + new-anger: s32, + cancelled: bool, + } + + record area-effect-cloud-apply-event-data { + entity-id: s32, + affected-entities: list, + cancelled: bool, + } + + record arrow-body-count-change-event-data { + entity-id: s32, + old-amount: u32, + new-amount: u32, + cancelled: bool, + } + + record bat-toggle-sleep-event-data { + entity-id: s32, + is-awake: bool, + cancelled: bool, + } + + record creeper-power-event-data { + entity-id: s32, + lightning-id: option, + cause: string, + cancelled: bool, + } + + record entity-combust-by-block-event-data { + entity-id: s32, + combuster: block-pos, + duration: f32, + cancelled: bool, + } + + record entity-combust-by-entity-event-data { + entity-id: s32, + combuster-id: s32, + duration: f32, + cancelled: bool, + } + + record entity-knockback-by-entity-event-data { + entity-id: s32, + hit-by-id: s32, + force: f64, + x: f64, + z: f64, + cancelled: bool, + } + + record entity-portal-enter-event-data { + entity-id: s32, + location: block-pos, + cancelled: bool, + } + + record entity-portal-exit-event-data { + entity-id: s32, + from-pos: block-pos, + to-pos: option, + cancelled: bool, + } + + record entity-remove-event-data { + entity-id: s32, + cause: string, + cancelled: bool, + } + + record entity-target-block-event-data { + entity-id: s32, + block-pos: block-pos, + cancelled: bool, + } + + record entity-unleash-event-data { + entity-id: s32, + reason: string, + cancelled: bool, + } + + record exp-bottle-event-data { + entity-id: s32, + experience: s32, + location: block-pos, + show-effect: bool, + cancelled: bool, + } + + record horse-jump-event-data { + entity-id: s32, + power: f32, + cancelled: bool, + } + + record lingering-potion-splash-event-data { + entity-id: s32, + location: block-pos, + potion-item: string, + cancelled: bool, + } + + record pig-zap-event-data { + entity-id: s32, + lightning-id: s32, + pig-zombie-id: s32, + cancelled: bool, + } + + record pig-zombie-anger-event-data { + entity-id: s32, + target-id: option, + new-anger: s32, + cancelled: bool, + } + + record potion-splash-event-data { + entity-id: s32, + location: block-pos, + potion-item: string, + affected-entities: list, + cancelled: bool, + } + + record spawner-spawn-event-data { + entity-id: s32, + spawner-pos: block-pos, + cancelled: bool, + } + + record trial-spawner-spawn-event-data { + entity-id: s32, + spawner-pos: block-pos, + cancelled: bool, + } + + record villager-reputation-change-event-data { + entity-id: s32, + target-id: s32, + reputation-change: s32, + cancelled: bool, + } + + record player-item-consume-event-data { + player: player, + item-name: string, + cancelled: bool, + } + + record player-item-damage-event-data { + player: player, + item-name: string, + damage: s32, + cancelled: bool, + } + + record player-drop-item-event-data { + player: player, + item-name: string, + count: u8, + cancelled: bool, + } + + record player-bed-enter-event-data { + player: player, + bed-pos: block-pos, + cancelled: bool, + } + + record player-bed-leave-event-data { + player: player, + bed-pos: block-pos, + } + + record player-bucket-empty-event-data { + player: player, + block-pos: block-pos, + bucket: string, + cancelled: bool, + } + + record player-bucket-fill-event-data { + player: player, + block-pos: block-pos, + bucket: string, + cancelled: bool, + } + + record async-player-chat-event-data { + player: player, + message: string, + format: text-component, + cancelled: bool, + } + + record async-player-pre-login-event-data { + player-name: string, + player-uuid: string, + ip-address: string, + kick-message: text-component, + cancelled: bool, + } + + record player-advancement-done-event-data { + player: player, + advancement-id: string, + cancelled: bool, + } + + record player-animation-event-data { + player: player, + animation-type: string, + cancelled: bool, + } + + record player-armor-stand-manipulate-event-data { + player: player, + armor-stand-id: s32, + slot: u8, + cancelled: bool, + } + + record player-bucket-entity-event-data { + player: player, + entity-id: s32, + bucket-item: string, + cancelled: bool, + } + + record player-changed-world-event-data { + player: player, + from-world: %world, + to-world: %world, + cancelled: bool, + } + + record player-channel-event-data { + player: player, + channel: string, + cancelled: bool, + } + + record player-command-preprocess-event-data { + player: player, + command: string, + cancelled: bool, + } + + record player-edit-book-event-data { + player: player, + slot: u32, + pages: list, + title: option, + signing: bool, + cancelled: bool, + } + + record player-elytra-boost-event-data { + player: player, + firework-id: s32, + cancelled: bool, + } + + record player-exp-cooldown-change-event-data { + player: player, + new-cooldown: s32, + cancelled: bool, + } + + record player-harvest-block-event-data { + player: player, + block-pos: block-pos, + harvested-items: list, + cancelled: bool, + } + + record player-hide-entity-event-data { + player: player, + entity-id: s32, + cancelled: bool, + } + + record player-item-break-event-data { + player: player, + item-name: string, + } + + record player-item-mend-event-data { + player: player, + item-name: string, + repair-amount: s32, + exp-consumed: s32, + cancelled: bool, + } + + record player-kick-event-data { + player: player, + reason: string, + cancelled: bool, + } + + record player-leash-entity-event-data { + player: player, + entity-id: s32, + holder-id: s32, + cancelled: bool, + } + + record player-level-change-event-data { + player: player, + old-level: s32, + new-level: s32, + } + + record player-locale-change-event-data { + player: player, + new-locale: string, + cancelled: bool, + } + + record player-name-entity-event-data { + player: player, + entity-id: s32, + name: text-component, + cancelled: bool, + } + + record player-open-sign-event-data { + player: player, + block-pos: block-pos, + is-front: bool, + cancelled: bool, + } + + record player-portal-event-data { + player: player, + from-pos: block-pos, + to-pos: option, + cancelled: bool, + } + + record player-pre-login-event-data { + player-name: string, + player-uuid: string, + ip-address: string, + kick-message: text-component, + cancelled: bool, + } + + record player-riptide-event-data { + player: player, + item-name: string, + cancelled: bool, + } + + record player-shear-entity-event-data { + player: player, + entity-id: s32, + hand: u8, + cancelled: bool, + } + + record player-show-entity-event-data { + player: player, + entity-id: s32, + cancelled: bool, + } + + record player-spawn-change-event-data { + player: player, + new-spawn: option, + forced: bool, + cancelled: bool, + } + + record player-statistic-increment-event-data { + player: player, + statistic-id: string, + amount: s32, + cancelled: bool, + } + + record player-swap-hands-event-data { + player: player, + cancelled: bool, + } + + record player-take-lectern-book-event-data { + player: player, + block-pos: block-pos, + book: item-stack, + cancelled: bool, + } + + record player-unleash-entity-event-data { + player: player, + entity-id: s32, + cancelled: bool, + } + + record player-velocity-event-data { + player: player, + velocity: position, + cancelled: bool, + } + + record player-input-event-data { + player: player, + input: string, + cancelled: bool, + } + + record player-interact-at-entity-event-data { + player: player, + entity-id: s32, + clicked-x: f64, + clicked-y: f64, + clicked-z: f64, + hand: u8, + cancelled: bool, + } + + record player-links-send-event-data { + player: player, + links: list, + cancelled: bool, + } + + record player-pickup-arrow-event-data { + player: player, + arrow-id: s32, + cancelled: bool, + } + + record player-recipe-book-click-event-data { + player: player, + recipe-id: string, + make-all: bool, + cancelled: bool, + } + + record player-recipe-book-settings-change-event-data { + player: player, + book-type: string, + is-open: bool, + is-filtering: bool, + cancelled: bool, + } + + record player-recipe-discover-event-data { + player: player, + recipe-id: string, + cancelled: bool, + } + + record player-register-channel-event-data { + player: player, + channel: string, + cancelled: bool, + } + + record player-resource-pack-status-event-data { + player: player, + pack-id: string, + status: string, + cancelled: bool, + } + + record player-spawn-location-event-data { + player: player, + spawn-pos: position, + cancelled: bool, + } + + record player-unregister-channel-event-data { + player: player, + channel: string, + cancelled: bool, + } + + record raid-finish-event-data { + victory: bool, + cancelled: bool, + } + + record raid-spawn-wave-event-data { + wave: u32, + pos: block-pos, + cancelled: bool, + } + + record raid-stop-event-data { + reason: string, + cancelled: bool, + } + + record raid-trigger-event-data { + pos: block-pos, + cancelled: bool, + } + + record block-damage-event-data { + player: player, + block-pos: block-pos, + insta-break: bool, + cancelled: bool, + } + + record block-ignite-event-data { + block-pos: block-pos, + cancelled: bool, + } + + record block-from-to-event-data { + from-pos: block-pos, + to-pos: block-pos, + cancelled: bool, + } + + record block-form-event-data { + block-pos: block-pos, + cancelled: bool, + } + + record block-fade-event-data { + block-pos: block-pos, + cancelled: bool, + } + + record block-dispense-event-data { + block-pos: block-pos, + item-name: string, + cancelled: bool, + } + + record block-explode-event-data { + block-pos: block-pos, + yield-rate: f32, + cancelled: bool, + } + + record block-physics-event-data { + block-pos: block-pos, + changed-pos: block-pos, + cancelled: bool, + } + + record block-piston-extend-event-data { + block-pos: block-pos, + direction: string, + cancelled: bool, + } + + record block-piston-retract-event-data { + block-pos: block-pos, + direction: string, + cancelled: bool, + } + + record note-play-event-data { + block-pos: block-pos, + instrument: string, + note: u8, + cancelled: bool, + } + + record sign-change-event-data { + player: player, + block-pos: block-pos, + lines: list, + cancelled: bool, + } + + record sponge-absorb-event-data { + block-pos: block-pos, + cancelled: bool, + } + + record tnt-prime-event-data { + block-pos: block-pos, + prime-reason: string, + cancelled: bool, + } + + record map-initialize-event-data { + map-id: s32, + } + + record hanging-break-event-data { + entity-id: s32, + remover-entity-id: option, + cancelled: bool, + } + + record hanging-break-by-entity-event-data { + entity-id: s32, + remover-entity-id: s32, + cancelled: bool, + } + + record hanging-place-event-data { + entity-id: s32, + player: option, + block-pos: block-pos, + block-face: string, + cancelled: bool, + } + + record bell-resonate-event-data { + block-pos: block-pos, + target-world: %world, + cancelled: bool, + } + + record bell-ring-event-data { + block-pos: block-pos, + target-world: %world, + entity-id: option, + direction: option, + cancelled: bool, + } + + record block-brush-event-data { + block-pos: block-pos, + target-world: %world, + player: player, + item: item-stack, + cancelled: bool, + } + + record block-cook-event-data { + block-pos: block-pos, + target-world: %world, + source: item-stack, + %result: item-stack, + cancelled: bool, + } + + record block-damage-abort-event-data { + player: player, + block-pos: block-pos, + target-world: %world, + item-in-hand: item-stack, + } + + record block-dispense-armor-event-data { + block-pos: block-pos, + target-world: %world, + target-entity-id: s32, + item: item-stack, + cancelled: bool, + } + + record block-dispense-loot-event-data { + block-pos: block-pos, + target-world: %world, + items: list, + cancelled: bool, + } + + record block-drop-item-event-data { + block-pos: block-pos, + target-world: %world, + player: option, + items: list, + cancelled: bool, + } + + record block-exp-event-data { + block-pos: block-pos, + target-world: %world, + exp: s32, + } + + record block-fertilize-event-data { + block-pos: block-pos, + target-world: %world, + player: option, + changed-blocks: list>, + cancelled: bool, + } + + record block-multi-place-event-data { + player: player, + target-world: %world, + placed-blocks: list>, + cancelled: bool, + } + + record block-receive-game-event-data { + block-pos: block-pos, + target-world: %world, + game-event: string, + source-entity-id: option, + cancelled: bool, + } + + record block-shear-entity-event-data { + block-pos: block-pos, + target-world: %world, + target-entity-id: s32, + item: item-stack, + cancelled: bool, + } + + record block-spread-event-data { + source-pos: block-pos, + target-pos: block-pos, + target-world: %world, + new-state-id: u16, + cancelled: bool, + } + + record brewing-start-event-data { + block-pos: block-pos, + target-world: %world, + brewing-time: s32, + cancelled: bool, + } + + record campfire-start-event-data { + block-pos: block-pos, + target-world: %world, + item: item-stack, + slot: u8, + cooking-time: s32, + cancelled: bool, + } + + record cauldron-level-change-event-data { + block-pos: block-pos, + target-world: %world, + old-level: s32, + new-level: s32, + reason: string, + entity-id: option, + cancelled: bool, + } + + record crafter-craft-event-data { + block-pos: block-pos, + target-world: %world, + %result: item-stack, + cancelled: bool, + } + + record entity-block-form-event-data { + entity-id: s32, + block-pos: block-pos, + target-world: %world, + new-state-id: u16, + cancelled: bool, + } + + record fluid-level-change-event-data { + block-pos: block-pos, + target-world: %world, + new-state-id: u16, + cancelled: bool, + } + + record inventory-block-start-event-data { + block-pos: block-pos, + target-world: %world, + } + + record leaves-decay-event-data { + block-pos: block-pos, + target-world: %world, + cancelled: bool, + } + + record moisture-change-event-data { + block-pos: block-pos, + target-world: %world, + new-moisture: s32, + cancelled: bool, + } + + record sculk-bloom-event-data { + block-pos: block-pos, + target-world: %world, + charge: s32, + cancelled: bool, + } + + record vault-display-item-event-data { + block-pos: block-pos, + target-world: %world, + item: item-stack, + cancelled: bool, + } + + record weather-change-event-data { + target-world: %world, + to-weather-state: bool, + cancelled: bool, + } + + record thunder-change-event-data { + target-world: %world, + to-thunder-state: bool, + cancelled: bool, + } + + record world-load-event-data { + target-world: %world, + } + + record world-unload-event-data { + target-world: %world, + cancelled: bool, + } + + record async-structure-generate-event-data { + world-name: string, + structure-name: string, + pos: block-pos, + cancelled: bool, + } + + record async-structure-spawn-event-data { + world-name: string, + structure-name: string, + pos: block-pos, + cancelled: bool, + } + + record chunk-populate-event-data { + chunk-x: s32, + chunk-z: s32, + cancelled: bool, + } + + record chunk-unload-event-data { + chunk-x: s32, + chunk-z: s32, + cancelled: bool, + } + + record entities-load-event-data { + chunk-x: s32, + chunk-z: s32, + entity-count: u32, + cancelled: bool, + } + + record entities-unload-event-data { + chunk-x: s32, + chunk-z: s32, + entity-count: u32, + cancelled: bool, + } + + record generic-game-event-data { + event-id: string, + pos: position, + cancelled: bool, + } + + record loot-generate-event-data { + loot-table: string, + cancelled: bool, + } + + record portal-create-event-data { + pos: block-pos, + portal-type: string, + cancelled: bool, + } + + record structure-grow-event-data { + pos: block-pos, + species: string, + bone-meal: bool, + cancelled: bool, + } + + record time-skip-event-data { + skip-amount: s64, + cancelled: bool, + } + + record world-init-event-data { + target-world: %world, + } + + record world-save-event-data { + world-name: string, + cancelled: bool, + } + + record inventory-open-event-data { + player: player, + cancelled: bool, + } + + record inventory-drag-event-data { + player: player, + cancelled: bool, + } + + record craft-item-event-data { + player: player, + recipe-id: string, + cancelled: bool, + } + + record furnace-smelt-event-data { + block-pos: block-pos, + source-item: string, + result-item: string, + cancelled: bool, + } + + record brew-event-data { + block-pos: block-pos, + fuel-level: u8, + cancelled: bool, + } + + record brewing-stand-fuel-event-data { + block-pos: block-pos, + fuel-power: u16, + cancelled: bool, + } + + record furnace-burn-event-data { + block-pos: block-pos, + fuel-item: string, + burn-time: u32, + cancelled: bool, + } + + record furnace-extract-event-data { + player: player, + block-pos: block-pos, + item-id: string, + item-amount: u32, + exp-gained: f32, + } + + record furnace-start-smelt-event-data { + block-pos: block-pos, + source-item: string, + cooking-time: u32, + cancelled: bool, + } + + record hopper-inventory-search-event-data { + block-pos: block-pos, + search-pos: block-pos, + cancelled: bool, + } + + record inventory-creative-event-data { + player: player, + slot: s16, + item-id: string, + item-count: u8, + cancelled: bool, + } + + record inventory-interact-event-data { + player: player, + cancelled: bool, + } + + record inventory-move-item-event-data { + source-pos: block-pos, + target-pos: block-pos, + item-id: string, + item-amount: u32, + cancelled: bool, + } + + record inventory-pickup-item-event-data { + block-pos: block-pos, + item-entity-id: s32, + item-id: string, + cancelled: bool, + } + + record prepare-anvil-event-data { + player: player, + rename-text: string, + repair-cost: u32, + } + + record prepare-grindstone-event-data { + player: player, + result-item: option, + } + + record prepare-inventory-result-event-data { + player: player, + result-item: option, + } + + record prepare-item-craft-event-data { + player: player, + recipe-id: string, + cancelled: bool, + } + + record prepare-smithing-event-data { + player: player, + result-item: option, + } + + record smith-item-event-data { + player: player, + recipe-id: string, + cancelled: bool, + } + + record trade-select-event-data { + player: player, + slot-index: u8, + cancelled: bool, + } + + record vehicle-block-collision-event-data { + vehicle-id: s32, + block-pos: block-pos, + cancelled: bool, + } + + record vehicle-collision-event-data { + vehicle-id: s32, + cancelled: bool, + } + + record vehicle-create-event-data { + vehicle-id: s32, + cancelled: bool, + } + + record vehicle-damage-event-data { + vehicle-id: s32, + damage: f32, + attacker-id: option, + cancelled: bool, + } + + record vehicle-destroy-event-data { + vehicle-id: s32, + attacker-id: option, + cancelled: bool, + } + + record vehicle-enter-event-data { + vehicle-id: s32, + entered-id: s32, + cancelled: bool, + } + + record vehicle-entity-collision-event-data { + vehicle-id: s32, + collided-entity-id: s32, + cancelled: bool, + } + + record vehicle-exit-event-data { + vehicle-id: s32, + exited-id: s32, + cancelled: bool, + } + + record vehicle-move-event-data { + vehicle-id: s32, + from-position: position, + to-position: position, + cancelled: bool, + } + + record vehicle-update-event-data { + vehicle-id: s32, + cancelled: bool, + } + + record enchantment-offer { + cost: s32, + enchantment-id: s32, + enchantment-level: s32, + } + + record prepare-item-enchant-event-data { + player: player, + item: item-stack, + offers: list, + bookshelf-count: s32, + cancelled: bool, + } + + record enchantment-value { + enchantment: enchantment, + level: u32, + } + + record enchant-item-event-data { + player: player, + item: item-stack, + %option: s32, + cost: s32, + enchantments-to-add: list, + cancelled: bool, + } + + record lightning-strike-event-data { + position: position, + is-effect: bool, + cancelled: bool, + } + + enum event-type { + player-join-event, + player-leave-event, + player-login-event, + player-chat-event, + player-command-send-event, + player-permission-check-event, + player-move-event, + player-teleport-event, + player-change-world-event, + player-respawn-event, + player-exp-change-event, + player-item-held-event, + player-changed-main-hand-event, + player-gamemode-change-event, + player-custom-payload-event, + player-fish-event, + player-egg-throw-event, + player-interact-unknown-entity-event, + player-interact-entity-event, + player-interact-event, + player-toggle-sneak-event, + player-toggle-flight-event, + player-toggle-sprint-event, + inventory-click-event, + inventory-close-event, + block-redstone-event, + block-break-event, + block-burn-event, + block-can-build-event, + block-grow-event, + block-place-event, + bedrock-form-response-event, + dialog-click-action-event, + dialog-show-event, + dialog-clear-event, + server-command-event, + server-list-ping-event, + server-load-event, + spawn-change-event, + server-broadcast-event, + server-tick-start-event, + server-tick-end-event, + packet-received-event, + packet-sent-event, + chunk-load-event, + chunk-save-event, + chunk-send-event, + entity-damage-event, + entity-death-event, + player-death-event, + entity-spawn-event, + entity-combust-event, + entity-regain-health-event, + entity-air-change-event, + entity-breed-event, + entity-dismount-event, + entity-dye-event, + entity-enter-love-mode-event, + entity-explode-event, + entity-mount-event, + entity-pickup-item-event, + entity-portal-event, + entity-resurrect-event, + entity-shoot-bow-event, + entity-tame-event, + entity-target-event, + entity-teleport-event, + entity-toggle-glide-event, + entity-transform-event, + player-item-consume-event, + player-item-damage-event, + player-drop-item-event, + player-bed-enter-event, + player-bed-leave-event, + player-bucket-empty-event, + player-bucket-fill-event, + block-damage-event, + block-ignite-event, + block-from-to-event, + block-form-event, + block-fade-event, + block-dispense-event, + block-explode-event, + block-physics-event, + block-piston-extend-event, + block-piston-retract-event, + note-play-event, + sign-change-event, + sponge-absorb-event, + tnt-prime-event, + weather-change-event, + thunder-change-event, + world-load-event, + world-unload-event, + async-structure-generate-event, + async-structure-spawn-event, + chunk-populate-event, + chunk-unload-event, + entities-load-event, + entities-unload-event, + generic-game-event, + loot-generate-event, + portal-create-event, + structure-grow-event, + time-skip-event, + world-init-event, + world-save-event, + inventory-open-event, + inventory-drag-event, + craft-item-event, + furnace-smelt-event, + brew-event, + brewing-stand-fuel-event, + furnace-burn-event, + furnace-extract-event, + furnace-start-smelt-event, + hopper-inventory-search-event, + inventory-creative-event, + inventory-interact-event, + inventory-move-item-event, + inventory-pickup-item-event, + prepare-anvil-event, + prepare-grindstone-event, + prepare-inventory-result-event, + prepare-item-craft-event, + prepare-smithing-event, + smith-item-event, + trade-select-event, + vehicle-block-collision-event, + vehicle-collision-event, + vehicle-create-event, + vehicle-damage-event, + vehicle-destroy-event, + vehicle-enter-event, + vehicle-entity-collision-event, + vehicle-exit-event, + vehicle-move-event, + vehicle-update-event, + prepare-item-enchant-event, + enchant-item-event, + map-initialize-event, + hanging-break-event, + hanging-break-by-entity-event, + hanging-place-event, + bell-resonate-event, + bell-ring-event, + block-brush-event, + block-cook-event, + block-damage-abort-event, + block-dispense-armor-event, + block-dispense-loot-event, + block-drop-item-event, + block-exp-event, + block-fertilize-event, + block-multi-place-event, + block-receive-game-event, + block-shear-entity-event, + block-spread-event, + brewing-start-event, + campfire-start-event, + cauldron-level-change-event, + crafter-craft-event, + entity-block-form-event, + fluid-level-change-event, + inventory-block-start-event, + leaves-decay-event, + moisture-change-event, + sculk-bloom-event, + vault-display-item-event, + creature-spawn-event, + ender-dragon-change-phase-event, + entity-break-door-event, + entity-change-block-event, + entity-damage-by-block-event, + entity-damage-by-entity-event, + entity-drop-item-event, + entity-enter-block-event, + entity-exhaustion-event, + entity-interact-event, + entity-knockback-event, + entity-place-event, + entity-pose-change-event, + entity-potion-effect-event, + entity-spell-cast-event, + entity-target-living-entity-event, + entity-toggle-swim-event, + explosion-prime-event, + firework-explode-event, + food-level-change-event, + item-despawn-event, + item-merge-event, + item-spawn-event, + piglin-barter-event, + projectile-hit-event, + projectile-launch-event, + sheep-dye-wool-event, + sheep-regrow-wool-event, + slime-split-event, + strider-temperature-change-event, + villager-acquire-trade-event, + villager-career-change-event, + villager-replenish-trade-event, + warden-anger-change-event, + area-effect-cloud-apply-event, + arrow-body-count-change-event, + bat-toggle-sleep-event, + creeper-power-event, + entity-combust-by-block-event, + entity-combust-by-entity-event, + entity-knockback-by-entity-event, + entity-portal-enter-event, + entity-portal-exit-event, + entity-remove-event, + entity-target-block-event, + entity-unleash-event, + exp-bottle-event, + horse-jump-event, + lingering-potion-splash-event, + pig-zap-event, + pig-zombie-anger-event, + potion-splash-event, + spawner-spawn-event, + trial-spawner-spawn-event, + villager-reputation-change-event, + async-player-chat-event, + async-player-pre-login-event, + player-advancement-done-event, + player-animation-event, + player-armor-stand-manipulate-event, + player-bucket-entity-event, + player-changed-world-event, + player-channel-event, + player-command-preprocess-event, + player-edit-book-event, + player-elytra-boost-event, + player-exp-cooldown-change-event, + player-harvest-block-event, + player-hide-entity-event, + player-item-break-event, + player-item-mend-event, + player-kick-event, + player-leash-entity-event, + player-level-change-event, + player-locale-change-event, + player-name-entity-event, + player-open-sign-event, + player-portal-event, + player-pre-login-event, + player-riptide-event, + player-shear-entity-event, + player-show-entity-event, + player-spawn-change-event, + player-statistic-increment-event, + player-swap-hands-event, + player-take-lectern-book-event, + player-unleash-entity-event, + player-velocity-event, + player-input-event, + player-interact-at-entity-event, + player-links-send-event, + player-pickup-arrow-event, + player-recipe-book-click-event, + player-recipe-book-settings-change-event, + player-recipe-discover-event, + player-register-channel-event, + player-resource-pack-status-event, + player-spawn-location-event, + player-unregister-channel-event, + raid-finish-event, + raid-spawn-wave-event, + raid-stop-event, + raid-trigger-event, + lightning-strike-event, + } + + variant event { + player-join-event(player-join-event-data), + player-leave-event(player-leave-event-data), + player-login-event(player-login-event-data), + player-chat-event(player-chat-event-data), + player-command-send-event(player-command-send-event-data), + player-permission-check-event(player-permission-check-event-data), + player-move-event(player-move-event-data), + player-teleport-event(player-teleport-event-data), + player-change-world-event(player-change-world-event-data), + player-respawn-event(player-respawn-event-data), + player-exp-change-event(player-exp-change-event-data), + player-item-held-event(player-item-held-event-data), + player-changed-main-hand-event(player-changed-main-hand-event-data), + player-gamemode-change-event(player-gamemode-change-event-data), + player-custom-payload-event(player-custom-payload-event-data), + player-fish-event(player-fish-event-data), + player-egg-throw-event(player-egg-throw-event-data), + player-interact-unknown-entity-event(player-interact-unknown-entity-event-data), + player-interact-entity-event(player-interact-entity-event-data), + player-interact-event(player-interact-event-data), + player-toggle-sneak-event(player-toggle-sneak-event-data), + player-toggle-flight-event(player-toggle-flight-event-data), + player-toggle-sprint-event(player-toggle-sprint-event-data), + inventory-click-event(inventory-click-event-data), + inventory-close-event(inventory-close-event-data), + block-redstone-event(block-redstone-event-data), + block-break-event(block-break-event-data), + block-burn-event(block-burn-event-data), + block-can-build-event(block-can-build-event-data), + block-grow-event(block-grow-event-data), + block-place-event(block-place-event-data), + dialog-click-action-event(dialog-click-action-event-data), + dialog-show-event(dialog-show-event-data), + dialog-clear-event(dialog-clear-event-data), + bedrock-form-response-event(bedrock-form-response-event-data), + server-command-event(server-command-event-data), + server-list-ping-event(server-list-ping-event-data), + server-load-event(server-load-event-data), + spawn-change-event(spawn-change-event-data), + server-broadcast-event(server-broadcast-event-data), + server-tick-start-event(server-tick-start-event-data), + server-tick-end-event(server-tick-end-event-data), + packet-received-event(packet-received-event-data), + packet-sent-event(packet-sent-event-data), + chunk-load-event(chunk-load-event-data), + chunk-save-event(chunk-save-event-data), + chunk-send-event(chunk-send-event-data), + entity-damage-event(entity-damage-event-data), + entity-death-event(entity-death-event-data), + player-death-event(player-death-event-data), + entity-spawn-event(entity-spawn-event-data), + entity-combust-event(entity-combust-event-data), + entity-regain-health-event(entity-regain-health-event-data), + entity-air-change-event(entity-air-change-event-data), + entity-breed-event(entity-breed-event-data), + entity-dismount-event(entity-dismount-event-data), + entity-dye-event(entity-dye-event-data), + entity-enter-love-mode-event(entity-enter-love-mode-event-data), + entity-explode-event(entity-explode-event-data), + entity-mount-event(entity-mount-event-data), + entity-pickup-item-event(entity-pickup-item-event-data), + entity-portal-event(entity-portal-event-data), + entity-resurrect-event(entity-resurrect-event-data), + entity-shoot-bow-event(entity-shoot-bow-event-data), + entity-tame-event(entity-tame-event-data), + entity-target-event(entity-target-event-data), + entity-teleport-event(entity-teleport-event-data), + entity-toggle-glide-event(entity-toggle-glide-event-data), + entity-transform-event(entity-transform-event-data), + player-item-consume-event(player-item-consume-event-data), + player-item-damage-event(player-item-damage-event-data), + player-drop-item-event(player-drop-item-event-data), + player-bed-enter-event(player-bed-enter-event-data), + player-bed-leave-event(player-bed-leave-event-data), + player-bucket-empty-event(player-bucket-empty-event-data), + player-bucket-fill-event(player-bucket-fill-event-data), + block-damage-event(block-damage-event-data), + block-ignite-event(block-ignite-event-data), + block-from-to-event(block-from-to-event-data), + block-form-event(block-form-event-data), + block-fade-event(block-fade-event-data), + block-dispense-event(block-dispense-event-data), + block-explode-event(block-explode-event-data), + block-physics-event(block-physics-event-data), + block-piston-extend-event(block-piston-extend-event-data), + block-piston-retract-event(block-piston-retract-event-data), + note-play-event(note-play-event-data), + sign-change-event(sign-change-event-data), + sponge-absorb-event(sponge-absorb-event-data), + tnt-prime-event(tnt-prime-event-data), + weather-change-event(weather-change-event-data), + thunder-change-event(thunder-change-event-data), + world-load-event(world-load-event-data), + world-unload-event(world-unload-event-data), + async-structure-generate-event(async-structure-generate-event-data), + async-structure-spawn-event(async-structure-spawn-event-data), + chunk-populate-event(chunk-populate-event-data), + chunk-unload-event(chunk-unload-event-data), + entities-load-event(entities-load-event-data), + entities-unload-event(entities-unload-event-data), + generic-game-event(generic-game-event-data), + loot-generate-event(loot-generate-event-data), + portal-create-event(portal-create-event-data), + structure-grow-event(structure-grow-event-data), + time-skip-event(time-skip-event-data), + world-init-event(world-init-event-data), + world-save-event(world-save-event-data), + inventory-open-event(inventory-open-event-data), + inventory-drag-event(inventory-drag-event-data), + craft-item-event(craft-item-event-data), + furnace-smelt-event(furnace-smelt-event-data), + brew-event(brew-event-data), + brewing-stand-fuel-event(brewing-stand-fuel-event-data), + furnace-burn-event(furnace-burn-event-data), + furnace-extract-event(furnace-extract-event-data), + furnace-start-smelt-event(furnace-start-smelt-event-data), + hopper-inventory-search-event(hopper-inventory-search-event-data), + inventory-creative-event(inventory-creative-event-data), + inventory-interact-event(inventory-interact-event-data), + inventory-move-item-event(inventory-move-item-event-data), + inventory-pickup-item-event(inventory-pickup-item-event-data), + prepare-anvil-event(prepare-anvil-event-data), + prepare-grindstone-event(prepare-grindstone-event-data), + prepare-inventory-result-event(prepare-inventory-result-event-data), + prepare-item-craft-event(prepare-item-craft-event-data), + prepare-smithing-event(prepare-smithing-event-data), + smith-item-event(smith-item-event-data), + trade-select-event(trade-select-event-data), + vehicle-block-collision-event(vehicle-block-collision-event-data), + vehicle-collision-event(vehicle-collision-event-data), + vehicle-create-event(vehicle-create-event-data), + vehicle-damage-event(vehicle-damage-event-data), + vehicle-destroy-event(vehicle-destroy-event-data), + vehicle-enter-event(vehicle-enter-event-data), + vehicle-entity-collision-event(vehicle-entity-collision-event-data), + vehicle-exit-event(vehicle-exit-event-data), + vehicle-move-event(vehicle-move-event-data), + vehicle-update-event(vehicle-update-event-data), + prepare-item-enchant-event(prepare-item-enchant-event-data), + enchant-item-event(enchant-item-event-data), + map-initialize-event(map-initialize-event-data), + hanging-break-event(hanging-break-event-data), + hanging-break-by-entity-event(hanging-break-by-entity-event-data), + hanging-place-event(hanging-place-event-data), + bell-resonate-event(bell-resonate-event-data), + bell-ring-event(bell-ring-event-data), + block-brush-event(block-brush-event-data), + block-cook-event(block-cook-event-data), + block-damage-abort-event(block-damage-abort-event-data), + block-dispense-armor-event(block-dispense-armor-event-data), + block-dispense-loot-event(block-dispense-loot-event-data), + block-drop-item-event(block-drop-item-event-data), + block-exp-event(block-exp-event-data), + block-fertilize-event(block-fertilize-event-data), + block-multi-place-event(block-multi-place-event-data), + block-receive-game-event(block-receive-game-event-data), + block-shear-entity-event(block-shear-entity-event-data), + block-spread-event(block-spread-event-data), + brewing-start-event(brewing-start-event-data), + campfire-start-event(campfire-start-event-data), + cauldron-level-change-event(cauldron-level-change-event-data), + crafter-craft-event(crafter-craft-event-data), + entity-block-form-event(entity-block-form-event-data), + fluid-level-change-event(fluid-level-change-event-data), + inventory-block-start-event(inventory-block-start-event-data), + leaves-decay-event(leaves-decay-event-data), + moisture-change-event(moisture-change-event-data), + sculk-bloom-event(sculk-bloom-event-data), + vault-display-item-event(vault-display-item-event-data), + creature-spawn-event(creature-spawn-event-data), + ender-dragon-change-phase-event(ender-dragon-change-phase-event-data), + entity-break-door-event(entity-break-door-event-data), + entity-change-block-event(entity-change-block-event-data), + entity-damage-by-block-event(entity-damage-by-block-event-data), + entity-damage-by-entity-event(entity-damage-by-entity-event-data), + entity-drop-item-event(entity-drop-item-event-data), + entity-enter-block-event(entity-enter-block-event-data), + entity-exhaustion-event(entity-exhaustion-event-data), + entity-interact-event(entity-interact-event-data), + entity-knockback-event(entity-knockback-event-data), + entity-place-event(entity-place-event-data), + entity-pose-change-event(entity-pose-change-event-data), + entity-potion-effect-event(entity-potion-effect-event-data), + entity-spell-cast-event(entity-spell-cast-event-data), + entity-target-living-entity-event(entity-target-living-entity-event-data), + entity-toggle-swim-event(entity-toggle-swim-event-data), + explosion-prime-event(explosion-prime-event-data), + firework-explode-event(firework-explode-event-data), + food-level-change-event(food-level-change-event-data), + item-despawn-event(item-despawn-event-data), + item-merge-event(item-merge-event-data), + item-spawn-event(item-spawn-event-data), + piglin-barter-event(piglin-barter-event-data), + projectile-hit-event(projectile-hit-event-data), + projectile-launch-event(projectile-launch-event-data), + sheep-dye-wool-event(sheep-dye-wool-event-data), + sheep-regrow-wool-event(sheep-regrow-wool-event-data), + slime-split-event(slime-split-event-data), + strider-temperature-change-event(strider-temperature-change-event-data), + villager-acquire-trade-event(villager-acquire-trade-event-data), + villager-career-change-event(villager-career-change-event-data), + villager-replenish-trade-event(villager-replenish-trade-event-data), + warden-anger-change-event(warden-anger-change-event-data), + area-effect-cloud-apply-event(area-effect-cloud-apply-event-data), + arrow-body-count-change-event(arrow-body-count-change-event-data), + bat-toggle-sleep-event(bat-toggle-sleep-event-data), + creeper-power-event(creeper-power-event-data), + entity-combust-by-block-event(entity-combust-by-block-event-data), + entity-combust-by-entity-event(entity-combust-by-entity-event-data), + entity-knockback-by-entity-event(entity-knockback-by-entity-event-data), + entity-portal-enter-event(entity-portal-enter-event-data), + entity-portal-exit-event(entity-portal-exit-event-data), + entity-remove-event(entity-remove-event-data), + entity-target-block-event(entity-target-block-event-data), + entity-unleash-event(entity-unleash-event-data), + exp-bottle-event(exp-bottle-event-data), + horse-jump-event(horse-jump-event-data), + lingering-potion-splash-event(lingering-potion-splash-event-data), + pig-zap-event(pig-zap-event-data), + pig-zombie-anger-event(pig-zombie-anger-event-data), + potion-splash-event(potion-splash-event-data), + spawner-spawn-event(spawner-spawn-event-data), + trial-spawner-spawn-event(trial-spawner-spawn-event-data), + villager-reputation-change-event(villager-reputation-change-event-data), + async-player-chat-event(async-player-chat-event-data), + async-player-pre-login-event(async-player-pre-login-event-data), + player-advancement-done-event(player-advancement-done-event-data), + player-animation-event(player-animation-event-data), + player-armor-stand-manipulate-event(player-armor-stand-manipulate-event-data), + player-bucket-entity-event(player-bucket-entity-event-data), + player-changed-world-event(player-changed-world-event-data), + player-channel-event(player-channel-event-data), + player-command-preprocess-event(player-command-preprocess-event-data), + player-edit-book-event(player-edit-book-event-data), + player-elytra-boost-event(player-elytra-boost-event-data), + player-exp-cooldown-change-event(player-exp-cooldown-change-event-data), + player-harvest-block-event(player-harvest-block-event-data), + player-hide-entity-event(player-hide-entity-event-data), + player-item-break-event(player-item-break-event-data), + player-item-mend-event(player-item-mend-event-data), + player-kick-event(player-kick-event-data), + player-leash-entity-event(player-leash-entity-event-data), + player-level-change-event(player-level-change-event-data), + player-locale-change-event(player-locale-change-event-data), + player-name-entity-event(player-name-entity-event-data), + player-open-sign-event(player-open-sign-event-data), + player-portal-event(player-portal-event-data), + player-pre-login-event(player-pre-login-event-data), + player-riptide-event(player-riptide-event-data), + player-shear-entity-event(player-shear-entity-event-data), + player-show-entity-event(player-show-entity-event-data), + player-spawn-change-event(player-spawn-change-event-data), + player-statistic-increment-event(player-statistic-increment-event-data), + player-swap-hands-event(player-swap-hands-event-data), + player-take-lectern-book-event(player-take-lectern-book-event-data), + player-unleash-entity-event(player-unleash-entity-event-data), + player-velocity-event(player-velocity-event-data), + player-input-event(player-input-event-data), + player-interact-at-entity-event(player-interact-at-entity-event-data), + player-links-send-event(player-links-send-event-data), + player-pickup-arrow-event(player-pickup-arrow-event-data), + player-recipe-book-click-event(player-recipe-book-click-event-data), + player-recipe-book-settings-change-event(player-recipe-book-settings-change-event-data), + player-recipe-discover-event(player-recipe-discover-event-data), + player-register-channel-event(player-register-channel-event-data), + player-resource-pack-status-event(player-resource-pack-status-event-data), + player-spawn-location-event(player-spawn-location-event-data), + player-unregister-channel-event(player-unregister-channel-event-data), + raid-finish-event(raid-finish-event-data), + raid-spawn-wave-event(raid-spawn-wave-event-data), + raid-stop-event(raid-stop-event-data), + raid-trigger-event(raid-trigger-event-data), + lightning-strike-event(lightning-strike-event-data), + } +} + +interface server { + use player.{player, ban-player-options, ban-ip-options, server-link, known-server-link, server-link-label}; + use common.{game-mode}; + use %world.{%world}; + use text.{text-component}; + use uuid.{uuid}; + use recipe.{recipe-manager}; + use enchantments.{enchantment-manager, custom-enchantment}; + use permission.{permission-level}; + use advancement.{advancement-info}; + use datapack.{datapack-manager, datapack-info}; + + /// Represents an operator entry in the ops configuration. + record op-entry { + uuid: uuid, + name: string, + level: permission-level, + bypasses-player-limit: bool, + } + + /// Interface for querying and managing server operators. + resource op-manager { + /// Checks if a player UUID is currently an operator. + is-op: func(id: uuid) -> bool; + /// Retrieves the operator entry for a player UUID, if present. + get-op: func(id: uuid) -> option; + /// Gets the effective permission level for a player UUID (returns zero if not op). + get-permission-level: func(id: uuid) -> permission-level; + /// Grants operator status to a player (online or offline) with the specified level and bypass setting. + op-player: func(name: string, id: uuid, level: permission-level, bypasses-player-limit: bool); + /// Revokes operator status from a player (online or offline). Returns true if the player was previously op. + deop-player: func(id: uuid) -> bool; + /// Returns a list of all operator entries on the server. + list-ops: func() -> list; + } + + /// Represents a banned player entry in the ban list. + record banned-player-entry { + uuid: uuid, + name: string, + created: string, + source: string, + expires: option, + reason: string, + } + + /// Represents a banned IP entry in the IP ban list. + record banned-ip-entry { + ip: string, + created: string, + source: string, + expires: option, + reason: string, + } + + /// Global manager for player and IP bans. + resource ban-manager { + /// Checks if a player UUID is currently banned. + is-player-banned: func(id: uuid) -> bool; + /// Retrieves the ban entry for a player UUID, if banned. + get-player-ban: func(id: uuid) -> option; + /// Bans a player by name and UUID with the specified options (works for online and offline players). + ban-player: func(name: string, id: uuid, options: ban-player-options); + /// Removes a player ban by UUID. Returns true if the player was banned. + unban-player: func(id: uuid) -> bool; + /// Returns all currently active player bans. + list-player-bans: func() -> list; + /// Checks if an IP address is currently banned. + is-ip-banned: func(ip: string) -> bool; + /// Retrieves the ban entry for an IP address, if banned. + get-ip-ban: func(ip: string) -> option; + /// Bans an IP address with the specified options. + ban-ip: func(ip: string, options: ban-ip-options); + /// Removes an IP ban. Returns true if the IP was banned. + unban-ip: func(ip: string) -> bool; + /// Returns all currently active IP bans. + list-ip-bans: func() -> list; + } + + /// Represents a player entry in the server whitelist. + record whitelist-entry { + uuid: uuid, + name: string, + } + + /// Global manager for the server whitelist. + resource whitelist-manager { + /// Returns whether the whitelist is currently enabled. + is-enabled: func() -> bool; + /// Enables or disables the server whitelist. If enabled and enforce-whitelist is set, kicks non-whitelisted players. + set-enabled: func(enabled: bool); + /// Checks if a player UUID is on the whitelist. + is-whitelisted: func(id: uuid) -> bool; + /// Adds a player to the whitelist (online or offline). Returns true if newly added. + add-player: func(name: string, id: uuid) -> bool; + /// Removes a player from the whitelist. Returns true if the player was on the whitelist. + remove-player: func(id: uuid) -> bool; + /// Returns all whitelisted player entries. + list-entries: func() -> list; + } + + /// Represents the difficulty setting of a Minecraft server. + enum difficulty { + /// Hostile mobs do not spawn. Players regain health automatically. + peaceful, + /// Hostile mobs deal less damage. + easy, + /// Standard Minecraft difficulty. + normal, + /// Hostile mobs deal more damage. + hard, + } + + /// Represents the three main Minecraft dimensions. + enum dimension { + overworld, + nether, + end, + } + + record sys-info { + cpu-count: option, + total-memory: option, + used-memory: option, + os-name: option, + os-version: option, + pumpkin-version: string, + } + + variant command-sender { + console, + player(player), + } + + /// Represents the global server instance. + resource server { + /// Returns system information (CPU, Memory, OS). + /// Fields are returned only if the plugin has the corresponding permissions. + get-sys-info: func() -> sys-info; + /// Returns the current difficulty level of the server. + get-difficulty: func() -> difficulty; + /// Returns the total number of players currently connected to the server. + get-player-count: func() -> u32; + /// Returns the rolling average Milliseconds Per Tick (MSPT). + /// A value below 50.0 is required for a stable 20 TPS. + get-mspt: func() -> f64; + /// Returns the effective Ticks Per Second (TPS). + /// Ideal value is 20.0. + get-tps: func() -> f64; + /// Returns a list of all online players across all worlds. + get-all-players: func() -> list; + /// Searches for a player by their exact name. + get-player-by-name: func(name: string) -> option; + /// Searches for a player by their UUID string. + get-player-by-uuid: func(id: uuid) -> option; + /// Returns a list of all worlds on this server. + get-all-worlds: func() -> list<%world>; + /// Gets a world by its dimension name (e.g., "minecraft:overworld") or custom world name (e.g., "world", "arena_1"). + get-world-by-name: func(name: string) -> option<%world>; + /// Checks if a world exists by name or dimension. + has-world: func(name: string) -> bool; + execute-command: func(command: string, sender: command-sender); + /// Creates or loads a world by its name and dimension. + /// If a world with the given name already exists, it will be returned. + create-world: func(name: string, dimension: dimension) -> %world; + /// Unloads and saves a world by its name or dimension. + /// Returns an error if the world cannot be found, is the primary/default world, or still has players inside. + unload-world: func(name: string) -> result<_, string>; + /// Saves all players, player advancements, and loaded worlds to disk. + save-all: func() -> result<_, string>; + /// Returns a list of all online players in a specific world. + get-players-in-world: func(world-ref: %world) -> list; + /// Returns the number of online players in a specific world. + get-player-count-in-world: func(world-ref: %world) -> u32; + /// Broadcasts a system chat message to all players. + broadcast: func(message: string); + /// Deletes a signed chat message from all players' chat windows using its 256-byte signature. + delete-message-by-signature: func(signature: list); + /// Deletes a signed chat message from all players' chat windows using its signature cache ID. + delete-message-by-id: func(signature-id: s32); + /// Broadcasts a tab list header and footer to all players. + broadcast-tab-list-header-footer: func(header: text-component, footer: text-component); + /// Returns the maximum number of players allowed on the server. + get-max-players: func() -> u32; + /// Returns whether the server is in hardcore mode. + is-hardcore: func() -> bool; + /// Returns whether the server is in online mode (authenticates with Mojang). + is-online-mode: func() -> bool; + /// Returns the server's Message of the Day (MOTD). + get-motd: func() -> string; + /// Returns whether the server has a whitelist enabled. + has-whitelist: func() -> bool; + /// Returns whether the server allows the Nether dimension. + get-allow-nether: func() -> bool; + /// Returns whether the server allows the End dimension. + get-allow-end: func() -> bool; + /// Returns the server's maximum view distance. + get-view-distance: func() -> u8; + /// Returns the server's maximum simulation distance. + get-simulation-distance: func() -> u8; + /// Returns the server's default gamemode. + get-default-gamemode: func() -> game-mode; + /// Returns the recipe manager to register custom recipes. + get-recipe-manager: func() -> recipe-manager; + /// Returns the operator manager to query or modify server operators. + get-op-manager: func() -> op-manager; + /// Returns the global ban manager for querying and modifying player and IP bans. + get-ban-manager: func() -> ban-manager; + /// Returns the global whitelist manager for querying and modifying the server whitelist. + get-whitelist-manager: func() -> whitelist-manager; + /// Returns detailed information about an advancement by its ID (e.g., "minecraft:story/mine_stone" or "story/mine_stone"). + get-advancement: func(id: string) -> option; + /// Returns a list of all registered advancement IDs on the server. + get-all-advancement-ids: func() -> list; + /// Returns the global enchantment manager for registering and querying custom enchantments. + get-enchantment-manager: func() -> enchantment-manager; + /// Returns information about an enchantment by its ID (vanilla or custom). + get-enchantment: func(id: string) -> option; + /// Returns a list of all registered enchantment IDs (custom and vanilla) on the server. + get-all-enchantment-ids: func() -> list; + /// Returns the global datapack manager for inspecting, enabling, disabling, and reloading datapacks. + get-datapack-manager: func() -> datapack-manager; + /// Broadcasts custom server links to all connected players (displayed in the client Esc pause menu in 1.21+). + set-server-links: func(links: list); + } +} + +interface command { + use %world.{%world, entity}; + use player.{player}; + use block-entity.{command-block-entity}; + use common.{position, block-pos, locale, game-mode}; + use item-stack.{item-stack}; + use server.{server, difficulty}; + use text.{text-component}; + + variant command-error { + invalid-consumption(option), + invalid-requirement, + permission-denied, + command-failed(text-component), + } + + resource command-node { + literal: static func(name: string) -> command-node; + argument: static func(name: string, %type: argument-type) -> command-node; + then: func(node: command-node); + execute-with-handler-id: func(handler-id: u32); + suggest-with-handler-id: func(handler-id: u32); + require-with-handler-id: func(handler-id: u32); + } + + record suggestion-request { + input: string, + cursor: u32, + start: u32, + remaining: string, + } + + record command-suggestion { + value: string, + tooltip: option, + } + + record command-suggestions { + start: u32, + length: u32, + values: list, + } + + record entity-argument { + single: bool, + players-only: bool, + } + + variant command-sender-type { + rcon, + console, + player(player), + command-block(tuple), + dummy, + } + + enum permission-level { + zero, + one, + two, + three, + four, + } + + resource command-sender { + get-command-sender-type: func() -> command-sender-type; + get-name: func() -> string; + send-message: func(text: text-component); + send-system-message: func(text: text-component); + send-error: func(text: text-component); + set-success-count: func(count: s32); + is-player: func() -> bool; + is-console: func() -> bool; + as-player: func() -> option; + permission-level: func() -> permission-level; + has-permission-level: func(level: permission-level) -> bool; + has-permission: func(server: borrow, node: string) -> bool; + position: func() -> option; + %world: func() -> option<%world>; + get-locale: func() -> locale; + should-receive-feedback: func() -> bool; + should-broadcast-console-to-ops: func() -> bool; + should-track-output: func() -> bool; + } + + enum string-type { + single-word, + quotable, + greedy, + } + + variant argument-type { + %bool, + float(tuple, option>), + double(tuple, option>), + integer(tuple, option>), + long(tuple, option>), + %string(string-type), + entities, + entity, + players, + game-profile, + block-pos, + column-pos, + position3d, + position2d, + block-state, + block-predicate, + item, + item-predicate, + color, + component, + style, + message, + nbt-compound-tag, + nbt-tag, + nbt-path, + objective, + objective-criteria, + operation, + particle, + angle, + rotation, + scoreboard-slot, + score-holder(bool), + swizzle, + team, + item-slot, + resource-location, + mob-effect, + function, + entity-anchor, + int-range, + float-range, + dimension, + gamemode, + difficulty, + time(option), + %resource(string), + resource-or-tag(string), + resource-or-tag-key(string), + resource-key(string), + template-mirror, + template-rotation, + uuid, + } + + enum suggestion-type { + ask-server, + all-recipes, + available-sounds, + available-biomes, + summonable-entities, + } + + enum bossbar-color { + pink, + blue, + red, + green, + yellow, + purple, + white, + } + + enum bossbar-style { + no-division, + notches6, + notches10, + notches12, + notches20, + } + + enum sound-category { + master, + music, + records, + weather, + blocks, + hostile, + neutral, + players, + ambient, + voice, + } + + enum entity-anchor { + eyes, + feet, + } + + variant number { + %float64(f64), + %float32(f32), + int32(s32), + int64(s64), + } + + variant not-in-bounds { + lower-bound(tuple), + upper-bound(tuple), + } + + variant arg { + simple(string), + msg(string), + %bool(bool), + item(string), + item-predicate(string), + resource-location(string), + block(string), + block-predicate(string), + time(s32), + num(result), + block-pos(block-pos), + pos3d(tuple), + pos2d(tuple), + rotation(tuple), + gamemode(game-mode), + difficulty(difficulty), + players(list), + particle(string), + text-component(text-component), + bossbar-color(bossbar-color), + bossbar-style(bossbar-style), + sound-category(sound-category), + damage-type(string), + effect(string), + enchantment(string), + advancement(string), + entity-anchor(entity-anchor), + } + + resource consumed-args { + get-value: func(key: string) -> arg; + } + + resource command { + /// First name is primary, rest are aliases + constructor(names: list, description: string); + then: func(node: command-node); + execute-with-handler-id: func(handler-id: u32); + } +} + +/// The core context provided to a plugin during initialization and event handling. +interface context { + use server.{server}; + use event.{event-type, event-priority}; + use command.{command}; + use permission.{permission}; + + /// Verified marketplace metadata for signed plugins. + record marketplace-metadata { + /// The marketplace base URL where this plugin is registered. + marketplace-url: string, + /// The unique plugin ID on the marketplace. + plugin-id: s64, + /// The canonical plugin name. + plugin-name: string, + /// The semver version string of the plugin. + version: string, + /// Developer ID. + dev-id: s64, + /// Developer display name or username. + dev-name: string, + /// Whether this is a paid marketplace plugin. + is-paid: bool, + /// The buyer / licensee user ID (0 for free/open-source). + user-id: s64, + /// Unique license key issued to the buyer, if paid. + license-key: option, + /// ISO-8601 timestamp of when this binary/license was issued. + issued-at: string, + } + + /// A contextual handle for plugin-related operations. + resource context { + /// Registers a handler for a specific event. + /// + /// * `handler-id`: Unique ID for the event handler. + /// * `event-type`: The type of event to listen for. + /// * `event-priority`: When this handler should be called relative to others. + /// * `blocking`: Whether the event should wait for this handler to finish. + register-event: func(handler-id: u32, event-type: event-type, event-priority: event-priority, blocking: bool); + /// Registers a new command. + /// + /// * `command`: The command definition. + /// * `permission`: The required permission node to execute this command. + register-command: func(command: command, permission: string); + /// Registers a permission node with the server. + register-permission: func(permission: permission) -> result<_, string>; + /// Returns the path to the plugin's private data folder. + get-data-folder: func() -> string; + /// Returns the global server instance. + get-server: func() -> server; + /// Returns verified marketplace metadata if this plugin binary is signed, or none if unsigned. + get-marketplace-metadata: func() -> option; + } +} + +world plugin { + /// --- Host-provided imports --- + /// Provides logging capabilities to the plugin. + import logging; + import common; + import text; + import attributes; + import data-components; + import enchantments; + import item-stack; + import screens; + import inventory; + /// Provides GUI creation and management. + import gui; + /// Provides scoreboard management. + import scoreboard; + import block-entity; + import particles; + import sounds; + import entity-types; + import biomes; + import damage-types; + import game-rules; + import uuid; + import %world; + import permission; + import forms; + import java-dialogs; + import java-packets; + import bedrock-packets; + import status-effect; + import advancement; + import statistics; + import entity-statuses; + import player; + import recipe; + import datapack; + /// Provides global server information and player lookup. + import server; + /// Provides command registration and argument parsing. + import command; + import event; + /// Provides the plugin execution context. + import context; + /// Provides internationalization and translation support. + import i18n; + /// Provides task scheduling for delayed or repeating logic. + import scheduler; + /// Provides entity types and manipulation. + import entity; + /// Provides boss bar creation and management. + import boss-bar; + /// Provides 1 : 1 inter-plugin communication + import ipc; + /// Provides Display and Interaction entities. + import display; + /// Provides game event types. + import game-events; + /// Provides potion types. + import potions; + use context.{context}; + use event.{event}; + use server.{server as server-instance}; + use command.{command-sender, consumed-args, command-error, command-suggestions, suggestion-request}; + use %world.{entity, chunk-buffer, generation-phase}; + use ipc.{plugin-id, ipc-message}; + + /// --- Plugin-provided exports --- + /// Called by the host once to initialize the plugin. + /// Internal use only; plugins should use the `register_plugin!` macro. + export init-plugin: func(); + /// Called when the plugin is being loaded. + /// Use this to register commands, events, and perform initial setup. + export on-load: func(context: context) -> result<_, string>; + /// Called when the plugin is being unloaded. + /// Use this to save data and clean up resources. + export on-unload: func(context: context) -> result<_, string>; + /// Dispatches an event to the plugin for handling. + export handle-event: func(event-id: u32, server: server-instance, event: event) -> event; + /// Dispatches a command execution to the plugin. + export handle-command: func(command-id: u32, sender: command-sender, server: server-instance, args: consumed-args) -> result; + /// Dispatches a command suggestion request to the plugin. + export handle-command-suggestion: func(handler-id: u32, sender: command-sender, server: server-instance, request: suggestion-request) -> command-suggestions; + /// Dispatches a scheduled task execution to the plugin. + export handle-task: func(handler-id: u32, server: server-instance); + /// Processes an incoming message from another plugin if possible, and returns (a possibly empty) response. + export handle-ipc-message: func(sender: plugin-id, message: ipc-message) -> result; + export handle-ai-goal-can-start: func(goal-id: u32, server: server-instance, entity: entity) -> bool; + export handle-ai-goal-should-continue: func(goal-id: u32, server: server-instance, entity: entity) -> bool; + export handle-ai-goal-start: func(goal-id: u32, server: server-instance, entity: entity); + export handle-ai-goal-tick: func(goal-id: u32, server: server-instance, entity: entity); + export handle-ai-goal-stop: func(goal-id: u32, server: server-instance, entity: entity); + /// Dispatches a chunk generation phase to the plugin. + export handle-generate-phase: func(generator-id: u32, phase: generation-phase, chunk: chunk-buffer); + /// Provides plugin metadata (name, version, etc.) to the host. + export metadata; +} diff --git a/src/pumpkin.zig b/src/pumpkin.zig new file mode 100644 index 0000000..b49f710 --- /dev/null +++ b/src/pumpkin.zig @@ -0,0 +1,307 @@ +//! Zig bindings for Pumpkin's plugin API. +//! +//! The namespaces below mirror the WIT interfaces one to one and are generated. +//! What's written by hand here is the glue a plugin needs to get going: +//! `register`, typed event and task handlers, `cmd` for commands, `msg` for +//! text components and `std.log` support. +//! +//! Whatever the API hands out is only good until the current callback returns: +//! strings, slices and records live in a per-call arena and handles are +//! released along with it. Call `keep` on a handle to hold on to it, from then +//! on it is yours to `deinit`. Functions that take a handle over are marked +//! "Consumes" in their docs. + +const std = @import("std"); + +pub const abi = @import("abi.zig"); +pub const cmd = @import("cmd.zig"); +pub const msg = @import("msg.zig"); +const wit = @import("wit.zig"); + +pub const advancement = wit.advancement; +pub const attributes = wit.attributes; +pub const bedrock_packets = wit.bedrock_packets; +pub const biomes = wit.biomes; +pub const block_entity = wit.block_entity; +pub const boss_bar = wit.boss_bar; +pub const command = wit.command; +pub const common = wit.common; +pub const context = wit.context; +pub const damage_types = wit.damage_types; +pub const data_components = wit.data_components; +pub const datapack = wit.datapack; +pub const display = wit.display; +pub const enchantments = wit.enchantments; +pub const entity = wit.entity; +pub const entity_statuses = wit.entity_statuses; +pub const entity_types = wit.entity_types; +pub const event = wit.event; +pub const forms = wit.forms; +pub const game_events = wit.game_events; +pub const game_rules = wit.game_rules; +pub const gui = wit.gui; +pub const i18n = wit.i18n; +pub const inventory = wit.inventory; +pub const ipc = wit.ipc; +pub const item_stack = wit.item_stack; +pub const java_dialogs = wit.java_dialogs; +pub const java_packets = wit.java_packets; +pub const logging = wit.logging; +pub const particles = wit.particles; +pub const permission = wit.permission; +pub const player = wit.player; +pub const potions = wit.potions; +pub const recipe = wit.recipe; +pub const scheduler = wit.scheduler; +pub const scoreboard = wit.scoreboard; +pub const screens = wit.screens; +pub const server = wit.server; +pub const sounds = wit.sounds; +pub const statistics = wit.statistics; +pub const status_effect = wit.status_effect; +pub const text = wit.text; +pub const uuid = wit.uuid; +pub const world = wit.world; + +pub const Context = context.Context; +pub const Server = server.Server; +pub const Player = player.Player; +pub const Entity = world.Entity; +pub const World = world.World; +pub const TextComponent = text.TextComponent; +pub const Event = event.Event; +pub const EventType = event.EventType; +pub const EventPriority = event.EventPriority; +pub const CommandSender = command.CommandSender; +pub const ConsumedArgs = command.ConsumedArgs; +pub const CommandError = command.CommandError; +pub const CommandResult = abi.Result(i32, CommandError); + +pub const Metadata = struct { + name: []const u8, + version: []const u8, + authors: []const []const u8 = &.{}, + description: []const u8 = "", + dependencies: []const []const u8 = &.{}, + permissions: []const []const u8 = &.{}, +}; + +/// Plug this into `std_options.logFn` to route `std.log` to the server console. +pub fn logFn( + comptime level: std.log.Level, + comptime scope: @EnumLiteral(), + comptime format: []const u8, + args: anytype, +) void { + const prefix = if (scope == .default) "" else "(" ++ @tagName(scope) ++ ") "; + const message = std.fmt.allocPrint(abi.arena(), prefix ++ format, args) catch return; + logging.log(switch (level) { + .err => .@"error", + .warn => .warn, + .info => .info, + .debug => .debug, + }, message); +} + +pub const EventOptions = struct { + priority: EventPriority = .normal, + /// Whether the server waits for the handler before carrying on. + /// Changes made to the event are only seen when this is set. + blocking: bool = true, +}; + +pub fn EventData(comptime event_type: EventType) type { + return @FieldType(Event, @tagName(event_type)); +} + +/// Registers `handler` for one kind of event. It gets the payload of exactly +/// that event and may edit it in place, e.g. set `cancelled`. +pub fn on( + ctx: Context, + comptime event_type: EventType, + comptime handler: fn (Server, *EventData(event_type)) void, + options: EventOptions, +) void { + const glue = struct { + fn dispatch(srv: Server, ev: *Event) void { + handler(srv, &@field(ev, @tagName(event_type))); + } + }; + ctx.registerEvent(handlerId(&glue.dispatch), event_type, options.priority, options.blocking); +} + +pub const EventHandler = fn (Server, *Event) void; +pub const CommandHandler = fn (CommandSender, Server, ConsumedArgs) CommandResult; +pub const SuggestionHandler = fn (CommandSender, Server, command.SuggestionRequest) command.CommandSuggestions; +pub const TaskHandler = fn (Server) void; +pub const GenerateHandler = fn (world.GenerationPhase, world.ChunkBuffer) void; + +pub const AiGoal = struct { + canStart: *const fn (Server, Entity) bool, + shouldContinue: *const fn (Server, Entity) bool, + start: *const fn (Server, Entity) void = noop, + tick: *const fn (Server, Entity) void = noop, + stop: *const fn (Server, Entity) void = noop, + + fn noop(_: Server, _: Entity) void {} +}; + +/// The server hands ids back untouched, so an id is simply the address of the +/// handler. Works for every `*-with-handler-id` style function in the API, +/// pass a pointer to a function of the matching `*Handler` type or to a +/// static `AiGoal`. +pub fn handlerId(handler: anytype) u32 { + return @intFromPtr(handler); +} + +pub fn runLater(comptime handler: TaskHandler, delay_ticks: u64) u32 { + return scheduler.scheduleDelayedTask(handlerId(&handler), delay_ticks); +} + +pub fn runEvery(comptime handler: TaskHandler, delay_ticks: u64, period_ticks: u64) u32 { + return scheduler.scheduleRepeatingTask(handlerId(&handler), delay_ticks, period_ticks); +} + +/// Registers what `Plugin.events` lists, each entry being `.event_name = handler` +/// or `.event_name = .{ handler, EventOptions{...} }`. +fn registerEvents(comptime Plugin: type, ctx: Context) void { + const table = Plugin.events; + inline for (@typeInfo(@TypeOf(table)).@"struct".fields) |field| { + const event_type = comptime std.meta.stringToEnum(EventType, field.name) orelse + @compileError("no event called '" ++ field.name ++ "'"); + const entry = @field(table, field.name); + if (@typeInfo(@TypeOf(entry)) == .@"fn") { + on(ctx, event_type, entry, .{}); + } else { + on(ctx, event_type, entry[0], entry[1]); + } + } +} + +/// Exports the plugin world for `Plugin`. Call it from a `comptime` block. +/// +/// `Plugin` needs a `pub const metadata: Metadata` and can have any of +/// pub const events = .{ .player_join_event = onJoin, ... } +/// pub const commands: []const cmd.Spec = &.{ ... } +/// pub fn onLoad(ctx: Context) !void +/// pub fn onUnload(ctx: Context) !void +/// pub fn onIpcMessage(sender: ipc.PluginId, message: ipc.IpcMessage) abi.Result(ipc.IpcMessage, []const u8) +/// +/// Events and commands are registered before `onLoad` runs. +pub fn register(comptime Plugin: type) void { + const glue = struct { + fn initPlugin() void {} + + fn getMetadata() wit.metadata.PluginMetadata { + const meta: Metadata = Plugin.metadata; + return .{ + .name = meta.name, + .version = meta.version, + .authors = meta.authors, + .description = meta.description, + .dependencies = meta.dependencies, + .permissions = meta.permissions, + }; + } + + fn onLoad(ctx: Context) abi.Result(void, []const u8) { + if (@hasDecl(Plugin, "events")) registerEvents(Plugin, ctx); + if (@hasDecl(Plugin, "commands")) { + const specs: []const cmd.Spec = Plugin.commands; + for (specs) |spec| cmd.register(ctx, spec) catch |err| return .{ .err = @errorName(err) }; + } + return lifecycle("onLoad", ctx); + } + + fn onUnload(ctx: Context) abi.Result(void, []const u8) { + return lifecycle("onUnload", ctx); + } + + fn lifecycle(comptime name: []const u8, ctx: Context) abi.Result(void, []const u8) { + if (!@hasDecl(Plugin, name)) return .ok; + @field(Plugin, name)(ctx) catch |err| return .{ .err = @errorName(err) }; + return .ok; + } + + fn handleEvent(id: u32, srv: Server, ev: Event) Event { + var out = ev; + handlerFromId(EventHandler, id)(srv, &out); + return out; + } + + fn handleCommand(id: u32, sender: CommandSender, srv: Server, args: ConsumedArgs) CommandResult { + return handlerFromId(CommandHandler, id)(sender, srv, args); + } + + fn handleCommandSuggestion( + id: u32, + sender: CommandSender, + srv: Server, + request: command.SuggestionRequest, + ) command.CommandSuggestions { + return handlerFromId(SuggestionHandler, id)(sender, srv, request); + } + + fn handleTask(id: u32, srv: Server) void { + handlerFromId(TaskHandler, id)(srv); + } + + fn handleIpcMessage(sender: ipc.PluginId, message: ipc.IpcMessage) abi.Result(ipc.IpcMessage, []const u8) { + if (@hasDecl(Plugin, "onIpcMessage")) return Plugin.onIpcMessage(sender, message); + return .{ .err = "this plugin does not take messages" }; + } + + fn aiCanStart(id: u32, srv: Server, mob: Entity) bool { + return goalFromId(id).canStart(srv, mob); + } + + fn aiShouldContinue(id: u32, srv: Server, mob: Entity) bool { + return goalFromId(id).shouldContinue(srv, mob); + } + + fn aiStart(id: u32, srv: Server, mob: Entity) void { + goalFromId(id).start(srv, mob); + } + + fn aiTick(id: u32, srv: Server, mob: Entity) void { + goalFromId(id).tick(srv, mob); + } + + fn aiStop(id: u32, srv: Server, mob: Entity) void { + goalFromId(id).stop(srv, mob); + } + + fn handleGeneratePhase(id: u32, phase: world.GenerationPhase, chunk: world.ChunkBuffer) void { + handlerFromId(GenerateHandler, id)(phase, chunk); + } + }; + + const exports = wit.exports; + exports.initPlugin(glue.initPlugin); + exports.getMetadata(glue.getMetadata); + exports.onLoad(glue.onLoad); + exports.onUnload(glue.onUnload); + exports.handleEvent(glue.handleEvent); + exports.handleCommand(glue.handleCommand); + exports.handleCommandSuggestion(glue.handleCommandSuggestion); + exports.handleTask(glue.handleTask); + exports.handleIpcMessage(glue.handleIpcMessage); + exports.handleAiGoalCanStart(glue.aiCanStart); + exports.handleAiGoalShouldContinue(glue.aiShouldContinue); + exports.handleAiGoalStart(glue.aiStart); + exports.handleAiGoalTick(glue.aiTick); + exports.handleAiGoalStop(glue.aiStop); + exports.handleGeneratePhase(glue.handleGeneratePhase); +} + +fn handlerFromId(comptime Fn: type, id: u32) *const Fn { + return @ptrFromInt(id); +} + +fn goalFromId(id: u32) *const AiGoal { + return @ptrFromInt(id); +} + +test { + _ = abi; +} diff --git a/src/wit.zig b/src/wit.zig new file mode 100644 index 0000000..4cad2ad --- /dev/null +++ b/src/wit.zig @@ -0,0 +1,48 @@ +// Generated by tools/gen.zig, do not edit. + +pub const attributes = @import("wit/attributes.zig"); +pub const biomes = @import("wit/biomes.zig"); +pub const common = @import("wit/common.zig"); +pub const damage_types = @import("wit/damage_types.zig"); +pub const data_components = @import("wit/data_components.zig"); +pub const datapack = @import("wit/datapack.zig"); +pub const entity_statuses = @import("wit/entity_statuses.zig"); +pub const entity_types = @import("wit/entity_types.zig"); +pub const game_events = @import("wit/game_events.zig"); +pub const game_rules = @import("wit/game_rules.zig"); +pub const i18n = @import("wit/i18n.zig"); +pub const ipc = @import("wit/ipc.zig"); +pub const logging = @import("wit/logging.zig"); +pub const metadata = @import("wit/metadata.zig"); +pub const particles = @import("wit/particles.zig"); +pub const permission = @import("wit/permission.zig"); +pub const potions = @import("wit/potions.zig"); +pub const scheduler = @import("wit/scheduler.zig"); +pub const screens = @import("wit/screens.zig"); +pub const sounds = @import("wit/sounds.zig"); +pub const statistics = @import("wit/statistics.zig"); +pub const status_effect = @import("wit/status_effect.zig"); +pub const text = @import("wit/text.zig"); +pub const advancement = @import("wit/advancement.zig"); +pub const enchantments = @import("wit/enchantments.zig"); +pub const forms = @import("wit/forms.zig"); +pub const item_stack = @import("wit/item_stack.zig"); +pub const inventory = @import("wit/inventory.zig"); +pub const block_entity = @import("wit/block_entity.zig"); +pub const gui = @import("wit/gui.zig"); +pub const java_dialogs = @import("wit/java_dialogs.zig"); +pub const recipe = @import("wit/recipe.zig"); +pub const scoreboard = @import("wit/scoreboard.zig"); +pub const uuid = @import("wit/uuid.zig"); +pub const bedrock_packets = @import("wit/bedrock_packets.zig"); +pub const java_packets = @import("wit/java_packets.zig"); +pub const world = @import("wit/world.zig"); +pub const display = @import("wit/display.zig"); +pub const entity = @import("wit/entity.zig"); +pub const player = @import("wit/player.zig"); +pub const boss_bar = @import("wit/boss_bar.zig"); +pub const event = @import("wit/event.zig"); +pub const server = @import("wit/server.zig"); +pub const command = @import("wit/command.zig"); +pub const context = @import("wit/context.zig"); +pub const exports = @import("wit/exports.zig"); diff --git a/src/wit/advancement.zig b/src/wit/advancement.zig new file mode 100644 index 0000000..e2f14f3 --- /dev/null +++ b/src/wit/advancement.zig @@ -0,0 +1,41 @@ +// Generated by tools/gen.zig, do not edit. + +const text = @import("text.zig"); + +pub const TextComponent = text.TextComponent; + +/// Frame type for an advancement. +pub const FrameType = enum(u8) { + task, + challenge, + goal, +}; + +/// Display information for an advancement. +pub const AdvancementDisplay = struct { + title: TextComponent, + description: TextComponent, + frame: FrameType, + show_toast: bool, + hidden: bool, + announce_to_chat: bool, + background: ?[]const u8, + x: f32, + y: f32, +}; + +/// Detailed information about an advancement. +pub const AdvancementInfo = struct { + id: []const u8, + parent_id: ?[]const u8, + criteria: []const []const u8, + display: ?AdvancementDisplay, +}; + +/// Represents progress of an advancement for a player. +pub const AdvancementProgress = struct { + advancement_id: []const u8, + done: bool, + awarded_criteria: []const []const u8, + remaining_criteria: []const []const u8, +}; diff --git a/src/wit/attributes.zig b/src/wit/attributes.zig new file mode 100644 index 0000000..fea871f --- /dev/null +++ b/src/wit/attributes.zig @@ -0,0 +1,56 @@ +// Generated by tools/gen.zig, do not edit. + +pub const Attribute = enum(u8) { + air_drag_modifier, + armor, + armor_toughness, + attack_damage, + attack_knockback, + attack_speed, + below_name_distance, + block_break_speed, + block_interaction_range, + bounciness, + burning_time, + camera_distance, + explosion_knockback_resistance, + entity_interaction_range, + fall_damage_multiplier, + flying_speed, + follow_range, + friction_modifier, + gravity, + jump_strength, + knockback_resistance, + luck, + max_absorption, + max_health, + mining_efficiency, + movement_efficiency, + movement_speed, + name_tag_distance, + oxygen_bonus, + safe_fall_distance, + scale, + sneaking_speed, + spawn_reinforcements, + step_height, + submerged_mining_speed, + sweeping_damage_ratio, + tempt_range, + water_movement_efficiency, + waypoint_transmit_range, + waypoint_receive_range, +}; + +pub const ModifierOperation = enum(u8) { + add, + multiply_base, + multiply_total, +}; + +pub const AttributeModifier = struct { + id: []const u8, + amount: f64, + operation: ModifierOperation, +}; diff --git a/src/wit/bedrock_packets.zig b/src/wit/bedrock_packets.zig new file mode 100644 index 0000000..ebf86e8 --- /dev/null +++ b/src/wit/bedrock_packets.zig @@ -0,0 +1,1901 @@ +// Generated by tools/gen.zig, do not edit. + +const uuid = @import("uuid.zig"); + +pub const Uuid = uuid.Uuid; + +pub const ActorEventId = enum(u8) { + none, + jump, + hurt, + death, + start_attacking, + stop_attacking, + taming_failed, + taming_succeeded, + shake_wetness, + eat_grass, + fishhook_bubble, + fishhook_fish_pos, + fishhook_hook_time, + fishhook_tease, + squid_fleeing, + zombie_converting, + play_ambient, + spawn_alive, + start_offer_flower, + stop_offer_flower, + love_hearts, + villager_angry, + villager_happy, + witch_hat_magic, + fireworks_explode, + in_love_hearts, + silverfish_merge_animation, + guardian_attack_sound, + drink_potion, + throw_potion, + prime_tnt_cart, + prime_creeper, + air_supply, + deprecated_add_player_levels, + guardian_mining_fatigue, + agent_swing_arm, + dragon_start_death_anim, + ground_dust, + shake, + feed, + baby_age, + instant_death, + notify_trade, + leash_destroyed, + caravan_updated, + talisman_activate, + deprecated_update_structure_feature, + player_spawned_mob, + puke, + update_stack_size, + start_swimming, + balloon_pop, + treasure_hunt, + summon_agent, + finished_charging_item, + actor_grow_up, + vibration_detected, + drink_milk, + shake_wetness_stop, + kinetic_damage_dealt, + hurt_without_receiving_damage, +}; + +pub const SActorEvent = struct { + target_runtime_id: i64, + event_id: ActorEventId, + data: i32, + fire_at_position: ?struct { f64, f64, f64 }, +}; + +pub const AnimateAction = enum(u8) { + no_action, + swing_arm, + wake_up, + critical_hit, + magic_critical_hit, +}; + +pub const ActorSwingSource = enum(u8) { + none, + build, + mine, + interact, + attack, + use_item, + throw_item, + drop_item, + event, +}; + +pub const SAnimate = struct { + action: AnimateAction, + target_actor_runtime_id: i64, + data: f32, + swing_source: ?ActorSwingSource, +}; + +pub const SBlockPickRequest = struct { + position: struct { i32, i32, i32 }, + with_data: bool, + max_slots: u8, +}; + +pub const SClientCacheBlobStatus = struct { + miss_hashes: []const i64, + hit_hashes: []const i64, +}; + +pub const SClientCacheStatus = struct { + is_cache_supported: bool, +}; + +pub const CommandOriginData = struct { + r_type: []const u8, + uuid: Uuid, + request_id: []const u8, + player_id: i64, +}; + +pub const SCommandRequest = struct { + command: []const u8, + origin: CommandOriginData, + is_internal: bool, + version: []const u8, +}; + +pub const SContainerClose = struct { + container_id: u8, + container_type: u8, + server_initiated_close: bool, +}; + +pub const SEmote = struct { + actor_runtime_id: i64, + emote_id: []const u8, + emote_length_ticks: i32, + xuid: []const u8, + platform_id: []const u8, + flags: u8, +}; + +pub const SEmoteList = struct { + runtime_id: i64, + emote_piece_ids: []const Uuid, +}; + +pub const Action = enum(u8) { + invalid, + stop_riding, + interact_update, + npc_open, + open_inventory, +}; + +pub const SInteract = struct { + action: Action, + target_runtime_id: i64, + position: ?struct { f64, f64, f64 }, +}; + +pub const InventoryActionSource = union(enum) { + container, + world, + creative, + todo, + unknown: i32, +}; + +pub const LegacySetItemSlot = struct { + container_id: u8, + slots: []const u8, +}; + +pub const StackRequestItem = struct { + identifier: ?[]const u8, + metadata_value: i32, + count: i32, + block_runtime_id: i32, + extra_data: []const u8, +}; + +pub const ItemStackRequestActionCreate = struct { + result_index: u8, +}; + +pub const ItemStackRequestActionBeaconPayment = struct { + primary_effect_id: i32, + secondary_effect_id: i32, +}; + +pub const ItemStackRequestActionMineBlock = struct { + hotbar_slot: i32, + predicted_durability: i32, + stack_id: i32, +}; + +pub const ItemStackRequestActionCraftRecipe = struct { + recipe_id: i32, + repetitions: u8, +}; + +pub const ItemStackRequestActionCraftRecipeAuto = struct { + recipe_id: i32, + repetitions: u8, +}; + +pub const ItemStackRequestActionCraftCreative = struct { + creative_item_id: i32, + repetitions: u8, +}; + +pub const ItemStackRequestActionOptional = struct { + recipe_id: i32, + filter_string_index: i32, +}; + +pub const ItemStackRequestActionGrindstone = struct { + recipe_id: i32, + repair_cost: i32, + repetitions: u8, +}; + +pub const ItemStackRequestActionLoom = struct { + pattern_id: []const u8, + repetitions: u8, +}; + +pub const ItemStackRequestActionCraftResultsDeprecated = struct { + result_items: []const StackRequestItem, + times_crafted: u8, +}; + +pub const LoadingScreenPacketType = enum(u8) { + start_loading_screen, + end_loading_screen, +}; + +pub const SLoadingScreen = struct { + loading_screen_packet_type: LoadingScreenPacketType, + loading_screen_id: ?i32, +}; + +pub const SLogin = struct { + protocol_version: i32, + jwt: []const u8, + raw_token: []const u8, +}; + +pub const SkinAnimation = struct { + frames: f64, + image: []const u8, + image_height: i32, + image_width: i32, + animation_type: i32, + animation_expression: i32, +}; + +pub const PersonaPiece = struct { + is_default: bool, + pack_id: []const u8, + piece_id: []const u8, + piece_type: []const u8, + product_id: []const u8, +}; + +pub const PersonaPieceTintColour = struct { + colours: []const []const u8, + piece_type: []const u8, +}; + +pub const ClientData = struct { + client_random_id: i64, + device_os: i32, + device_id: []const u8, + game_version: []const u8, + language_code: []const u8, + current_input_mode: i32, + default_input_mode: i32, + ui_profile: i32, + server_address: []const u8, + device_model: []const u8, + gui_scale: i32, + client_is_editor_capable: bool, + client_editor_connection_intent: i32, + max_view_distance: i32, + memory_tier: i32, + platform_type: i32, + graphics_mode: i32, + compatible_with_client_side_chunk_gen: bool, + platform_offline_id: []const u8, + platform_online_id: []const u8, + platform_user_id: []const u8, + self_signed_id: []const u8, + play_fab_id: []const u8, + third_party_name: []const u8, + third_party_name_only: bool, + skin_id: []const u8, + skin_data: []const u8, + skin_image_height: i32, + skin_image_width: i32, + skin_colour: []const u8, + arm_size: []const u8, + persona_skin: bool, + premium_skin: bool, + trusted_skin: bool, + override_skin: bool, + cape_data: []const u8, + cape_id: []const u8, + cape_image_height: i32, + cape_image_width: i32, + cape_on_classic_skin: bool, + skin_geometry: []const u8, + skin_geometry_version: []const u8, + skin_resource_patch: []const u8, + animated_image_data: []const SkinAnimation, + skin_animation_data: []const u8, + persona_pieces: []const PersonaPiece, + piece_tint_colours: []const PersonaPieceTintColour, +}; + +pub const SModalFormResponse = struct { + form_id: i32, + json_response: ?[]const u8, + form_cancel_reason: ?u8, +}; + +pub const SPacketViolationWarning = struct { + violation_type: i32, + violation_severity: i32, + violation_packet_id: i32, + violation_context: []const u8, +}; + +pub const PlayerActionType = enum(u8) { + unknown, + start_destroy_block, + abort_destroy_block, + stop_destroy_block, + get_updated_block, + drop_item, + start_sleeping, + stop_sleeping, + respawn, + start_jump, + start_sprinting, + stop_sprinting, + start_sneaking, + stop_sneaking, + creative_destroy_block, + change_dimension_ack, + start_gliding, + stop_gliding, + deny_destroy_block, + crack_block, + change_skin, + updated_enchanting_seed, + start_swimming, + stop_swimming, + start_spin_attack, + stop_spin_attack, + interact_with_block, + predict_destroy_block, + continue_destroy_block, + start_item_use_on, + stop_item_use_on, + handled_teleport, + missed_swing, + start_crawling, + stop_crawling, + start_flying, + stop_flying, + client_ack_server_data, + start_using_item, + internal_update, + count, +}; + +pub const SPlayerAction = struct { + player_runtime_id: i64, + action: PlayerActionType, + block_position: struct { i32, i32, i32 }, + result_pos: struct { i32, i32, i32 }, + face: i32, +}; + +pub const PlayerBlockAction = struct { + action: i32, + block_pos: struct { i32, i32, i32 }, + face: i32, +}; + +pub const InputMode = enum(u8) { + mouse, + touch, + game_pad, + motion_controller, +}; + +pub const PlayMode = enum(u8) { + normal, + teaser, + screen, + exit_level, + num_modes, +}; + +pub const InteractionModel = enum(u8) { + touch, + crosshair, + classic, +}; + +pub const InputData = enum(u8) { + ascend, + descend, + north_jump, + jump_down, + sprint_down, + change_height, + jumping, + auto_jumping_in_water, + sneaking, + sneak_down, + up, + down, + left, + right, + up_left, + up_right, + want_up, + want_down, + want_down_slow, + want_up_slow, + sprinting, + ascend_block, + descend_block, + sneak_toggle_down, + persist_sneak, + start_sprinting, + stop_sprinting, + start_sneaking, + stop_sneaking, + start_swimming, + stop_swimming, + start_jumping, + start_gliding, + stop_gliding, + perform_item_interaction, + perform_block_actions, + perform_item_stack_request, + handled_teleport, + emoting, + missed_swing, + start_crawling, + stop_crawling, + start_flying, + stop_flying, + client_ack_server_data, + client_predicted_vehicle, + paddling_left, + paddling_right, + block_breaking_delay_enabled, + horizontal_collision, + vertical_collision, + down_left, + down_right, + start_using_item, + camera_relative_movement_enabled, + rot_controlled_by_move_direction, + start_spin_attack, + stop_spin_attack, + is_hotbar_touch_only, + jump_released_raw, + jump_pressed_raw, + jump_current_raw, + sneak_released_raw, + sneak_pressed_raw, + sneak_current_raw, + internal_update, +}; + +pub const SPlayerHotbar = struct { + selected_slot: i32, + container_id: u8, + should_select_slot: bool, +}; + +pub const AbilityValue = union(enum) { + bool: bool, + float: f32, +}; + +pub const SRequestAbility = struct { + ability: i32, + value: AbilityValue, +}; + +pub const SRequestChunkRadius = struct { + chunk_radius: i32, + max_chunk_radius: u8, +}; + +pub const SRequestNetworkSettings = struct { + client_network_version: i32, +}; + +pub const SResourcePackClientResponse = struct { + response: u8, + download_size: i32, + pack_ids: []const []const u8, +}; + +pub const RespawnState = enum(u8) { + searching_for_spawn, + ready_to_spawn, + client_ready_to_spawn, +}; + +pub const SRespawn = struct { + position: struct { f64, f64, f64 }, + state: RespawnState, + player_runtime_id: i64, +}; + +pub const SSetLocalPlayerAsInitialized = struct { + player_id: i64, +}; + +pub const SSetPlayerInventoryOptions = struct { + left_inventory_tab: i32, + right_inventory_tab: i32, + filtering: bool, + layout_inv: i32, + layout_craft: i32, +}; + +pub const TextPacketType = enum(u8) { + raw, + chat, + translation, + popup, + jukebox_popup, + tip, + system, + whisper, + announcement, + json_whisper, + json, + json_announcement, +}; + +pub const SText = struct { + needs_translation: bool, + r_type: TextPacketType, + source_name: []const u8, + message: []const u8, + parameters: []const []const u8, + xuid: []const u8, + platform_chat_id: []const u8, + filtered_message: ?[]const u8, +}; + +pub const SyncedAttribute = struct { + attribute_name: []const u8, + min_value: f32, + current_value: f32, + max_value: f32, +}; + +pub const EnumData = struct { + name: []const u8, + values: []const i32, +}; + +pub const ChainedSubcommandRelationship = struct { + index: i32, + value: i32, +}; + +pub const ChainedSubcommandData = struct { + name: []const u8, + subcommand_values: []const ChainedSubcommandRelationship, +}; + +pub const ParamData = struct { + name: []const u8, + parse_symbol: i32, + is_optional: bool, + options: u8, +}; + +pub const OverloadData = struct { + is_chaining: bool, + parameter_data: []const ParamData, +}; + +pub const SoftEnumData = struct { + enum_name: []const u8, + enum_options: []const []const u8, +}; + +pub const ConstrainedValueData = struct { + enum_value_symbol: i32, + enum_symbol: i32, + constraint_indices: []const u8, +}; + +pub const CBlockActorData = struct { + block_position: struct { i32, i32, i32 }, + actor_data_tags: []const u8, +}; + +pub const CBlockEvent = struct { + block_position: struct { i32, i32, i32 }, + event_type: i32, + event_value: i32, +}; + +pub const CBossEvent = struct { + boss_entity_id: i64, + event_type: u8, + title: []const u8, + filtered_title: []const u8, + health_percentage: f32, + color: u8, + overlay: u8, +}; + +pub const CChangeDimension = struct { + dimension_id: i32, + position: struct { f64, f64, f64 }, + respawn: bool, + loading_screen_id: ?i32, +}; + +pub const CChunkRadiusUpdated = struct { + chunk_radius: i32, +}; + +pub const MissingBlobData = struct { + blob_id: i64, + blob_data: []const u8, +}; + +pub const CClientCacheMissResponse = struct { + missing_blobs: []const MissingBlobData, +}; + +pub const BuildPlatform = enum(u8) { + unknown, + google, + ios, + osx, + amazon, + gear_vr, + uwp, + win32, + dedicated, + tv_os, + sony, + nx, + xbox, + windows_phone, + linux, +}; + +pub const GameType = enum(u8) { + unknown, + survival, + creative, + adventure, + default, + spectator, +}; + +pub const PlayerPermissionLevel = enum(u8) { + visitor, + member, + operator, + custom, +}; + +pub const CommandPermissionLevel = enum(u8) { + any, + game_directors, + admin, + host, + owner, + internal, +}; + +pub const CommandData = struct { + name: []const u8, + description: []const u8, + flags: i32, + permission_level: CommandPermissionLevel, + alias_enum: i32, + command_data_chained_subcommand_indexes: []const i32, + overloads: []const OverloadData, +}; + +pub const CAvailableCommands = struct { + enum_values: []const []const u8, + chained_subcommand_values: []const []const u8, + post_fixes: []const []const u8, + enum_data: []const EnumData, + chained_subcommand_data: []const ChainedSubcommandData, + commands: []const CommandData, + soft_enums: []const SoftEnumData, + constraints: []const ConstrainedValueData, +}; + +pub const SerializedAbilitiesDataSerializedLayer = struct { + serialized_layer: i32, + abilities_set: i32, + ability_value: i32, + fly_speed: f32, + vertical_fly_speed: f32, + walk_speed: f32, +}; + +pub const SerializedAbilitiesData = struct { + target_player_raw_id: i64, + player_permissions: PlayerPermissionLevel, + command_permissions: CommandPermissionLevel, + layers: []const SerializedAbilitiesDataSerializedLayer, +}; + +pub const ActorLink = struct { + ridden_unique_id: i64, + rider_unique_id: i64, + link_type: u8, + immediate: bool, + rider_initiated: bool, + vehicle_angular_velocity: f32, +}; + +pub const CContainerOpen = struct { + container_id: u8, + container_type: u8, + position: struct { i32, i32, i32 }, + target_entity_id: i64, +}; + +pub const CCorrectPlayerMovePrediction = struct { + prediction_type: u8, + pos: struct { f64, f64, f64 }, + pos_delta: struct { f64, f64, f64 }, + rotation: struct { f64, f64 }, + vehicle_angular_velocity: ?f32, + on_ground: bool, + tick: i64, +}; + +pub const ItemDescriptorCount = struct { + item_identifier: []const u8, + metadata_value: i32, + count: i32, +}; + +pub const RecipeUnlockRequirement = struct { + context: i32, +}; + +pub const CreativeCategory = enum(u8) { + all, + construction, + nature, + equipment, + items, + item_command_only, + undefined, +}; + +pub const CDisconnect = struct { + reason: i32, + skip_message: bool, + message: []const u8, + filtered_message: []const u8, +}; + +pub const RuleValue = enum(u8) { + null, +}; + +pub const GameRule = struct { + rule_name: []const u8, + rule_can_be_modified: bool, + rule_value: RuleValue, +}; + +pub const CGamerulesChanged = struct { + rule_data: []const GameRule, +}; + +pub const ItemData = struct { + item_name: []const u8, + item_id: i32, + is_component_based: bool, + item_version: i32, + component_data: []const u8, +}; + +pub const CItemRegistry = struct { + items: []const ItemData, +}; + +pub const ItemStackResponseSlotInfo = struct { + requested_slot: u8, + slot: u8, + amount: u8, + item_stack_net_id: i32, + custom_name: []const u8, + filtered_custom_name: []const u8, + durability_correction: i32, +}; + +pub const CLevelEvent = struct { + event_id: i32, + position: struct { f64, f64, f64 }, + data: i32, +}; + +pub const LevelEvent = enum(u8) { + particles_destroy_block, + block_start_break, + block_stop_break, + block_update_break, +}; + +pub const CLevelSoundEvent = struct { + sound_event: []const u8, + position: struct { f64, f64, f64 }, + data: i32, + actor_identifier: []const u8, + is_baby: bool, + is_global: bool, + actor_unique_id: i64, + fire_at_position: ?struct { f64, f64, f64 }, +}; + +pub const CMobEffect = struct { + target_runtime_id: i64, + event_id: u8, + effect_id: i32, + effect_amplifier: i32, + show_particles: bool, + effect_duration_ticks: i32, + tick: i64, + ambient: bool, +}; + +pub const CModalFormRequest = struct { + form_id: i32, + form_ui_json: []const u8, +}; + +pub const CMoveActorAbsolute = struct { + actor_runtime_id: i64, + header: u8, + position: struct { f64, f64, f64 }, + rotation_x: u8, + rotation_y: u8, + rotation_y_head: u8, +}; + +pub const CMoveActorDelta = struct { + entity_runtime_id: i64, + flags: i32, + x: f32, + y: f32, + z: f32, + pitch: u8, + yaw: u8, + head_yaw: u8, + tick: i64, +}; + +pub const CMovePlayer = struct { + player_runtime_id: i64, + position: struct { f64, f64, f64 }, + pitch: f32, + yaw: f32, + head_yaw: f32, + mode: u8, + on_ground: bool, + riding_runtime_id: i64, + teleport_cause: i32, + teleport_source_entity_type: i32, + tick: i64, +}; + +pub const CNetworkChunkPublisherUpdate = struct { + pos_for_view: struct { i32, i32, i32 }, + new_radius: i32, + server_build_chunk_list: []const struct { f64, f64 }, +}; + +pub const CNetworkSettings = struct { + compression_threshold: i32, + compression_algorithm: i32, + client_throttle_enabled: bool, + client_throttle_threshold: u8, + client_throttle_scalar: f32, +}; + +pub const CPlayStatus = enum(u8) { + login_success, + outdated_client, + outdated_server, + player_spawn, + invalid_tenant, + edition_mismatch_edu_to_vanilla, + edition_mismatch_vanilla_to_edu, + server_full_sub_client, + editor_mismatch_editor_to_vanilla, + editor_mismatch_vanilla_to_editor, +}; + +pub const CPlayerHotbar = struct { + selected_slot: i32, + container_id: u8, + should_select_slot: bool, +}; + +pub const PieceTintColor = struct { + piece_type: []const u8, + colors: []const i32, +}; + +pub const Skin = struct { + skin_id: []const u8, + play_fab_id: []const u8, + resource_patch: []const u8, + image_width: i32, + image_height: i32, + skin_data: []const u8, + animations: []const SkinAnimation, + cape_width: i32, + cape_height: i32, + cape_data: []const u8, + geometry_data: []const u8, + animation_data: []const u8, + geometry_data_engine_version: []const u8, + cape_id: []const u8, + full_id: []const u8, + arm_size: []const u8, + skin_color: []const u8, + persona_pieces: []const PersonaPiece, + piece_tint_colors: []const PieceTintColor, + is_premium: bool, + is_persona: bool, + persona_cape_on_classic: bool, + is_primary_user: bool, + override_appearance: bool, + is_trusted: bool, + profile_hash: []const u8, +}; + +pub const PlayerListEntry = struct { + uuid: Uuid, + entity_unique_id: i64, + username: []const u8, + xuid: []const u8, + platform_chat_id: []const u8, + build_platform: BuildPlatform, + skin: Skin, + is_teacher: bool, + is_host: bool, + is_sub_client: bool, + player_color: []const u8, +}; + +pub const CPlayerList = struct { + action: u8, + entries: []const PlayerListEntry, +}; + +pub const CRemoveActor = struct { + target_actor_id: i64, +}; + +pub const CRemoveObjective = struct { + objective_name: []const u8, +}; + +pub const PackInstanceId = struct { + pack_id: []const u8, + version: []const u8, + sub_pack_name: []const u8, +}; + +pub const PackIdVersion = struct { + pack_uuid: Uuid, + pack_version: []const u8, +}; + +pub const PackInfoData = struct { + pack_id_version: PackIdVersion, + pack_size: i64, + content_key: []const u8, + subpack_name: []const u8, + content_identity: []const u8, + has_scripts: bool, + is_addon_pack: bool, + is_ray_tracing_capable: bool, + cdn_url: []const u8, +}; + +pub const CResourcePacksInfo = struct { + resource_pack_required: bool, + has_addon_packs: bool, + has_scripts: bool, + force_disable_vibrant_visuals: bool, + world_template_id_and_version: PackIdVersion, + resource_packs: []const PackInfoData, +}; + +pub const MetadataValue = union(enum) { + byte: u8, + short: i32, + int: i32, + float: f32, + string: []const u8, + compound_tag, + item_pos: struct { i32, i32, i32 }, + int64: i64, + vec3: struct { f64, f64, f64 }, +}; + +pub const PropertySyncData = struct { + int_entries_list: []const struct { i32, i32 }, + float_entries_list: []const struct { i32, f32 }, +}; + +pub const CAddActor = struct { + target_actor_id: i64, + target_runtime_id: i64, + actor_type: []const u8, + position: struct { f64, f64, f64 }, + velocity: struct { f64, f64, f64 }, + rotation: struct { f64, f64 }, + y_head_rotation: f32, + y_body_rotation: f32, + attributes_list: []const SyncedAttribute, + actor_data: []const u8, + synced_properties: PropertySyncData, + actor_links: []const ActorLink, +}; + +pub const CSetActorData = struct { + target_runtime_id: i64, + actor_data: []const u8, + synced_properties: PropertySyncData, + tick: i64, +}; + +pub const CSetActorLink = struct { + link: ActorLink, +}; + +pub const CSetActorMotion = struct { + target_runtime_id: i64, + motion: struct { f64, f64, f64 }, + tick: i64, +}; + +pub const CSetDifficulty = struct { + difficulty: i32, +}; + +pub const CSetDisplayObjective = struct { + display_slot_name: []const u8, + objective_name: []const u8, + objective_display_name: []const u8, + criteria_name: []const u8, + sort_order: i32, +}; + +pub const CSetHealth = struct { + health: i32, +}; + +pub const CSetPlayerGameType = struct { + player_game_type: GameType, +}; + +pub const ScoreEntry = struct { + scoreboard_id: i64, + objective_name: []const u8, + score: i32, + entry_type: i32, + entity_unique_id: i64, + custom_name: []const u8, +}; + +pub const CSetScore = struct { + action: i32, + entries: []const ScoreEntry, +}; + +pub const SpawnPositionType = enum(u8) { + player_respawn, + world_respawn, +}; + +pub const CSetSpawnPosition = struct { + spawn_position_type: SpawnPositionType, + block_position: struct { i32, i32, i32 }, + dimension_type: i32, + spawn_block_pos: struct { i32, i32, i32 }, +}; + +pub const CSetTime = struct { + time: i32, +}; + +pub const TitleType = enum(u8) { + clear, + reset, + title, + subtitle, + actionbar, + times, + title_text_object, + subtitle_text_object, + actionbar_text_object, +}; + +pub const CSetTitle = struct { + title_type: TitleType, + title_text: []const u8, + fade_in_time: i32, + stay_time: i32, + fade_out_time: i32, + xuid: []const u8, + platform_online_id: []const u8, + filtered_title_message: []const u8, +}; + +pub const CShowCredits = struct { + player_runtime_id: i64, + credits_state: i32, +}; + +pub const GatheringJoinInfo = struct { + experience_id: Uuid, + experience_name: []const u8, + experience_world_id: Uuid, + experience_world_name: []const u8, + creator_id: []const u8, + unknown_uuid_1: Uuid, + unknown_uuid_2: Uuid, + server_id: []const u8, +}; + +pub const StoreEntryPointInfo = struct { + store_id: []const u8, + store_name: []const u8, +}; + +pub const PresenceInfo = struct { + experience_name: []const u8, + world_name: []const u8, +}; + +pub const ServerJoinInformation = struct { + gathering: ?GatheringJoinInfo, + store_entry_point: ?StoreEntryPointInfo, + presence: ?PresenceInfo, +}; + +pub const ServerTelemetryData = struct { + server_id: []const u8, + scenario_id: []const u8, + world_id: []const u8, + owner_id: []const u8, +}; + +pub const ExperimentToggle = struct { + name: []const u8, + enabled: bool, +}; + +pub const Experiments = struct { + toggles: []const ExperimentToggle, + experiments_ever_toggled: bool, +}; + +pub const CResourcePackStackPacket = struct { + texture_pack_required: bool, + texture_pack_list: []const PackInstanceId, + base_game_version: []const u8, + experiments: Experiments, + include_editor_packs: bool, +}; + +pub const GamePublishSetting = enum(u8) { + no_multi_play, + invite_only, + friends_only, + friends_of_friends, + public, +}; + +pub const LevelSettings = struct { + seed: i64, + spawn_biome_type: i32, + custom_biome_name: []const u8, + dimension: i32, + generator_type: i32, + world_gamemode: GameType, + hardcore: bool, + difficulty: i32, + spawn_position: struct { i32, i32, i32 }, + has_achievements_disabled: bool, + editor_world_type: i32, + is_created_in_editor: bool, + is_exported_from_editor: bool, + day_cycle_stop_time: i32, + education_edition_offer: i32, + has_education_features_enabled: bool, + education_product_id: []const u8, + rain_level: f32, + lightning_level: f32, + has_confirmed_platform_locked_content: bool, + was_multiplayer_intended: bool, + was_lan_broadcasting_intended: bool, + xbox_live_broadcast_setting: GamePublishSetting, + platform_broadcast_setting: GamePublishSetting, + commands_enabled: bool, + is_texture_packs_required: bool, + rule_data: []const GameRule, + experiments: Experiments, + bonus_chest: bool, + has_start_with_map_enabled: bool, + permission_level: u8, + server_simulation_distance: i32, + has_locked_behavior_pack: bool, + has_locked_resource_pack: bool, + is_from_locked_world_template: bool, + is_using_msa_gamertags_only: bool, + is_from_world_template: bool, + is_world_template_option_locked: bool, + is_only_spawning_v1_villagers: bool, + is_disabling_personas: bool, + is_disabling_custom_skins: bool, + emote_chat_muted: bool, + game_version: []const u8, + limited_world_width: i32, + limited_world_height: i32, + new_nether: bool, + edu_shared_uri_button_name: []const u8, + edu_shared_uri_link_uri: []const u8, + override_force_experimental_gameplay_has_value: bool, + chat_restriction_level: u8, + disable_player_interactions: bool, + server_editor_connection_policy: i32, + allow_anonymous_block_drops_in_editor_worlds: bool, +}; + +pub const CStartGame = struct { + entity_id: i64, + runtime_entity_id: i64, + player_gamemode: GameType, + position: struct { f64, f64, f64 }, + pitch: f32, + yaw: f32, + level_settings: LevelSettings, + level_id: []const u8, + level_name: []const u8, + premium_world_template_id: []const u8, + is_trial: bool, + rewind_history_size: i32, + server_authoritative_block_breaking: bool, + current_level_time: i64, + enchantment_seed: i32, + block_properties_size: i32, + multiplayer_correlation_id: []const u8, + enable_itemstack_net_manager: bool, + server_version: []const u8, + compound_id: u8, + compound_len: i32, + compound_end: u8, + block_registry_checksum: i64, + world_template_id: Uuid, + enable_clientside_generation: bool, + blocknetwork_ids_are_hashed: bool, + server_auth_sounds: bool, + server_join_information: ?ServerJoinInformation, + telemetry: ServerTelemetryData, +}; + +pub const Gg = struct { + name: []const u8, + id: u8, + len: i32, + end: u8, +}; + +pub const CTakeItemActor = struct { + item_runtime_id: i64, + actor_runtime_id: i64, +}; + +pub const CTransfer = struct { + server_address: []const u8, + server_port: i32, + reload_world: bool, +}; + +pub const CUpdateAbilities = struct { + data: SerializedAbilitiesData, +}; + +pub const Ability = enum(u8) { + build, + mine, + doors_and_switches, + open_containers, + attack_players, + attack_mobs, + operator_commands, + teleport, + invulnerable, + flying, + may_fly, + instabuild, + lightning, + fly_speed, + walk_speed, + muted, + world_builder, + no_clip, + privileged_builder, + vertical_fly_speed, + ability_count, +}; + +pub const AttributeModifier = struct { + id: []const u8, + name: []const u8, + amount: f32, + operation: i32, + operand: i32, + is_serializable: bool, +}; + +pub const AttributeData = struct { + min_value: f32, + max_value: f32, + current_value: f32, + default_min_value: f32, + default_max_value: f32, + default_value: f32, + name: []const u8, + modifiers: []const AttributeModifier, +}; + +pub const CUpdateAttributes = struct { + target_runtime_id: i64, + attribute_list: []const AttributeData, + tick: i64, +}; + +pub const CUpdateBlock = struct { + block_position: struct { i32, i32, i32 }, + block_runtime_id: i32, + flags: i32, + layer: i32, +}; + +pub const CUpdateTrade = struct { + container_id: u8, + r_type: u8, + size: i32, + trader_tier: i32, + entity_unique_id: i64, + last_trading_player: i64, + display_name: []const u8, + use_new_trade_screen: bool, + using_economy_trade: bool, + data: []const u8, +}; + +pub const NetworkItemDescriptor = struct { + id: i32, + stack_size: i32, + aux_value: i32, + block_runtime_id: i32, + nbt_data: []const u8, + place_on_blocks: []const []const u8, + destroy_blocks: []const []const u8, + shield_blocking_tick: i64, +}; + +pub const InventoryAction = struct { + source_type: i32, + window_id: ?i32, + source_flags: ?i32, + inventory_slot: i32, + old_item: NetworkItemDescriptor, + new_item: NetworkItemDescriptor, +}; + +pub const UseItemTransactionData = struct { + action_type: i32, + trigger_type: u8, + block_position: struct { i32, i32, i32 }, + block_face: u8, + hot_bar_slot: i32, + hand: u8, + item_in_hand: NetworkItemDescriptor, + player_position: struct { f64, f64, f64 }, + click_position: struct { f64, f64, f64 }, + block_runtime_id: i32, + client_prediction: u8, + client_cooldown_state: u8, +}; + +pub const UseItemOnEntityTransactionData = struct { + target_entity_runtime_id: i64, + action_type: i32, + hot_bar_slot: i32, + item_in_hand: NetworkItemDescriptor, + player_position: struct { f64, f64, f64 }, + click_position: struct { f64, f64, f64 }, +}; + +pub const ReleaseItemTransactionData = struct { + action_type: i32, + hot_bar_slot: i32, + item_in_hand: NetworkItemDescriptor, + head_position: struct { f64, f64, f64 }, +}; + +pub const TransactionData = union(enum) { + normal: []const u8, + mismatch: []const u8, + use_item: UseItemTransactionData, + use_item_on_entity: UseItemOnEntityTransactionData, + release_item: ReleaseItemTransactionData, +}; + +pub const SInventoryTransaction = struct { + legacy_request_id: i32, + legacy_set_item_slots: []const LegacySetItemSlot, + has_value: bool, + actions: []const InventoryAction, + transaction_type: i32, + transaction_data: TransactionData, +}; + +pub const PlayerUseItemTransactionData = struct { + action_type: i32, + trigger_type: u8, + block_position: struct { i32, i32, i32 }, + block_face: u8, + hot_bar_slot: i32, + item_in_hand: NetworkItemDescriptor, + player_position: struct { f64, f64, f64 }, + click_position: struct { f64, f64, f64 }, + block_runtime_id: i32, + client_prediction: u8, + client_cooldown_state: u8, +}; + +pub const PlayerInventoryAction = struct { + legacy_request_id: i32, + legacy_slots: []const LegacySetItemSlot, + actions: []const InventoryAction, + transaction: PlayerUseItemTransactionData, +}; + +pub const BedrockShapelessRecipe = struct { + recipe_id: []const u8, + input: []const ItemDescriptorCount, + output: []const NetworkItemDescriptor, + uuid: Uuid, + block: []const u8, + priority: i32, + unlock_requirement: RecipeUnlockRequirement, + recipe_network_id: i32, +}; + +pub const BedrockShapedRecipe = struct { + recipe_id: []const u8, + width: i32, + height: i32, + input: []const ItemDescriptorCount, + output: []const NetworkItemDescriptor, + uuid: Uuid, + block: []const u8, + priority: i32, + assume_symmetry: bool, + unlock_requirement: RecipeUnlockRequirement, + recipe_network_id: i32, +}; + +pub const BedrockRecipe = union(enum) { + shapeless: BedrockShapelessRecipe, + shaped: BedrockShapedRecipe, +}; + +pub const CCraftingData = struct { + recipes: []const BedrockRecipe, + clean_recipes: bool, +}; + +pub const CreativeGroupInfoPayload = struct { + creative_category: CreativeCategory, + name: []const u8, + group_icon_item: NetworkItemDescriptor, +}; + +pub const CreativeItemEntryPayload = struct { + id: i32, + item: NetworkItemDescriptor, + group_index: i32, +}; + +pub const CCreativeContent = struct { + groups: []const CreativeGroupInfoPayload, + entries: []const CreativeItemEntryPayload, +}; + +pub const ItemStackWrapper = struct { + id: i32, + stack_size: i32, + aux_value: i32, + block_runtime_id: i32, + nbt_data: []const u8, + place_on_blocks: []const []const u8, + destroy_blocks: []const []const u8, + shield_blocking_tick: i64, + net_id: ?i32, +}; + +pub const CAddItemActor = struct { + target_actor_id: i64, + target_runtime_id: i64, + item: ItemStackWrapper, + position: struct { f64, f64, f64 }, + velocity: struct { f64, f64, f64 }, + entity_data: []const u8, + is_from_fishing: bool, +}; + +pub const NetworkItemStackDescriptor = struct { + id: i32, + stack_size: i32, + aux_value: i32, + block_runtime_id: i32, + extra_data: []const u8, + net_id: ?i32, +}; + +pub const SMobEquipment = struct { + entity_runtime_id: i64, + item: NetworkItemStackDescriptor, + slot: u8, + selected_slot: u8, + container_id: u8, +}; + +pub const CAddPlayer = struct { + uuid: Uuid, + player_name: []const u8, + target_runtime_id: i64, + platform_chat_id: []const u8, + position: struct { f64, f64, f64 }, + velocity: struct { f64, f64, f64 }, + rotation: struct { f64, f64 }, + y_head_rotation: f32, + carried_item: NetworkItemStackDescriptor, + player_game_type: GameType, + entity_data: []const u8, + synced_properties: PropertySyncData, + abilities_data: SerializedAbilitiesData, + actor_links: []const ActorLink, + device_id: []const u8, + build_platform: BuildPlatform, +}; + +pub const CMobEquipment = struct { + target_runtime_id: i64, + item: NetworkItemStackDescriptor, + slot: u8, + selected_slot: u8, + container_id: u8, +}; + +pub const ContainerName = enum(u8) { + anvil_input, + anvil_material, + anvil_result_preview, + smithing_table_input, + smithing_table_material, + smithing_table_result_preview, + armor, + level_entity, + beacon_payment, + brewing_stand_input, + brewing_stand_result, + brewing_stand_fuel, + combined_hot_bar_and_inventory, + crafting_input, + crafting_output_preview, + recipe_construction, + recipe_nature, + recipe_items, + recipe_search, + recipe_search_bar, + recipe_equipment, + recipe_book, + enchanting_input, + enchanting_material, + furnace_fuel, + furnace_ingredient, + furnace_result, + horse_equip, + hot_bar, + inventory, + shulker_box, + trade_ingredient1, + trade_ingredient2, + trade_result_preview, + offhand, + compound_creator_input, + compound_creator_output_preview, + element_constructor_output_preview, + material_reducer_input, + material_reducer_output, + lab_table_input, + loom_input, + loom_dye, + loom_material, + loom_result_preview, + blast_furnace_ingredient, + smoker_ingredient, + trade2_ingredient1, + trade2_ingredient2, + trade2_result_preview, + grindstone_input, + grindstone_additional, + grindstone_result_preview, + stonecutter_input, + stonecutter_result_preview, + cartography_input, + cartography_additional, + cartography_result_preview, + barrel, + cursor, + created_output, + smithing_table_template, + crafter_level_entity, + dynamic, + recipe_food, + recipe_blocks, + recipe_furnace_items, +}; + +pub const FullContainerName = struct { + container_name: ContainerName, + dynamic_id: ?i32, +}; + +pub const ItemStackRequestSlotInfo = struct { + container_name: FullContainerName, + slot_id: u8, + stack_id: i32, +}; + +pub const ItemStackRequestActionTake = struct { + count: u8, + source: ItemStackRequestSlotInfo, + destination: ItemStackRequestSlotInfo, +}; + +pub const ItemStackRequestActionPlace = struct { + count: u8, + source: ItemStackRequestSlotInfo, + destination: ItemStackRequestSlotInfo, +}; + +pub const ItemStackRequestActionSwap = struct { + slot1: ItemStackRequestSlotInfo, + slot2: ItemStackRequestSlotInfo, +}; + +pub const ItemStackRequestActionDrop = struct { + count: u8, + source: ItemStackRequestSlotInfo, + randomly: bool, +}; + +pub const ItemStackRequestActionDestroy = struct { + count: u8, + source: ItemStackRequestSlotInfo, +}; + +pub const ItemStackRequestActionConsume = struct { + count: u8, + source: ItemStackRequestSlotInfo, +}; + +pub const ItemStackRequestAction = union(enum) { + take: ItemStackRequestActionTake, + place: ItemStackRequestActionPlace, + swap: ItemStackRequestActionSwap, + drop: ItemStackRequestActionDrop, + destroy: ItemStackRequestActionDestroy, + consume: ItemStackRequestActionConsume, + create: ItemStackRequestActionCreate, + lab_table_combine, + beacon_payment: ItemStackRequestActionBeaconPayment, + mine_block: ItemStackRequestActionMineBlock, + craft_recipe: ItemStackRequestActionCraftRecipe, + craft_recipe_auto: ItemStackRequestActionCraftRecipeAuto, + craft_creative: ItemStackRequestActionCraftCreative, + optional: ItemStackRequestActionOptional, + grindstone: ItemStackRequestActionGrindstone, + loom: ItemStackRequestActionLoom, + craft_non_implemented, + craft_results_deprecated: ItemStackRequestActionCraftResultsDeprecated, +}; + +pub const ItemStackRequest = struct { + request_id: i32, + actions: []const ItemStackRequestAction, + filter_strings: []const []const u8, + filter_cause: i32, +}; + +pub const SItemStackRequest = struct { + requests: []const ItemStackRequest, +}; + +pub const SPlayerAuthInput = struct { + pitch: f32, + yaw: f32, + position: struct { f64, f64, f64 }, + move_vec: struct { f64, f64 }, + head_yaw: f32, + input_data: []const i64, + input_mode: i32, + play_mode: i32, + interaction_model: i32, + interact_pitch: f32, + interact_yaw: f32, + tick: i64, + delta: struct { f64, f64, f64 }, + block_actions: ?[]const PlayerBlockAction, + item_interaction: ?PlayerInventoryAction, + item_stack_request: ?ItemStackRequest, + vehicle_rotation: ?struct { f64, f64 }, + vehicle_unique_id: ?i64, + analog_move: struct { f64, f64 }, + camera_orientation: struct { f64, f64, f64 }, + raw_move: struct { f64, f64 }, +}; + +pub const CInventoryContent = struct { + container_id: i32, + slots: []const NetworkItemStackDescriptor, + full_container_name: FullContainerName, + storage_item: NetworkItemStackDescriptor, +}; + +pub const CInventorySlot = struct { + container_id: i32, + slot: i32, + full_container_name: ?FullContainerName, + storage_item: ?NetworkItemStackDescriptor, + item: NetworkItemStackDescriptor, +}; + +pub const ItemStackResponseContainerInfo = struct { + full_container_name: FullContainerName, + slots: []const ItemStackResponseSlotInfo, +}; + +pub const ItemStackResponseInfo = struct { + result: u8, + client_request_id: i32, + containers: []const ItemStackResponseContainerInfo, +}; + +pub const CItemStackResponse = struct { + responses: []const ItemStackResponseInfo, +}; + +pub const NetworkItemStack = struct { + id: i32, + count: i32, + aux_value: i32, + block_runtime_id: i32, + extra_data: []const u8, +}; + +pub const ServerboundPacket = union(enum) { + s_actor_event: SActorEvent, + s_animate: SAnimate, + s_block_pick_request: SBlockPickRequest, + s_client_cache_blob_status: SClientCacheBlobStatus, + s_client_cache_status: SClientCacheStatus, + s_command_request: SCommandRequest, + s_container_close: SContainerClose, + s_emote: SEmote, + s_emote_list: SEmoteList, + s_interact: SInteract, + s_inventory_transaction: SInventoryTransaction, + s_item_stack_request: SItemStackRequest, + s_loading_screen: SLoadingScreen, + s_login: SLogin, + s_mob_equipment: SMobEquipment, + s_modal_form_response: SModalFormResponse, + s_packet_violation_warning: SPacketViolationWarning, + s_player_action: SPlayerAction, + s_player_auth_input: SPlayerAuthInput, + s_player_hotbar: SPlayerHotbar, + s_request_ability: SRequestAbility, + s_request_chunk_radius: SRequestChunkRadius, + s_request_network_settings: SRequestNetworkSettings, + s_resource_pack_client_response: SResourcePackClientResponse, + s_respawn: SRespawn, + s_set_local_player_as_initialized: SSetLocalPlayerAsInitialized, + s_set_player_inventory_options: SSetPlayerInventoryOptions, + s_text: SText, + unknown, +}; + +pub const ClientboundPacket = union(enum) { + c_add_actor: CAddActor, + c_add_item_actor: CAddItemActor, + c_add_player: CAddPlayer, + c_available_commands: CAvailableCommands, + c_biome_definition_list, + c_block_actor_data: CBlockActorData, + c_block_event: CBlockEvent, + c_boss_event: CBossEvent, + c_change_dimension: CChangeDimension, + c_chunk_radius_updated: CChunkRadiusUpdated, + c_client_cache_miss_response: CClientCacheMissResponse, + c_container_open: CContainerOpen, + c_correct_player_move_prediction: CCorrectPlayerMovePrediction, + c_crafting_data: CCraftingData, + c_creative_content: CCreativeContent, + c_disconnect: CDisconnect, + c_gamerules_changed: CGamerulesChanged, + c_inventory_content: CInventoryContent, + c_inventory_slot: CInventorySlot, + c_item_registry: CItemRegistry, + c_item_stack_response: CItemStackResponse, + c_jigsaw_structure_data, + c_level_event: CLevelEvent, + c_level_sound_event: CLevelSoundEvent, + c_mob_effect: CMobEffect, + c_mob_equipment: CMobEquipment, + c_modal_form_request: CModalFormRequest, + c_move_actor_absolute: CMoveActorAbsolute, + c_move_actor_delta: CMoveActorDelta, + c_move_player: CMovePlayer, + c_network_chunk_publisher_update: CNetworkChunkPublisherUpdate, + c_network_settings: CNetworkSettings, + c_play_status: CPlayStatus, + c_player_hotbar: CPlayerHotbar, + c_player_list: CPlayerList, + c_remove_actor: CRemoveActor, + c_remove_objective: CRemoveObjective, + c_resource_pack_stack_packet: CResourcePackStackPacket, + c_resource_packs_info: CResourcePacksInfo, + c_set_actor_data: CSetActorData, + c_set_actor_link: CSetActorLink, + c_set_actor_motion: CSetActorMotion, + c_set_difficulty: CSetDifficulty, + c_set_display_objective: CSetDisplayObjective, + c_set_health: CSetHealth, + c_set_player_game_type: CSetPlayerGameType, + c_set_score: CSetScore, + c_set_spawn_position: CSetSpawnPosition, + c_set_time: CSetTime, + c_set_title: CSetTitle, + c_show_credits: CShowCredits, + c_start_game: CStartGame, + c_take_item_actor: CTakeItemActor, + c_transfer: CTransfer, + c_update_abilities: CUpdateAbilities, + c_update_attributes: CUpdateAttributes, + c_update_block: CUpdateBlock, + c_update_trade: CUpdateTrade, + c_voxel_shapes, + unknown, +}; diff --git a/src/wit/biomes.zig b/src/wit/biomes.zig new file mode 100644 index 0000000..fef2019 --- /dev/null +++ b/src/wit/biomes.zig @@ -0,0 +1,70 @@ +// Generated by tools/gen.zig, do not edit. + +pub const Biome = enum(u8) { + badlands, + bamboo_jungle, + basalt_deltas, + beach, + birch_forest, + cherry_grove, + cold_ocean, + crimson_forest, + dark_forest, + deep_cold_ocean, + deep_dark, + deep_frozen_ocean, + deep_lukewarm_ocean, + deep_ocean, + desert, + dripstone_caves, + end_barrens, + end_highlands, + end_midlands, + eroded_badlands, + flower_forest, + forest, + frozen_ocean, + frozen_peaks, + frozen_river, + grove, + ice_spikes, + jagged_peaks, + jungle, + lukewarm_ocean, + lush_caves, + mangrove_swamp, + meadow, + mushroom_fields, + nether_wastes, + ocean, + old_growth_birch_forest, + old_growth_pine_taiga, + old_growth_spruce_taiga, + pale_garden, + plains, + river, + savanna, + savanna_plateau, + small_end_islands, + snowy_beach, + snowy_plains, + snowy_slopes, + snowy_taiga, + soul_sand_valley, + sparse_jungle, + stony_peaks, + stony_shore, + sulfur_caves, + sunflower_plains, + swamp, + taiga, + the_end, + the_void, + warm_ocean, + warped_forest, + windswept_forest, + windswept_gravelly_hills, + windswept_hills, + windswept_savanna, + wooded_badlands, +}; diff --git a/src/wit/block_entity.zig b/src/wit/block_entity.zig new file mode 100644 index 0000000..6d32a64 --- /dev/null +++ b/src/wit/block_entity.zig @@ -0,0 +1,1865 @@ +// Generated by tools/gen.zig, do not edit. + +const abi = @import("../abi.zig"); +const common = @import("common.zig"); +const item_stack = @import("item_stack.zig"); +const inventory = @import("inventory.zig"); + +pub const BlockPos = common.BlockPos; +pub const NbtTree = common.NbtTree; +pub const ItemStack = item_stack.ItemStack; +pub const Inventory = inventory.Inventory; + +pub const BlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]block-entity"; + + pub fn resourceLocation(self: BlockEntity) []const u8 { + return abi.call(raw.@"[method]block-entity.resource-location", []const u8, .{abi.borrow(self)}); + } + + pub fn getPosition(self: BlockEntity) BlockPos { + return abi.call(raw.@"[method]block-entity.get-position", BlockPos, .{abi.borrow(self)}); + } + + pub fn getId(self: BlockEntity) u32 { + return abi.call(raw.@"[method]block-entity.get-id", u32, .{abi.borrow(self)}); + } + + pub fn isDirty(self: BlockEntity) bool { + return abi.call(raw.@"[method]block-entity.is-dirty", bool, .{abi.borrow(self)}); + } + + pub fn clearDirty(self: BlockEntity) void { + return abi.call(raw.@"[method]block-entity.clear-dirty", void, .{abi.borrow(self)}); + } + + /// Sets a namespaced custom data value on this block entity. + pub fn setCustomData(self: BlockEntity, namespace: []const u8, key: []const u8, value: NbtTree) void { + return abi.call(raw.@"[method]block-entity.set-custom-data", void, .{ abi.borrow(self), namespace, key, value }); + } + + /// Returns a namespaced custom data value from this block entity, if set. + pub fn getCustomData(self: BlockEntity, namespace: []const u8, key: []const u8) ?NbtTree { + return abi.call(raw.@"[method]block-entity.get-custom-data", ?NbtTree, .{ abi.borrow(self), namespace, key }); + } + + /// Removes a namespaced custom data value from this block entity. + pub fn removeCustomData(self: BlockEntity, namespace: []const u8, key: []const u8) void { + return abi.call(raw.@"[method]block-entity.remove-custom-data", void, .{ abi.borrow(self), namespace, key }); + } + + /// Returns whether this block entity has a namespaced custom data value. + pub fn hasCustomData(self: BlockEntity, namespace: []const u8, key: []const u8) bool { + return abi.call(raw.@"[method]block-entity.has-custom-data", bool, .{ abi.borrow(self), namespace, key }); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: BlockEntity) void { + abi.keep(BlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: BlockEntity) void { + abi.drop(BlockEntity, self); + } +}; + +pub const ContainerBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]container-block-entity"; + + pub fn getBlockEntity(self: ContainerBlockEntity) BlockEntity { + return abi.call(raw.@"[method]container-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + /// Returns the generic inventory handle for this container. + pub fn getInventory(self: ContainerBlockEntity) Inventory { + return abi.call(raw.@"[method]container-block-entity.get-inventory", Inventory, .{abi.borrow(self)}); + } + + pub fn getSize(self: ContainerBlockEntity) u32 { + return abi.call(raw.@"[method]container-block-entity.get-size", u32, .{abi.borrow(self)}); + } + + pub fn isEmpty(self: ContainerBlockEntity) bool { + return abi.call(raw.@"[method]container-block-entity.is-empty", bool, .{abi.borrow(self)}); + } + + pub fn getStack(self: ContainerBlockEntity, slot: u32) ?ItemStack { + return abi.call(raw.@"[method]container-block-entity.get-stack", ?ItemStack, .{ abi.borrow(self), slot }); + } + + pub fn setStack(self: ContainerBlockEntity, slot: u32, stack: ?ItemStack) void { + return abi.call(raw.@"[method]container-block-entity.set-stack", void, .{ abi.borrow(self), slot, stack }); + } + + pub fn removeStack(self: ContainerBlockEntity, slot: u32) ?ItemStack { + return abi.call(raw.@"[method]container-block-entity.remove-stack", ?ItemStack, .{ abi.borrow(self), slot }); + } + + pub fn clear(self: ContainerBlockEntity) void { + return abi.call(raw.@"[method]container-block-entity.clear", void, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: ContainerBlockEntity) void { + abi.keep(ContainerBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: ContainerBlockEntity) void { + abi.drop(ContainerBlockEntity, self); + } +}; + +pub const CommandBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]command-block-entity"; + + pub fn getBlockEntity(self: CommandBlockEntity) BlockEntity { + return abi.call(raw.@"[method]command-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn lastOutput(self: CommandBlockEntity) []const u8 { + return abi.call(raw.@"[method]command-block-entity.last-output", []const u8, .{abi.borrow(self)}); + } + + pub fn trackOutput(self: CommandBlockEntity) bool { + return abi.call(raw.@"[method]command-block-entity.track-output", bool, .{abi.borrow(self)}); + } + + pub fn successCount(self: CommandBlockEntity) u32 { + return abi.call(raw.@"[method]command-block-entity.success-count", u32, .{abi.borrow(self)}); + } + + pub fn command(self: CommandBlockEntity) []const u8 { + return abi.call(raw.@"[method]command-block-entity.command", []const u8, .{abi.borrow(self)}); + } + + pub fn auto(self: CommandBlockEntity) bool { + return abi.call(raw.@"[method]command-block-entity.auto", bool, .{abi.borrow(self)}); + } + + pub fn conditionMet(self: CommandBlockEntity) bool { + return abi.call(raw.@"[method]command-block-entity.condition-met", bool, .{abi.borrow(self)}); + } + + pub fn powered(self: CommandBlockEntity) bool { + return abi.call(raw.@"[method]command-block-entity.powered", bool, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: CommandBlockEntity) void { + abi.keep(CommandBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: CommandBlockEntity) void { + abi.drop(CommandBlockEntity, self); + } +}; + +pub const DyeColor = enum(u8) { + white, + orange, + magenta, + light_blue, + yellow, + lime, + pink, + gray, + light_gray, + cyan, + purple, + blue, + brown, + green, + red, + black, +}; + +pub const SignText = struct { + messages: []const []const u8, + color: DyeColor, + has_glowing_text: bool, +}; + +pub const SignBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]sign-block-entity"; + + pub fn getBlockEntity(self: SignBlockEntity) BlockEntity { + return abi.call(raw.@"[method]sign-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getFrontText(self: SignBlockEntity) SignText { + return abi.call(raw.@"[method]sign-block-entity.get-front-text", SignText, .{abi.borrow(self)}); + } + + pub fn setFrontText(self: SignBlockEntity, text: SignText) void { + return abi.call(raw.@"[method]sign-block-entity.set-front-text", void, .{ abi.borrow(self), text }); + } + + pub fn getBackText(self: SignBlockEntity) SignText { + return abi.call(raw.@"[method]sign-block-entity.get-back-text", SignText, .{abi.borrow(self)}); + } + + pub fn setBackText(self: SignBlockEntity, text: SignText) void { + return abi.call(raw.@"[method]sign-block-entity.set-back-text", void, .{ abi.borrow(self), text }); + } + + pub fn isWaxed(self: SignBlockEntity) bool { + return abi.call(raw.@"[method]sign-block-entity.is-waxed", bool, .{abi.borrow(self)}); + } + + pub fn setWaxed(self: SignBlockEntity, waxed: bool) void { + return abi.call(raw.@"[method]sign-block-entity.set-waxed", void, .{ abi.borrow(self), waxed }); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: SignBlockEntity) void { + abi.keep(SignBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: SignBlockEntity) void { + abi.drop(SignBlockEntity, self); + } +}; + +pub const JukeboxBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]jukebox-block-entity"; + + pub fn getBlockEntity(self: JukeboxBlockEntity) BlockEntity { + return abi.call(raw.@"[method]jukebox-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getContainer(self: JukeboxBlockEntity) ContainerBlockEntity { + return abi.call(raw.@"[method]jukebox-block-entity.get-container", ContainerBlockEntity, .{abi.borrow(self)}); + } + + pub fn isPlaying(self: JukeboxBlockEntity) bool { + return abi.call(raw.@"[method]jukebox-block-entity.is-playing", bool, .{abi.borrow(self)}); + } + + pub fn stopPlaying(self: JukeboxBlockEntity) void { + return abi.call(raw.@"[method]jukebox-block-entity.stop-playing", void, .{abi.borrow(self)}); + } + + pub fn startPlaying(self: JukeboxBlockEntity, length_in_ticks: u64) void { + return abi.call(raw.@"[method]jukebox-block-entity.start-playing", void, .{ abi.borrow(self), length_in_ticks }); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: JukeboxBlockEntity) void { + abi.keep(JukeboxBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: JukeboxBlockEntity) void { + abi.drop(JukeboxBlockEntity, self); + } +}; + +pub const ChestBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]chest-block-entity"; + + pub fn getBlockEntity(self: ChestBlockEntity) BlockEntity { + return abi.call(raw.@"[method]chest-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getContainer(self: ChestBlockEntity) ContainerBlockEntity { + return abi.call(raw.@"[method]chest-block-entity.get-container", ContainerBlockEntity, .{abi.borrow(self)}); + } + + pub fn viewerCount(self: ChestBlockEntity) u32 { + return abi.call(raw.@"[method]chest-block-entity.viewer-count", u32, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: ChestBlockEntity) void { + abi.keep(ChestBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: ChestBlockEntity) void { + abi.drop(ChestBlockEntity, self); + } +}; + +pub const MobSpawnerBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]mob-spawner-block-entity"; + + pub fn getBlockEntity(self: MobSpawnerBlockEntity) BlockEntity { + return abi.call(raw.@"[method]mob-spawner-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getSpawnCount(self: MobSpawnerBlockEntity) i32 { + return abi.call(raw.@"[method]mob-spawner-block-entity.get-spawn-count", i32, .{abi.borrow(self)}); + } + + pub fn getSpawnRange(self: MobSpawnerBlockEntity) i32 { + return abi.call(raw.@"[method]mob-spawner-block-entity.get-spawn-range", i32, .{abi.borrow(self)}); + } + + pub fn getDelay(self: MobSpawnerBlockEntity) i32 { + return abi.call(raw.@"[method]mob-spawner-block-entity.get-delay", i32, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: MobSpawnerBlockEntity) void { + abi.keep(MobSpawnerBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: MobSpawnerBlockEntity) void { + abi.drop(MobSpawnerBlockEntity, self); + } +}; + +pub const MapBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]map-block-entity"; + + pub fn getBlockEntity(self: MapBlockEntity) BlockEntity { + return abi.call(raw.@"[method]map-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getMapId(self: MapBlockEntity) i32 { + return abi.call(raw.@"[method]map-block-entity.get-map-id", i32, .{abi.borrow(self)}); + } + + pub fn setMapId(self: MapBlockEntity, map_id: i32) void { + return abi.call(raw.@"[method]map-block-entity.set-map-id", void, .{ abi.borrow(self), map_id }); + } + + pub fn getColors(self: MapBlockEntity) []const u8 { + return abi.call(raw.@"[method]map-block-entity.get-colors", []const u8, .{abi.borrow(self)}); + } + + pub fn setColors(self: MapBlockEntity, colors: []const u8) void { + return abi.call(raw.@"[method]map-block-entity.set-colors", void, .{ abi.borrow(self), colors }); + } + + pub fn setPixel(self: MapBlockEntity, x: u32, y: u32, color: u8) void { + return abi.call(raw.@"[method]map-block-entity.set-pixel", void, .{ abi.borrow(self), x, y, color }); + } + + pub fn getPixel(self: MapBlockEntity, x: u32, y: u32) u8 { + return abi.call(raw.@"[method]map-block-entity.get-pixel", u8, .{ abi.borrow(self), x, y }); + } + + pub fn update(self: MapBlockEntity) void { + return abi.call(raw.@"[method]map-block-entity.update", void, .{abi.borrow(self)}); + } + + pub fn streamFrame(self: MapBlockEntity, frame_data: []const u8) void { + return abi.call(raw.@"[method]map-block-entity.stream-frame", void, .{ abi.borrow(self), frame_data }); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: MapBlockEntity) void { + abi.keep(MapBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: MapBlockEntity) void { + abi.drop(MapBlockEntity, self); + } +}; + +pub const HangingSignBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]hanging-sign-block-entity"; + + pub fn getBlockEntity(self: HangingSignBlockEntity) BlockEntity { + return abi.call(raw.@"[method]hanging-sign-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getFrontText(self: HangingSignBlockEntity) SignText { + return abi.call(raw.@"[method]hanging-sign-block-entity.get-front-text", SignText, .{abi.borrow(self)}); + } + + pub fn setFrontText(self: HangingSignBlockEntity, text: SignText) void { + return abi.call(raw.@"[method]hanging-sign-block-entity.set-front-text", void, .{ abi.borrow(self), text }); + } + + pub fn getBackText(self: HangingSignBlockEntity) SignText { + return abi.call(raw.@"[method]hanging-sign-block-entity.get-back-text", SignText, .{abi.borrow(self)}); + } + + pub fn setBackText(self: HangingSignBlockEntity, text: SignText) void { + return abi.call(raw.@"[method]hanging-sign-block-entity.set-back-text", void, .{ abi.borrow(self), text }); + } + + pub fn isWaxed(self: HangingSignBlockEntity) bool { + return abi.call(raw.@"[method]hanging-sign-block-entity.is-waxed", bool, .{abi.borrow(self)}); + } + + pub fn setWaxed(self: HangingSignBlockEntity, waxed: bool) void { + return abi.call(raw.@"[method]hanging-sign-block-entity.set-waxed", void, .{ abi.borrow(self), waxed }); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: HangingSignBlockEntity) void { + abi.keep(HangingSignBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: HangingSignBlockEntity) void { + abi.drop(HangingSignBlockEntity, self); + } +}; + +pub const TrappedChestBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]trapped-chest-block-entity"; + + pub fn getBlockEntity(self: TrappedChestBlockEntity) BlockEntity { + return abi.call(raw.@"[method]trapped-chest-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getContainer(self: TrappedChestBlockEntity) ContainerBlockEntity { + return abi.call(raw.@"[method]trapped-chest-block-entity.get-container", ContainerBlockEntity, .{abi.borrow(self)}); + } + + pub fn viewerCount(self: TrappedChestBlockEntity) u32 { + return abi.call(raw.@"[method]trapped-chest-block-entity.viewer-count", u32, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: TrappedChestBlockEntity) void { + abi.keep(TrappedChestBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: TrappedChestBlockEntity) void { + abi.drop(TrappedChestBlockEntity, self); + } +}; + +pub const BannerBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]banner-block-entity"; + + pub fn getBlockEntity(self: BannerBlockEntity) BlockEntity { + return abi.call(raw.@"[method]banner-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getCustomName(self: BannerBlockEntity) ?[]const u8 { + return abi.call(raw.@"[method]banner-block-entity.get-custom-name", ?[]const u8, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: BannerBlockEntity) void { + abi.keep(BannerBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: BannerBlockEntity) void { + abi.drop(BannerBlockEntity, self); + } +}; + +pub const BarrelBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]barrel-block-entity"; + + pub fn getBlockEntity(self: BarrelBlockEntity) BlockEntity { + return abi.call(raw.@"[method]barrel-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getContainer(self: BarrelBlockEntity) ContainerBlockEntity { + return abi.call(raw.@"[method]barrel-block-entity.get-container", ContainerBlockEntity, .{abi.borrow(self)}); + } + + pub fn viewerCount(self: BarrelBlockEntity) u32 { + return abi.call(raw.@"[method]barrel-block-entity.viewer-count", u32, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: BarrelBlockEntity) void { + abi.keep(BarrelBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: BarrelBlockEntity) void { + abi.drop(BarrelBlockEntity, self); + } +}; + +pub const BeaconBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]beacon-block-entity"; + + pub fn getBlockEntity(self: BeaconBlockEntity) BlockEntity { + return abi.call(raw.@"[method]beacon-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getContainer(self: BeaconBlockEntity) ContainerBlockEntity { + return abi.call(raw.@"[method]beacon-block-entity.get-container", ContainerBlockEntity, .{abi.borrow(self)}); + } + + pub fn getPrimaryEffect(self: BeaconBlockEntity) i32 { + return abi.call(raw.@"[method]beacon-block-entity.get-primary-effect", i32, .{abi.borrow(self)}); + } + + pub fn getSecondaryEffect(self: BeaconBlockEntity) i32 { + return abi.call(raw.@"[method]beacon-block-entity.get-secondary-effect", i32, .{abi.borrow(self)}); + } + + pub fn getLevels(self: BeaconBlockEntity) i32 { + return abi.call(raw.@"[method]beacon-block-entity.get-levels", i32, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: BeaconBlockEntity) void { + abi.keep(BeaconBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: BeaconBlockEntity) void { + abi.drop(BeaconBlockEntity, self); + } +}; + +pub const BedBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]bed-block-entity"; + + pub fn getBlockEntity(self: BedBlockEntity) BlockEntity { + return abi.call(raw.@"[method]bed-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: BedBlockEntity) void { + abi.keep(BedBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: BedBlockEntity) void { + abi.drop(BedBlockEntity, self); + } +}; + +pub const BeehiveBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]beehive-block-entity"; + + pub fn getBlockEntity(self: BeehiveBlockEntity) BlockEntity { + return abi.call(raw.@"[method]beehive-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getBeeCount(self: BeehiveBlockEntity) u32 { + return abi.call(raw.@"[method]beehive-block-entity.get-bee-count", u32, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: BeehiveBlockEntity) void { + abi.keep(BeehiveBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: BeehiveBlockEntity) void { + abi.drop(BeehiveBlockEntity, self); + } +}; + +pub const BellBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]bell-block-entity"; + + pub fn getBlockEntity(self: BellBlockEntity) BlockEntity { + return abi.call(raw.@"[method]bell-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn isRinging(self: BellBlockEntity) bool { + return abi.call(raw.@"[method]bell-block-entity.is-ringing", bool, .{abi.borrow(self)}); + } + + pub fn getRingTicks(self: BellBlockEntity) i32 { + return abi.call(raw.@"[method]bell-block-entity.get-ring-ticks", i32, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: BellBlockEntity) void { + abi.keep(BellBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: BellBlockEntity) void { + abi.drop(BellBlockEntity, self); + } +}; + +pub const BlastingFurnaceBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]blasting-furnace-block-entity"; + + pub fn getBlockEntity(self: BlastingFurnaceBlockEntity) BlockEntity { + return abi.call(raw.@"[method]blasting-furnace-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getContainer(self: BlastingFurnaceBlockEntity) ContainerBlockEntity { + return abi.call(raw.@"[method]blasting-furnace-block-entity.get-container", ContainerBlockEntity, .{abi.borrow(self)}); + } + + pub fn getCookingTimeSpent(self: BlastingFurnaceBlockEntity) u16 { + return abi.call(raw.@"[method]blasting-furnace-block-entity.get-cooking-time-spent", u16, .{abi.borrow(self)}); + } + + pub fn getCookingTotalTime(self: BlastingFurnaceBlockEntity) u16 { + return abi.call(raw.@"[method]blasting-furnace-block-entity.get-cooking-total-time", u16, .{abi.borrow(self)}); + } + + pub fn getLitTimeRemaining(self: BlastingFurnaceBlockEntity) u16 { + return abi.call(raw.@"[method]blasting-furnace-block-entity.get-lit-time-remaining", u16, .{abi.borrow(self)}); + } + + pub fn getLitTotalTime(self: BlastingFurnaceBlockEntity) u16 { + return abi.call(raw.@"[method]blasting-furnace-block-entity.get-lit-total-time", u16, .{abi.borrow(self)}); + } + + pub fn isBurning(self: BlastingFurnaceBlockEntity) bool { + return abi.call(raw.@"[method]blasting-furnace-block-entity.is-burning", bool, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: BlastingFurnaceBlockEntity) void { + abi.keep(BlastingFurnaceBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: BlastingFurnaceBlockEntity) void { + abi.drop(BlastingFurnaceBlockEntity, self); + } +}; + +pub const BrewingStandBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]brewing-stand-block-entity"; + + pub fn getBlockEntity(self: BrewingStandBlockEntity) BlockEntity { + return abi.call(raw.@"[method]brewing-stand-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getContainer(self: BrewingStandBlockEntity) ContainerBlockEntity { + return abi.call(raw.@"[method]brewing-stand-block-entity.get-container", ContainerBlockEntity, .{abi.borrow(self)}); + } + + pub fn getBrewTime(self: BrewingStandBlockEntity) i32 { + return abi.call(raw.@"[method]brewing-stand-block-entity.get-brew-time", i32, .{abi.borrow(self)}); + } + + pub fn getFuel(self: BrewingStandBlockEntity) i32 { + return abi.call(raw.@"[method]brewing-stand-block-entity.get-fuel", i32, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: BrewingStandBlockEntity) void { + abi.keep(BrewingStandBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: BrewingStandBlockEntity) void { + abi.drop(BrewingStandBlockEntity, self); + } +}; + +pub const BrushableBlockBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]brushable-block-block-entity"; + + pub fn getBlockEntity(self: BrushableBlockBlockEntity) BlockEntity { + return abi.call(raw.@"[method]brushable-block-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: BrushableBlockBlockEntity) void { + abi.keep(BrushableBlockBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: BrushableBlockBlockEntity) void { + abi.drop(BrushableBlockBlockEntity, self); + } +}; + +pub const CalibratedSculkSensorBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]calibrated-sculk-sensor-block-entity"; + + pub fn getBlockEntity(self: CalibratedSculkSensorBlockEntity) BlockEntity { + return abi.call(raw.@"[method]calibrated-sculk-sensor-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: CalibratedSculkSensorBlockEntity) void { + abi.keep(CalibratedSculkSensorBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: CalibratedSculkSensorBlockEntity) void { + abi.drop(CalibratedSculkSensorBlockEntity, self); + } +}; + +pub const CampfireBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]campfire-block-entity"; + + pub fn getBlockEntity(self: CampfireBlockEntity) BlockEntity { + return abi.call(raw.@"[method]campfire-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getContainer(self: CampfireBlockEntity) ContainerBlockEntity { + return abi.call(raw.@"[method]campfire-block-entity.get-container", ContainerBlockEntity, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: CampfireBlockEntity) void { + abi.keep(CampfireBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: CampfireBlockEntity) void { + abi.drop(CampfireBlockEntity, self); + } +}; + +pub const ChiseledBookshelfBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]chiseled-bookshelf-block-entity"; + + pub fn getBlockEntity(self: ChiseledBookshelfBlockEntity) BlockEntity { + return abi.call(raw.@"[method]chiseled-bookshelf-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getContainer(self: ChiseledBookshelfBlockEntity) ContainerBlockEntity { + return abi.call(raw.@"[method]chiseled-bookshelf-block-entity.get-container", ContainerBlockEntity, .{abi.borrow(self)}); + } + + pub fn getLastInteractedSlot(self: ChiseledBookshelfBlockEntity) i8 { + return abi.call(raw.@"[method]chiseled-bookshelf-block-entity.get-last-interacted-slot", i8, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: ChiseledBookshelfBlockEntity) void { + abi.keep(ChiseledBookshelfBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: ChiseledBookshelfBlockEntity) void { + abi.drop(ChiseledBookshelfBlockEntity, self); + } +}; + +pub const ComparatorBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]comparator-block-entity"; + + pub fn getBlockEntity(self: ComparatorBlockEntity) BlockEntity { + return abi.call(raw.@"[method]comparator-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getOutputSignal(self: ComparatorBlockEntity) u8 { + return abi.call(raw.@"[method]comparator-block-entity.get-output-signal", u8, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: ComparatorBlockEntity) void { + abi.keep(ComparatorBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: ComparatorBlockEntity) void { + abi.drop(ComparatorBlockEntity, self); + } +}; + +pub const ConduitBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]conduit-block-entity"; + + pub fn getBlockEntity(self: ConduitBlockEntity) BlockEntity { + return abi.call(raw.@"[method]conduit-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: ConduitBlockEntity) void { + abi.keep(ConduitBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: ConduitBlockEntity) void { + abi.drop(ConduitBlockEntity, self); + } +}; + +pub const CopperGolemStatueBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]copper-golem-statue-block-entity"; + + pub fn getBlockEntity(self: CopperGolemStatueBlockEntity) BlockEntity { + return abi.call(raw.@"[method]copper-golem-statue-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: CopperGolemStatueBlockEntity) void { + abi.keep(CopperGolemStatueBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: CopperGolemStatueBlockEntity) void { + abi.drop(CopperGolemStatueBlockEntity, self); + } +}; + +pub const CrafterBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]crafter-block-entity"; + + pub fn getBlockEntity(self: CrafterBlockEntity) BlockEntity { + return abi.call(raw.@"[method]crafter-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getContainer(self: CrafterBlockEntity) ContainerBlockEntity { + return abi.call(raw.@"[method]crafter-block-entity.get-container", ContainerBlockEntity, .{abi.borrow(self)}); + } + + pub fn getCraftingTicksRemaining(self: CrafterBlockEntity) i32 { + return abi.call(raw.@"[method]crafter-block-entity.get-crafting-ticks-remaining", i32, .{abi.borrow(self)}); + } + + pub fn isTriggered(self: CrafterBlockEntity) bool { + return abi.call(raw.@"[method]crafter-block-entity.is-triggered", bool, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: CrafterBlockEntity) void { + abi.keep(CrafterBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: CrafterBlockEntity) void { + abi.drop(CrafterBlockEntity, self); + } +}; + +pub const CreakingHeartBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]creaking-heart-block-entity"; + + pub fn getBlockEntity(self: CreakingHeartBlockEntity) BlockEntity { + return abi.call(raw.@"[method]creaking-heart-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getCreakingUuid(self: CreakingHeartBlockEntity) ?[]const u8 { + return abi.call(raw.@"[method]creaking-heart-block-entity.get-creaking-uuid", ?[]const u8, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: CreakingHeartBlockEntity) void { + abi.keep(CreakingHeartBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: CreakingHeartBlockEntity) void { + abi.drop(CreakingHeartBlockEntity, self); + } +}; + +pub const DaylightDetectorBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]daylight-detector-block-entity"; + + pub fn getBlockEntity(self: DaylightDetectorBlockEntity) BlockEntity { + return abi.call(raw.@"[method]daylight-detector-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: DaylightDetectorBlockEntity) void { + abi.keep(DaylightDetectorBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: DaylightDetectorBlockEntity) void { + abi.drop(DaylightDetectorBlockEntity, self); + } +}; + +pub const DecoratedPotBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]decorated-pot-block-entity"; + + pub fn getBlockEntity(self: DecoratedPotBlockEntity) BlockEntity { + return abi.call(raw.@"[method]decorated-pot-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: DecoratedPotBlockEntity) void { + abi.keep(DecoratedPotBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: DecoratedPotBlockEntity) void { + abi.drop(DecoratedPotBlockEntity, self); + } +}; + +pub const DispenserBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]dispenser-block-entity"; + + pub fn getBlockEntity(self: DispenserBlockEntity) BlockEntity { + return abi.call(raw.@"[method]dispenser-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getContainer(self: DispenserBlockEntity) ContainerBlockEntity { + return abi.call(raw.@"[method]dispenser-block-entity.get-container", ContainerBlockEntity, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: DispenserBlockEntity) void { + abi.keep(DispenserBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: DispenserBlockEntity) void { + abi.drop(DispenserBlockEntity, self); + } +}; + +pub const DropperBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]dropper-block-entity"; + + pub fn getBlockEntity(self: DropperBlockEntity) BlockEntity { + return abi.call(raw.@"[method]dropper-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getContainer(self: DropperBlockEntity) ContainerBlockEntity { + return abi.call(raw.@"[method]dropper-block-entity.get-container", ContainerBlockEntity, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: DropperBlockEntity) void { + abi.keep(DropperBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: DropperBlockEntity) void { + abi.drop(DropperBlockEntity, self); + } +}; + +pub const EnchantingTableBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]enchanting-table-block-entity"; + + pub fn getBlockEntity(self: EnchantingTableBlockEntity) BlockEntity { + return abi.call(raw.@"[method]enchanting-table-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: EnchantingTableBlockEntity) void { + abi.keep(EnchantingTableBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: EnchantingTableBlockEntity) void { + abi.drop(EnchantingTableBlockEntity, self); + } +}; + +pub const EndGatewayBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]end-gateway-block-entity"; + + pub fn getBlockEntity(self: EndGatewayBlockEntity) BlockEntity { + return abi.call(raw.@"[method]end-gateway-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getAge(self: EndGatewayBlockEntity) i64 { + return abi.call(raw.@"[method]end-gateway-block-entity.get-age", i64, .{abi.borrow(self)}); + } + + pub fn isExactTeleport(self: EndGatewayBlockEntity) bool { + return abi.call(raw.@"[method]end-gateway-block-entity.is-exact-teleport", bool, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: EndGatewayBlockEntity) void { + abi.keep(EndGatewayBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: EndGatewayBlockEntity) void { + abi.drop(EndGatewayBlockEntity, self); + } +}; + +pub const EndPortalBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]end-portal-block-entity"; + + pub fn getBlockEntity(self: EndPortalBlockEntity) BlockEntity { + return abi.call(raw.@"[method]end-portal-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: EndPortalBlockEntity) void { + abi.keep(EndPortalBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: EndPortalBlockEntity) void { + abi.drop(EndPortalBlockEntity, self); + } +}; + +pub const EnderChestBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]ender-chest-block-entity"; + + pub fn getBlockEntity(self: EnderChestBlockEntity) BlockEntity { + return abi.call(raw.@"[method]ender-chest-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn viewerCount(self: EnderChestBlockEntity) u32 { + return abi.call(raw.@"[method]ender-chest-block-entity.viewer-count", u32, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: EnderChestBlockEntity) void { + abi.keep(EnderChestBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: EnderChestBlockEntity) void { + abi.drop(EnderChestBlockEntity, self); + } +}; + +pub const FurnaceBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]furnace-block-entity"; + + pub fn getBlockEntity(self: FurnaceBlockEntity) BlockEntity { + return abi.call(raw.@"[method]furnace-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getContainer(self: FurnaceBlockEntity) ContainerBlockEntity { + return abi.call(raw.@"[method]furnace-block-entity.get-container", ContainerBlockEntity, .{abi.borrow(self)}); + } + + pub fn getCookingTimeSpent(self: FurnaceBlockEntity) u16 { + return abi.call(raw.@"[method]furnace-block-entity.get-cooking-time-spent", u16, .{abi.borrow(self)}); + } + + pub fn getCookingTotalTime(self: FurnaceBlockEntity) u16 { + return abi.call(raw.@"[method]furnace-block-entity.get-cooking-total-time", u16, .{abi.borrow(self)}); + } + + pub fn getLitTimeRemaining(self: FurnaceBlockEntity) u16 { + return abi.call(raw.@"[method]furnace-block-entity.get-lit-time-remaining", u16, .{abi.borrow(self)}); + } + + pub fn getLitTotalTime(self: FurnaceBlockEntity) u16 { + return abi.call(raw.@"[method]furnace-block-entity.get-lit-total-time", u16, .{abi.borrow(self)}); + } + + pub fn isBurning(self: FurnaceBlockEntity) bool { + return abi.call(raw.@"[method]furnace-block-entity.is-burning", bool, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: FurnaceBlockEntity) void { + abi.keep(FurnaceBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: FurnaceBlockEntity) void { + abi.drop(FurnaceBlockEntity, self); + } +}; + +pub const HopperBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]hopper-block-entity"; + + pub fn getBlockEntity(self: HopperBlockEntity) BlockEntity { + return abi.call(raw.@"[method]hopper-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getContainer(self: HopperBlockEntity) ContainerBlockEntity { + return abi.call(raw.@"[method]hopper-block-entity.get-container", ContainerBlockEntity, .{abi.borrow(self)}); + } + + pub fn getCooldown(self: HopperBlockEntity) i32 { + return abi.call(raw.@"[method]hopper-block-entity.get-cooldown", i32, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: HopperBlockEntity) void { + abi.keep(HopperBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: HopperBlockEntity) void { + abi.drop(HopperBlockEntity, self); + } +}; + +pub const JigsawBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]jigsaw-block-entity"; + + pub fn getBlockEntity(self: JigsawBlockEntity) BlockEntity { + return abi.call(raw.@"[method]jigsaw-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getName(self: JigsawBlockEntity) []const u8 { + return abi.call(raw.@"[method]jigsaw-block-entity.get-name", []const u8, .{abi.borrow(self)}); + } + + pub fn getTarget(self: JigsawBlockEntity) []const u8 { + return abi.call(raw.@"[method]jigsaw-block-entity.get-target", []const u8, .{abi.borrow(self)}); + } + + pub fn getPool(self: JigsawBlockEntity) []const u8 { + return abi.call(raw.@"[method]jigsaw-block-entity.get-pool", []const u8, .{abi.borrow(self)}); + } + + pub fn getFinalState(self: JigsawBlockEntity) []const u8 { + return abi.call(raw.@"[method]jigsaw-block-entity.get-final-state", []const u8, .{abi.borrow(self)}); + } + + pub fn getSelectionPriority(self: JigsawBlockEntity) i32 { + return abi.call(raw.@"[method]jigsaw-block-entity.get-selection-priority", i32, .{abi.borrow(self)}); + } + + pub fn getPlacementPriority(self: JigsawBlockEntity) i32 { + return abi.call(raw.@"[method]jigsaw-block-entity.get-placement-priority", i32, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: JigsawBlockEntity) void { + abi.keep(JigsawBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: JigsawBlockEntity) void { + abi.drop(JigsawBlockEntity, self); + } +}; + +pub const LecternBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]lectern-block-entity"; + + pub fn getBlockEntity(self: LecternBlockEntity) BlockEntity { + return abi.call(raw.@"[method]lectern-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getContainer(self: LecternBlockEntity) ContainerBlockEntity { + return abi.call(raw.@"[method]lectern-block-entity.get-container", ContainerBlockEntity, .{abi.borrow(self)}); + } + + pub fn getPage(self: LecternBlockEntity) u32 { + return abi.call(raw.@"[method]lectern-block-entity.get-page", u32, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: LecternBlockEntity) void { + abi.keep(LecternBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: LecternBlockEntity) void { + abi.drop(LecternBlockEntity, self); + } +}; + +pub const PistonBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]piston-block-entity"; + + pub fn getBlockEntity(self: PistonBlockEntity) BlockEntity { + return abi.call(raw.@"[method]piston-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getProgress(self: PistonBlockEntity) f32 { + return abi.call(raw.@"[method]piston-block-entity.get-progress", f32, .{abi.borrow(self)}); + } + + pub fn isExtending(self: PistonBlockEntity) bool { + return abi.call(raw.@"[method]piston-block-entity.is-extending", bool, .{abi.borrow(self)}); + } + + pub fn isSource(self: PistonBlockEntity) bool { + return abi.call(raw.@"[method]piston-block-entity.is-source", bool, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: PistonBlockEntity) void { + abi.keep(PistonBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: PistonBlockEntity) void { + abi.drop(PistonBlockEntity, self); + } +}; + +pub const PotentSulfurBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]potent-sulfur-block-entity"; + + pub fn getBlockEntity(self: PotentSulfurBlockEntity) BlockEntity { + return abi.call(raw.@"[method]potent-sulfur-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: PotentSulfurBlockEntity) void { + abi.keep(PotentSulfurBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: PotentSulfurBlockEntity) void { + abi.drop(PotentSulfurBlockEntity, self); + } +}; + +pub const SculkCatalystBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]sculk-catalyst-block-entity"; + + pub fn getBlockEntity(self: SculkCatalystBlockEntity) BlockEntity { + return abi.call(raw.@"[method]sculk-catalyst-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: SculkCatalystBlockEntity) void { + abi.keep(SculkCatalystBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: SculkCatalystBlockEntity) void { + abi.drop(SculkCatalystBlockEntity, self); + } +}; + +pub const SculkSensorBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]sculk-sensor-block-entity"; + + pub fn getBlockEntity(self: SculkSensorBlockEntity) BlockEntity { + return abi.call(raw.@"[method]sculk-sensor-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: SculkSensorBlockEntity) void { + abi.keep(SculkSensorBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: SculkSensorBlockEntity) void { + abi.drop(SculkSensorBlockEntity, self); + } +}; + +pub const SculkShriekerBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]sculk-shrieker-block-entity"; + + pub fn getBlockEntity(self: SculkShriekerBlockEntity) BlockEntity { + return abi.call(raw.@"[method]sculk-shrieker-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getWarningLevel(self: SculkShriekerBlockEntity) i32 { + return abi.call(raw.@"[method]sculk-shrieker-block-entity.get-warning-level", i32, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: SculkShriekerBlockEntity) void { + abi.keep(SculkShriekerBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: SculkShriekerBlockEntity) void { + abi.drop(SculkShriekerBlockEntity, self); + } +}; + +pub const ShelfBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]shelf-block-entity"; + + pub fn getBlockEntity(self: ShelfBlockEntity) BlockEntity { + return abi.call(raw.@"[method]shelf-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getContainer(self: ShelfBlockEntity) ContainerBlockEntity { + return abi.call(raw.@"[method]shelf-block-entity.get-container", ContainerBlockEntity, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: ShelfBlockEntity) void { + abi.keep(ShelfBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: ShelfBlockEntity) void { + abi.drop(ShelfBlockEntity, self); + } +}; + +pub const ShulkerBoxBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]shulker-box-block-entity"; + + pub fn getBlockEntity(self: ShulkerBoxBlockEntity) BlockEntity { + return abi.call(raw.@"[method]shulker-box-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getContainer(self: ShulkerBoxBlockEntity) ContainerBlockEntity { + return abi.call(raw.@"[method]shulker-box-block-entity.get-container", ContainerBlockEntity, .{abi.borrow(self)}); + } + + pub fn viewerCount(self: ShulkerBoxBlockEntity) u32 { + return abi.call(raw.@"[method]shulker-box-block-entity.viewer-count", u32, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: ShulkerBoxBlockEntity) void { + abi.keep(ShulkerBoxBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: ShulkerBoxBlockEntity) void { + abi.drop(ShulkerBoxBlockEntity, self); + } +}; + +pub const SkullBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]skull-block-entity"; + + pub fn getBlockEntity(self: SkullBlockEntity) BlockEntity { + return abi.call(raw.@"[method]skull-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getNoteBlockSound(self: SkullBlockEntity) ?[]const u8 { + return abi.call(raw.@"[method]skull-block-entity.get-note-block-sound", ?[]const u8, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: SkullBlockEntity) void { + abi.keep(SkullBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: SkullBlockEntity) void { + abi.drop(SkullBlockEntity, self); + } +}; + +pub const SmokerBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]smoker-block-entity"; + + pub fn getBlockEntity(self: SmokerBlockEntity) BlockEntity { + return abi.call(raw.@"[method]smoker-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getContainer(self: SmokerBlockEntity) ContainerBlockEntity { + return abi.call(raw.@"[method]smoker-block-entity.get-container", ContainerBlockEntity, .{abi.borrow(self)}); + } + + pub fn getCookingTimeSpent(self: SmokerBlockEntity) u16 { + return abi.call(raw.@"[method]smoker-block-entity.get-cooking-time-spent", u16, .{abi.borrow(self)}); + } + + pub fn getCookingTotalTime(self: SmokerBlockEntity) u16 { + return abi.call(raw.@"[method]smoker-block-entity.get-cooking-total-time", u16, .{abi.borrow(self)}); + } + + pub fn getLitTimeRemaining(self: SmokerBlockEntity) u16 { + return abi.call(raw.@"[method]smoker-block-entity.get-lit-time-remaining", u16, .{abi.borrow(self)}); + } + + pub fn getLitTotalTime(self: SmokerBlockEntity) u16 { + return abi.call(raw.@"[method]smoker-block-entity.get-lit-total-time", u16, .{abi.borrow(self)}); + } + + pub fn isBurning(self: SmokerBlockEntity) bool { + return abi.call(raw.@"[method]smoker-block-entity.is-burning", bool, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: SmokerBlockEntity) void { + abi.keep(SmokerBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: SmokerBlockEntity) void { + abi.drop(SmokerBlockEntity, self); + } +}; + +pub const StructureBlockBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]structure-block-block-entity"; + + pub fn getBlockEntity(self: StructureBlockBlockEntity) BlockEntity { + return abi.call(raw.@"[method]structure-block-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + pub fn getName(self: StructureBlockBlockEntity) []const u8 { + return abi.call(raw.@"[method]structure-block-block-entity.get-name", []const u8, .{abi.borrow(self)}); + } + + pub fn getAuthor(self: StructureBlockBlockEntity) []const u8 { + return abi.call(raw.@"[method]structure-block-block-entity.get-author", []const u8, .{abi.borrow(self)}); + } + + pub fn getMode(self: StructureBlockBlockEntity) []const u8 { + return abi.call(raw.@"[method]structure-block-block-entity.get-mode", []const u8, .{abi.borrow(self)}); + } + + pub fn getIntegrity(self: StructureBlockBlockEntity) f32 { + return abi.call(raw.@"[method]structure-block-block-entity.get-integrity", f32, .{abi.borrow(self)}); + } + + pub fn getSeed(self: StructureBlockBlockEntity) i64 { + return abi.call(raw.@"[method]structure-block-block-entity.get-seed", i64, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: StructureBlockBlockEntity) void { + abi.keep(StructureBlockBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: StructureBlockBlockEntity) void { + abi.drop(StructureBlockBlockEntity, self); + } +}; + +pub const TestBlockBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]test-block-block-entity"; + + pub fn getBlockEntity(self: TestBlockBlockEntity) BlockEntity { + return abi.call(raw.@"[method]test-block-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: TestBlockBlockEntity) void { + abi.keep(TestBlockBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: TestBlockBlockEntity) void { + abi.drop(TestBlockBlockEntity, self); + } +}; + +pub const TestInstanceBlockBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]test-instance-block-block-entity"; + + pub fn getBlockEntity(self: TestInstanceBlockBlockEntity) BlockEntity { + return abi.call(raw.@"[method]test-instance-block-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: TestInstanceBlockBlockEntity) void { + abi.keep(TestInstanceBlockBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: TestInstanceBlockBlockEntity) void { + abi.drop(TestInstanceBlockBlockEntity, self); + } +}; + +pub const TrialSpawnerBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]trial-spawner-block-entity"; + + pub fn getBlockEntity(self: TrialSpawnerBlockEntity) BlockEntity { + return abi.call(raw.@"[method]trial-spawner-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: TrialSpawnerBlockEntity) void { + abi.keep(TrialSpawnerBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: TrialSpawnerBlockEntity) void { + abi.drop(TrialSpawnerBlockEntity, self); + } +}; + +pub const VaultBlockEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]vault-block-entity"; + + pub fn getBlockEntity(self: VaultBlockEntity) BlockEntity { + return abi.call(raw.@"[method]vault-block-entity.get-block-entity", BlockEntity, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: VaultBlockEntity) void { + abi.keep(VaultBlockEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: VaultBlockEntity) void { + abi.drop(VaultBlockEntity, self); + } +}; + +pub const BlockEntityType = union(enum) { + command_block_entity: CommandBlockEntity, + sign_block_entity: SignBlockEntity, + hanging_sign_block_entity: HangingSignBlockEntity, + jukebox_block_entity: JukeboxBlockEntity, + chest_block_entity: ChestBlockEntity, + trapped_chest_block_entity: TrappedChestBlockEntity, + mob_spawner_block_entity: MobSpawnerBlockEntity, + map_block_entity: MapBlockEntity, + banner_block_entity: BannerBlockEntity, + barrel_block_entity: BarrelBlockEntity, + beacon_block_entity: BeaconBlockEntity, + bed_block_entity: BedBlockEntity, + beehive_block_entity: BeehiveBlockEntity, + bell_block_entity: BellBlockEntity, + blasting_furnace_block_entity: BlastingFurnaceBlockEntity, + brewing_stand_block_entity: BrewingStandBlockEntity, + brushable_block_block_entity: BrushableBlockBlockEntity, + calibrated_sculk_sensor_block_entity: CalibratedSculkSensorBlockEntity, + campfire_block_entity: CampfireBlockEntity, + chiseled_bookshelf_block_entity: ChiseledBookshelfBlockEntity, + comparator_block_entity: ComparatorBlockEntity, + conduit_block_entity: ConduitBlockEntity, + copper_golem_statue_block_entity: CopperGolemStatueBlockEntity, + crafter_block_entity: CrafterBlockEntity, + creaking_heart_block_entity: CreakingHeartBlockEntity, + daylight_detector_block_entity: DaylightDetectorBlockEntity, + decorated_pot_block_entity: DecoratedPotBlockEntity, + dispenser_block_entity: DispenserBlockEntity, + dropper_block_entity: DropperBlockEntity, + enchanting_table_block_entity: EnchantingTableBlockEntity, + end_gateway_block_entity: EndGatewayBlockEntity, + end_portal_block_entity: EndPortalBlockEntity, + ender_chest_block_entity: EnderChestBlockEntity, + furnace_block_entity: FurnaceBlockEntity, + hopper_block_entity: HopperBlockEntity, + jigsaw_block_entity: JigsawBlockEntity, + lectern_block_entity: LecternBlockEntity, + piston_block_entity: PistonBlockEntity, + potent_sulfur_block_entity: PotentSulfurBlockEntity, + sculk_catalyst_block_entity: SculkCatalystBlockEntity, + sculk_sensor_block_entity: SculkSensorBlockEntity, + sculk_shrieker_block_entity: SculkShriekerBlockEntity, + shelf_block_entity: ShelfBlockEntity, + shulker_box_block_entity: ShulkerBoxBlockEntity, + skull_block_entity: SkullBlockEntity, + smoker_block_entity: SmokerBlockEntity, + structure_block_block_entity: StructureBlockBlockEntity, + test_block_block_entity: TestBlockBlockEntity, + test_instance_block_block_entity: TestInstanceBlockBlockEntity, + trial_spawner_block_entity: TrialSpawnerBlockEntity, + vault_block_entity: VaultBlockEntity, + container_block_entity: ContainerBlockEntity, +}; + +const raw = struct { + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]block-entity.resource-location"(i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]block-entity.get-position"(i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]block-entity.get-id"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]block-entity.is-dirty"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]block-entity.clear-dirty"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]block-entity.set-custom-data"(i32, i32, i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]block-entity.get-custom-data"(i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]block-entity.remove-custom-data"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]block-entity.has-custom-data"(i32, i32, i32, i32, i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]container-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]container-block-entity.get-inventory"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]container-block-entity.get-size"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]container-block-entity.is-empty"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]container-block-entity.get-stack"(i32, i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]container-block-entity.set-stack"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]container-block-entity.remove-stack"(i32, i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]container-block-entity.clear"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]command-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]command-block-entity.last-output"(i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]command-block-entity.track-output"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]command-block-entity.success-count"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]command-block-entity.command"(i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]command-block-entity.auto"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]command-block-entity.condition-met"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]command-block-entity.powered"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]sign-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]sign-block-entity.get-front-text"(i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]sign-block-entity.set-front-text"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]sign-block-entity.get-back-text"(i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]sign-block-entity.set-back-text"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]sign-block-entity.is-waxed"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]sign-block-entity.set-waxed"(i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]jukebox-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]jukebox-block-entity.get-container"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]jukebox-block-entity.is-playing"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]jukebox-block-entity.stop-playing"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]jukebox-block-entity.start-playing"(i32, i64) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]chest-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]chest-block-entity.get-container"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]chest-block-entity.viewer-count"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]mob-spawner-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]mob-spawner-block-entity.get-spawn-count"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]mob-spawner-block-entity.get-spawn-range"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]mob-spawner-block-entity.get-delay"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]map-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]map-block-entity.get-map-id"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]map-block-entity.set-map-id"(i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]map-block-entity.get-colors"(i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]map-block-entity.set-colors"(i32, i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]map-block-entity.set-pixel"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]map-block-entity.get-pixel"(i32, i32, i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]map-block-entity.update"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]map-block-entity.stream-frame"(i32, i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]hanging-sign-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]hanging-sign-block-entity.get-front-text"(i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]hanging-sign-block-entity.set-front-text"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]hanging-sign-block-entity.get-back-text"(i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]hanging-sign-block-entity.set-back-text"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]hanging-sign-block-entity.is-waxed"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]hanging-sign-block-entity.set-waxed"(i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]trapped-chest-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]trapped-chest-block-entity.get-container"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]trapped-chest-block-entity.viewer-count"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]banner-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]banner-block-entity.get-custom-name"(i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]barrel-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]barrel-block-entity.get-container"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]barrel-block-entity.viewer-count"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]beacon-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]beacon-block-entity.get-container"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]beacon-block-entity.get-primary-effect"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]beacon-block-entity.get-secondary-effect"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]beacon-block-entity.get-levels"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]bed-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]beehive-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]beehive-block-entity.get-bee-count"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]bell-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]bell-block-entity.is-ringing"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]bell-block-entity.get-ring-ticks"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]blasting-furnace-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]blasting-furnace-block-entity.get-container"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]blasting-furnace-block-entity.get-cooking-time-spent"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]blasting-furnace-block-entity.get-cooking-total-time"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]blasting-furnace-block-entity.get-lit-time-remaining"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]blasting-furnace-block-entity.get-lit-total-time"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]blasting-furnace-block-entity.is-burning"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]brewing-stand-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]brewing-stand-block-entity.get-container"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]brewing-stand-block-entity.get-brew-time"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]brewing-stand-block-entity.get-fuel"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]brushable-block-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]calibrated-sculk-sensor-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]campfire-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]campfire-block-entity.get-container"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]chiseled-bookshelf-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]chiseled-bookshelf-block-entity.get-container"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]chiseled-bookshelf-block-entity.get-last-interacted-slot"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]comparator-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]comparator-block-entity.get-output-signal"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]conduit-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]copper-golem-statue-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]crafter-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]crafter-block-entity.get-container"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]crafter-block-entity.get-crafting-ticks-remaining"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]crafter-block-entity.is-triggered"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]creaking-heart-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]creaking-heart-block-entity.get-creaking-uuid"(i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]daylight-detector-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]decorated-pot-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]dispenser-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]dispenser-block-entity.get-container"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]dropper-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]dropper-block-entity.get-container"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]enchanting-table-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]end-gateway-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]end-gateway-block-entity.get-age"(i32) i64; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]end-gateway-block-entity.is-exact-teleport"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]end-portal-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]ender-chest-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]ender-chest-block-entity.viewer-count"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]furnace-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]furnace-block-entity.get-container"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]furnace-block-entity.get-cooking-time-spent"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]furnace-block-entity.get-cooking-total-time"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]furnace-block-entity.get-lit-time-remaining"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]furnace-block-entity.get-lit-total-time"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]furnace-block-entity.is-burning"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]hopper-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]hopper-block-entity.get-container"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]hopper-block-entity.get-cooldown"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]jigsaw-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]jigsaw-block-entity.get-name"(i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]jigsaw-block-entity.get-target"(i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]jigsaw-block-entity.get-pool"(i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]jigsaw-block-entity.get-final-state"(i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]jigsaw-block-entity.get-selection-priority"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]jigsaw-block-entity.get-placement-priority"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]lectern-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]lectern-block-entity.get-container"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]lectern-block-entity.get-page"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]piston-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]piston-block-entity.get-progress"(i32) f32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]piston-block-entity.is-extending"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]piston-block-entity.is-source"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]potent-sulfur-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]sculk-catalyst-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]sculk-sensor-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]sculk-shrieker-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]sculk-shrieker-block-entity.get-warning-level"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]shelf-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]shelf-block-entity.get-container"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]shulker-box-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]shulker-box-block-entity.get-container"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]shulker-box-block-entity.viewer-count"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]skull-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]skull-block-entity.get-note-block-sound"(i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]smoker-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]smoker-block-entity.get-container"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]smoker-block-entity.get-cooking-time-spent"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]smoker-block-entity.get-cooking-total-time"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]smoker-block-entity.get-lit-time-remaining"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]smoker-block-entity.get-lit-total-time"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]smoker-block-entity.is-burning"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]structure-block-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]structure-block-block-entity.get-name"(i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]structure-block-block-entity.get-author"(i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]structure-block-block-entity.get-mode"(i32, i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]structure-block-block-entity.get-integrity"(i32) f32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]structure-block-block-entity.get-seed"(i32) i64; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]test-block-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]test-instance-block-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]trial-spawner-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[method]vault-block-entity.get-block-entity"(i32) i32; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]container-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]command-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]sign-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]jukebox-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]chest-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]mob-spawner-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]map-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]hanging-sign-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]trapped-chest-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]banner-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]barrel-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]beacon-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]bed-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]beehive-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]bell-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]blasting-furnace-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]brewing-stand-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]brushable-block-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]calibrated-sculk-sensor-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]campfire-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]chiseled-bookshelf-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]comparator-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]conduit-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]copper-golem-statue-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]crafter-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]creaking-heart-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]daylight-detector-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]decorated-pot-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]dispenser-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]dropper-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]enchanting-table-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]end-gateway-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]end-portal-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]ender-chest-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]furnace-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]hopper-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]jigsaw-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]lectern-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]piston-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]potent-sulfur-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]sculk-catalyst-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]sculk-sensor-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]sculk-shrieker-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]shelf-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]shulker-box-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]skull-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]smoker-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]structure-block-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]test-block-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]test-instance-block-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]trial-spawner-block-entity"(i32) void; + extern "pumpkin:plugin/block-entity@0.1.0" fn @"[resource-drop]vault-block-entity"(i32) void; +}; diff --git a/src/wit/boss_bar.zig b/src/wit/boss_bar.zig new file mode 100644 index 0000000..867b574 --- /dev/null +++ b/src/wit/boss_bar.zig @@ -0,0 +1,157 @@ +// Generated by tools/gen.zig, do not edit. + +const abi = @import("../abi.zig"); +const text = @import("text.zig"); +const player = @import("player.zig"); + +pub const TextComponent = text.TextComponent; +pub const Player = player.Player; + +/// Represents the color of a boss bar. +pub const BossBarColor = enum(u8) { + pink, + blue, + red, + green, + yellow, + purple, + white, +}; + +/// Represents the notches/divisions of a boss bar. +pub const BossBarDivision = enum(u8) { + no_division, + notches_6, + notches_10, + notches_12, + notches_20, +}; + +/// Metadata flags that can be toggled on a boss bar. +pub const BossBarMetadata = struct { + /// Darkens the sky for players who see the boss bar. + darken_sky: bool, + /// If true, the bar is considered a "dragon bar" (used for Ender Dragon). + dragon_bar: bool, + /// If true, fog is created around the players who see the boss bar. + create_fog: bool, +}; + +/// Represents a boss bar that can be shown to players. +pub const BossBar = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]boss-bar"; + + /// Creates a new boss bar. + /// + /// Consumes `title`. + pub fn init(title: TextComponent, color: BossBarColor, division: BossBarDivision) BossBar { + return abi.call(raw.@"[constructor]boss-bar", BossBar, .{ title, color, division }); + } + + /// Returns the title of this boss bar. + pub fn getTitle(self: BossBar) TextComponent { + return abi.call(raw.@"[method]boss-bar.get-title", TextComponent, .{abi.borrow(self)}); + } + + /// Sets the title of this boss bar. + /// + /// Consumes `title`. + pub fn setTitle(self: BossBar, title: TextComponent) void { + return abi.call(raw.@"[method]boss-bar.set-title", void, .{ abi.borrow(self), title }); + } + + /// Returns the health (0.0 to 1.0) of this boss bar. + pub fn getHealth(self: BossBar) f32 { + return abi.call(raw.@"[method]boss-bar.get-health", f32, .{abi.borrow(self)}); + } + + /// Sets the health (0.0 to 1.0) of this boss bar. + pub fn setHealth(self: BossBar, health: f32) void { + return abi.call(raw.@"[method]boss-bar.set-health", void, .{ abi.borrow(self), health }); + } + + /// Returns the color of this boss bar. + pub fn getColor(self: BossBar) BossBarColor { + return abi.call(raw.@"[method]boss-bar.get-color", BossBarColor, .{abi.borrow(self)}); + } + + /// Sets the color of this boss bar. + pub fn setColor(self: BossBar, color: BossBarColor) void { + return abi.call(raw.@"[method]boss-bar.set-color", void, .{ abi.borrow(self), color }); + } + + /// Returns the division of this boss bar. + pub fn getDivision(self: BossBar) BossBarDivision { + return abi.call(raw.@"[method]boss-bar.get-division", BossBarDivision, .{abi.borrow(self)}); + } + + /// Sets the division of this boss bar. + pub fn setDivision(self: BossBar, division: BossBarDivision) void { + return abi.call(raw.@"[method]boss-bar.set-division", void, .{ abi.borrow(self), division }); + } + + /// Returns the currently active metadata on this boss bar. + pub fn getMetadata(self: BossBar) BossBarMetadata { + return abi.call(raw.@"[method]boss-bar.get-metadata", BossBarMetadata, .{abi.borrow(self)}); + } + + /// Updates the metadata on this boss bar. + pub fn setMetadata(self: BossBar, metadata: BossBarMetadata) void { + return abi.call(raw.@"[method]boss-bar.set-metadata", void, .{ abi.borrow(self), metadata }); + } + + /// Adds a player to this boss bar, making it visible to them. + /// + /// Consumes `player_`. + pub fn addPlayer(self: BossBar, player_: Player) void { + return abi.call(raw.@"[method]boss-bar.add-player", void, .{ abi.borrow(self), player_ }); + } + + /// Removes a player from this boss bar, hiding it from them. + /// + /// Consumes `player_`. + pub fn removePlayer(self: BossBar, player_: Player) void { + return abi.call(raw.@"[method]boss-bar.remove-player", void, .{ abi.borrow(self), player_ }); + } + + /// Returns a list of all players currently seeing this boss bar. + pub fn getPlayers(self: BossBar) []const Player { + return abi.call(raw.@"[method]boss-bar.get-players", []const Player, .{abi.borrow(self)}); + } + + /// Removes this boss bar from all players and cleans it up. + pub fn removeAll(self: BossBar) void { + return abi.call(raw.@"[method]boss-bar.remove-all", void, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: BossBar) void { + abi.keep(BossBar, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: BossBar) void { + abi.drop(BossBar, self); + } +}; + +const raw = struct { + extern "pumpkin:plugin/boss-bar@0.1.0" fn @"[constructor]boss-bar"(i32, i32, i32) i32; + extern "pumpkin:plugin/boss-bar@0.1.0" fn @"[method]boss-bar.get-title"(i32) i32; + extern "pumpkin:plugin/boss-bar@0.1.0" fn @"[method]boss-bar.set-title"(i32, i32) void; + extern "pumpkin:plugin/boss-bar@0.1.0" fn @"[method]boss-bar.get-health"(i32) f32; + extern "pumpkin:plugin/boss-bar@0.1.0" fn @"[method]boss-bar.set-health"(i32, f32) void; + extern "pumpkin:plugin/boss-bar@0.1.0" fn @"[method]boss-bar.get-color"(i32) i32; + extern "pumpkin:plugin/boss-bar@0.1.0" fn @"[method]boss-bar.set-color"(i32, i32) void; + extern "pumpkin:plugin/boss-bar@0.1.0" fn @"[method]boss-bar.get-division"(i32) i32; + extern "pumpkin:plugin/boss-bar@0.1.0" fn @"[method]boss-bar.set-division"(i32, i32) void; + extern "pumpkin:plugin/boss-bar@0.1.0" fn @"[method]boss-bar.get-metadata"(i32, i32) void; + extern "pumpkin:plugin/boss-bar@0.1.0" fn @"[method]boss-bar.set-metadata"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/boss-bar@0.1.0" fn @"[method]boss-bar.add-player"(i32, i32) void; + extern "pumpkin:plugin/boss-bar@0.1.0" fn @"[method]boss-bar.remove-player"(i32, i32) void; + extern "pumpkin:plugin/boss-bar@0.1.0" fn @"[method]boss-bar.get-players"(i32, i32) void; + extern "pumpkin:plugin/boss-bar@0.1.0" fn @"[method]boss-bar.remove-all"(i32) void; + extern "pumpkin:plugin/boss-bar@0.1.0" fn @"[resource-drop]boss-bar"(i32) void; +}; diff --git a/src/wit/command.zig b/src/wit/command.zig new file mode 100644 index 0000000..cf67165 --- /dev/null +++ b/src/wit/command.zig @@ -0,0 +1,434 @@ +// Generated by tools/gen.zig, do not edit. + +const abi = @import("../abi.zig"); +const world = @import("world.zig"); +const player = @import("player.zig"); +const block_entity = @import("block_entity.zig"); +const common = @import("common.zig"); +const item_stack = @import("item_stack.zig"); +const server = @import("server.zig"); +const text = @import("text.zig"); + +pub const World = world.World; +pub const Entity = world.Entity; +pub const Player = player.Player; +pub const CommandBlockEntity = block_entity.CommandBlockEntity; +pub const Position = common.Position; +pub const BlockPos = common.BlockPos; +pub const Locale = common.Locale; +pub const GameMode = common.GameMode; +pub const ItemStack = item_stack.ItemStack; +pub const Server = server.Server; +pub const Difficulty = server.Difficulty; +pub const TextComponent = text.TextComponent; + +pub const CommandError = union(enum) { + invalid_consumption: ?[]const u8, + invalid_requirement, + permission_denied, + command_failed: TextComponent, +}; + +pub const CommandNode = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]command-node"; + + pub fn literal(name: []const u8) CommandNode { + return abi.call(raw.@"[static]command-node.literal", CommandNode, .{name}); + } + + pub fn argument(name: []const u8, @"type": ArgumentType) CommandNode { + return abi.call(raw.@"[static]command-node.argument", CommandNode, .{ name, @"type" }); + } + + /// Consumes `node`. + pub fn then(self: CommandNode, node: CommandNode) void { + return abi.call(raw.@"[method]command-node.then", void, .{ abi.borrow(self), node }); + } + + pub fn executeWithHandlerId(self: CommandNode, handler_id: u32) void { + return abi.call(raw.@"[method]command-node.execute-with-handler-id", void, .{ abi.borrow(self), handler_id }); + } + + pub fn suggestWithHandlerId(self: CommandNode, handler_id: u32) void { + return abi.call(raw.@"[method]command-node.suggest-with-handler-id", void, .{ abi.borrow(self), handler_id }); + } + + pub fn requireWithHandlerId(self: CommandNode, handler_id: u32) void { + return abi.call(raw.@"[method]command-node.require-with-handler-id", void, .{ abi.borrow(self), handler_id }); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: CommandNode) void { + abi.keep(CommandNode, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: CommandNode) void { + abi.drop(CommandNode, self); + } +}; + +pub const SuggestionRequest = struct { + input: []const u8, + cursor: u32, + start: u32, + remaining: []const u8, +}; + +pub const CommandSuggestion = struct { + value: []const u8, + tooltip: ?TextComponent, +}; + +pub const CommandSuggestions = struct { + start: u32, + length: u32, + values: []const CommandSuggestion, +}; + +pub const EntityArgument = struct { + single: bool, + players_only: bool, +}; + +pub const CommandSenderType = union(enum) { + rcon, + console, + player: Player, + command_block: struct { CommandBlockEntity, World }, + dummy, +}; + +pub const PermissionLevel = enum(u8) { + zero, + one, + two, + three, + four, +}; + +pub const CommandSender = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]command-sender"; + + pub fn getCommandSenderType(self: CommandSender) CommandSenderType { + return abi.call(raw.@"[method]command-sender.get-command-sender-type", CommandSenderType, .{abi.borrow(self)}); + } + + pub fn getName(self: CommandSender) []const u8 { + return abi.call(raw.@"[method]command-sender.get-name", []const u8, .{abi.borrow(self)}); + } + + /// Consumes `text_`. + pub fn sendMessage(self: CommandSender, text_: TextComponent) void { + return abi.call(raw.@"[method]command-sender.send-message", void, .{ abi.borrow(self), text_ }); + } + + /// Consumes `text_`. + pub fn sendSystemMessage(self: CommandSender, text_: TextComponent) void { + return abi.call(raw.@"[method]command-sender.send-system-message", void, .{ abi.borrow(self), text_ }); + } + + /// Consumes `text_`. + pub fn sendError(self: CommandSender, text_: TextComponent) void { + return abi.call(raw.@"[method]command-sender.send-error", void, .{ abi.borrow(self), text_ }); + } + + pub fn setSuccessCount(self: CommandSender, count: i32) void { + return abi.call(raw.@"[method]command-sender.set-success-count", void, .{ abi.borrow(self), count }); + } + + pub fn isPlayer(self: CommandSender) bool { + return abi.call(raw.@"[method]command-sender.is-player", bool, .{abi.borrow(self)}); + } + + pub fn isConsole(self: CommandSender) bool { + return abi.call(raw.@"[method]command-sender.is-console", bool, .{abi.borrow(self)}); + } + + pub fn asPlayer(self: CommandSender) ?Player { + return abi.call(raw.@"[method]command-sender.as-player", ?Player, .{abi.borrow(self)}); + } + + pub fn permissionLevel(self: CommandSender) PermissionLevel { + return abi.call(raw.@"[method]command-sender.permission-level", PermissionLevel, .{abi.borrow(self)}); + } + + pub fn hasPermissionLevel(self: CommandSender, level: PermissionLevel) bool { + return abi.call(raw.@"[method]command-sender.has-permission-level", bool, .{ abi.borrow(self), level }); + } + + pub fn hasPermission(self: CommandSender, server_: Server, node: []const u8) bool { + return abi.call(raw.@"[method]command-sender.has-permission", bool, .{ abi.borrow(self), abi.borrow(server_), node }); + } + + pub fn position(self: CommandSender) ?Position { + return abi.call(raw.@"[method]command-sender.position", ?Position, .{abi.borrow(self)}); + } + + pub fn world(self: CommandSender) ?World { + return abi.call(raw.@"[method]command-sender.world", ?World, .{abi.borrow(self)}); + } + + pub fn getLocale(self: CommandSender) Locale { + return abi.call(raw.@"[method]command-sender.get-locale", Locale, .{abi.borrow(self)}); + } + + pub fn shouldReceiveFeedback(self: CommandSender) bool { + return abi.call(raw.@"[method]command-sender.should-receive-feedback", bool, .{abi.borrow(self)}); + } + + pub fn shouldBroadcastConsoleToOps(self: CommandSender) bool { + return abi.call(raw.@"[method]command-sender.should-broadcast-console-to-ops", bool, .{abi.borrow(self)}); + } + + pub fn shouldTrackOutput(self: CommandSender) bool { + return abi.call(raw.@"[method]command-sender.should-track-output", bool, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: CommandSender) void { + abi.keep(CommandSender, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: CommandSender) void { + abi.drop(CommandSender, self); + } +}; + +pub const StringType = enum(u8) { + single_word, + quotable, + greedy, +}; + +pub const ArgumentType = union(enum) { + bool, + float: struct { ?f32, ?f32 }, + double: struct { ?f64, ?f64 }, + integer: struct { ?i32, ?i32 }, + long: struct { ?i64, ?i64 }, + string: StringType, + entities, + entity, + players, + game_profile, + block_pos, + column_pos, + position3d, + position2d, + block_state, + block_predicate, + item, + item_predicate, + color, + component, + style, + message, + nbt_compound_tag, + nbt_tag, + nbt_path, + objective, + objective_criteria, + operation, + particle, + angle, + rotation, + scoreboard_slot, + score_holder: bool, + swizzle, + team, + item_slot, + resource_location, + mob_effect, + function, + entity_anchor, + int_range, + float_range, + dimension, + gamemode, + difficulty, + time: ?i32, + resource: []const u8, + resource_or_tag: []const u8, + resource_or_tag_key: []const u8, + resource_key: []const u8, + template_mirror, + template_rotation, + uuid, +}; + +pub const SuggestionType = enum(u8) { + ask_server, + all_recipes, + available_sounds, + available_biomes, + summonable_entities, +}; + +pub const BossbarColor = enum(u8) { + pink, + blue, + red, + green, + yellow, + purple, + white, +}; + +pub const BossbarStyle = enum(u8) { + no_division, + notches6, + notches10, + notches12, + notches20, +}; + +pub const SoundCategory = enum(u8) { + master, + music, + records, + weather, + blocks, + hostile, + neutral, + players, + ambient, + voice, +}; + +pub const EntityAnchor = enum(u8) { + eyes, + feet, +}; + +pub const Number = union(enum) { + float64: f64, + float32: f32, + int32: i32, + int64: i64, +}; + +pub const NotInBounds = union(enum) { + lower_bound: struct { Number, Number }, + upper_bound: struct { Number, Number }, +}; + +pub const Arg = union(enum) { + simple: []const u8, + msg: []const u8, + bool: bool, + item: []const u8, + item_predicate: []const u8, + resource_location: []const u8, + block: []const u8, + block_predicate: []const u8, + time: i32, + num: abi.Result(Number, NotInBounds), + block_pos: BlockPos, + pos3d: struct { f64, f64, f64 }, + pos2d: struct { f64, f64 }, + rotation: struct { f32, bool, f32, bool }, + gamemode: GameMode, + difficulty: Difficulty, + players: []const Player, + particle: []const u8, + text_component: TextComponent, + bossbar_color: BossbarColor, + bossbar_style: BossbarStyle, + sound_category: SoundCategory, + damage_type: []const u8, + effect: []const u8, + enchantment: []const u8, + advancement: []const u8, + entity_anchor: EntityAnchor, +}; + +pub const ConsumedArgs = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]consumed-args"; + + pub fn getValue(self: ConsumedArgs, key: []const u8) Arg { + return abi.call(raw.@"[method]consumed-args.get-value", Arg, .{ abi.borrow(self), key }); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: ConsumedArgs) void { + abi.keep(ConsumedArgs, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: ConsumedArgs) void { + abi.drop(ConsumedArgs, self); + } +}; + +pub const Command = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]command"; + + /// First name is primary, rest are aliases + pub fn init(names: []const []const u8, description: []const u8) Command { + return abi.call(raw.@"[constructor]command", Command, .{ names, description }); + } + + /// Consumes `node`. + pub fn then(self: Command, node: CommandNode) void { + return abi.call(raw.@"[method]command.then", void, .{ abi.borrow(self), node }); + } + + pub fn executeWithHandlerId(self: Command, handler_id: u32) void { + return abi.call(raw.@"[method]command.execute-with-handler-id", void, .{ abi.borrow(self), handler_id }); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: Command) void { + abi.keep(Command, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: Command) void { + abi.drop(Command, self); + } +}; + +const raw = struct { + extern "pumpkin:plugin/command@0.1.0" fn @"[static]command-node.literal"(i32, i32) i32; + extern "pumpkin:plugin/command@0.1.0" fn @"[static]command-node.argument"(i32, i32, i32, i32, i64, i32, i64) i32; + extern "pumpkin:plugin/command@0.1.0" fn @"[method]command-node.then"(i32, i32) void; + extern "pumpkin:plugin/command@0.1.0" fn @"[method]command-node.execute-with-handler-id"(i32, i32) void; + extern "pumpkin:plugin/command@0.1.0" fn @"[method]command-node.suggest-with-handler-id"(i32, i32) void; + extern "pumpkin:plugin/command@0.1.0" fn @"[method]command-node.require-with-handler-id"(i32, i32) void; + extern "pumpkin:plugin/command@0.1.0" fn @"[method]command-sender.get-command-sender-type"(i32, i32) void; + extern "pumpkin:plugin/command@0.1.0" fn @"[method]command-sender.get-name"(i32, i32) void; + extern "pumpkin:plugin/command@0.1.0" fn @"[method]command-sender.send-message"(i32, i32) void; + extern "pumpkin:plugin/command@0.1.0" fn @"[method]command-sender.send-system-message"(i32, i32) void; + extern "pumpkin:plugin/command@0.1.0" fn @"[method]command-sender.send-error"(i32, i32) void; + extern "pumpkin:plugin/command@0.1.0" fn @"[method]command-sender.set-success-count"(i32, i32) void; + extern "pumpkin:plugin/command@0.1.0" fn @"[method]command-sender.is-player"(i32) i32; + extern "pumpkin:plugin/command@0.1.0" fn @"[method]command-sender.is-console"(i32) i32; + extern "pumpkin:plugin/command@0.1.0" fn @"[method]command-sender.as-player"(i32, i32) void; + extern "pumpkin:plugin/command@0.1.0" fn @"[method]command-sender.permission-level"(i32) i32; + extern "pumpkin:plugin/command@0.1.0" fn @"[method]command-sender.has-permission-level"(i32, i32) i32; + extern "pumpkin:plugin/command@0.1.0" fn @"[method]command-sender.has-permission"(i32, i32, i32, i32) i32; + extern "pumpkin:plugin/command@0.1.0" fn @"[method]command-sender.position"(i32, i32) void; + extern "pumpkin:plugin/command@0.1.0" fn @"[method]command-sender.world"(i32, i32) void; + extern "pumpkin:plugin/command@0.1.0" fn @"[method]command-sender.get-locale"(i32) i32; + extern "pumpkin:plugin/command@0.1.0" fn @"[method]command-sender.should-receive-feedback"(i32) i32; + extern "pumpkin:plugin/command@0.1.0" fn @"[method]command-sender.should-broadcast-console-to-ops"(i32) i32; + extern "pumpkin:plugin/command@0.1.0" fn @"[method]command-sender.should-track-output"(i32) i32; + extern "pumpkin:plugin/command@0.1.0" fn @"[method]consumed-args.get-value"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/command@0.1.0" fn @"[constructor]command"(i32, i32, i32, i32) i32; + extern "pumpkin:plugin/command@0.1.0" fn @"[method]command.then"(i32, i32) void; + extern "pumpkin:plugin/command@0.1.0" fn @"[method]command.execute-with-handler-id"(i32, i32) void; + extern "pumpkin:plugin/command@0.1.0" fn @"[resource-drop]command-node"(i32) void; + extern "pumpkin:plugin/command@0.1.0" fn @"[resource-drop]command-sender"(i32) void; + extern "pumpkin:plugin/command@0.1.0" fn @"[resource-drop]consumed-args"(i32) void; + extern "pumpkin:plugin/command@0.1.0" fn @"[resource-drop]command"(i32) void; +}; diff --git a/src/wit/common.zig b/src/wit/common.zig new file mode 100644 index 0000000..997461b --- /dev/null +++ b/src/wit/common.zig @@ -0,0 +1,260 @@ +// Generated by tools/gen.zig, do not edit. + +/// Serialized text component as a postcard byte array. +/// @deprecated Use the text-component resource from the text interface instead. +pub const RawTextComponent = []const u8; + +/// Represents one entry in an NBT compound tag. +pub const NbtEntry = struct { + key: []const u8, + value: u32, +}; + +/// Represents a Minecraft NBT tag. +pub const NbtTag = union(enum) { + byte: i8, + short: i16, + int: i32, + long: i64, + float: f32, + double: f64, + byte_array: []const i8, + string_tag: []const u8, + list_tag: []const u32, + compound: []const NbtEntry, + int_array: []const i32, + long_array: []const i64, +}; + +/// Represents a Minecraft NBT tag tree. +pub const NbtTree = struct { + root: u32, + tags: []const NbtTag, +}; + +/// A position in the world grid (integers). +pub const BlockPos = struct { + x: i32, + y: i32, + z: i32, +}; + +/// A precise coordinate in the world (floats). +pub const Position = struct { f64, f64, f64 }; + +/// Represents the hands of a player. +pub const Hand = enum(u8) { + left, + right, +}; + +/// Represents the game modes available in Minecraft. +pub const GameMode = enum(u8) { + survival, + creative, + adventure, + spectator, +}; + +/// The 16 base Minecraft colors. +pub const NamedColor = enum(u8) { + black, + dark_blue, + dark_green, + dark_aqua, + dark_red, + dark_purple, + gold, + gray, + dark_gray, + blue, + green, + aqua, + red, + light_purple, + yellow, + white, +}; + +/// An RGB color represented by its red, green, and blue components. +pub const RgbColor = struct { + r: u8, + g: u8, + b: u8, +}; + +/// An ARGB color with alpha (transparency) channel. +pub const ArgbColor = struct { + a: u8, + r: u8, + g: u8, + b: u8, +}; + +/// Represents the type of click interaction in a GUI. +pub const ClickType = enum(u8) { + left, + right, + shift_left, + shift_right, + middle, + drop, + control_drop, + double_click, + number_key, + unknown, +}; + +/// Represents the various poses an entity can be in. +pub const EntityPose = enum(u8) { + standing, + fall_flying, + sleeping, + swimming, + spin_attack, + crouching, + long_jumping, + dying, + croaking, + using_tongue, + sitting, + roaring, + sniffing, + emerging, + digging, + sliding, + shooting, + inhaling, +}; + +/// All Minecraft-supported locales. +pub const Locale = enum(u8) { + af_za, + ar_sa, + ast_es, + az_az, + ba_ru, + bar, + be_by, + bg_bg, + br_fr, + brb, + bs_ba, + ca_es, + cs_cz, + cy_gb, + da_dk, + de_at, + de_ch, + de_de, + el_gr, + en_au, + en_ca, + en_gb, + en_nz, + en_pt, + en_ud, + en_us, + enp, + enws, + eo_uy, + es_ar, + es_cl, + es_ec, + es_es, + es_mx, + es_uy, + es_ve, + esan, + et_ee, + eu_es, + fa_ir, + fi_fi, + fil_ph, + fo_fo, + fr_ca, + fr_fr, + fra_de, + fur_it, + fy_nl, + ga_ie, + gd_gb, + gl_es, + haw_us, + he_il, + hi_in, + hr_hr, + hu_hu, + hy_am, + id_id, + ig_ng, + io_en, + is_is, + isv, + it_it, + ja_jp, + jbo_en, + ka_ge, + kk_kz, + kn_in, + ko_kr, + ksh, + kw_gb, + la_la, + lb_lu, + li_li, + lmo, + lo_la, + lol_us, + lt_lt, + lv_lv, + lzh, + mk_mk, + mn_mn, + ms_my, + mt_mt, + nah, + nds_de, + nl_be, + nl_nl, + nn_no, + no_no, + oc_fr, + ovd, + pl_pl, + pt_br, + pt_pt, + qya_aa, + ro_ro, + rpr, + ru_ru, + ry_ua, + sah_sah, + se_no, + sk_sk, + sl_si, + so_so, + sq_al, + sr_cs, + sr_sp, + sv_se, + sxu, + szl, + ta_in, + th_th, + tl_ph, + tlh_aa, + tok, + tr_tr, + tt_ru, + uk_ua, + val_es, + vec_it, + vi_vn, + yi_de, + yo_ng, + zh_cn, + zh_hk, + zh_tw, + zlm_arab, +}; diff --git a/src/wit/context.zig b/src/wit/context.zig new file mode 100644 index 0000000..72b4091 --- /dev/null +++ b/src/wit/context.zig @@ -0,0 +1,104 @@ +// Generated by tools/gen.zig, do not edit. + +const abi = @import("../abi.zig"); +const server = @import("server.zig"); +const event = @import("event.zig"); +const command = @import("command.zig"); +const permission = @import("permission.zig"); + +pub const Server = server.Server; +pub const EventType = event.EventType; +pub const EventPriority = event.EventPriority; +pub const Command = command.Command; +pub const Permission = permission.Permission; + +/// Verified marketplace metadata for signed plugins. +pub const MarketplaceMetadata = struct { + /// The marketplace base URL where this plugin is registered. + marketplace_url: []const u8, + /// The unique plugin ID on the marketplace. + plugin_id: i64, + /// The canonical plugin name. + plugin_name: []const u8, + /// The semver version string of the plugin. + version: []const u8, + /// Developer ID. + dev_id: i64, + /// Developer display name or username. + dev_name: []const u8, + /// Whether this is a paid marketplace plugin. + is_paid: bool, + /// The buyer / licensee user ID (0 for free/open-source). + user_id: i64, + /// Unique license key issued to the buyer, if paid. + license_key: ?[]const u8, + /// ISO-8601 timestamp of when this binary/license was issued. + issued_at: []const u8, +}; + +/// A contextual handle for plugin-related operations. +pub const Context = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]context"; + + /// Registers a handler for a specific event. + /// + /// * `handler-id`: Unique ID for the event handler. + /// * `event-type`: The type of event to listen for. + /// * `event-priority`: When this handler should be called relative to others. + /// * `blocking`: Whether the event should wait for this handler to finish. + pub fn registerEvent(self: Context, handler_id: u32, event_type: EventType, event_priority: EventPriority, blocking: bool) void { + return abi.call(raw.@"[method]context.register-event", void, .{ abi.borrow(self), handler_id, event_type, event_priority, blocking }); + } + + /// Registers a new command. + /// + /// * `command`: The command definition. + /// * `permission`: The required permission node to execute this command. + /// + /// Consumes `command_`. + pub fn registerCommand(self: Context, command_: Command, permission_: []const u8) void { + return abi.call(raw.@"[method]context.register-command", void, .{ abi.borrow(self), command_, permission_ }); + } + + /// Registers a permission node with the server. + pub fn registerPermission(self: Context, permission_: Permission) abi.Result(void, []const u8) { + return abi.call(raw.@"[method]context.register-permission", abi.Result(void, []const u8), .{ abi.borrow(self), permission_ }); + } + + /// Returns the path to the plugin's private data folder. + pub fn getDataFolder(self: Context) []const u8 { + return abi.call(raw.@"[method]context.get-data-folder", []const u8, .{abi.borrow(self)}); + } + + /// Returns the global server instance. + pub fn getServer(self: Context) Server { + return abi.call(raw.@"[method]context.get-server", Server, .{abi.borrow(self)}); + } + + /// Returns verified marketplace metadata if this plugin binary is signed, or none if unsigned. + pub fn getMarketplaceMetadata(self: Context) ?MarketplaceMetadata { + return abi.call(raw.@"[method]context.get-marketplace-metadata", ?MarketplaceMetadata, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: Context) void { + abi.keep(Context, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: Context) void { + abi.drop(Context, self); + } +}; + +const raw = struct { + extern "pumpkin:plugin/context@0.1.0" fn @"[method]context.register-event"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/context@0.1.0" fn @"[method]context.register-command"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/context@0.1.0" fn @"[method]context.register-permission"(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/context@0.1.0" fn @"[method]context.get-data-folder"(i32, i32) void; + extern "pumpkin:plugin/context@0.1.0" fn @"[method]context.get-server"(i32) i32; + extern "pumpkin:plugin/context@0.1.0" fn @"[method]context.get-marketplace-metadata"(i32, i32) void; + extern "pumpkin:plugin/context@0.1.0" fn @"[resource-drop]context"(i32) void; +}; diff --git a/src/wit/damage_types.zig b/src/wit/damage_types.zig new file mode 100644 index 0000000..0b17aa0 --- /dev/null +++ b/src/wit/damage_types.zig @@ -0,0 +1,55 @@ +// Generated by tools/gen.zig, do not edit. + +pub const DamageType = enum(u8) { + arrow, + bad_respawn_point, + cactus, + campfire, + cramming, + dragon_breath, + drown, + dry_out, + ender_pearl, + explosion, + fall, + falling_anvil, + falling_block, + falling_stalactite, + fireball, + fireworks, + fly_into_wall, + freeze, + generic, + generic_kill, + hot_floor, + in_fire, + in_wall, + indirect_magic, + lava, + lightning_bolt, + mace_smash, + magic, + mob_attack, + mob_attack_no_aggro, + mob_projectile, + on_fire, + out_of_world, + outside_border, + player_attack, + player_explosion, + sonic_boom, + spear, + spit, + stalagmite, + starve, + sting, + sulfur_cube_hot, + sweet_berry_bush, + thorns, + thrown, + trident, + unattributed_fireball, + wind_charge, + wither, + wither_skull, +}; diff --git a/src/wit/data_components.zig b/src/wit/data_components.zig new file mode 100644 index 0000000..b0f893f --- /dev/null +++ b/src/wit/data_components.zig @@ -0,0 +1,115 @@ +// Generated by tools/gen.zig, do not edit. + +pub const DataComponent = enum(u8) { + custom_data, + max_stack_size, + max_damage, + damage, + unbreakable, + use_effects, + custom_name, + minimum_attack_charge, + damage_type, + item_name, + item_model, + lore, + rarity, + enchantments, + can_place_on, + can_break, + attribute_modifiers, + custom_model_data, + tooltip_display, + repair_cost, + creative_slot_lock, + enchantment_glint_override, + intangible_projectile, + food, + consumable, + use_remainder, + use_cooldown, + damage_resistant, + tool, + weapon, + attack_range, + enchantable, + equippable, + repairable, + glider, + tooltip_style, + death_protection, + blocks_attacks, + piercing_weapon, + kinetic_weapon, + swing_animation, + additional_trade_cost, + stored_enchantments, + dye, + dyed_color, + map_color, + map_id, + map_decorations, + map_post_processing, + charged_projectiles, + bundle_contents, + potion_contents, + potion_duration_scale, + suspicious_stew_effects, + writable_book_content, + written_book_content, + trim, + debug_stick_state, + entity_data, + bucket_entity_data, + block_entity_data, + instrument, + provides_trim_material, + ominous_bottle_amplifier, + jukebox_playable, + provides_banner_patterns, + recipes, + lodestone_tracker, + firework_explosion, + fireworks, + profile, + note_block_sound, + banner_patterns, + base_color, + pot_decorations, + container, + block_state, + bees, + sulfur_cube_content, + lock, + container_loot, + break_sound, + villager_variant, + wolf_variant, + wolf_sound_variant, + wolf_collar, + fox_variant, + salmon_size, + parrot_variant, + tropical_fish_pattern, + tropical_fish_base_color, + tropical_fish_pattern_color, + mooshroom_variant, + rabbit_variant, + pig_variant, + pig_sound_variant, + cow_variant, + cow_sound_variant, + chicken_variant, + chicken_sound_variant, + zombie_nautilus_variant, + frog_variant, + horse_variant, + painting_variant, + llama_variant, + axolotl_variant, + cat_variant, + cat_sound_variant, + cat_collar, + sheep_color, + shulker_color, +}; diff --git a/src/wit/datapack.zig b/src/wit/datapack.zig new file mode 100644 index 0000000..a548364 --- /dev/null +++ b/src/wit/datapack.zig @@ -0,0 +1,99 @@ +// Generated by tools/gen.zig, do not edit. + +const abi = @import("../abi.zig"); + +/// Information about a discovered or loaded datapack. +pub const DatapackInfo = struct { + id: []const u8, + name: []const u8, + description: []const u8, + pack_format: u32, + is_enabled: bool, + recipe_count: u32, + function_count: u32, +}; + +/// Position options for enabling a datapack relative to other packs. +pub const EnablePosition = union(enum) { + first, + last, + before: []const u8, + after: []const u8, +}; + +/// Global manager for inspecting and controlling server datapacks. +pub const DatapackManager = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]datapack-manager"; + + /// Returns all known datapacks (both enabled and available/disabled). + pub fn listAllPacks(self: DatapackManager) []const DatapackInfo { + return abi.call(raw.@"[method]datapack-manager.list-all-packs", []const DatapackInfo, .{abi.borrow(self)}); + } + + /// Returns only currently enabled datapacks. + pub fn listEnabledPacks(self: DatapackManager) []const DatapackInfo { + return abi.call(raw.@"[method]datapack-manager.list-enabled-packs", []const DatapackInfo, .{abi.borrow(self)}); + } + + /// Returns available (disabled) datapacks. + pub fn listAvailablePacks(self: DatapackManager) []const DatapackInfo { + return abi.call(raw.@"[method]datapack-manager.list-available-packs", []const DatapackInfo, .{abi.borrow(self)}); + } + + /// Retrieves details about a specific datapack by name or ID. + pub fn getPack(self: DatapackManager, name: []const u8) ?DatapackInfo { + return abi.call(raw.@"[method]datapack-manager.get-pack", ?DatapackInfo, .{ abi.borrow(self), name }); + } + + /// Checks if a datapack is currently enabled. + pub fn isEnabled(self: DatapackManager, name: []const u8) bool { + return abi.call(raw.@"[method]datapack-manager.is-enabled", bool, .{ abi.borrow(self), name }); + } + + /// Enables a datapack with a specific priority position. + pub fn enablePack(self: DatapackManager, name: []const u8, position: EnablePosition) abi.Result(void, []const u8) { + return abi.call(raw.@"[method]datapack-manager.enable-pack", abi.Result(void, []const u8), .{ abi.borrow(self), name, position }); + } + + /// Disables an enabled datapack. + pub fn disablePack(self: DatapackManager, name: []const u8) abi.Result(void, []const u8) { + return abi.call(raw.@"[method]datapack-manager.disable-pack", abi.Result(void, []const u8), .{ abi.borrow(self), name }); + } + + /// Reloads all enabled datapacks, recipes, and function tags, + /// synchronizes recipes with online players, and triggers `#minecraft:load`. + pub fn reload(self: DatapackManager) abi.Result(void, []const u8) { + return abi.call(raw.@"[method]datapack-manager.reload", abi.Result(void, []const u8), .{abi.borrow(self)}); + } + + /// Executes a datapack function or function tag (e.g. "namespace:fn" or "#namespace:tag"). + /// Returns the number of commands executed. + pub fn executeFunction(self: DatapackManager, name: []const u8) abi.Result(u32, []const u8) { + return abi.call(raw.@"[method]datapack-manager.execute-function", abi.Result(u32, []const u8), .{ abi.borrow(self), name }); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: DatapackManager) void { + abi.keep(DatapackManager, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: DatapackManager) void { + abi.drop(DatapackManager, self); + } +}; + +const raw = struct { + extern "pumpkin:plugin/datapack@0.1.0" fn @"[method]datapack-manager.list-all-packs"(i32, i32) void; + extern "pumpkin:plugin/datapack@0.1.0" fn @"[method]datapack-manager.list-enabled-packs"(i32, i32) void; + extern "pumpkin:plugin/datapack@0.1.0" fn @"[method]datapack-manager.list-available-packs"(i32, i32) void; + extern "pumpkin:plugin/datapack@0.1.0" fn @"[method]datapack-manager.get-pack"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/datapack@0.1.0" fn @"[method]datapack-manager.is-enabled"(i32, i32, i32) i32; + extern "pumpkin:plugin/datapack@0.1.0" fn @"[method]datapack-manager.enable-pack"(i32, i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/datapack@0.1.0" fn @"[method]datapack-manager.disable-pack"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/datapack@0.1.0" fn @"[method]datapack-manager.reload"(i32, i32) void; + extern "pumpkin:plugin/datapack@0.1.0" fn @"[method]datapack-manager.execute-function"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/datapack@0.1.0" fn @"[resource-drop]datapack-manager"(i32) void; +}; diff --git a/src/wit/display.zig b/src/wit/display.zig new file mode 100644 index 0000000..0853884 --- /dev/null +++ b/src/wit/display.zig @@ -0,0 +1,492 @@ +// Generated by tools/gen.zig, do not edit. + +const abi = @import("../abi.zig"); +const world = @import("world.zig"); +const text = @import("text.zig"); +const item_stack = @import("item_stack.zig"); +const uuid = @import("uuid.zig"); + +pub const Entity = world.Entity; +pub const TextComponent = text.TextComponent; +pub const ItemStack = item_stack.ItemStack; +pub const Uuid = uuid.Uuid; + +/// Billboard rendering constraints for display entities. +pub const BillboardMode = enum(u8) { + fixed, + vertical, + horizontal, + center, +}; + +/// Item display transformation modes for item display entities. +pub const ItemDisplayMode = enum(u8) { + none, + thirdperson_lefthand, + thirdperson_righthand, + firstperson_lefthand, + firstperson_righthand, + head, + gui, + ground, + fixed, +}; + +/// Text alignment options for text display entities. +pub const TextAlignment = enum(u8) { + center, + left, + right, +}; + +/// 3D single-precision vector. +pub const Vector3f = struct { + x: f32, + y: f32, + z: f32, +}; + +/// Single-precision quaternion representing a 3D rotation. +pub const Quaternionf = struct { + x: f32, + y: f32, + z: f32, + w: f32, +}; + +/// Transformation (translation, scale, left and right rotations) for display entities. +pub const DisplayTransformation = struct { + translation: Vector3f, + scale: Vector3f, + left_rotation: Quaternionf, + right_rotation: Quaternionf, +}; + +/// Common base resource for all display entities. +pub const DisplayEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]display-entity"; + + pub fn fromEntity(entity: Entity) ?DisplayEntity { + return abi.call(raw.@"[static]display-entity.from-entity", ?DisplayEntity, .{abi.borrow(entity)}); + } + + pub fn getEntity(self: DisplayEntity) Entity { + return abi.call(raw.@"[method]display-entity.get-entity", Entity, .{abi.borrow(self)}); + } + + pub fn getTransformation(self: DisplayEntity) DisplayTransformation { + return abi.call(raw.@"[method]display-entity.get-transformation", DisplayTransformation, .{abi.borrow(self)}); + } + + pub fn setTransformation(self: DisplayEntity, transformation: DisplayTransformation) void { + return abi.call(raw.@"[method]display-entity.set-transformation", void, .{ abi.borrow(self), transformation }); + } + + pub fn getInterpolationDuration(self: DisplayEntity) i32 { + return abi.call(raw.@"[method]display-entity.get-interpolation-duration", i32, .{abi.borrow(self)}); + } + + pub fn setInterpolationDuration(self: DisplayEntity, duration: i32) void { + return abi.call(raw.@"[method]display-entity.set-interpolation-duration", void, .{ abi.borrow(self), duration }); + } + + pub fn getInterpolationStart(self: DisplayEntity) i32 { + return abi.call(raw.@"[method]display-entity.get-interpolation-start", i32, .{abi.borrow(self)}); + } + + pub fn setInterpolationStart(self: DisplayEntity, delta_ticks: i32) void { + return abi.call(raw.@"[method]display-entity.set-interpolation-start", void, .{ abi.borrow(self), delta_ticks }); + } + + pub fn getTeleportDuration(self: DisplayEntity) i32 { + return abi.call(raw.@"[method]display-entity.get-teleport-duration", i32, .{abi.borrow(self)}); + } + + pub fn setTeleportDuration(self: DisplayEntity, duration: i32) void { + return abi.call(raw.@"[method]display-entity.set-teleport-duration", void, .{ abi.borrow(self), duration }); + } + + pub fn getBillboard(self: DisplayEntity) BillboardMode { + return abi.call(raw.@"[method]display-entity.get-billboard", BillboardMode, .{abi.borrow(self)}); + } + + pub fn setBillboard(self: DisplayEntity, mode: BillboardMode) void { + return abi.call(raw.@"[method]display-entity.set-billboard", void, .{ abi.borrow(self), mode }); + } + + pub fn getViewRange(self: DisplayEntity) f32 { + return abi.call(raw.@"[method]display-entity.get-view-range", f32, .{abi.borrow(self)}); + } + + pub fn setViewRange(self: DisplayEntity, range: f32) void { + return abi.call(raw.@"[method]display-entity.set-view-range", void, .{ abi.borrow(self), range }); + } + + pub fn getShadowRadius(self: DisplayEntity) f32 { + return abi.call(raw.@"[method]display-entity.get-shadow-radius", f32, .{abi.borrow(self)}); + } + + pub fn setShadowRadius(self: DisplayEntity, radius: f32) void { + return abi.call(raw.@"[method]display-entity.set-shadow-radius", void, .{ abi.borrow(self), radius }); + } + + pub fn getShadowStrength(self: DisplayEntity) f32 { + return abi.call(raw.@"[method]display-entity.get-shadow-strength", f32, .{abi.borrow(self)}); + } + + pub fn setShadowStrength(self: DisplayEntity, strength: f32) void { + return abi.call(raw.@"[method]display-entity.set-shadow-strength", void, .{ abi.borrow(self), strength }); + } + + pub fn getDisplayWidth(self: DisplayEntity) f32 { + return abi.call(raw.@"[method]display-entity.get-display-width", f32, .{abi.borrow(self)}); + } + + pub fn setDisplayWidth(self: DisplayEntity, width: f32) void { + return abi.call(raw.@"[method]display-entity.set-display-width", void, .{ abi.borrow(self), width }); + } + + pub fn getDisplayHeight(self: DisplayEntity) f32 { + return abi.call(raw.@"[method]display-entity.get-display-height", f32, .{abi.borrow(self)}); + } + + pub fn setDisplayHeight(self: DisplayEntity, height: f32) void { + return abi.call(raw.@"[method]display-entity.set-display-height", void, .{ abi.borrow(self), height }); + } + + pub fn getGlowColorOverride(self: DisplayEntity) i32 { + return abi.call(raw.@"[method]display-entity.get-glow-color-override", i32, .{abi.borrow(self)}); + } + + pub fn setGlowColorOverride(self: DisplayEntity, color: i32) void { + return abi.call(raw.@"[method]display-entity.set-glow-color-override", void, .{ abi.borrow(self), color }); + } + + pub fn getBrightness(self: DisplayEntity) i32 { + return abi.call(raw.@"[method]display-entity.get-brightness", i32, .{abi.borrow(self)}); + } + + pub fn setBrightness(self: DisplayEntity, brightness: i32) void { + return abi.call(raw.@"[method]display-entity.set-brightness", void, .{ abi.borrow(self), brightness }); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: DisplayEntity) void { + abi.keep(DisplayEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: DisplayEntity) void { + abi.drop(DisplayEntity, self); + } +}; + +/// Resource specifically for Block Display entities. +pub const BlockDisplayEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]block-display-entity"; + + pub fn fromEntity(entity: Entity) ?BlockDisplayEntity { + return abi.call(raw.@"[static]block-display-entity.from-entity", ?BlockDisplayEntity, .{abi.borrow(entity)}); + } + + pub fn getDisplay(self: BlockDisplayEntity) DisplayEntity { + return abi.call(raw.@"[method]block-display-entity.get-display", DisplayEntity, .{abi.borrow(self)}); + } + + pub fn getEntity(self: BlockDisplayEntity) Entity { + return abi.call(raw.@"[method]block-display-entity.get-entity", Entity, .{abi.borrow(self)}); + } + + pub fn getBlockStateId(self: BlockDisplayEntity) u16 { + return abi.call(raw.@"[method]block-display-entity.get-block-state-id", u16, .{abi.borrow(self)}); + } + + pub fn setBlockStateId(self: BlockDisplayEntity, state_id: u16) void { + return abi.call(raw.@"[method]block-display-entity.set-block-state-id", void, .{ abi.borrow(self), state_id }); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: BlockDisplayEntity) void { + abi.keep(BlockDisplayEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: BlockDisplayEntity) void { + abi.drop(BlockDisplayEntity, self); + } +}; + +/// Resource specifically for Item Display entities. +pub const ItemDisplayEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]item-display-entity"; + + pub fn fromEntity(entity: Entity) ?ItemDisplayEntity { + return abi.call(raw.@"[static]item-display-entity.from-entity", ?ItemDisplayEntity, .{abi.borrow(entity)}); + } + + pub fn getDisplay(self: ItemDisplayEntity) DisplayEntity { + return abi.call(raw.@"[method]item-display-entity.get-display", DisplayEntity, .{abi.borrow(self)}); + } + + pub fn getEntity(self: ItemDisplayEntity) Entity { + return abi.call(raw.@"[method]item-display-entity.get-entity", Entity, .{abi.borrow(self)}); + } + + pub fn getItem(self: ItemDisplayEntity) ?ItemStack { + return abi.call(raw.@"[method]item-display-entity.get-item", ?ItemStack, .{abi.borrow(self)}); + } + + pub fn setItem(self: ItemDisplayEntity, item: ?ItemStack) void { + return abi.call(raw.@"[method]item-display-entity.set-item", void, .{ abi.borrow(self), item }); + } + + pub fn getItemDisplayMode(self: ItemDisplayEntity) ItemDisplayMode { + return abi.call(raw.@"[method]item-display-entity.get-item-display-mode", ItemDisplayMode, .{abi.borrow(self)}); + } + + pub fn setItemDisplayMode(self: ItemDisplayEntity, mode: ItemDisplayMode) void { + return abi.call(raw.@"[method]item-display-entity.set-item-display-mode", void, .{ abi.borrow(self), mode }); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: ItemDisplayEntity) void { + abi.keep(ItemDisplayEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: ItemDisplayEntity) void { + abi.drop(ItemDisplayEntity, self); + } +}; + +/// Resource specifically for Text Display entities. +pub const TextDisplayEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]text-display-entity"; + + pub fn fromEntity(entity: Entity) ?TextDisplayEntity { + return abi.call(raw.@"[static]text-display-entity.from-entity", ?TextDisplayEntity, .{abi.borrow(entity)}); + } + + pub fn getDisplay(self: TextDisplayEntity) DisplayEntity { + return abi.call(raw.@"[method]text-display-entity.get-display", DisplayEntity, .{abi.borrow(self)}); + } + + pub fn getEntity(self: TextDisplayEntity) Entity { + return abi.call(raw.@"[method]text-display-entity.get-entity", Entity, .{abi.borrow(self)}); + } + + pub fn getText(self: TextDisplayEntity) TextComponent { + return abi.call(raw.@"[method]text-display-entity.get-text", TextComponent, .{abi.borrow(self)}); + } + + /// Consumes `text_`. + pub fn setText(self: TextDisplayEntity, text_: TextComponent) void { + return abi.call(raw.@"[method]text-display-entity.set-text", void, .{ abi.borrow(self), text_ }); + } + + pub fn getLineWidth(self: TextDisplayEntity) i32 { + return abi.call(raw.@"[method]text-display-entity.get-line-width", i32, .{abi.borrow(self)}); + } + + pub fn setLineWidth(self: TextDisplayEntity, width: i32) void { + return abi.call(raw.@"[method]text-display-entity.set-line-width", void, .{ abi.borrow(self), width }); + } + + pub fn getBackground(self: TextDisplayEntity) i32 { + return abi.call(raw.@"[method]text-display-entity.get-background", i32, .{abi.borrow(self)}); + } + + pub fn setBackground(self: TextDisplayEntity, color: i32) void { + return abi.call(raw.@"[method]text-display-entity.set-background", void, .{ abi.borrow(self), color }); + } + + pub fn getTextOpacity(self: TextDisplayEntity) i8 { + return abi.call(raw.@"[method]text-display-entity.get-text-opacity", i8, .{abi.borrow(self)}); + } + + pub fn setTextOpacity(self: TextDisplayEntity, opacity: i8) void { + return abi.call(raw.@"[method]text-display-entity.set-text-opacity", void, .{ abi.borrow(self), opacity }); + } + + pub fn getShadow(self: TextDisplayEntity) bool { + return abi.call(raw.@"[method]text-display-entity.get-shadow", bool, .{abi.borrow(self)}); + } + + pub fn setShadow(self: TextDisplayEntity, shadow: bool) void { + return abi.call(raw.@"[method]text-display-entity.set-shadow", void, .{ abi.borrow(self), shadow }); + } + + pub fn getSeeThrough(self: TextDisplayEntity) bool { + return abi.call(raw.@"[method]text-display-entity.get-see-through", bool, .{abi.borrow(self)}); + } + + pub fn setSeeThrough(self: TextDisplayEntity, see_through: bool) void { + return abi.call(raw.@"[method]text-display-entity.set-see-through", void, .{ abi.borrow(self), see_through }); + } + + pub fn getDefaultBackground(self: TextDisplayEntity) bool { + return abi.call(raw.@"[method]text-display-entity.get-default-background", bool, .{abi.borrow(self)}); + } + + pub fn setDefaultBackground(self: TextDisplayEntity, default_background: bool) void { + return abi.call(raw.@"[method]text-display-entity.set-default-background", void, .{ abi.borrow(self), default_background }); + } + + pub fn getAlignment(self: TextDisplayEntity) TextAlignment { + return abi.call(raw.@"[method]text-display-entity.get-alignment", TextAlignment, .{abi.borrow(self)}); + } + + pub fn setAlignment(self: TextDisplayEntity, alignment: TextAlignment) void { + return abi.call(raw.@"[method]text-display-entity.set-alignment", void, .{ abi.borrow(self), alignment }); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: TextDisplayEntity) void { + abi.keep(TextDisplayEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: TextDisplayEntity) void { + abi.drop(TextDisplayEntity, self); + } +}; + +/// Resource specifically for Interaction entities. +pub const InteractionEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]interaction-entity"; + + pub fn fromEntity(entity: Entity) ?InteractionEntity { + return abi.call(raw.@"[static]interaction-entity.from-entity", ?InteractionEntity, .{abi.borrow(entity)}); + } + + pub fn getEntity(self: InteractionEntity) Entity { + return abi.call(raw.@"[method]interaction-entity.get-entity", Entity, .{abi.borrow(self)}); + } + + pub fn getWidth(self: InteractionEntity) f32 { + return abi.call(raw.@"[method]interaction-entity.get-width", f32, .{abi.borrow(self)}); + } + + pub fn setWidth(self: InteractionEntity, width: f32) void { + return abi.call(raw.@"[method]interaction-entity.set-width", void, .{ abi.borrow(self), width }); + } + + pub fn getHeight(self: InteractionEntity) f32 { + return abi.call(raw.@"[method]interaction-entity.get-height", f32, .{abi.borrow(self)}); + } + + pub fn setHeight(self: InteractionEntity, height: f32) void { + return abi.call(raw.@"[method]interaction-entity.set-height", void, .{ abi.borrow(self), height }); + } + + pub fn getResponse(self: InteractionEntity) bool { + return abi.call(raw.@"[method]interaction-entity.get-response", bool, .{abi.borrow(self)}); + } + + pub fn setResponse(self: InteractionEntity, response: bool) void { + return abi.call(raw.@"[method]interaction-entity.set-response", void, .{ abi.borrow(self), response }); + } + + pub fn getLastAttacker(self: InteractionEntity) ?Uuid { + return abi.call(raw.@"[method]interaction-entity.get-last-attacker", ?Uuid, .{abi.borrow(self)}); + } + + pub fn getLastInteraction(self: InteractionEntity) ?Uuid { + return abi.call(raw.@"[method]interaction-entity.get-last-interaction", ?Uuid, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: InteractionEntity) void { + abi.keep(InteractionEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: InteractionEntity) void { + abi.drop(InteractionEntity, self); + } +}; + +const raw = struct { + extern "pumpkin:plugin/display@0.1.0" fn @"[static]display-entity.from-entity"(i32, i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]display-entity.get-entity"(i32) i32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]display-entity.get-transformation"(i32, i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]display-entity.set-transformation"(i32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]display-entity.get-interpolation-duration"(i32) i32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]display-entity.set-interpolation-duration"(i32, i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]display-entity.get-interpolation-start"(i32) i32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]display-entity.set-interpolation-start"(i32, i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]display-entity.get-teleport-duration"(i32) i32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]display-entity.set-teleport-duration"(i32, i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]display-entity.get-billboard"(i32) i32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]display-entity.set-billboard"(i32, i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]display-entity.get-view-range"(i32) f32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]display-entity.set-view-range"(i32, f32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]display-entity.get-shadow-radius"(i32) f32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]display-entity.set-shadow-radius"(i32, f32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]display-entity.get-shadow-strength"(i32) f32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]display-entity.set-shadow-strength"(i32, f32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]display-entity.get-display-width"(i32) f32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]display-entity.set-display-width"(i32, f32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]display-entity.get-display-height"(i32) f32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]display-entity.set-display-height"(i32, f32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]display-entity.get-glow-color-override"(i32) i32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]display-entity.set-glow-color-override"(i32, i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]display-entity.get-brightness"(i32) i32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]display-entity.set-brightness"(i32, i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[static]block-display-entity.from-entity"(i32, i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]block-display-entity.get-display"(i32) i32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]block-display-entity.get-entity"(i32) i32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]block-display-entity.get-block-state-id"(i32) i32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]block-display-entity.set-block-state-id"(i32, i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[static]item-display-entity.from-entity"(i32, i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]item-display-entity.get-display"(i32) i32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]item-display-entity.get-entity"(i32) i32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]item-display-entity.get-item"(i32, i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]item-display-entity.set-item"(i32, i32, i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]item-display-entity.get-item-display-mode"(i32) i32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]item-display-entity.set-item-display-mode"(i32, i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[static]text-display-entity.from-entity"(i32, i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]text-display-entity.get-display"(i32) i32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]text-display-entity.get-entity"(i32) i32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]text-display-entity.get-text"(i32) i32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]text-display-entity.set-text"(i32, i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]text-display-entity.get-line-width"(i32) i32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]text-display-entity.set-line-width"(i32, i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]text-display-entity.get-background"(i32) i32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]text-display-entity.set-background"(i32, i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]text-display-entity.get-text-opacity"(i32) i32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]text-display-entity.set-text-opacity"(i32, i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]text-display-entity.get-shadow"(i32) i32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]text-display-entity.set-shadow"(i32, i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]text-display-entity.get-see-through"(i32) i32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]text-display-entity.set-see-through"(i32, i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]text-display-entity.get-default-background"(i32) i32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]text-display-entity.set-default-background"(i32, i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]text-display-entity.get-alignment"(i32) i32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]text-display-entity.set-alignment"(i32, i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[static]interaction-entity.from-entity"(i32, i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]interaction-entity.get-entity"(i32) i32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]interaction-entity.get-width"(i32) f32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]interaction-entity.set-width"(i32, f32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]interaction-entity.get-height"(i32) f32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]interaction-entity.set-height"(i32, f32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]interaction-entity.get-response"(i32) i32; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]interaction-entity.set-response"(i32, i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]interaction-entity.get-last-attacker"(i32, i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[method]interaction-entity.get-last-interaction"(i32, i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[resource-drop]display-entity"(i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[resource-drop]block-display-entity"(i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[resource-drop]item-display-entity"(i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[resource-drop]text-display-entity"(i32) void; + extern "pumpkin:plugin/display@0.1.0" fn @"[resource-drop]interaction-entity"(i32) void; +}; diff --git a/src/wit/enchantments.zig b/src/wit/enchantments.zig new file mode 100644 index 0000000..9c89c0b --- /dev/null +++ b/src/wit/enchantments.zig @@ -0,0 +1,133 @@ +// Generated by tools/gen.zig, do not edit. + +const abi = @import("../abi.zig"); +const text = @import("text.zig"); + +pub const TextComponent = text.TextComponent; + +/// Equipment slot where an enchantment is active. +pub const AttributeModifierSlot = enum(u8) { + any, + main_hand, + off_hand, + hand, + feet, + legs, + chest, + head, + armor, + body, + saddle, +}; + +/// Vanilla enchantments enum. +pub const Enchantment = enum(u8) { + aqua_affinity, + bane_of_arthropods, + binding_curse, + blast_protection, + breach, + channeling, + density, + depth_strider, + efficiency, + feather_falling, + fire_aspect, + fire_protection, + flame, + fortune, + frost_walker, + impaling, + infinity, + knockback, + looting, + loyalty, + luck_of_the_sea, + lunge, + lure, + mending, + multishot, + piercing, + power, + projectile_protection, + protection, + punch, + quick_charge, + respiration, + riptide, + sharpness, + silk_touch, + smite, + soul_speed, + sweeping_edge, + swift_sneak, + thorns, + unbreaking, + vanishing_curse, + wind_burst, +}; + +/// Represents a custom enchantment definition. +pub const CustomEnchantment = struct { + /// Unique identifier for the enchantment (e.g. "my_plugin:lifesteal"). + id: []const u8, + /// Description or display name of the enchantment. + description: TextComponent, + /// Maximum level of the enchantment (e.g. 1..=10). + max_level: u32, + /// Base anvil repair/combination cost multiplier. + anvil_cost: u32, + /// Tag or item pattern for supported items (e.g. "#minecraft:enchantable/weapon"). + supported_items: []const u8, + /// Weight / rarity of the enchantment (higher = more common, default 5). + weight: u32, + /// Equipment slots where this enchantment is active. + slots: []const AttributeModifierSlot, + /// List of exclusive/conflicting enchantment IDs. + exclusive_set: []const []const u8, +}; + +/// Global manager for registering and querying custom enchantments. +pub const EnchantmentManager = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]enchantment-manager"; + + /// Registers a new custom enchantment with the server. + pub fn registerEnchantment(self: EnchantmentManager, enchantment: CustomEnchantment) abi.Result(void, []const u8) { + return abi.call(raw.@"[method]enchantment-manager.register-enchantment", abi.Result(void, []const u8), .{ abi.borrow(self), enchantment }); + } + + /// Gets an enchantment definition by its ID. + pub fn getEnchantment(self: EnchantmentManager, id: []const u8) ?CustomEnchantment { + return abi.call(raw.@"[method]enchantment-manager.get-enchantment", ?CustomEnchantment, .{ abi.borrow(self), id }); + } + + /// Checks if an enchantment ID is registered. + pub fn hasEnchantment(self: EnchantmentManager, id: []const u8) bool { + return abi.call(raw.@"[method]enchantment-manager.has-enchantment", bool, .{ abi.borrow(self), id }); + } + + /// Returns all registered custom enchantment IDs. + pub fn getAllEnchantmentIds(self: EnchantmentManager) []const []const u8 { + return abi.call(raw.@"[method]enchantment-manager.get-all-enchantment-ids", []const []const u8, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: EnchantmentManager) void { + abi.keep(EnchantmentManager, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: EnchantmentManager) void { + abi.drop(EnchantmentManager, self); + } +}; + +const raw = struct { + extern "pumpkin:plugin/enchantments@0.1.0" fn @"[method]enchantment-manager.register-enchantment"(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/enchantments@0.1.0" fn @"[method]enchantment-manager.get-enchantment"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/enchantments@0.1.0" fn @"[method]enchantment-manager.has-enchantment"(i32, i32, i32) i32; + extern "pumpkin:plugin/enchantments@0.1.0" fn @"[method]enchantment-manager.get-all-enchantment-ids"(i32, i32) void; + extern "pumpkin:plugin/enchantments@0.1.0" fn @"[resource-drop]enchantment-manager"(i32) void; +}; diff --git a/src/wit/entity.zig b/src/wit/entity.zig new file mode 100644 index 0000000..4ff5d3b --- /dev/null +++ b/src/wit/entity.zig @@ -0,0 +1,27 @@ +// Generated by tools/gen.zig, do not edit. + +const world = @import("world.zig"); + +pub const Entity = world.Entity; +pub const LivingEntity = world.LivingEntity; +pub const Mob = world.Mob; +pub const PathNodeType = world.PathNodeType; +pub const DyeColor = world.DyeColor; +pub const VillagerProfession = world.VillagerProfession; +pub const MobData = world.MobData; +pub const SheepData = world.SheepData; +pub const WolfData = world.WolfData; +pub const CatData = world.CatData; +pub const VillagerData = world.VillagerData; +pub const CreeperData = world.CreeperData; +pub const SlimeData = world.SlimeData; +pub const EndermanData = world.EndermanData; +pub const IronGolemData = world.IronGolemData; +pub const FoxData = world.FoxData; +pub const AgeableData = world.AgeableData; +pub const ZombieData = world.ZombieData; +pub const ShulkerData = world.ShulkerData; +pub const RaycastResult = world.RaycastResult; +pub const RayTraceBlockResult = world.RayTraceBlockResult; +pub const RayTraceEntityResult = world.RayTraceEntityResult; +pub const BlockDirection = world.BlockDirection; diff --git a/src/wit/entity_statuses.zig b/src/wit/entity_statuses.zig new file mode 100644 index 0000000..794fa62 --- /dev/null +++ b/src/wit/entity_statuses.zig @@ -0,0 +1,66 @@ +// Generated by tools/gen.zig, do not edit. + +pub const EntityStatus = enum(u8) { + armadillo_peek, + armorstand_wobble, + body_break, + cancel_shake_wetness, + chest_break, + death, + dolphin_looking_for_treasure, + drown_particles, + eat_grass, + end_ram, + feet_break, + fireworks_explode, + fishing_rod_reel_in, + fox_eat, + full_debug_info, + guardian_attack_sound, + head_break, + honey_jump, + honey_slide, + in_love_hearts, + jump, + kinetic_hit, + legs_break, + love_hearts, + mainhand_break, + offer_flower, + offhand_break, + permission_level_admins, + permission_level_all, + permission_level_gamemasters, + permission_level_moderators, + permission_level_owners, + poof, + protected_from_death, + ravager_roared, + ravager_stunned, + reduced_debug_info, + saddle_break, + shake, + shake_wetness, + silverfish_merge_anim, + sniffer_digging_sound, + sonic_charge, + squid_anim_synch, + start_attacking, + start_ram, + stop_attacking, + stop_offer_flower, + swap_hands, + taming_failed, + taming_succeeded, + teleport, + tendrils_shiver, + tnt_prime, + trusting_failed, + trusting_succeeded, + use_item_complete, + villager_angry, + villager_happy, + villager_sweat, + witch_hat_magic, + zombie_converting, +}; diff --git a/src/wit/entity_types.zig b/src/wit/entity_types.zig new file mode 100644 index 0000000..4ba8819 --- /dev/null +++ b/src/wit/entity_types.zig @@ -0,0 +1,162 @@ +// Generated by tools/gen.zig, do not edit. + +pub const EntityType = enum(u8) { + acacia_boat, + acacia_chest_boat, + allay, + area_effect_cloud, + armadillo, + armor_stand, + arrow, + axolotl, + bamboo_chest_raft, + bamboo_raft, + bat, + bee, + birch_boat, + birch_chest_boat, + blaze, + block_display, + bogged, + breeze, + breeze_wind_charge, + camel, + camel_husk, + cat, + cave_spider, + cherry_boat, + cherry_chest_boat, + chest_minecart, + chicken, + cod, + command_block_minecart, + copper_golem, + cow, + creaking, + creeper, + dark_oak_boat, + dark_oak_chest_boat, + dolphin, + donkey, + dragon_fireball, + drowned, + egg, + elder_guardian, + end_crystal, + ender_dragon, + ender_pearl, + enderman, + endermite, + evoker, + evoker_fangs, + experience_bottle, + experience_orb, + eye_of_ender, + falling_block, + fireball, + firework_rocket, + fishing_bobber, + fox, + frog, + furnace_minecart, + ghast, + giant, + glow_item_frame, + glow_squid, + goat, + guardian, + happy_ghast, + hoglin, + hopper_minecart, + horse, + husk, + illusioner, + interaction, + iron_golem, + item, + item_display, + item_frame, + jungle_boat, + jungle_chest_boat, + leash_knot, + lightning_bolt, + lingering_potion, + llama, + llama_spit, + magma_cube, + mangrove_boat, + mangrove_chest_boat, + mannequin, + marker, + minecart, + mooshroom, + mule, + nautilus, + oak_boat, + oak_chest_boat, + ocelot, + ominous_item_spawner, + painting, + pale_oak_boat, + pale_oak_chest_boat, + panda, + parched, + parrot, + phantom, + pig, + piglin, + piglin_brute, + pillager, + player, + polar_bear, + pufferfish, + rabbit, + ravager, + salmon, + sheep, + shulker, + shulker_bullet, + silverfish, + skeleton, + skeleton_horse, + slime, + small_fireball, + sniffer, + snow_golem, + snowball, + spawner_minecart, + spectral_arrow, + spider, + splash_potion, + spruce_boat, + spruce_chest_boat, + squid, + stray, + strider, + sulfur_cube, + tadpole, + text_display, + tnt, + tnt_minecart, + trader_llama, + trident, + tropical_fish, + turtle, + vex, + villager, + vindicator, + wandering_trader, + warden, + wind_charge, + witch, + wither, + wither_skeleton, + wither_skull, + wolf, + zoglin, + zombie, + zombie_horse, + zombie_nautilus, + zombie_villager, + zombified_piglin, +}; diff --git a/src/wit/event.zig b/src/wit/event.zig new file mode 100644 index 0000000..c9811a2 --- /dev/null +++ b/src/wit/event.zig @@ -0,0 +1,2454 @@ +// Generated by tools/gen.zig, do not edit. + +const common = @import("common.zig"); +const item_stack = @import("item_stack.zig"); +const enchantments = @import("enchantments.zig"); +const damage_types = @import("damage_types.zig"); +const screens = @import("screens.zig"); +const player = @import("player.zig"); +const text = @import("text.zig"); +const world = @import("world.zig"); +const java_packets = @import("java_packets.zig"); +const bedrock_packets = @import("bedrock_packets.zig"); +const uuid = @import("uuid.zig"); +const java_dialogs = @import("java_dialogs.zig"); + +pub const BlockPos = common.BlockPos; +pub const GameMode = common.GameMode; +pub const Hand = common.Hand; +pub const Position = common.Position; +pub const ClickType = common.ClickType; +pub const ItemStack = item_stack.ItemStack; +pub const Enchantment = enchantments.Enchantment; +pub const DamageType = damage_types.DamageType; +pub const Screen = screens.Screen; +pub const Player = player.Player; +pub const TextComponent = text.TextComponent; +pub const World = world.World; +pub const JavaServerboundPacket = java_packets.ServerboundPacket; +pub const JavaClientboundPacket = java_packets.ClientboundPacket; +pub const BedrockServerboundPacket = bedrock_packets.ServerboundPacket; +pub const BedrockClientboundPacket = bedrock_packets.ClientboundPacket; +pub const Uuid = uuid.Uuid; +pub const Dialog = java_dialogs.Dialog; + +pub const ServerboundPacket = union(enum) { + java: JavaServerboundPacket, + bedrock: BedrockServerboundPacket, + unknown, +}; + +pub const ClientboundPacket = union(enum) { + java: JavaClientboundPacket, + bedrock: BedrockClientboundPacket, + unknown, +}; + +pub const EventPriority = enum(u8) { + highest, + high, + normal, + low, + lowest, +}; + +pub const PlayerJoinEventData = struct { + player: Player, + join_message: TextComponent, + cancelled: bool, +}; + +pub const PlayerLeaveEventData = struct { + player: Player, + leave_message: TextComponent, + cancelled: bool, +}; + +pub const PlayerLoginEventData = struct { + player: Player, + kick_message: TextComponent, + cancelled: bool, +}; + +pub const PlayerChatEventData = struct { + player: Player, + message: []const u8, + recipients: []const Player, + signature: ?[]const u8, + cancelled: bool, +}; + +pub const PlayerCommandSendEventData = struct { + player: Player, + command: []const u8, + cancelled: bool, +}; + +pub const PlayerPermissionCheckEventData = struct { + player: Player, + permission: []const u8, + permission_result: bool, +}; + +pub const PlayerMoveEventData = struct { + player: Player, + from_position: Position, + to_position: Position, + cancelled: bool, +}; + +pub const PlayerTeleportEventData = struct { + player: Player, + from_position: Position, + to_position: Position, + cancelled: bool, +}; + +pub const PlayerChangeWorldEventData = struct { + player: Player, + previous_world: World, + new_world: World, + position: Position, + yaw: f32, + pitch: f32, + cancelled: bool, +}; + +pub const PlayerRespawnEventData = struct { + player: Player, + previous_world: World, + respawned_world: World, + position: Position, + yaw: f32, + pitch: f32, + alive: bool, +}; + +pub const PlayerExpChangeEventData = struct { + player: Player, + amount: i32, +}; + +pub const PlayerItemHeldEventData = struct { + player: Player, + previous_slot: u8, + new_slot: u8, + cancelled: bool, +}; + +pub const PlayerChangedMainHandEventData = struct { + player: Player, + main_hand: Hand, +}; + +pub const PlayerGamemodeChangeEventData = struct { + player: Player, + previous_gamemode: GameMode, + new_gamemode: GameMode, + cancelled: bool, +}; + +pub const PlayerCustomPayloadEventData = struct { + player: Player, + channel: []const u8, + data: []const u8, +}; + +pub const PlayerFishState = enum(u8) { + fishing, + caught_fish, + caught_entity, + in_ground, + failed_attempt, + reel_in, + bite, +}; + +pub const PlayerFishEventData = struct { + player: Player, + caught_uuid: ?Uuid, + caught_type: []const u8, + hook_uuid: Uuid, + state: PlayerFishState, + hand: Hand, + exp_to_drop: i32, + cancelled: bool, +}; + +pub const PlayerEggThrowEventData = struct { + player: Player, + egg_uuid: Uuid, + hatching: bool, + num_hatches: u8, + hatching_type: []const u8, + cancelled: bool, +}; + +pub const EntityInteractionAction = enum(u8) { + interact, + attack, + interact_at, +}; + +pub const InteractAction = enum(u8) { + left_click_block, + left_click_air, + right_click_air, + right_click_block, +}; + +pub const PlayerInteractEventData = struct { + player: Player, + action: InteractAction, + clicked_pos: ?BlockPos, + block: []const u8, + cancelled: bool, +}; + +pub const PlayerToggleSneakEventData = struct { + player: Player, + is_sneaking: bool, + cancelled: bool, +}; + +pub const PlayerToggleFlightEventData = struct { + player: Player, + is_flying: bool, + cancelled: bool, +}; + +pub const PlayerToggleSprintEventData = struct { + player: Player, + is_sprinting: bool, + cancelled: bool, +}; + +pub const PlayerInteractUnknownEntityEventData = struct { + player: Player, + entity_id: i32, + action: EntityInteractionAction, + cancelled: bool, +}; + +pub const InventoryClickEventData = struct { + player: Player, + window_type: ?Screen, + click_type: ClickType, + slot: i16, + raw_slot: i16, + clicked_item: ?ItemStack, + cursor: ?ItemStack, + hotbar_button: i32, + cancelled: bool, +}; + +pub const InventoryCloseEventData = struct { + player: Player, + window_type: ?Screen, +}; + +pub const BlockRedstoneEventData = struct { + target_world: World, + state_id: u16, + block_pos: BlockPos, + old_current: i32, + new_current: i32, + cancelled: bool, +}; + +pub const BlockBreakEventData = struct { + player: ?Player, + block: []const u8, + block_pos: BlockPos, + exp: u32, + should_drop: bool, + cancelled: bool, +}; + +pub const BlockBurnEventData = struct { + igniting_block: []const u8, + block: []const u8, + cancelled: bool, +}; + +pub const BlockCanBuildEventData = struct { + block_to_build: []const u8, + buildable: bool, + player: Player, + block: []const u8, + cancelled: bool, +}; + +pub const BlockGrowEventData = struct { + target_world: World, + old_block: []const u8, + old_state_id: u16, + new_block: []const u8, + new_state_id: u16, + block_pos: BlockPos, + cancelled: bool, +}; + +pub const BlockPlaceEventData = struct { + player: Player, + block_placed: []const u8, + block_placed_against: []const u8, + block_pos: BlockPos, + can_build: bool, + cancelled: bool, +}; + +pub const BedrockFormResponseEventData = struct { + player: Player, + form_id: u32, + response_data: ?[]const u8, +}; + +pub const DialogClickActionEventData = struct { + player: Player, + id: []const u8, + payload: ?[]const u8, + cancelled: bool, +}; + +pub const DialogShowEventData = struct { + player: Player, + dialog: Dialog, + cancelled: bool, +}; + +pub const DialogClearEventData = struct { + player: Player, + cancelled: bool, +}; + +pub const ServerCommandEventData = struct { + command: []const u8, + cancelled: bool, +}; + +pub const ServerListPingAddress = struct { + host: []const u8, + port: u16, +}; + +pub const ServerListPingEventData = struct { + hostname: []const u8, + address: ServerListPingAddress, + motd: TextComponent, + max_players: u32, + num_players: u32, + favicon: ?[]const u8, +}; + +pub const ServerLoadType = enum(u8) { + startup, + reload, +}; + +pub const ServerLoadEventData = struct { + load_type: ServerLoadType, +}; + +pub const SpawnChangeEventData = struct { + target_world: World, + previous_position: BlockPos, + previous_yaw: f32, + previous_pitch: f32, + new_position: BlockPos, + new_yaw: f32, + new_pitch: f32, +}; + +pub const ServerBroadcastEventData = struct { + message: TextComponent, + sender: TextComponent, + cancelled: bool, +}; + +pub const ServerTickStartEventData = struct { + tick: i32, +}; + +pub const ServerTickEndEventData = struct { + tick: i32, + duration_nanos: i64, +}; + +pub const PacketReceivedEventData = struct { + player: Player, + packet: ServerboundPacket, + packet_id: i32, + raw_payload: []const u8, + cancelled: bool, +}; + +pub const PacketSentEventData = struct { + player: Player, + packet: ClientboundPacket, + packet_id: i32, + raw_payload: []const u8, + cancelled: bool, +}; + +pub const PlayerInteractEntityEventData = struct { + player: Player, + entity_id: i32, + action: EntityInteractionAction, + sneaking: bool, + cancelled: bool, +}; + +pub const ChunkLoadEventData = struct { + target_world: World, + chunk_x: i32, + chunk_z: i32, + cancelled: bool, +}; + +pub const ChunkSaveEventData = struct { + target_world: World, + chunk_x: i32, + chunk_z: i32, + cancelled: bool, +}; + +pub const ChunkSendEventData = struct { + target_world: World, + chunk_x: i32, + chunk_z: i32, + cancelled: bool, +}; + +pub const EntityDamageEventData = struct { + entity_id: i32, + damage: f32, + damage_type: DamageType, + cancelled: bool, +}; + +pub const EntityDeathEventData = struct { + entity_id: i32, + dropped_exp: i32, +}; + +pub const PlayerDeathEventData = struct { + player: Player, + death_message: TextComponent, + dropped_exp: i32, + keep_inventory: bool, + cancelled: bool, +}; + +pub const EntitySpawnEventData = struct { + entity_id: i32, + entity_type: []const u8, + position: Position, + target_world: World, + cancelled: bool, +}; + +pub const EntityCombustEventData = struct { + entity_id: i32, + duration_secs: f32, + cancelled: bool, +}; + +pub const EntityRegainHealthEventData = struct { + entity_id: i32, + amount: f32, + cancelled: bool, +}; + +pub const EntityAirChangeEventData = struct { + entity_id: i32, + amount: i32, + cancelled: bool, +}; + +pub const EntityBreedEventData = struct { + father_id: i32, + mother_id: i32, + child_id: i32, + cancelled: bool, +}; + +pub const EntityDismountEventData = struct { + entity_id: i32, + dismounted_id: i32, + cancelled: bool, +}; + +pub const EntityDyeEventData = struct { + entity_id: i32, + color: []const u8, + player: ?Player, + cancelled: bool, +}; + +pub const EntityEnterLoveModeEventData = struct { + entity_id: i32, + human_entity_id: ?i32, + ticks_in_love: i32, + cancelled: bool, +}; + +pub const EntityExplodeEventData = struct { + entity_id: i32, + position: Position, + yield_rate: f32, + cancelled: bool, +}; + +pub const EntityMountEventData = struct { + entity_id: i32, + mounted_id: i32, + cancelled: bool, +}; + +pub const EntityPickupItemEventData = struct { + entity_id: i32, + item_name: []const u8, + count: u8, + cancelled: bool, +}; + +pub const EntityPortalEventData = struct { + entity_id: i32, + portal_pos: BlockPos, + cancelled: bool, +}; + +pub const EntityResurrectEventData = struct { + entity_id: i32, + cancelled: bool, +}; + +pub const EntityShootBowEventData = struct { + entity_id: i32, + weapon_name: []const u8, + force: f32, + cancelled: bool, +}; + +pub const EntityTameEventData = struct { + entity_id: i32, + owner: Player, + cancelled: bool, +}; + +pub const EntityTargetEventData = struct { + entity_id: i32, + target_id: ?i32, + cancelled: bool, +}; + +pub const EntityTeleportEventData = struct { + entity_id: i32, + from_position: Position, + to_position: Position, + cancelled: bool, +}; + +pub const EntityToggleGlideEventData = struct { + entity_id: i32, + is_gliding: bool, + cancelled: bool, +}; + +pub const EntityTransformEventData = struct { + entity_id: i32, + new_entity_id: i32, + transform_reason: []const u8, + cancelled: bool, +}; + +pub const CreatureSpawnEventData = struct { + entity_id: i32, + entity_type: []const u8, + position: Position, + target_world: World, + spawn_reason: []const u8, + cancelled: bool, +}; + +pub const EnderDragonChangePhaseEventData = struct { + entity_id: i32, + current_phase: []const u8, + new_phase: []const u8, + cancelled: bool, +}; + +pub const EntityBreakDoorEventData = struct { + entity_id: i32, + block_pos: BlockPos, + cancelled: bool, +}; + +pub const EntityChangeBlockEventData = struct { + entity_id: i32, + block_pos: BlockPos, + new_block: []const u8, + cancelled: bool, +}; + +pub const EntityDamageByBlockEventData = struct { + entity_id: i32, + damager_pos: ?BlockPos, + damage: f32, + cause: []const u8, + cancelled: bool, +}; + +pub const EntityDamageByEntityEventData = struct { + entity_id: i32, + damager_id: i32, + damage: f32, + cause: []const u8, + cancelled: bool, +}; + +pub const EntityDropItemEventData = struct { + entity_id: i32, + item_name: []const u8, + count: u8, + cancelled: bool, +}; + +pub const EntityEnterBlockEventData = struct { + entity_id: i32, + block_pos: BlockPos, + cancelled: bool, +}; + +pub const EntityExhaustionEventData = struct { + entity_id: i32, + exhaustion: f32, + cancelled: bool, +}; + +pub const EntityInteractEventData = struct { + entity_id: i32, + block_pos: BlockPos, + cancelled: bool, +}; + +pub const EntityKnockbackEventData = struct { + entity_id: i32, + hit_by_id: ?i32, + knockback: Position, + cancelled: bool, +}; + +pub const EntityPlaceEventData = struct { + entity_id: i32, + block_pos: BlockPos, + block_name: []const u8, + cancelled: bool, +}; + +pub const EntityPoseChangeEventData = struct { + entity_id: i32, + pose: []const u8, + cancelled: bool, +}; + +pub const EntityPotionEffectEventData = struct { + entity_id: i32, + effect_name: []const u8, + duration: i32, + amplifier: u8, + cancelled: bool, +}; + +pub const EntitySpellCastEventData = struct { + entity_id: i32, + spell: []const u8, + cancelled: bool, +}; + +pub const EntityTargetLivingEntityEventData = struct { + entity_id: i32, + target_id: ?i32, + reason: []const u8, + cancelled: bool, +}; + +pub const EntityToggleSwimEventData = struct { + entity_id: i32, + is_swimming: bool, + cancelled: bool, +}; + +pub const ExplosionPrimeEventData = struct { + entity_id: i32, + radius: f32, + fire: bool, + cancelled: bool, +}; + +pub const FireworkExplodeEventData = struct { + entity_id: i32, + cancelled: bool, +}; + +pub const FoodLevelChangeEventData = struct { + entity_id: i32, + food_level: u8, + cancelled: bool, +}; + +pub const ItemDespawnEventData = struct { + entity_id: i32, + cancelled: bool, +}; + +pub const ItemMergeEventData = struct { + entity_id: i32, + target_id: i32, + cancelled: bool, +}; + +pub const ItemSpawnEventData = struct { + entity_id: i32, + position: Position, + item_name: []const u8, + cancelled: bool, +}; + +pub const PiglinBarterEventData = struct { + entity_id: i32, + input_item: ItemStack, + outcome: []const ItemStack, + cancelled: bool, +}; + +pub const ProjectileHitEventData = struct { + entity_id: i32, + hit_position: Position, + hit_entity_id: ?i32, + cancelled: bool, +}; + +pub const ProjectileLaunchEventData = struct { + entity_id: i32, + shooter_id: ?i32, + cancelled: bool, +}; + +pub const SheepDyeWoolEventData = struct { + entity_id: i32, + dye_color: u8, + player_id: ?i32, + cancelled: bool, +}; + +pub const SheepRegrowWoolEventData = struct { + entity_id: i32, + cancelled: bool, +}; + +pub const SlimeSplitEventData = struct { + entity_id: i32, + count: i32, + cancelled: bool, +}; + +pub const StriderTemperatureChangeEventData = struct { + entity_id: i32, + is_shivering: bool, + cancelled: bool, +}; + +pub const VillagerAcquireTradeEventData = struct { + entity_id: i32, + recipe_index: i32, + cancelled: bool, +}; + +pub const VillagerCareerChangeEventData = struct { + entity_id: i32, + profession: []const u8, + reason: []const u8, + cancelled: bool, +}; + +pub const VillagerReplenishTradeEventData = struct { + entity_id: i32, + restock_quantity: i32, + cancelled: bool, +}; + +pub const WardenAngerChangeEventData = struct { + entity_id: i32, + target_id: i32, + old_anger: i32, + new_anger: i32, + cancelled: bool, +}; + +pub const AreaEffectCloudApplyEventData = struct { + entity_id: i32, + affected_entities: []const i32, + cancelled: bool, +}; + +pub const ArrowBodyCountChangeEventData = struct { + entity_id: i32, + old_amount: u32, + new_amount: u32, + cancelled: bool, +}; + +pub const BatToggleSleepEventData = struct { + entity_id: i32, + is_awake: bool, + cancelled: bool, +}; + +pub const CreeperPowerEventData = struct { + entity_id: i32, + lightning_id: ?i32, + cause: []const u8, + cancelled: bool, +}; + +pub const EntityCombustByBlockEventData = struct { + entity_id: i32, + combuster: BlockPos, + duration: f32, + cancelled: bool, +}; + +pub const EntityCombustByEntityEventData = struct { + entity_id: i32, + combuster_id: i32, + duration: f32, + cancelled: bool, +}; + +pub const EntityKnockbackByEntityEventData = struct { + entity_id: i32, + hit_by_id: i32, + force: f64, + x: f64, + z: f64, + cancelled: bool, +}; + +pub const EntityPortalEnterEventData = struct { + entity_id: i32, + location: BlockPos, + cancelled: bool, +}; + +pub const EntityPortalExitEventData = struct { + entity_id: i32, + from_pos: BlockPos, + to_pos: ?BlockPos, + cancelled: bool, +}; + +pub const EntityRemoveEventData = struct { + entity_id: i32, + cause: []const u8, + cancelled: bool, +}; + +pub const EntityTargetBlockEventData = struct { + entity_id: i32, + block_pos: BlockPos, + cancelled: bool, +}; + +pub const EntityUnleashEventData = struct { + entity_id: i32, + reason: []const u8, + cancelled: bool, +}; + +pub const ExpBottleEventData = struct { + entity_id: i32, + experience: i32, + location: BlockPos, + show_effect: bool, + cancelled: bool, +}; + +pub const HorseJumpEventData = struct { + entity_id: i32, + power: f32, + cancelled: bool, +}; + +pub const LingeringPotionSplashEventData = struct { + entity_id: i32, + location: BlockPos, + potion_item: []const u8, + cancelled: bool, +}; + +pub const PigZapEventData = struct { + entity_id: i32, + lightning_id: i32, + pig_zombie_id: i32, + cancelled: bool, +}; + +pub const PigZombieAngerEventData = struct { + entity_id: i32, + target_id: ?i32, + new_anger: i32, + cancelled: bool, +}; + +pub const PotionSplashEventData = struct { + entity_id: i32, + location: BlockPos, + potion_item: []const u8, + affected_entities: []const i32, + cancelled: bool, +}; + +pub const SpawnerSpawnEventData = struct { + entity_id: i32, + spawner_pos: BlockPos, + cancelled: bool, +}; + +pub const TrialSpawnerSpawnEventData = struct { + entity_id: i32, + spawner_pos: BlockPos, + cancelled: bool, +}; + +pub const VillagerReputationChangeEventData = struct { + entity_id: i32, + target_id: i32, + reputation_change: i32, + cancelled: bool, +}; + +pub const PlayerItemConsumeEventData = struct { + player: Player, + item_name: []const u8, + cancelled: bool, +}; + +pub const PlayerItemDamageEventData = struct { + player: Player, + item_name: []const u8, + damage: i32, + cancelled: bool, +}; + +pub const PlayerDropItemEventData = struct { + player: Player, + item_name: []const u8, + count: u8, + cancelled: bool, +}; + +pub const PlayerBedEnterEventData = struct { + player: Player, + bed_pos: BlockPos, + cancelled: bool, +}; + +pub const PlayerBedLeaveEventData = struct { + player: Player, + bed_pos: BlockPos, +}; + +pub const PlayerBucketEmptyEventData = struct { + player: Player, + block_pos: BlockPos, + bucket: []const u8, + cancelled: bool, +}; + +pub const PlayerBucketFillEventData = struct { + player: Player, + block_pos: BlockPos, + bucket: []const u8, + cancelled: bool, +}; + +pub const AsyncPlayerChatEventData = struct { + player: Player, + message: []const u8, + format: TextComponent, + cancelled: bool, +}; + +pub const AsyncPlayerPreLoginEventData = struct { + player_name: []const u8, + player_uuid: []const u8, + ip_address: []const u8, + kick_message: TextComponent, + cancelled: bool, +}; + +pub const PlayerAdvancementDoneEventData = struct { + player: Player, + advancement_id: []const u8, + cancelled: bool, +}; + +pub const PlayerAnimationEventData = struct { + player: Player, + animation_type: []const u8, + cancelled: bool, +}; + +pub const PlayerArmorStandManipulateEventData = struct { + player: Player, + armor_stand_id: i32, + slot: u8, + cancelled: bool, +}; + +pub const PlayerBucketEntityEventData = struct { + player: Player, + entity_id: i32, + bucket_item: []const u8, + cancelled: bool, +}; + +pub const PlayerChangedWorldEventData = struct { + player: Player, + from_world: World, + to_world: World, + cancelled: bool, +}; + +pub const PlayerChannelEventData = struct { + player: Player, + channel: []const u8, + cancelled: bool, +}; + +pub const PlayerCommandPreprocessEventData = struct { + player: Player, + command: []const u8, + cancelled: bool, +}; + +pub const PlayerEditBookEventData = struct { + player: Player, + slot: u32, + pages: []const []const u8, + title: ?[]const u8, + signing: bool, + cancelled: bool, +}; + +pub const PlayerElytraBoostEventData = struct { + player: Player, + firework_id: i32, + cancelled: bool, +}; + +pub const PlayerExpCooldownChangeEventData = struct { + player: Player, + new_cooldown: i32, + cancelled: bool, +}; + +pub const PlayerHarvestBlockEventData = struct { + player: Player, + block_pos: BlockPos, + harvested_items: []const ItemStack, + cancelled: bool, +}; + +pub const PlayerHideEntityEventData = struct { + player: Player, + entity_id: i32, + cancelled: bool, +}; + +pub const PlayerItemBreakEventData = struct { + player: Player, + item_name: []const u8, +}; + +pub const PlayerItemMendEventData = struct { + player: Player, + item_name: []const u8, + repair_amount: i32, + exp_consumed: i32, + cancelled: bool, +}; + +pub const PlayerKickEventData = struct { + player: Player, + reason: []const u8, + cancelled: bool, +}; + +pub const PlayerLeashEntityEventData = struct { + player: Player, + entity_id: i32, + holder_id: i32, + cancelled: bool, +}; + +pub const PlayerLevelChangeEventData = struct { + player: Player, + old_level: i32, + new_level: i32, +}; + +pub const PlayerLocaleChangeEventData = struct { + player: Player, + new_locale: []const u8, + cancelled: bool, +}; + +pub const PlayerNameEntityEventData = struct { + player: Player, + entity_id: i32, + name: TextComponent, + cancelled: bool, +}; + +pub const PlayerOpenSignEventData = struct { + player: Player, + block_pos: BlockPos, + is_front: bool, + cancelled: bool, +}; + +pub const PlayerPortalEventData = struct { + player: Player, + from_pos: BlockPos, + to_pos: ?BlockPos, + cancelled: bool, +}; + +pub const PlayerPreLoginEventData = struct { + player_name: []const u8, + player_uuid: []const u8, + ip_address: []const u8, + kick_message: TextComponent, + cancelled: bool, +}; + +pub const PlayerRiptideEventData = struct { + player: Player, + item_name: []const u8, + cancelled: bool, +}; + +pub const PlayerShearEntityEventData = struct { + player: Player, + entity_id: i32, + hand: u8, + cancelled: bool, +}; + +pub const PlayerShowEntityEventData = struct { + player: Player, + entity_id: i32, + cancelled: bool, +}; + +pub const PlayerSpawnChangeEventData = struct { + player: Player, + new_spawn: ?BlockPos, + forced: bool, + cancelled: bool, +}; + +pub const PlayerStatisticIncrementEventData = struct { + player: Player, + statistic_id: []const u8, + amount: i32, + cancelled: bool, +}; + +pub const PlayerSwapHandsEventData = struct { + player: Player, + cancelled: bool, +}; + +pub const PlayerTakeLecternBookEventData = struct { + player: Player, + block_pos: BlockPos, + book: ItemStack, + cancelled: bool, +}; + +pub const PlayerUnleashEntityEventData = struct { + player: Player, + entity_id: i32, + cancelled: bool, +}; + +pub const PlayerVelocityEventData = struct { + player: Player, + velocity: Position, + cancelled: bool, +}; + +pub const PlayerInputEventData = struct { + player: Player, + input: []const u8, + cancelled: bool, +}; + +pub const PlayerInteractAtEntityEventData = struct { + player: Player, + entity_id: i32, + clicked_x: f64, + clicked_y: f64, + clicked_z: f64, + hand: u8, + cancelled: bool, +}; + +pub const PlayerLinksSendEventData = struct { + player: Player, + links: []const []const u8, + cancelled: bool, +}; + +pub const PlayerPickupArrowEventData = struct { + player: Player, + arrow_id: i32, + cancelled: bool, +}; + +pub const PlayerRecipeBookClickEventData = struct { + player: Player, + recipe_id: []const u8, + make_all: bool, + cancelled: bool, +}; + +pub const PlayerRecipeBookSettingsChangeEventData = struct { + player: Player, + book_type: []const u8, + is_open: bool, + is_filtering: bool, + cancelled: bool, +}; + +pub const PlayerRecipeDiscoverEventData = struct { + player: Player, + recipe_id: []const u8, + cancelled: bool, +}; + +pub const PlayerRegisterChannelEventData = struct { + player: Player, + channel: []const u8, + cancelled: bool, +}; + +pub const PlayerResourcePackStatusEventData = struct { + player: Player, + pack_id: []const u8, + status: []const u8, + cancelled: bool, +}; + +pub const PlayerSpawnLocationEventData = struct { + player: Player, + spawn_pos: Position, + cancelled: bool, +}; + +pub const PlayerUnregisterChannelEventData = struct { + player: Player, + channel: []const u8, + cancelled: bool, +}; + +pub const RaidFinishEventData = struct { + victory: bool, + cancelled: bool, +}; + +pub const RaidSpawnWaveEventData = struct { + wave: u32, + pos: BlockPos, + cancelled: bool, +}; + +pub const RaidStopEventData = struct { + reason: []const u8, + cancelled: bool, +}; + +pub const RaidTriggerEventData = struct { + pos: BlockPos, + cancelled: bool, +}; + +pub const BlockDamageEventData = struct { + player: Player, + block_pos: BlockPos, + insta_break: bool, + cancelled: bool, +}; + +pub const BlockIgniteEventData = struct { + block_pos: BlockPos, + cancelled: bool, +}; + +pub const BlockFromToEventData = struct { + from_pos: BlockPos, + to_pos: BlockPos, + cancelled: bool, +}; + +pub const BlockFormEventData = struct { + block_pos: BlockPos, + cancelled: bool, +}; + +pub const BlockFadeEventData = struct { + block_pos: BlockPos, + cancelled: bool, +}; + +pub const BlockDispenseEventData = struct { + block_pos: BlockPos, + item_name: []const u8, + cancelled: bool, +}; + +pub const BlockExplodeEventData = struct { + block_pos: BlockPos, + yield_rate: f32, + cancelled: bool, +}; + +pub const BlockPhysicsEventData = struct { + block_pos: BlockPos, + changed_pos: BlockPos, + cancelled: bool, +}; + +pub const BlockPistonExtendEventData = struct { + block_pos: BlockPos, + direction: []const u8, + cancelled: bool, +}; + +pub const BlockPistonRetractEventData = struct { + block_pos: BlockPos, + direction: []const u8, + cancelled: bool, +}; + +pub const NotePlayEventData = struct { + block_pos: BlockPos, + instrument: []const u8, + note: u8, + cancelled: bool, +}; + +pub const SignChangeEventData = struct { + player: Player, + block_pos: BlockPos, + lines: []const []const u8, + cancelled: bool, +}; + +pub const SpongeAbsorbEventData = struct { + block_pos: BlockPos, + cancelled: bool, +}; + +pub const TntPrimeEventData = struct { + block_pos: BlockPos, + prime_reason: []const u8, + cancelled: bool, +}; + +pub const MapInitializeEventData = struct { + map_id: i32, +}; + +pub const HangingBreakEventData = struct { + entity_id: i32, + remover_entity_id: ?i32, + cancelled: bool, +}; + +pub const HangingBreakByEntityEventData = struct { + entity_id: i32, + remover_entity_id: i32, + cancelled: bool, +}; + +pub const HangingPlaceEventData = struct { + entity_id: i32, + player: ?Player, + block_pos: BlockPos, + block_face: []const u8, + cancelled: bool, +}; + +pub const BellResonateEventData = struct { + block_pos: BlockPos, + target_world: World, + cancelled: bool, +}; + +pub const BellRingEventData = struct { + block_pos: BlockPos, + target_world: World, + entity_id: ?i32, + direction: ?[]const u8, + cancelled: bool, +}; + +pub const BlockBrushEventData = struct { + block_pos: BlockPos, + target_world: World, + player: Player, + item: ItemStack, + cancelled: bool, +}; + +pub const BlockCookEventData = struct { + block_pos: BlockPos, + target_world: World, + source: ItemStack, + result: ItemStack, + cancelled: bool, +}; + +pub const BlockDamageAbortEventData = struct { + player: Player, + block_pos: BlockPos, + target_world: World, + item_in_hand: ItemStack, +}; + +pub const BlockDispenseArmorEventData = struct { + block_pos: BlockPos, + target_world: World, + target_entity_id: i32, + item: ItemStack, + cancelled: bool, +}; + +pub const BlockDispenseLootEventData = struct { + block_pos: BlockPos, + target_world: World, + items: []const ItemStack, + cancelled: bool, +}; + +pub const BlockDropItemEventData = struct { + block_pos: BlockPos, + target_world: World, + player: ?Player, + items: []const ItemStack, + cancelled: bool, +}; + +pub const BlockExpEventData = struct { + block_pos: BlockPos, + target_world: World, + exp: i32, +}; + +pub const BlockFertilizeEventData = struct { + block_pos: BlockPos, + target_world: World, + player: ?Player, + changed_blocks: []const struct { BlockPos, u16 }, + cancelled: bool, +}; + +pub const BlockMultiPlaceEventData = struct { + player: Player, + target_world: World, + placed_blocks: []const struct { BlockPos, u16 }, + cancelled: bool, +}; + +pub const BlockReceiveGameEventData = struct { + block_pos: BlockPos, + target_world: World, + game_event: []const u8, + source_entity_id: ?i32, + cancelled: bool, +}; + +pub const BlockShearEntityEventData = struct { + block_pos: BlockPos, + target_world: World, + target_entity_id: i32, + item: ItemStack, + cancelled: bool, +}; + +pub const BlockSpreadEventData = struct { + source_pos: BlockPos, + target_pos: BlockPos, + target_world: World, + new_state_id: u16, + cancelled: bool, +}; + +pub const BrewingStartEventData = struct { + block_pos: BlockPos, + target_world: World, + brewing_time: i32, + cancelled: bool, +}; + +pub const CampfireStartEventData = struct { + block_pos: BlockPos, + target_world: World, + item: ItemStack, + slot: u8, + cooking_time: i32, + cancelled: bool, +}; + +pub const CauldronLevelChangeEventData = struct { + block_pos: BlockPos, + target_world: World, + old_level: i32, + new_level: i32, + reason: []const u8, + entity_id: ?i32, + cancelled: bool, +}; + +pub const CrafterCraftEventData = struct { + block_pos: BlockPos, + target_world: World, + result: ItemStack, + cancelled: bool, +}; + +pub const EntityBlockFormEventData = struct { + entity_id: i32, + block_pos: BlockPos, + target_world: World, + new_state_id: u16, + cancelled: bool, +}; + +pub const FluidLevelChangeEventData = struct { + block_pos: BlockPos, + target_world: World, + new_state_id: u16, + cancelled: bool, +}; + +pub const InventoryBlockStartEventData = struct { + block_pos: BlockPos, + target_world: World, +}; + +pub const LeavesDecayEventData = struct { + block_pos: BlockPos, + target_world: World, + cancelled: bool, +}; + +pub const MoistureChangeEventData = struct { + block_pos: BlockPos, + target_world: World, + new_moisture: i32, + cancelled: bool, +}; + +pub const SculkBloomEventData = struct { + block_pos: BlockPos, + target_world: World, + charge: i32, + cancelled: bool, +}; + +pub const VaultDisplayItemEventData = struct { + block_pos: BlockPos, + target_world: World, + item: ItemStack, + cancelled: bool, +}; + +pub const WeatherChangeEventData = struct { + target_world: World, + to_weather_state: bool, + cancelled: bool, +}; + +pub const ThunderChangeEventData = struct { + target_world: World, + to_thunder_state: bool, + cancelled: bool, +}; + +pub const WorldLoadEventData = struct { + target_world: World, +}; + +pub const WorldUnloadEventData = struct { + target_world: World, + cancelled: bool, +}; + +pub const AsyncStructureGenerateEventData = struct { + world_name: []const u8, + structure_name: []const u8, + pos: BlockPos, + cancelled: bool, +}; + +pub const AsyncStructureSpawnEventData = struct { + world_name: []const u8, + structure_name: []const u8, + pos: BlockPos, + cancelled: bool, +}; + +pub const ChunkPopulateEventData = struct { + chunk_x: i32, + chunk_z: i32, + cancelled: bool, +}; + +pub const ChunkUnloadEventData = struct { + chunk_x: i32, + chunk_z: i32, + cancelled: bool, +}; + +pub const EntitiesLoadEventData = struct { + chunk_x: i32, + chunk_z: i32, + entity_count: u32, + cancelled: bool, +}; + +pub const EntitiesUnloadEventData = struct { + chunk_x: i32, + chunk_z: i32, + entity_count: u32, + cancelled: bool, +}; + +pub const GenericGameEventData = struct { + event_id: []const u8, + pos: Position, + cancelled: bool, +}; + +pub const LootGenerateEventData = struct { + loot_table: []const u8, + cancelled: bool, +}; + +pub const PortalCreateEventData = struct { + pos: BlockPos, + portal_type: []const u8, + cancelled: bool, +}; + +pub const StructureGrowEventData = struct { + pos: BlockPos, + species: []const u8, + bone_meal: bool, + cancelled: bool, +}; + +pub const TimeSkipEventData = struct { + skip_amount: i64, + cancelled: bool, +}; + +pub const WorldInitEventData = struct { + target_world: World, +}; + +pub const WorldSaveEventData = struct { + world_name: []const u8, + cancelled: bool, +}; + +pub const InventoryOpenEventData = struct { + player: Player, + cancelled: bool, +}; + +pub const InventoryDragEventData = struct { + player: Player, + cancelled: bool, +}; + +pub const CraftItemEventData = struct { + player: Player, + recipe_id: []const u8, + cancelled: bool, +}; + +pub const FurnaceSmeltEventData = struct { + block_pos: BlockPos, + source_item: []const u8, + result_item: []const u8, + cancelled: bool, +}; + +pub const BrewEventData = struct { + block_pos: BlockPos, + fuel_level: u8, + cancelled: bool, +}; + +pub const BrewingStandFuelEventData = struct { + block_pos: BlockPos, + fuel_power: u16, + cancelled: bool, +}; + +pub const FurnaceBurnEventData = struct { + block_pos: BlockPos, + fuel_item: []const u8, + burn_time: u32, + cancelled: bool, +}; + +pub const FurnaceExtractEventData = struct { + player: Player, + block_pos: BlockPos, + item_id: []const u8, + item_amount: u32, + exp_gained: f32, +}; + +pub const FurnaceStartSmeltEventData = struct { + block_pos: BlockPos, + source_item: []const u8, + cooking_time: u32, + cancelled: bool, +}; + +pub const HopperInventorySearchEventData = struct { + block_pos: BlockPos, + search_pos: BlockPos, + cancelled: bool, +}; + +pub const InventoryCreativeEventData = struct { + player: Player, + slot: i16, + item_id: []const u8, + item_count: u8, + cancelled: bool, +}; + +pub const InventoryInteractEventData = struct { + player: Player, + cancelled: bool, +}; + +pub const InventoryMoveItemEventData = struct { + source_pos: BlockPos, + target_pos: BlockPos, + item_id: []const u8, + item_amount: u32, + cancelled: bool, +}; + +pub const InventoryPickupItemEventData = struct { + block_pos: BlockPos, + item_entity_id: i32, + item_id: []const u8, + cancelled: bool, +}; + +pub const PrepareAnvilEventData = struct { + player: Player, + rename_text: []const u8, + repair_cost: u32, +}; + +pub const PrepareGrindstoneEventData = struct { + player: Player, + result_item: ?[]const u8, +}; + +pub const PrepareInventoryResultEventData = struct { + player: Player, + result_item: ?[]const u8, +}; + +pub const PrepareItemCraftEventData = struct { + player: Player, + recipe_id: []const u8, + cancelled: bool, +}; + +pub const PrepareSmithingEventData = struct { + player: Player, + result_item: ?[]const u8, +}; + +pub const SmithItemEventData = struct { + player: Player, + recipe_id: []const u8, + cancelled: bool, +}; + +pub const TradeSelectEventData = struct { + player: Player, + slot_index: u8, + cancelled: bool, +}; + +pub const VehicleBlockCollisionEventData = struct { + vehicle_id: i32, + block_pos: BlockPos, + cancelled: bool, +}; + +pub const VehicleCollisionEventData = struct { + vehicle_id: i32, + cancelled: bool, +}; + +pub const VehicleCreateEventData = struct { + vehicle_id: i32, + cancelled: bool, +}; + +pub const VehicleDamageEventData = struct { + vehicle_id: i32, + damage: f32, + attacker_id: ?i32, + cancelled: bool, +}; + +pub const VehicleDestroyEventData = struct { + vehicle_id: i32, + attacker_id: ?i32, + cancelled: bool, +}; + +pub const VehicleEnterEventData = struct { + vehicle_id: i32, + entered_id: i32, + cancelled: bool, +}; + +pub const VehicleEntityCollisionEventData = struct { + vehicle_id: i32, + collided_entity_id: i32, + cancelled: bool, +}; + +pub const VehicleExitEventData = struct { + vehicle_id: i32, + exited_id: i32, + cancelled: bool, +}; + +pub const VehicleMoveEventData = struct { + vehicle_id: i32, + from_position: Position, + to_position: Position, + cancelled: bool, +}; + +pub const VehicleUpdateEventData = struct { + vehicle_id: i32, + cancelled: bool, +}; + +pub const EnchantmentOffer = struct { + cost: i32, + enchantment_id: i32, + enchantment_level: i32, +}; + +pub const PrepareItemEnchantEventData = struct { + player: Player, + item: ItemStack, + offers: []const EnchantmentOffer, + bookshelf_count: i32, + cancelled: bool, +}; + +pub const EnchantmentValue = struct { + enchantment: Enchantment, + level: u32, +}; + +pub const EnchantItemEventData = struct { + player: Player, + item: ItemStack, + option: i32, + cost: i32, + enchantments_to_add: []const EnchantmentValue, + cancelled: bool, +}; + +pub const LightningStrikeEventData = struct { + position: Position, + is_effect: bool, + cancelled: bool, +}; + +pub const EventType = enum(u16) { + player_join_event, + player_leave_event, + player_login_event, + player_chat_event, + player_command_send_event, + player_permission_check_event, + player_move_event, + player_teleport_event, + player_change_world_event, + player_respawn_event, + player_exp_change_event, + player_item_held_event, + player_changed_main_hand_event, + player_gamemode_change_event, + player_custom_payload_event, + player_fish_event, + player_egg_throw_event, + player_interact_unknown_entity_event, + player_interact_entity_event, + player_interact_event, + player_toggle_sneak_event, + player_toggle_flight_event, + player_toggle_sprint_event, + inventory_click_event, + inventory_close_event, + block_redstone_event, + block_break_event, + block_burn_event, + block_can_build_event, + block_grow_event, + block_place_event, + bedrock_form_response_event, + dialog_click_action_event, + dialog_show_event, + dialog_clear_event, + server_command_event, + server_list_ping_event, + server_load_event, + spawn_change_event, + server_broadcast_event, + server_tick_start_event, + server_tick_end_event, + packet_received_event, + packet_sent_event, + chunk_load_event, + chunk_save_event, + chunk_send_event, + entity_damage_event, + entity_death_event, + player_death_event, + entity_spawn_event, + entity_combust_event, + entity_regain_health_event, + entity_air_change_event, + entity_breed_event, + entity_dismount_event, + entity_dye_event, + entity_enter_love_mode_event, + entity_explode_event, + entity_mount_event, + entity_pickup_item_event, + entity_portal_event, + entity_resurrect_event, + entity_shoot_bow_event, + entity_tame_event, + entity_target_event, + entity_teleport_event, + entity_toggle_glide_event, + entity_transform_event, + player_item_consume_event, + player_item_damage_event, + player_drop_item_event, + player_bed_enter_event, + player_bed_leave_event, + player_bucket_empty_event, + player_bucket_fill_event, + block_damage_event, + block_ignite_event, + block_from_to_event, + block_form_event, + block_fade_event, + block_dispense_event, + block_explode_event, + block_physics_event, + block_piston_extend_event, + block_piston_retract_event, + note_play_event, + sign_change_event, + sponge_absorb_event, + tnt_prime_event, + weather_change_event, + thunder_change_event, + world_load_event, + world_unload_event, + async_structure_generate_event, + async_structure_spawn_event, + chunk_populate_event, + chunk_unload_event, + entities_load_event, + entities_unload_event, + generic_game_event, + loot_generate_event, + portal_create_event, + structure_grow_event, + time_skip_event, + world_init_event, + world_save_event, + inventory_open_event, + inventory_drag_event, + craft_item_event, + furnace_smelt_event, + brew_event, + brewing_stand_fuel_event, + furnace_burn_event, + furnace_extract_event, + furnace_start_smelt_event, + hopper_inventory_search_event, + inventory_creative_event, + inventory_interact_event, + inventory_move_item_event, + inventory_pickup_item_event, + prepare_anvil_event, + prepare_grindstone_event, + prepare_inventory_result_event, + prepare_item_craft_event, + prepare_smithing_event, + smith_item_event, + trade_select_event, + vehicle_block_collision_event, + vehicle_collision_event, + vehicle_create_event, + vehicle_damage_event, + vehicle_destroy_event, + vehicle_enter_event, + vehicle_entity_collision_event, + vehicle_exit_event, + vehicle_move_event, + vehicle_update_event, + prepare_item_enchant_event, + enchant_item_event, + map_initialize_event, + hanging_break_event, + hanging_break_by_entity_event, + hanging_place_event, + bell_resonate_event, + bell_ring_event, + block_brush_event, + block_cook_event, + block_damage_abort_event, + block_dispense_armor_event, + block_dispense_loot_event, + block_drop_item_event, + block_exp_event, + block_fertilize_event, + block_multi_place_event, + block_receive_game_event, + block_shear_entity_event, + block_spread_event, + brewing_start_event, + campfire_start_event, + cauldron_level_change_event, + crafter_craft_event, + entity_block_form_event, + fluid_level_change_event, + inventory_block_start_event, + leaves_decay_event, + moisture_change_event, + sculk_bloom_event, + vault_display_item_event, + creature_spawn_event, + ender_dragon_change_phase_event, + entity_break_door_event, + entity_change_block_event, + entity_damage_by_block_event, + entity_damage_by_entity_event, + entity_drop_item_event, + entity_enter_block_event, + entity_exhaustion_event, + entity_interact_event, + entity_knockback_event, + entity_place_event, + entity_pose_change_event, + entity_potion_effect_event, + entity_spell_cast_event, + entity_target_living_entity_event, + entity_toggle_swim_event, + explosion_prime_event, + firework_explode_event, + food_level_change_event, + item_despawn_event, + item_merge_event, + item_spawn_event, + piglin_barter_event, + projectile_hit_event, + projectile_launch_event, + sheep_dye_wool_event, + sheep_regrow_wool_event, + slime_split_event, + strider_temperature_change_event, + villager_acquire_trade_event, + villager_career_change_event, + villager_replenish_trade_event, + warden_anger_change_event, + area_effect_cloud_apply_event, + arrow_body_count_change_event, + bat_toggle_sleep_event, + creeper_power_event, + entity_combust_by_block_event, + entity_combust_by_entity_event, + entity_knockback_by_entity_event, + entity_portal_enter_event, + entity_portal_exit_event, + entity_remove_event, + entity_target_block_event, + entity_unleash_event, + exp_bottle_event, + horse_jump_event, + lingering_potion_splash_event, + pig_zap_event, + pig_zombie_anger_event, + potion_splash_event, + spawner_spawn_event, + trial_spawner_spawn_event, + villager_reputation_change_event, + async_player_chat_event, + async_player_pre_login_event, + player_advancement_done_event, + player_animation_event, + player_armor_stand_manipulate_event, + player_bucket_entity_event, + player_changed_world_event, + player_channel_event, + player_command_preprocess_event, + player_edit_book_event, + player_elytra_boost_event, + player_exp_cooldown_change_event, + player_harvest_block_event, + player_hide_entity_event, + player_item_break_event, + player_item_mend_event, + player_kick_event, + player_leash_entity_event, + player_level_change_event, + player_locale_change_event, + player_name_entity_event, + player_open_sign_event, + player_portal_event, + player_pre_login_event, + player_riptide_event, + player_shear_entity_event, + player_show_entity_event, + player_spawn_change_event, + player_statistic_increment_event, + player_swap_hands_event, + player_take_lectern_book_event, + player_unleash_entity_event, + player_velocity_event, + player_input_event, + player_interact_at_entity_event, + player_links_send_event, + player_pickup_arrow_event, + player_recipe_book_click_event, + player_recipe_book_settings_change_event, + player_recipe_discover_event, + player_register_channel_event, + player_resource_pack_status_event, + player_spawn_location_event, + player_unregister_channel_event, + raid_finish_event, + raid_spawn_wave_event, + raid_stop_event, + raid_trigger_event, + lightning_strike_event, +}; + +pub const Event = union(enum) { + player_join_event: PlayerJoinEventData, + player_leave_event: PlayerLeaveEventData, + player_login_event: PlayerLoginEventData, + player_chat_event: PlayerChatEventData, + player_command_send_event: PlayerCommandSendEventData, + player_permission_check_event: PlayerPermissionCheckEventData, + player_move_event: PlayerMoveEventData, + player_teleport_event: PlayerTeleportEventData, + player_change_world_event: PlayerChangeWorldEventData, + player_respawn_event: PlayerRespawnEventData, + player_exp_change_event: PlayerExpChangeEventData, + player_item_held_event: PlayerItemHeldEventData, + player_changed_main_hand_event: PlayerChangedMainHandEventData, + player_gamemode_change_event: PlayerGamemodeChangeEventData, + player_custom_payload_event: PlayerCustomPayloadEventData, + player_fish_event: PlayerFishEventData, + player_egg_throw_event: PlayerEggThrowEventData, + player_interact_unknown_entity_event: PlayerInteractUnknownEntityEventData, + player_interact_entity_event: PlayerInteractEntityEventData, + player_interact_event: PlayerInteractEventData, + player_toggle_sneak_event: PlayerToggleSneakEventData, + player_toggle_flight_event: PlayerToggleFlightEventData, + player_toggle_sprint_event: PlayerToggleSprintEventData, + inventory_click_event: InventoryClickEventData, + inventory_close_event: InventoryCloseEventData, + block_redstone_event: BlockRedstoneEventData, + block_break_event: BlockBreakEventData, + block_burn_event: BlockBurnEventData, + block_can_build_event: BlockCanBuildEventData, + block_grow_event: BlockGrowEventData, + block_place_event: BlockPlaceEventData, + dialog_click_action_event: DialogClickActionEventData, + dialog_show_event: DialogShowEventData, + dialog_clear_event: DialogClearEventData, + bedrock_form_response_event: BedrockFormResponseEventData, + server_command_event: ServerCommandEventData, + server_list_ping_event: ServerListPingEventData, + server_load_event: ServerLoadEventData, + spawn_change_event: SpawnChangeEventData, + server_broadcast_event: ServerBroadcastEventData, + server_tick_start_event: ServerTickStartEventData, + server_tick_end_event: ServerTickEndEventData, + packet_received_event: PacketReceivedEventData, + packet_sent_event: PacketSentEventData, + chunk_load_event: ChunkLoadEventData, + chunk_save_event: ChunkSaveEventData, + chunk_send_event: ChunkSendEventData, + entity_damage_event: EntityDamageEventData, + entity_death_event: EntityDeathEventData, + player_death_event: PlayerDeathEventData, + entity_spawn_event: EntitySpawnEventData, + entity_combust_event: EntityCombustEventData, + entity_regain_health_event: EntityRegainHealthEventData, + entity_air_change_event: EntityAirChangeEventData, + entity_breed_event: EntityBreedEventData, + entity_dismount_event: EntityDismountEventData, + entity_dye_event: EntityDyeEventData, + entity_enter_love_mode_event: EntityEnterLoveModeEventData, + entity_explode_event: EntityExplodeEventData, + entity_mount_event: EntityMountEventData, + entity_pickup_item_event: EntityPickupItemEventData, + entity_portal_event: EntityPortalEventData, + entity_resurrect_event: EntityResurrectEventData, + entity_shoot_bow_event: EntityShootBowEventData, + entity_tame_event: EntityTameEventData, + entity_target_event: EntityTargetEventData, + entity_teleport_event: EntityTeleportEventData, + entity_toggle_glide_event: EntityToggleGlideEventData, + entity_transform_event: EntityTransformEventData, + player_item_consume_event: PlayerItemConsumeEventData, + player_item_damage_event: PlayerItemDamageEventData, + player_drop_item_event: PlayerDropItemEventData, + player_bed_enter_event: PlayerBedEnterEventData, + player_bed_leave_event: PlayerBedLeaveEventData, + player_bucket_empty_event: PlayerBucketEmptyEventData, + player_bucket_fill_event: PlayerBucketFillEventData, + block_damage_event: BlockDamageEventData, + block_ignite_event: BlockIgniteEventData, + block_from_to_event: BlockFromToEventData, + block_form_event: BlockFormEventData, + block_fade_event: BlockFadeEventData, + block_dispense_event: BlockDispenseEventData, + block_explode_event: BlockExplodeEventData, + block_physics_event: BlockPhysicsEventData, + block_piston_extend_event: BlockPistonExtendEventData, + block_piston_retract_event: BlockPistonRetractEventData, + note_play_event: NotePlayEventData, + sign_change_event: SignChangeEventData, + sponge_absorb_event: SpongeAbsorbEventData, + tnt_prime_event: TntPrimeEventData, + weather_change_event: WeatherChangeEventData, + thunder_change_event: ThunderChangeEventData, + world_load_event: WorldLoadEventData, + world_unload_event: WorldUnloadEventData, + async_structure_generate_event: AsyncStructureGenerateEventData, + async_structure_spawn_event: AsyncStructureSpawnEventData, + chunk_populate_event: ChunkPopulateEventData, + chunk_unload_event: ChunkUnloadEventData, + entities_load_event: EntitiesLoadEventData, + entities_unload_event: EntitiesUnloadEventData, + generic_game_event: GenericGameEventData, + loot_generate_event: LootGenerateEventData, + portal_create_event: PortalCreateEventData, + structure_grow_event: StructureGrowEventData, + time_skip_event: TimeSkipEventData, + world_init_event: WorldInitEventData, + world_save_event: WorldSaveEventData, + inventory_open_event: InventoryOpenEventData, + inventory_drag_event: InventoryDragEventData, + craft_item_event: CraftItemEventData, + furnace_smelt_event: FurnaceSmeltEventData, + brew_event: BrewEventData, + brewing_stand_fuel_event: BrewingStandFuelEventData, + furnace_burn_event: FurnaceBurnEventData, + furnace_extract_event: FurnaceExtractEventData, + furnace_start_smelt_event: FurnaceStartSmeltEventData, + hopper_inventory_search_event: HopperInventorySearchEventData, + inventory_creative_event: InventoryCreativeEventData, + inventory_interact_event: InventoryInteractEventData, + inventory_move_item_event: InventoryMoveItemEventData, + inventory_pickup_item_event: InventoryPickupItemEventData, + prepare_anvil_event: PrepareAnvilEventData, + prepare_grindstone_event: PrepareGrindstoneEventData, + prepare_inventory_result_event: PrepareInventoryResultEventData, + prepare_item_craft_event: PrepareItemCraftEventData, + prepare_smithing_event: PrepareSmithingEventData, + smith_item_event: SmithItemEventData, + trade_select_event: TradeSelectEventData, + vehicle_block_collision_event: VehicleBlockCollisionEventData, + vehicle_collision_event: VehicleCollisionEventData, + vehicle_create_event: VehicleCreateEventData, + vehicle_damage_event: VehicleDamageEventData, + vehicle_destroy_event: VehicleDestroyEventData, + vehicle_enter_event: VehicleEnterEventData, + vehicle_entity_collision_event: VehicleEntityCollisionEventData, + vehicle_exit_event: VehicleExitEventData, + vehicle_move_event: VehicleMoveEventData, + vehicle_update_event: VehicleUpdateEventData, + prepare_item_enchant_event: PrepareItemEnchantEventData, + enchant_item_event: EnchantItemEventData, + map_initialize_event: MapInitializeEventData, + hanging_break_event: HangingBreakEventData, + hanging_break_by_entity_event: HangingBreakByEntityEventData, + hanging_place_event: HangingPlaceEventData, + bell_resonate_event: BellResonateEventData, + bell_ring_event: BellRingEventData, + block_brush_event: BlockBrushEventData, + block_cook_event: BlockCookEventData, + block_damage_abort_event: BlockDamageAbortEventData, + block_dispense_armor_event: BlockDispenseArmorEventData, + block_dispense_loot_event: BlockDispenseLootEventData, + block_drop_item_event: BlockDropItemEventData, + block_exp_event: BlockExpEventData, + block_fertilize_event: BlockFertilizeEventData, + block_multi_place_event: BlockMultiPlaceEventData, + block_receive_game_event: BlockReceiveGameEventData, + block_shear_entity_event: BlockShearEntityEventData, + block_spread_event: BlockSpreadEventData, + brewing_start_event: BrewingStartEventData, + campfire_start_event: CampfireStartEventData, + cauldron_level_change_event: CauldronLevelChangeEventData, + crafter_craft_event: CrafterCraftEventData, + entity_block_form_event: EntityBlockFormEventData, + fluid_level_change_event: FluidLevelChangeEventData, + inventory_block_start_event: InventoryBlockStartEventData, + leaves_decay_event: LeavesDecayEventData, + moisture_change_event: MoistureChangeEventData, + sculk_bloom_event: SculkBloomEventData, + vault_display_item_event: VaultDisplayItemEventData, + creature_spawn_event: CreatureSpawnEventData, + ender_dragon_change_phase_event: EnderDragonChangePhaseEventData, + entity_break_door_event: EntityBreakDoorEventData, + entity_change_block_event: EntityChangeBlockEventData, + entity_damage_by_block_event: EntityDamageByBlockEventData, + entity_damage_by_entity_event: EntityDamageByEntityEventData, + entity_drop_item_event: EntityDropItemEventData, + entity_enter_block_event: EntityEnterBlockEventData, + entity_exhaustion_event: EntityExhaustionEventData, + entity_interact_event: EntityInteractEventData, + entity_knockback_event: EntityKnockbackEventData, + entity_place_event: EntityPlaceEventData, + entity_pose_change_event: EntityPoseChangeEventData, + entity_potion_effect_event: EntityPotionEffectEventData, + entity_spell_cast_event: EntitySpellCastEventData, + entity_target_living_entity_event: EntityTargetLivingEntityEventData, + entity_toggle_swim_event: EntityToggleSwimEventData, + explosion_prime_event: ExplosionPrimeEventData, + firework_explode_event: FireworkExplodeEventData, + food_level_change_event: FoodLevelChangeEventData, + item_despawn_event: ItemDespawnEventData, + item_merge_event: ItemMergeEventData, + item_spawn_event: ItemSpawnEventData, + piglin_barter_event: PiglinBarterEventData, + projectile_hit_event: ProjectileHitEventData, + projectile_launch_event: ProjectileLaunchEventData, + sheep_dye_wool_event: SheepDyeWoolEventData, + sheep_regrow_wool_event: SheepRegrowWoolEventData, + slime_split_event: SlimeSplitEventData, + strider_temperature_change_event: StriderTemperatureChangeEventData, + villager_acquire_trade_event: VillagerAcquireTradeEventData, + villager_career_change_event: VillagerCareerChangeEventData, + villager_replenish_trade_event: VillagerReplenishTradeEventData, + warden_anger_change_event: WardenAngerChangeEventData, + area_effect_cloud_apply_event: AreaEffectCloudApplyEventData, + arrow_body_count_change_event: ArrowBodyCountChangeEventData, + bat_toggle_sleep_event: BatToggleSleepEventData, + creeper_power_event: CreeperPowerEventData, + entity_combust_by_block_event: EntityCombustByBlockEventData, + entity_combust_by_entity_event: EntityCombustByEntityEventData, + entity_knockback_by_entity_event: EntityKnockbackByEntityEventData, + entity_portal_enter_event: EntityPortalEnterEventData, + entity_portal_exit_event: EntityPortalExitEventData, + entity_remove_event: EntityRemoveEventData, + entity_target_block_event: EntityTargetBlockEventData, + entity_unleash_event: EntityUnleashEventData, + exp_bottle_event: ExpBottleEventData, + horse_jump_event: HorseJumpEventData, + lingering_potion_splash_event: LingeringPotionSplashEventData, + pig_zap_event: PigZapEventData, + pig_zombie_anger_event: PigZombieAngerEventData, + potion_splash_event: PotionSplashEventData, + spawner_spawn_event: SpawnerSpawnEventData, + trial_spawner_spawn_event: TrialSpawnerSpawnEventData, + villager_reputation_change_event: VillagerReputationChangeEventData, + async_player_chat_event: AsyncPlayerChatEventData, + async_player_pre_login_event: AsyncPlayerPreLoginEventData, + player_advancement_done_event: PlayerAdvancementDoneEventData, + player_animation_event: PlayerAnimationEventData, + player_armor_stand_manipulate_event: PlayerArmorStandManipulateEventData, + player_bucket_entity_event: PlayerBucketEntityEventData, + player_changed_world_event: PlayerChangedWorldEventData, + player_channel_event: PlayerChannelEventData, + player_command_preprocess_event: PlayerCommandPreprocessEventData, + player_edit_book_event: PlayerEditBookEventData, + player_elytra_boost_event: PlayerElytraBoostEventData, + player_exp_cooldown_change_event: PlayerExpCooldownChangeEventData, + player_harvest_block_event: PlayerHarvestBlockEventData, + player_hide_entity_event: PlayerHideEntityEventData, + player_item_break_event: PlayerItemBreakEventData, + player_item_mend_event: PlayerItemMendEventData, + player_kick_event: PlayerKickEventData, + player_leash_entity_event: PlayerLeashEntityEventData, + player_level_change_event: PlayerLevelChangeEventData, + player_locale_change_event: PlayerLocaleChangeEventData, + player_name_entity_event: PlayerNameEntityEventData, + player_open_sign_event: PlayerOpenSignEventData, + player_portal_event: PlayerPortalEventData, + player_pre_login_event: PlayerPreLoginEventData, + player_riptide_event: PlayerRiptideEventData, + player_shear_entity_event: PlayerShearEntityEventData, + player_show_entity_event: PlayerShowEntityEventData, + player_spawn_change_event: PlayerSpawnChangeEventData, + player_statistic_increment_event: PlayerStatisticIncrementEventData, + player_swap_hands_event: PlayerSwapHandsEventData, + player_take_lectern_book_event: PlayerTakeLecternBookEventData, + player_unleash_entity_event: PlayerUnleashEntityEventData, + player_velocity_event: PlayerVelocityEventData, + player_input_event: PlayerInputEventData, + player_interact_at_entity_event: PlayerInteractAtEntityEventData, + player_links_send_event: PlayerLinksSendEventData, + player_pickup_arrow_event: PlayerPickupArrowEventData, + player_recipe_book_click_event: PlayerRecipeBookClickEventData, + player_recipe_book_settings_change_event: PlayerRecipeBookSettingsChangeEventData, + player_recipe_discover_event: PlayerRecipeDiscoverEventData, + player_register_channel_event: PlayerRegisterChannelEventData, + player_resource_pack_status_event: PlayerResourcePackStatusEventData, + player_spawn_location_event: PlayerSpawnLocationEventData, + player_unregister_channel_event: PlayerUnregisterChannelEventData, + raid_finish_event: RaidFinishEventData, + raid_spawn_wave_event: RaidSpawnWaveEventData, + raid_stop_event: RaidStopEventData, + raid_trigger_event: RaidTriggerEventData, + lightning_strike_event: LightningStrikeEventData, +}; diff --git a/src/wit/exports.zig b/src/wit/exports.zig new file mode 100644 index 0000000..66e446a --- /dev/null +++ b/src/wit/exports.zig @@ -0,0 +1,217 @@ +// Generated by tools/gen.zig, do not edit. + +const std = @import("std"); +const abi = @import("../abi.zig"); +const context = @import("context.zig"); +const server = @import("server.zig"); +const event = @import("event.zig"); +const command = @import("command.zig"); +const ipc = @import("ipc.zig"); +const world = @import("world.zig"); +const metadata = @import("metadata.zig"); + +/// --- Plugin-provided exports --- +/// Called by the host once to initialize the plugin. +/// Internal use only; plugins should use the `register_plugin!` macro. +pub fn initPlugin(comptime impl: fn () void) void { + const glue = struct { + fn call() callconv(.c) void { + const args = abi.liftArgs(std.meta.ArgsTuple(@TypeOf(impl)), .{}); + defer abi.endCall(); + return abi.lowerReturn(void, @call(.auto, impl, args)); + } + }; + @export(&glue.call, .{ .name = "init-plugin" }); +} + +/// Called when the plugin is being loaded. +/// Use this to register commands, events, and perform initial setup. +pub fn onLoad(comptime impl: fn (context.Context) abi.Result(void, []const u8)) void { + const glue = struct { + fn call(p0: i32) callconv(.c) i32 { + const args = abi.liftArgs(std.meta.ArgsTuple(@TypeOf(impl)), .{p0}); + return abi.lowerReturn(abi.Result(void, []const u8), @call(.auto, impl, args)); + } + + fn post(_: i32) callconv(.c) void { + abi.endCall(); + } + }; + @export(&glue.call, .{ .name = "on-load" }); + @export(&glue.post, .{ .name = "cabi_post_on-load" }); +} + +/// Called when the plugin is being unloaded. +/// Use this to save data and clean up resources. +pub fn onUnload(comptime impl: fn (context.Context) abi.Result(void, []const u8)) void { + const glue = struct { + fn call(p0: i32) callconv(.c) i32 { + const args = abi.liftArgs(std.meta.ArgsTuple(@TypeOf(impl)), .{p0}); + return abi.lowerReturn(abi.Result(void, []const u8), @call(.auto, impl, args)); + } + + fn post(_: i32) callconv(.c) void { + abi.endCall(); + } + }; + @export(&glue.call, .{ .name = "on-unload" }); + @export(&glue.post, .{ .name = "cabi_post_on-unload" }); +} + +/// Dispatches an event to the plugin for handling. +pub fn handleEvent(comptime impl: fn (u32, server.Server, event.Event) event.Event) void { + const glue = struct { + fn call(p0: i32) callconv(.c) i32 { + const args = abi.liftArgs(std.meta.ArgsTuple(@TypeOf(impl)), .{p0}); + return abi.lowerReturn(event.Event, @call(.auto, impl, args)); + } + + fn post(_: i32) callconv(.c) void { + abi.endCall(); + } + }; + @export(&glue.call, .{ .name = "handle-event" }); + @export(&glue.post, .{ .name = "cabi_post_handle-event" }); +} + +/// Dispatches a command execution to the plugin. +pub fn handleCommand(comptime impl: fn (u32, command.CommandSender, server.Server, command.ConsumedArgs) abi.Result(i32, command.CommandError)) void { + const glue = struct { + fn call(p0: i32, p1: i32, p2: i32, p3: i32) callconv(.c) i32 { + const args = abi.liftArgs(std.meta.ArgsTuple(@TypeOf(impl)), .{ p0, p1, p2, p3 }); + return abi.lowerReturn(abi.Result(i32, command.CommandError), @call(.auto, impl, args)); + } + + fn post(_: i32) callconv(.c) void { + abi.endCall(); + } + }; + @export(&glue.call, .{ .name = "handle-command" }); + @export(&glue.post, .{ .name = "cabi_post_handle-command" }); +} + +/// Dispatches a command suggestion request to the plugin. +pub fn handleCommandSuggestion(comptime impl: fn (u32, command.CommandSender, server.Server, command.SuggestionRequest) command.CommandSuggestions) void { + const glue = struct { + fn call(p0: i32, p1: i32, p2: i32, p3: i32, p4: i32, p5: i32, p6: i32, p7: i32, p8: i32) callconv(.c) i32 { + const args = abi.liftArgs(std.meta.ArgsTuple(@TypeOf(impl)), .{ p0, p1, p2, p3, p4, p5, p6, p7, p8 }); + return abi.lowerReturn(command.CommandSuggestions, @call(.auto, impl, args)); + } + + fn post(_: i32) callconv(.c) void { + abi.endCall(); + } + }; + @export(&glue.call, .{ .name = "handle-command-suggestion" }); + @export(&glue.post, .{ .name = "cabi_post_handle-command-suggestion" }); +} + +/// Dispatches a scheduled task execution to the plugin. +pub fn handleTask(comptime impl: fn (u32, server.Server) void) void { + const glue = struct { + fn call(p0: i32, p1: i32) callconv(.c) void { + const args = abi.liftArgs(std.meta.ArgsTuple(@TypeOf(impl)), .{ p0, p1 }); + defer abi.endCall(); + return abi.lowerReturn(void, @call(.auto, impl, args)); + } + }; + @export(&glue.call, .{ .name = "handle-task" }); +} + +/// Processes an incoming message from another plugin if possible, and returns (a possibly empty) response. +pub fn handleIpcMessage(comptime impl: fn (ipc.PluginId, ipc.IpcMessage) abi.Result(ipc.IpcMessage, []const u8)) void { + const glue = struct { + fn call(p0: i32, p1: i32, p2: i32, p3: i32) callconv(.c) i32 { + const args = abi.liftArgs(std.meta.ArgsTuple(@TypeOf(impl)), .{ p0, p1, p2, p3 }); + return abi.lowerReturn(abi.Result(ipc.IpcMessage, []const u8), @call(.auto, impl, args)); + } + + fn post(_: i32) callconv(.c) void { + abi.endCall(); + } + }; + @export(&glue.call, .{ .name = "handle-ipc-message" }); + @export(&glue.post, .{ .name = "cabi_post_handle-ipc-message" }); +} + +pub fn handleAiGoalCanStart(comptime impl: fn (u32, server.Server, world.Entity) bool) void { + const glue = struct { + fn call(p0: i32, p1: i32, p2: i32) callconv(.c) i32 { + const args = abi.liftArgs(std.meta.ArgsTuple(@TypeOf(impl)), .{ p0, p1, p2 }); + defer abi.endCall(); + return abi.lowerReturn(bool, @call(.auto, impl, args)); + } + }; + @export(&glue.call, .{ .name = "handle-ai-goal-can-start" }); +} + +pub fn handleAiGoalShouldContinue(comptime impl: fn (u32, server.Server, world.Entity) bool) void { + const glue = struct { + fn call(p0: i32, p1: i32, p2: i32) callconv(.c) i32 { + const args = abi.liftArgs(std.meta.ArgsTuple(@TypeOf(impl)), .{ p0, p1, p2 }); + defer abi.endCall(); + return abi.lowerReturn(bool, @call(.auto, impl, args)); + } + }; + @export(&glue.call, .{ .name = "handle-ai-goal-should-continue" }); +} + +pub fn handleAiGoalStart(comptime impl: fn (u32, server.Server, world.Entity) void) void { + const glue = struct { + fn call(p0: i32, p1: i32, p2: i32) callconv(.c) void { + const args = abi.liftArgs(std.meta.ArgsTuple(@TypeOf(impl)), .{ p0, p1, p2 }); + defer abi.endCall(); + return abi.lowerReturn(void, @call(.auto, impl, args)); + } + }; + @export(&glue.call, .{ .name = "handle-ai-goal-start" }); +} + +pub fn handleAiGoalTick(comptime impl: fn (u32, server.Server, world.Entity) void) void { + const glue = struct { + fn call(p0: i32, p1: i32, p2: i32) callconv(.c) void { + const args = abi.liftArgs(std.meta.ArgsTuple(@TypeOf(impl)), .{ p0, p1, p2 }); + defer abi.endCall(); + return abi.lowerReturn(void, @call(.auto, impl, args)); + } + }; + @export(&glue.call, .{ .name = "handle-ai-goal-tick" }); +} + +pub fn handleAiGoalStop(comptime impl: fn (u32, server.Server, world.Entity) void) void { + const glue = struct { + fn call(p0: i32, p1: i32, p2: i32) callconv(.c) void { + const args = abi.liftArgs(std.meta.ArgsTuple(@TypeOf(impl)), .{ p0, p1, p2 }); + defer abi.endCall(); + return abi.lowerReturn(void, @call(.auto, impl, args)); + } + }; + @export(&glue.call, .{ .name = "handle-ai-goal-stop" }); +} + +/// Dispatches a chunk generation phase to the plugin. +pub fn handleGeneratePhase(comptime impl: fn (u32, world.GenerationPhase, world.ChunkBuffer) void) void { + const glue = struct { + fn call(p0: i32, p1: i32, p2: i32) callconv(.c) void { + const args = abi.liftArgs(std.meta.ArgsTuple(@TypeOf(impl)), .{ p0, p1, p2 }); + defer abi.endCall(); + return abi.lowerReturn(void, @call(.auto, impl, args)); + } + }; + @export(&glue.call, .{ .name = "handle-generate-phase" }); +} + +pub fn getMetadata(comptime impl: fn () metadata.PluginMetadata) void { + const glue = struct { + fn call() callconv(.c) i32 { + const args = abi.liftArgs(std.meta.ArgsTuple(@TypeOf(impl)), .{}); + return abi.lowerReturn(metadata.PluginMetadata, @call(.auto, impl, args)); + } + + fn post(_: i32) callconv(.c) void { + abi.endCall(); + } + }; + @export(&glue.call, .{ .name = "pumpkin:plugin/metadata@0.1.0#get-metadata" }); + @export(&glue.post, .{ .name = "cabi_post_pumpkin:plugin/metadata@0.1.0#get-metadata" }); +} diff --git a/src/wit/forms.zig b/src/wit/forms.zig new file mode 100644 index 0000000..cc4304a --- /dev/null +++ b/src/wit/forms.zig @@ -0,0 +1,56 @@ +// Generated by tools/gen.zig, do not edit. + +const text = @import("text.zig"); + +pub const TextComponent = text.TextComponent; + +pub const ImageType = enum(u8) { + url, + path, +}; + +pub const FormImage = struct { + type: ImageType, + data: []const u8, +}; + +pub const SimpleFormButton = struct { + text: TextComponent, + image: ?FormImage, +}; + +pub const SimpleForm = struct { + title: TextComponent, + content: TextComponent, + buttons: []const SimpleFormButton, +}; + +pub const ModalForm = struct { + title: TextComponent, + content: TextComponent, + button1: TextComponent, + button2: TextComponent, +}; + +pub const CustomFormElement = union(enum) { + label: TextComponent, + toggle: struct { TextComponent, bool }, + slider: struct { TextComponent, f32, f32, f32, f32 }, + /// text, min, max, step, default + step_slider: struct { TextComponent, []const []const u8, u32 }, + /// text, steps, default + dropdown: struct { TextComponent, []const []const u8, u32 }, + /// text, options, default + input: struct { TextComponent, []const u8, []const u8 }, +}; + +pub const CustomForm = struct { + title: TextComponent, + elements: []const CustomFormElement, +}; + +pub const Form = union(enum) { + simple: SimpleForm, + modal: ModalForm, + custom: CustomForm, +}; diff --git a/src/wit/game_events.zig b/src/wit/game_events.zig new file mode 100644 index 0000000..282d2e6 --- /dev/null +++ b/src/wit/game_events.zig @@ -0,0 +1,65 @@ +// Generated by tools/gen.zig, do not edit. + +pub const GameEvent = enum(u8) { + block_activate, + block_attach, + block_change, + block_close, + block_deactivate, + block_destroy, + block_detach, + block_open, + block_place, + bounce, + container_close, + container_open, + drink, + eat, + elytra_glide, + entity_damage, + entity_die, + entity_dismount, + entity_interact, + entity_mount, + entity_place, + entity_action, + equip, + explode, + flap, + fluid_pickup, + fluid_place, + hit_ground, + instrument_play, + item_interact_finish, + item_interact_start, + jukebox_play, + jukebox_stop_play, + lightning_strike, + note_block_play, + prime_fuse, + projectile_land, + projectile_shoot, + sculk_sensor_tendrils_clicking, + shear, + shriek, + splash, + step, + swim, + teleport, + unequip, + resonate_1, + resonate_2, + resonate_3, + resonate_4, + resonate_5, + resonate_6, + resonate_7, + resonate_8, + resonate_9, + resonate_10, + resonate_11, + resonate_12, + resonate_13, + resonate_14, + resonate_15, +}; diff --git a/src/wit/game_rules.zig b/src/wit/game_rules.zig new file mode 100644 index 0000000..d856807 --- /dev/null +++ b/src/wit/game_rules.zig @@ -0,0 +1,68 @@ +// Generated by tools/gen.zig, do not edit. + +pub const GameRule = enum(u8) { + advance_time, + advance_weather, + allow_entering_nether_using_portals, + block_drops, + block_explosion_drop_decay, + command_block_output, + command_blocks_work, + drowning_damage, + elytra_movement_check, + ender_pearls_vanish_on_death, + entity_drops, + fall_damage, + fire_damage, + fire_spread_radius_around_player, + forgive_dead_players, + freeze_damage, + global_sound_events, + immediate_respawn, + keep_inventory, + lava_source_conversion, + limited_crafting, + locator_bar, + log_admin_commands, + max_block_modifications, + max_command_forks, + max_command_sequence_length, + max_entity_cramming, + max_minecart_speed, + max_snow_accumulation_height, + mob_drops, + mob_explosion_drop_decay, + mob_griefing, + natural_health_regeneration, + player_movement_check, + players_nether_portal_creative_delay, + players_nether_portal_default_delay, + players_sleeping_percentage, + projectiles_can_break_blocks, + pvp, + raids, + random_tick_speed, + reduced_debug_info, + respawn_radius, + send_command_feedback, + show_advancement_messages, + show_death_messages, + spawn_mobs, + spawn_monsters, + spawn_patrols, + spawn_phantoms, + spawn_wandering_traders, + spawn_wardens, + spawner_blocks_work, + spectators_generate_chunks, + spread_vines, + tnt_explodes, + tnt_explosion_drop_decay, + universal_anger, + water_source_conversion, +}; + +pub const GameRuleValue = union(enum) { + int: i32, + bool: bool, +}; diff --git a/src/wit/gui.zig b/src/wit/gui.zig new file mode 100644 index 0000000..3ef8353 --- /dev/null +++ b/src/wit/gui.zig @@ -0,0 +1,105 @@ +// Generated by tools/gen.zig, do not edit. + +const abi = @import("../abi.zig"); +const text = @import("text.zig"); +const common = @import("common.zig"); +const item_stack = @import("item_stack.zig"); +const screens = @import("screens.zig"); +const inventory = @import("inventory.zig"); + +pub const TextComponent = text.TextComponent; +pub const ClickType = common.ClickType; +pub const ItemStack = item_stack.ItemStack; +pub const Screen = screens.Screen; +pub const Inventory = inventory.Inventory; + +pub const Gui = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]gui"; + + /// Consumes `title`. + pub fn init(@"type": Screen, title: TextComponent) Gui { + return abi.call(raw.@"[constructor]gui", Gui, .{ @"type", title }); + } + + /// Returns the underlying inventory handle for this GUI. + pub fn getInventory(self: Gui) Inventory { + return abi.call(raw.@"[method]gui.get-inventory", Inventory, .{abi.borrow(self)}); + } + + /// Consumes `item`. + pub fn setItem(self: Gui, slot: u32, item: ItemStack) void { + return abi.call(raw.@"[method]gui.set-item", void, .{ abi.borrow(self), slot, item }); + } + + pub fn getItem(self: Gui, slot: u32) ?ItemStack { + return abi.call(raw.@"[method]gui.get-item", ?ItemStack, .{ abi.borrow(self), slot }); + } + + /// Returns the type of this GUI. + pub fn getType(self: Gui) Screen { + return abi.call(raw.@"[method]gui.get-type", Screen, .{abi.borrow(self)}); + } + + /// Returns the title of this GUI. + pub fn getTitle(self: Gui) TextComponent { + return abi.call(raw.@"[method]gui.get-title", TextComponent, .{abi.borrow(self)}); + } + + /// Returns the number of slots in this GUI. + pub fn getSize(self: Gui) u32 { + return abi.call(raw.@"[method]gui.get-size", u32, .{abi.borrow(self)}); + } + + /// Clears all items from the GUI. + pub fn clearItems(self: Gui) void { + return abi.call(raw.@"[method]gui.clear-items", void, .{abi.borrow(self)}); + } + + /// Sets whether players can grab items out of the inventory. + pub fn setAllowGrabItems(self: Gui, allow: bool) void { + return abi.call(raw.@"[method]gui.set-allow-grab-items", void, .{ abi.borrow(self), allow }); + } + + /// Returns whether players can grab items out of the inventory. + pub fn getAllowGrabItems(self: Gui) bool { + return abi.call(raw.@"[method]gui.get-allow-grab-items", bool, .{abi.borrow(self)}); + } + + /// Sets whether players can put items into the inventory from their own. + pub fn setAllowPutItems(self: Gui, allow: bool) void { + return abi.call(raw.@"[method]gui.set-allow-put-items", void, .{ abi.borrow(self), allow }); + } + + /// Returns whether players can put items into the inventory from their own. + pub fn getAllowPutItems(self: Gui) bool { + return abi.call(raw.@"[method]gui.get-allow-put-items", bool, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: Gui) void { + abi.keep(Gui, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: Gui) void { + abi.drop(Gui, self); + } +}; + +const raw = struct { + extern "pumpkin:plugin/gui@0.1.0" fn @"[constructor]gui"(i32, i32) i32; + extern "pumpkin:plugin/gui@0.1.0" fn @"[method]gui.get-inventory"(i32) i32; + extern "pumpkin:plugin/gui@0.1.0" fn @"[method]gui.set-item"(i32, i32, i32) void; + extern "pumpkin:plugin/gui@0.1.0" fn @"[method]gui.get-item"(i32, i32, i32) void; + extern "pumpkin:plugin/gui@0.1.0" fn @"[method]gui.get-type"(i32) i32; + extern "pumpkin:plugin/gui@0.1.0" fn @"[method]gui.get-title"(i32) i32; + extern "pumpkin:plugin/gui@0.1.0" fn @"[method]gui.get-size"(i32) i32; + extern "pumpkin:plugin/gui@0.1.0" fn @"[method]gui.clear-items"(i32) void; + extern "pumpkin:plugin/gui@0.1.0" fn @"[method]gui.set-allow-grab-items"(i32, i32) void; + extern "pumpkin:plugin/gui@0.1.0" fn @"[method]gui.get-allow-grab-items"(i32) i32; + extern "pumpkin:plugin/gui@0.1.0" fn @"[method]gui.set-allow-put-items"(i32, i32) void; + extern "pumpkin:plugin/gui@0.1.0" fn @"[method]gui.get-allow-put-items"(i32) i32; + extern "pumpkin:plugin/gui@0.1.0" fn @"[resource-drop]gui"(i32) void; +}; diff --git a/src/wit/i18n.zig b/src/wit/i18n.zig new file mode 100644 index 0000000..119d96e --- /dev/null +++ b/src/wit/i18n.zig @@ -0,0 +1,33 @@ +// Generated by tools/gen.zig, do not edit. + +const abi = @import("../abi.zig"); +const common = @import("common.zig"); + +pub const Locale = common.Locale; + +/// Retrieves a translated string from the host. +/// +/// # Arguments +/// * `key`: The namespaced translation key (e.g. `pumpkin:my_key`). +/// * `locale`: The target locale. +/// +/// # Returns +/// The localized string, falling back to English or the key itself. +pub fn translate(key: []const u8, locale: Locale) []const u8 { + return abi.call(raw.translate, []const u8, .{ key, locale }); +} + +/// Loads custom translations from a JSON string. +/// +/// # Arguments +/// * `namespace`: The namespace to associate these keys with. +/// * `json`: A JSON string containing a flat map of translations. +/// * `locale`: The target locale for these translations. +pub fn loadTranslations(namespace: []const u8, json: []const u8, locale: Locale) void { + return abi.call(raw.@"load-translations", void, .{ namespace, json, locale }); +} + +const raw = struct { + extern "pumpkin:plugin/i18n@0.1.0" fn translate(i32, i32, i32, i32) void; + extern "pumpkin:plugin/i18n@0.1.0" fn @"load-translations"(i32, i32, i32, i32, i32) void; +}; diff --git a/src/wit/inventory.zig b/src/wit/inventory.zig new file mode 100644 index 0000000..970545f --- /dev/null +++ b/src/wit/inventory.zig @@ -0,0 +1,206 @@ +// Generated by tools/gen.zig, do not edit. + +const abi = @import("../abi.zig"); +const item_stack = @import("item_stack.zig"); +const common = @import("common.zig"); + +pub const ItemStack = item_stack.ItemStack; +pub const Hand = common.Hand; + +/// Common inventory resource used across GUIs, player inventories, and containers. +pub const Inventory = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]inventory"; + + /// Returns the number of slots in this inventory. + pub fn getSize(self: Inventory) u32 { + return abi.call(raw.@"[method]inventory.get-size", u32, .{abi.borrow(self)}); + } + + /// Returns true if all slots in this inventory are empty. + pub fn isEmpty(self: Inventory) bool { + return abi.call(raw.@"[method]inventory.is-empty", bool, .{abi.borrow(self)}); + } + + /// Returns the item in the specified slot index, or none if empty. + pub fn getItem(self: Inventory, slot: u32) ?ItemStack { + return abi.call(raw.@"[method]inventory.get-item", ?ItemStack, .{ abi.borrow(self), slot }); + } + + /// Sets the item in the specified slot index. + pub fn setItem(self: Inventory, slot: u32, item: ?ItemStack) void { + return abi.call(raw.@"[method]inventory.set-item", void, .{ abi.borrow(self), slot, item }); + } + + /// Removes and returns the item in the specified slot index. + pub fn removeItem(self: Inventory, slot: u32) ?ItemStack { + return abi.call(raw.@"[method]inventory.remove-item", ?ItemStack, .{ abi.borrow(self), slot }); + } + + /// Clears all items from this inventory. + pub fn clear(self: Inventory) void { + return abi.call(raw.@"[method]inventory.clear", void, .{abi.borrow(self)}); + } + + /// Returns all items in this inventory as a list of slots. + pub fn getAllItems(self: Inventory) []const ?ItemStack { + return abi.call(raw.@"[method]inventory.get-all-items", []const ?ItemStack, .{abi.borrow(self)}); + } + + /// Sets all items in this inventory from a list. + pub fn setAllItems(self: Inventory, items: []const ?ItemStack) void { + return abi.call(raw.@"[method]inventory.set-all-items", void, .{ abi.borrow(self), items }); + } + + /// Counts the total number of items with the given ID in this inventory. + pub fn countItem(self: Inventory, item_id: []const u8) u32 { + return abi.call(raw.@"[method]inventory.count-item", u32, .{ abi.borrow(self), item_id }); + } + + /// Checks if the inventory contains at least one item with the given ID. + pub fn containsItem(self: Inventory, item_id: []const u8) bool { + return abi.call(raw.@"[method]inventory.contains-item", bool, .{ abi.borrow(self), item_id }); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: Inventory) void { + abi.keep(Inventory, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: Inventory) void { + abi.drop(Inventory, self); + } +}; + +/// Specialized player inventory handle providing access to main inventory, armor, offhand, and hotbar. +pub const PlayerInventory = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]player-inventory"; + + /// Returns the generic 36-slot inventory handle (hotbar + main storage). + pub fn asInventory(self: PlayerInventory) Inventory { + return abi.call(raw.@"[method]player-inventory.as-inventory", Inventory, .{abi.borrow(self)}); + } + + /// Returns the item currently held in the specified hand. + pub fn getItemInHand(self: PlayerInventory, hand: Hand) ?ItemStack { + return abi.call(raw.@"[method]player-inventory.get-item-in-hand", ?ItemStack, .{ abi.borrow(self), hand }); + } + + /// Sets the item in the specified hand. + pub fn setItemInHand(self: PlayerInventory, hand: Hand, item: ?ItemStack) void { + return abi.call(raw.@"[method]player-inventory.set-item-in-hand", void, .{ abi.borrow(self), hand, item }); + } + + /// Returns the currently selected hotbar slot index (0-8). + pub fn getSelectedSlot(self: PlayerInventory) u8 { + return abi.call(raw.@"[method]player-inventory.get-selected-slot", u8, .{abi.borrow(self)}); + } + + /// Sets the currently selected hotbar slot index (0-8). + pub fn setSelectedSlot(self: PlayerInventory, slot: u8) void { + return abi.call(raw.@"[method]player-inventory.set-selected-slot", void, .{ abi.borrow(self), slot }); + } + + /// Armor slot accessors + pub fn getHelmet(self: PlayerInventory) ?ItemStack { + return abi.call(raw.@"[method]player-inventory.get-helmet", ?ItemStack, .{abi.borrow(self)}); + } + + pub fn setHelmet(self: PlayerInventory, item: ?ItemStack) void { + return abi.call(raw.@"[method]player-inventory.set-helmet", void, .{ abi.borrow(self), item }); + } + + pub fn getChestplate(self: PlayerInventory) ?ItemStack { + return abi.call(raw.@"[method]player-inventory.get-chestplate", ?ItemStack, .{abi.borrow(self)}); + } + + pub fn setChestplate(self: PlayerInventory, item: ?ItemStack) void { + return abi.call(raw.@"[method]player-inventory.set-chestplate", void, .{ abi.borrow(self), item }); + } + + pub fn getLeggings(self: PlayerInventory) ?ItemStack { + return abi.call(raw.@"[method]player-inventory.get-leggings", ?ItemStack, .{abi.borrow(self)}); + } + + pub fn setLeggings(self: PlayerInventory, item: ?ItemStack) void { + return abi.call(raw.@"[method]player-inventory.set-leggings", void, .{ abi.borrow(self), item }); + } + + pub fn getBoots(self: PlayerInventory) ?ItemStack { + return abi.call(raw.@"[method]player-inventory.get-boots", ?ItemStack, .{abi.borrow(self)}); + } + + pub fn setBoots(self: PlayerInventory, item: ?ItemStack) void { + return abi.call(raw.@"[method]player-inventory.set-boots", void, .{ abi.borrow(self), item }); + } + + pub fn getOffHand(self: PlayerInventory) ?ItemStack { + return abi.call(raw.@"[method]player-inventory.get-off-hand", ?ItemStack, .{abi.borrow(self)}); + } + + pub fn setOffHand(self: PlayerInventory, item: ?ItemStack) void { + return abi.call(raw.@"[method]player-inventory.set-off-hand", void, .{ abi.borrow(self), item }); + } + + /// Clears all armor slots. + pub fn clearArmor(self: PlayerInventory) void { + return abi.call(raw.@"[method]player-inventory.clear-armor", void, .{abi.borrow(self)}); + } + + /// Clears the 36 main inventory slots. + pub fn clearMain(self: PlayerInventory) void { + return abi.call(raw.@"[method]player-inventory.clear-main", void, .{abi.borrow(self)}); + } + + /// Clears all slots (main inventory, armor, offhand). + pub fn clearAll(self: PlayerInventory) void { + return abi.call(raw.@"[method]player-inventory.clear-all", void, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: PlayerInventory) void { + abi.keep(PlayerInventory, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: PlayerInventory) void { + abi.drop(PlayerInventory, self); + } +}; + +const raw = struct { + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]inventory.get-size"(i32) i32; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]inventory.is-empty"(i32) i32; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]inventory.get-item"(i32, i32, i32) void; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]inventory.set-item"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]inventory.remove-item"(i32, i32, i32) void; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]inventory.clear"(i32) void; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]inventory.get-all-items"(i32, i32) void; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]inventory.set-all-items"(i32, i32, i32) void; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]inventory.count-item"(i32, i32, i32) i32; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]inventory.contains-item"(i32, i32, i32) i32; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]player-inventory.as-inventory"(i32) i32; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]player-inventory.get-item-in-hand"(i32, i32, i32) void; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]player-inventory.set-item-in-hand"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]player-inventory.get-selected-slot"(i32) i32; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]player-inventory.set-selected-slot"(i32, i32) void; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]player-inventory.get-helmet"(i32, i32) void; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]player-inventory.set-helmet"(i32, i32, i32) void; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]player-inventory.get-chestplate"(i32, i32) void; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]player-inventory.set-chestplate"(i32, i32, i32) void; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]player-inventory.get-leggings"(i32, i32) void; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]player-inventory.set-leggings"(i32, i32, i32) void; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]player-inventory.get-boots"(i32, i32) void; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]player-inventory.set-boots"(i32, i32, i32) void; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]player-inventory.get-off-hand"(i32, i32) void; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]player-inventory.set-off-hand"(i32, i32, i32) void; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]player-inventory.clear-armor"(i32) void; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]player-inventory.clear-main"(i32) void; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[method]player-inventory.clear-all"(i32) void; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[resource-drop]inventory"(i32) void; + extern "pumpkin:plugin/inventory@0.1.0" fn @"[resource-drop]player-inventory"(i32) void; +}; diff --git a/src/wit/ipc.zig b/src/wit/ipc.zig new file mode 100644 index 0000000..e43096a --- /dev/null +++ b/src/wit/ipc.zig @@ -0,0 +1,16 @@ +// Generated by tools/gen.zig, do not edit. + +const abi = @import("../abi.zig"); + +pub const PluginId = []const u8; + +pub const IpcMessage = []const u8; + +/// Sends a message to the specified plugin, synchronously receiving a response (or an error). +pub fn sendIpcMessage(recipient: PluginId, message: IpcMessage) abi.Result(abi.Result(IpcMessage, []const u8), void) { + return abi.call(raw.@"send-ipc-message", abi.Result(abi.Result(IpcMessage, []const u8), void), .{ recipient, message }); +} + +const raw = struct { + extern "pumpkin:plugin/ipc@0.1.0" fn @"send-ipc-message"(i32, i32, i32, i32, i32) void; +}; diff --git a/src/wit/item_stack.zig b/src/wit/item_stack.zig new file mode 100644 index 0000000..e134e2e --- /dev/null +++ b/src/wit/item_stack.zig @@ -0,0 +1,239 @@ +// Generated by tools/gen.zig, do not edit. + +const abi = @import("../abi.zig"); +const attributes = @import("attributes.zig"); +const data_components = @import("data_components.zig"); +const enchantments = @import("enchantments.zig"); +const text = @import("text.zig"); +const common = @import("common.zig"); + +pub const Attribute = attributes.Attribute; +pub const AttributeModifier = attributes.AttributeModifier; +pub const DataComponent = data_components.DataComponent; +pub const AttributeModifierSlot = enchantments.AttributeModifierSlot; +pub const Enchantment = enchantments.Enchantment; +pub const TextComponent = text.TextComponent; +pub const NbtEntry = common.NbtEntry; +pub const NbtTree = common.NbtTree; +pub const NbtTag = common.NbtTag; + +/// Represents an enchantment and its level. +pub const EnchantmentValue = struct { + enchantment: Enchantment, + level: u32, +}; + +/// Represents a custom enchantment and its level on an item stack. +pub const CustomEnchantmentValue = struct { + enchantment_id: []const u8, + level: u32, +}; + +/// Represents an attribute modifier applied to an item stack for a specific slot. +pub const ItemAttributeModifier = struct { + attribute: Attribute, + modifier: AttributeModifier, + slot: AttributeModifierSlot, +}; + +/// Represents a data component and its serialized value. +pub const DataComponentValue = struct { + component: DataComponent, + /// The serialized value of the component. + value: []const u8, +}; + +pub const ItemStack = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]item-stack"; + + pub fn init(registry_key: []const u8, count: u8) ItemStack { + return abi.call(raw.@"[constructor]item-stack", ItemStack, .{ registry_key, count }); + } + + /// Returns the unique registry key of the item (e.g., "minecraft:diamond"). + pub fn getRegistryKey(self: ItemStack) []const u8 { + return abi.call(raw.@"[method]item-stack.get-registry-key", []const u8, .{abi.borrow(self)}); + } + + /// Returns the number of items in the stack. + pub fn getCount(self: ItemStack) u8 { + return abi.call(raw.@"[method]item-stack.get-count", u8, .{abi.borrow(self)}); + } + + /// Sets the number of items in the stack. + pub fn setCount(self: ItemStack, count: u8) void { + return abi.call(raw.@"[method]item-stack.set-count", void, .{ abi.borrow(self), count }); + } + + /// Returns the maximum number of items that can be in this stack. + pub fn getMaxCount(self: ItemStack) u8 { + return abi.call(raw.@"[method]item-stack.get-max-count", u8, .{abi.borrow(self)}); + } + + /// Returns all enchantments on this item stack. + pub fn getEnchantments(self: ItemStack) []const EnchantmentValue { + return abi.call(raw.@"[method]item-stack.get-enchantments", []const EnchantmentValue, .{abi.borrow(self)}); + } + + /// Adds an enchantment to this item stack. + pub fn addEnchantment(self: ItemStack, enchantment: Enchantment, level: u32) void { + return abi.call(raw.@"[method]item-stack.add-enchantment", void, .{ abi.borrow(self), enchantment, level }); + } + + /// Removes an enchantment from this item stack. + pub fn removeEnchantment(self: ItemStack, enchantment: Enchantment) void { + return abi.call(raw.@"[method]item-stack.remove-enchantment", void, .{ abi.borrow(self), enchantment }); + } + + /// Returns all custom enchantments on this item stack. + pub fn getCustomEnchantments(self: ItemStack) []const CustomEnchantmentValue { + return abi.call(raw.@"[method]item-stack.get-custom-enchantments", []const CustomEnchantmentValue, .{abi.borrow(self)}); + } + + /// Adds a custom enchantment to this item stack. + pub fn addCustomEnchantment(self: ItemStack, enchantment_id: []const u8, level: u32) void { + return abi.call(raw.@"[method]item-stack.add-custom-enchantment", void, .{ abi.borrow(self), enchantment_id, level }); + } + + /// Removes a custom enchantment from this item stack. + pub fn removeCustomEnchantment(self: ItemStack, enchantment_id: []const u8) void { + return abi.call(raw.@"[method]item-stack.remove-custom-enchantment", void, .{ abi.borrow(self), enchantment_id }); + } + + /// Returns the level of a custom enchantment on this item stack, if present. + pub fn getCustomEnchantmentLevel(self: ItemStack, enchantment_id: []const u8) ?u32 { + return abi.call(raw.@"[method]item-stack.get-custom-enchantment-level", ?u32, .{ abi.borrow(self), enchantment_id }); + } + + /// Returns whether this item stack has a specific custom enchantment. + pub fn hasCustomEnchantment(self: ItemStack, enchantment_id: []const u8) bool { + return abi.call(raw.@"[method]item-stack.has-custom-enchantment", bool, .{ abi.borrow(self), enchantment_id }); + } + + /// Returns all attribute modifiers on this item stack. + pub fn getAttributeModifiers(self: ItemStack) []const ItemAttributeModifier { + return abi.call(raw.@"[method]item-stack.get-attribute-modifiers", []const ItemAttributeModifier, .{abi.borrow(self)}); + } + + /// Adds an attribute modifier to this item stack. + pub fn addAttributeModifier(self: ItemStack, modifier: ItemAttributeModifier) void { + return abi.call(raw.@"[method]item-stack.add-attribute-modifier", void, .{ abi.borrow(self), modifier }); + } + + /// Removes all attribute modifiers for a specific attribute from this item stack. + pub fn removeAttributeModifiers(self: ItemStack, attribute: Attribute) void { + return abi.call(raw.@"[method]item-stack.remove-attribute-modifiers", void, .{ abi.borrow(self), attribute }); + } + + /// Clears all custom attribute modifiers from this item stack. + pub fn clearAttributeModifiers(self: ItemStack) void { + return abi.call(raw.@"[method]item-stack.clear-attribute-modifiers", void, .{abi.borrow(self)}); + } + + /// Returns the lore of this item stack. + pub fn getLore(self: ItemStack) []const TextComponent { + return abi.call(raw.@"[method]item-stack.get-lore", []const TextComponent, .{abi.borrow(self)}); + } + + /// Sets the lore of this item stack. + pub fn setLore(self: ItemStack, lore: []const TextComponent) void { + return abi.call(raw.@"[method]item-stack.set-lore", void, .{ abi.borrow(self), lore }); + } + + /// Adds a line to the lore of this item stack. + /// + /// Consumes `line`. + pub fn addLore(self: ItemStack, line: TextComponent) void { + return abi.call(raw.@"[method]item-stack.add-lore", void, .{ abi.borrow(self), line }); + } + + /// Returns the custom name of this item stack, if set. + pub fn getCustomName(self: ItemStack) ?TextComponent { + return abi.call(raw.@"[method]item-stack.get-custom-name", ?TextComponent, .{abi.borrow(self)}); + } + + /// Sets the custom name of this item stack. + pub fn setCustomName(self: ItemStack, name: ?TextComponent) void { + return abi.call(raw.@"[method]item-stack.set-custom-name", void, .{ abi.borrow(self), name }); + } + + /// Sets a namespaced custom data value on this item stack. + pub fn setCustomData(self: ItemStack, namespace: []const u8, key: []const u8, value: NbtTree) void { + return abi.call(raw.@"[method]item-stack.set-custom-data", void, .{ abi.borrow(self), namespace, key, value }); + } + + /// Returns a namespaced custom data value from this item stack, if set. + pub fn getCustomData(self: ItemStack, namespace: []const u8, key: []const u8) ?NbtTree { + return abi.call(raw.@"[method]item-stack.get-custom-data", ?NbtTree, .{ abi.borrow(self), namespace, key }); + } + + /// Removes a namespaced custom data value from this item stack. + pub fn removeCustomData(self: ItemStack, namespace: []const u8, key: []const u8) void { + return abi.call(raw.@"[method]item-stack.remove-custom-data", void, .{ abi.borrow(self), namespace, key }); + } + + /// Returns whether this item stack has a namespaced custom data value. + pub fn hasCustomData(self: ItemStack, namespace: []const u8, key: []const u8) bool { + return abi.call(raw.@"[method]item-stack.has-custom-data", bool, .{ abi.borrow(self), namespace, key }); + } + + /// Returns all data components on this item stack. + pub fn getComponents(self: ItemStack) []const DataComponentValue { + return abi.call(raw.@"[method]item-stack.get-components", []const DataComponentValue, .{abi.borrow(self)}); + } + + /// Sets a data component on this item stack. + pub fn setComponent(self: ItemStack, component: DataComponent, value: []const u8) void { + return abi.call(raw.@"[method]item-stack.set-component", void, .{ abi.borrow(self), component, value }); + } + + /// Removes a data component from this item stack. + pub fn removeComponent(self: ItemStack, component: DataComponent) void { + return abi.call(raw.@"[method]item-stack.remove-component", void, .{ abi.borrow(self), component }); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: ItemStack) void { + abi.keep(ItemStack, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: ItemStack) void { + abi.drop(ItemStack, self); + } +}; + +const raw = struct { + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[constructor]item-stack"(i32, i32, i32) i32; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.get-registry-key"(i32, i32) void; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.get-count"(i32) i32; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.set-count"(i32, i32) void; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.get-max-count"(i32) i32; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.get-enchantments"(i32, i32) void; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.add-enchantment"(i32, i32, i32) void; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.remove-enchantment"(i32, i32) void; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.get-custom-enchantments"(i32, i32) void; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.add-custom-enchantment"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.remove-custom-enchantment"(i32, i32, i32) void; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.get-custom-enchantment-level"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.has-custom-enchantment"(i32, i32, i32) i32; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.get-attribute-modifiers"(i32, i32) void; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.add-attribute-modifier"(i32, i32, i32, i32, f64, i32, i32) void; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.remove-attribute-modifiers"(i32, i32) void; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.clear-attribute-modifiers"(i32) void; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.get-lore"(i32, i32) void; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.set-lore"(i32, i32, i32) void; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.add-lore"(i32, i32) void; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.get-custom-name"(i32, i32) void; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.set-custom-name"(i32, i32, i32) void; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.set-custom-data"(i32, i32, i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.get-custom-data"(i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.remove-custom-data"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.has-custom-data"(i32, i32, i32, i32, i32) i32; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.get-components"(i32, i32) void; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.set-component"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[method]item-stack.remove-component"(i32, i32) void; + extern "pumpkin:plugin/item-stack@0.1.0" fn @"[resource-drop]item-stack"(i32) void; +}; diff --git a/src/wit/java_dialogs.zig b/src/wit/java_dialogs.zig new file mode 100644 index 0000000..48cf109 --- /dev/null +++ b/src/wit/java_dialogs.zig @@ -0,0 +1,155 @@ +// Generated by tools/gen.zig, do not edit. + +const text = @import("text.zig"); +const item_stack = @import("item_stack.zig"); + +pub const TextComponent = text.TextComponent; +pub const ItemStack = item_stack.ItemStack; + +/// Represents the layout and button configuration of a dialog. +pub const DialogType = enum(u8) { + /// A simple dialog with a single "OK" button. + notice, + /// A dialog with "Yes" and "No" buttons. + confirmation, + /// A scrollable list of custom buttons. + multi_action, + /// A list of buttons that open other registered dialogs. + dialog_list, + /// A dedicated menu for displaying server-related links. + server_links, +}; + +/// Represents an element in the main content area of a dialog. +pub const DialogBody = union(enum) { + /// A simple text message. + plain_message: TextComponent, + /// A visual item display. + item: ItemStack, +}; + +/// A checkbox input control. +pub const DialogInputBool = struct { + label: TextComponent, + default_value: bool, +}; + +/// A text field input control. +pub const DialogInputText = struct { + label: TextComponent, + placeholder: TextComponent, + default_value: []const u8, +}; + +/// A numerical range slider input control. +pub const DialogInputNumberRange = struct { + label: TextComponent, + min_value: f32, + max_value: f32, + initial_value: f32, + step: f32, + label_format: ?[]const u8, +}; + +/// A multiple-choice selection input control. +pub const DialogInputSingleOption = struct { + label: TextComponent, + options: []const TextComponent, + initial_index: u32, +}; + +/// Represents an interactive input control in a dialog. +pub const DialogInput = union(enum) { + /// A checkbox for true/false states. + bool: DialogInputBool, + /// A simple string input field. + text: DialogInputText, + /// A slider for numerical input within a range. + number_range: DialogInputNumberRange, + /// A multiple-choice selection button. + single_option: DialogInputSingleOption, +}; + +/// Defines what happens after a dialog is closed. +pub const AfterAction = enum(u8) { + /// Returns the player to the previous screen (e.g., keeping an inventory open). + peek, + /// Closes all open screens. + pop, +}; + +/// Represents a custom server-side action. +pub const CustomClickAction = struct { + /// A unique identifier for the action (sent back to the server). + id: []const u8, + /// Optional binary data to send with the action. + payload: ?[]const u8, +}; + +/// Represents an action triggered by a button click. +pub const Action = union(enum) { + /// Opens an external URL. + open_url: []const u8, + /// Triggers a custom server-side callback with an ID and optional payload. + custom_click: CustomClickAction, +}; + +/// Represents a clickable button in a dialog. +pub const ActionButton = struct { + text: TextComponent, + tooltip: ?TextComponent, + width: ?u32, + action: Action, +}; + +/// Built-in link types recognized by the Java Edition client. +pub const LinkType = enum(u8) { + bug_report, + community_guidelines, + support, + status, + feedback, + community, + website, + forums, + news, + announcements, +}; + +/// The label for a link, which can be a built-in type or custom text. +pub const LinkLabel = union(enum) { + /// A built-in link type with a predefined icon/label. + built_in: LinkType, + /// A custom text component label. + custom: TextComponent, +}; + +/// Represents a link displayed in a Java Edition dialog. +pub const Link = struct { + /// The label to display for the link. + label: LinkLabel, + /// The URL the link points to. + url: []const u8, +}; + +/// Represents a dialog shown to a Java Edition player. +pub const Dialog = struct { + /// The main title of the dialog. + title: TextComponent, + /// The layout type of the dialog. + type: DialogType, + /// A list of body elements to display in the main area. + body: []const DialogBody, + /// A list of interactive input controls. + inputs: []const DialogInput, + /// A list of clickable buttons (for multi-action and other types). + buttons: []const ActionButton, + /// A list of links (primarily for server-links type). + links: []const Link, + /// What to do after the dialog is closed. + after_action: ?AfterAction, + /// Whether the player can exit the dialog using the Esc key. + can_close_with_escape: bool, + /// The text shown on buttons that link to/open this dialog. + external_title: ?TextComponent, +}; diff --git a/src/wit/java_packets.zig b/src/wit/java_packets.zig new file mode 100644 index 0000000..e2725f9 --- /dev/null +++ b/src/wit/java_packets.zig @@ -0,0 +1,2145 @@ +// Generated by tools/gen.zig, do not edit. + +const uuid = @import("uuid.zig"); + +pub const Uuid = uuid.Uuid; + +pub const ConfigSClientInformationConfig = struct { + locale: []const u8, + view_distance: u8, + chat_mode: i32, + chat_colors: bool, + skin_parts: u8, + main_hand: i32, + text_filtering: bool, + server_listing: bool, +}; + +pub const ConfigSConfigCookieResponse = struct { + key: []const u8, + has_payload: bool, + payload: ?[]const u8, +}; + +pub const ConfigSCustomClickAction = struct { + action_id: []const u8, + payload: ?[]const u8, +}; + +pub const ConfigSKeepAlive = struct { + keep_alive_id: i64, +}; + +pub const ConfigSKnownPacks = struct { + known_packs: []const []const u8, +}; + +pub const ConfigSPluginMessage = struct { + channel: []const u8, + data: []const u8, +}; + +pub const ConfigSConfigPong = struct { + id: i32, +}; + +pub const ResourcePackResponseResult = union(enum) { + download_success, + download_fail, + downloaded, + accepted, + declined, + invalid_url, + reload_failed, + discarded, + unknown: i32, +}; + +pub const ConfigSConfigResourcePack = struct { + uuid: Uuid, + result: i32, +}; + +pub const LoginSLoginCookieResponse = struct { + key: []const u8, + payload: ?[]const u8, +}; + +pub const SEncryptionResponse = struct { + shared_secret: []const u8, + verify_token: []const u8, +}; + +pub const LoginSLoginStart = struct { + name: []const u8, + uuid: Uuid, +}; + +pub const LoginSLoginPluginResponse = struct { + message_id: i32, + data: ?[]const u8, +}; + +pub const SAttack = struct { + entity_id: i32, +}; + +pub const SBlockEntityTagQuery = struct { + transaction_id: i32, + location: struct { i32, i32, i32 }, +}; + +pub const SBundleItemSelected = struct { + slot_id: i32, + selected_item_index: i32, +}; + +pub const SChangeDifficulty = struct { + difficulty: []const u8, +}; + +pub const SChangeGameMode = struct { + game_mode: []const u8, +}; + +pub const SChatAck = struct { + offset: i32, +}; + +pub const SChatCommand = struct { + command: []const u8, +}; + +pub const ArgumentSignature = struct { + name: []const u8, + signature: []const u8, +}; + +pub const SChatCommandSigned = struct { + command: []const u8, + timestamp: i64, + salt: i64, + argument_signatures: []const ArgumentSignature, + message_count: i32, + acknowledged: []const u8, + checksum: u8, +}; + +pub const SChatMessage = struct { + message: []const u8, + timestamp: i64, + salt: i64, + signature: ?[]const u8, + message_count: i32, + acknowledged: []const u8, + checksum: u8, +}; + +pub const SChunkBatch = struct { + chunks_per_tick: f32, +}; + +pub const SlotActionType = enum(u8) { + pickup, + quick_move, + swap, + clone, + throw, + quick_craft, + pickup_all, +}; + +pub const SClickSlot = struct { + sync_id: i32, + revision: i32, + slot: i32, + button: u8, + mode: SlotActionType, + length_of_array: i32, + array_of_changed_slots: []const struct { i32, []const u8 }, + carried_item: []const u8, +}; + +pub const SClientCommand = struct { + action_id: i32, +}; + +pub const SClientInformationPlay = struct { + locale: []const u8, + view_distance: u8, + chat_mode: i32, + chat_colors: bool, + skin_parts: u8, + main_hand: i32, + text_filtering: bool, + server_listing: bool, +}; + +pub const SCloseContainer = struct { + window_id: i32, +}; + +pub const SCommandSuggestion = struct { + id: i32, + command: []const u8, +}; + +pub const SConfirmTeleport = struct { + teleport_id: i32, +}; + +pub const SContainerButtonClick = struct { + window_id: i32, + button_id: i32, +}; + +pub const SContainerSlotStateChanged = struct { + slot_id: i32, + container_id: i32, + new_state: bool, +}; + +pub const SCookieResponse = struct { + key: []const u8, + payload: ?[]const u8, +}; + +pub const SCustomClickAction = struct { + action_id: []const u8, + payload: ?[]const u8, +}; + +pub const SCustomPayload = struct { + channel: []const u8, + data: []const u8, +}; + +pub const SDebugSampleSubscription = struct { + sample_type: i32, +}; + +pub const SDebugSubscriptionRequest = struct { + sample_type: i32, +}; + +pub const SEditBook = struct { + slot: i32, + pages: []const []const u8, + title: ?[]const u8, +}; + +pub const SEntityTagQuery = struct { + transaction_id: i32, + entity_id: i32, +}; + +pub const SInteract = struct { + entity_id: i32, + r_type: i32, + target_position: ?struct { f64, f64, f64 }, + hand: ?i32, + sneaking: bool, +}; + +pub const ActionType = enum(u8) { + interact, + attack, + interact_at, +}; + +pub const SJigsawGenerate = struct { + pos: struct { i32, i32, i32 }, + levels: i32, + keep_jigsaws: bool, +}; + +pub const SKeepAlive = struct { + keep_alive_id: i64, +}; + +pub const SLockDifficulty = struct { + locked: bool, +}; + +pub const SMoveVehicle = struct { + x: f64, + y: f64, + z: f64, + yaw: f32, + pitch: f32, + on_ground: bool, +}; + +pub const SPaddleBoat = struct { + left_paddle: bool, + right_paddle: bool, +}; + +pub const SPickItemFromBlock = struct { + pos: struct { i32, i32, i32 }, + include_data: bool, +}; + +pub const SPickItemFromEntity = struct { + id: i32, + include_data: bool, +}; + +pub const SPlayPingRequest = struct { + payload: i64, +}; + +pub const SPlaceRecipe = struct { + container_id: u8, + recipe_display_id: i32, + use_max_items: bool, +}; + +pub const SPlayerAbilities = struct { + flags: u8, + fly_speed: ?f32, + walk_speed: ?f32, +}; + +pub const SPlayerAction = struct { + status: i32, + position: struct { i32, i32, i32 }, + face: u8, + sequence: i32, +}; + +pub const Status = enum(u8) { + started_digging, + cancelled_digging, + finished_digging, + drop_item_stack, + drop_item, + release_item_in_use, + swap_item, + spear_jab, +}; + +pub const Action = enum(u8) { + start_sneaking, + stop_sneaking, + leave_bed, + start_sprinting, + stop_sprinting, + start_horse_jump, + stop_horse_jump, + open_vehicle_inventory, + start_flying_elytra, +}; + +pub const SPlayerCommand = struct { + entity_id: i32, + action: Action, + jump_boost: i32, +}; + +pub const SSetPlayerGround = struct { + on_ground: bool, +}; + +pub const SPlayerInput = struct { + input: u8, +}; + +pub const SPlayerPosition = struct { + position: struct { f64, f64, f64 }, + collision: u8, +}; + +pub const SPlayerPositionRotation = struct { + position: struct { f64, f64, f64 }, + yaw: f32, + pitch: f32, + collision: u8, +}; + +pub const SPlayerRotation = struct { + yaw: f32, + pitch: f32, + ground: bool, +}; + +pub const SPlayerSession = struct { + session_id: Uuid, + expires_at: i64, + public_key: []const u8, + key_signature: []const u8, +}; + +pub const SPlayPong = struct { + id: i32, +}; + +pub const SRecipeBookChangeSettings = struct { + book_type: i32, + is_open: bool, + is_filtering: bool, +}; + +pub const SRecipeBookSeenRecipe = struct { + recipe_display_id: i32, +}; + +pub const SRenameItem = struct { + item_name: []const u8, +}; + +pub const PlayResourcePackResult = union(enum) { + download_success, + declined, + download_fail, + accepted, + downloaded, + invalid_url, + reload_failed, + discarded, + unknown: i32, +}; + +pub const SPlayResourcePack = struct { + uuid: Uuid, + result: i32, +}; + +pub const SSeenAdvancement = union(enum) { + open_tab: []const u8, + close_tab, +}; + +pub const SSelectTrade = struct { + selected_slot: i32, +}; + +pub const SSetBeacon = struct { + primary_effect: ?i32, + secondary_effect: ?i32, +}; + +pub const SSetCommandBlock = struct { + pos: struct { i32, i32, i32 }, + command: []const u8, + mode: i32, + flags: u8, +}; + +pub const CommandBlockMode = enum(u8) { + chain, + repeating, + impulse, +}; + +pub const SSetCommandMinecart = struct { + entity_id: i32, + command: []const u8, + track_output: bool, +}; + +pub const SSetCreativeSlot = struct { + slot: i32, + clicked_item: []const u8, +}; + +pub const GameRuleEntry = struct { + game_rule_key: []const u8, + value: []const u8, +}; + +pub const SSetGameRule = struct { + entries: []const GameRuleEntry, +}; + +pub const SSetHeldItem = struct { + slot: i32, +}; + +pub const SSetJigsawBlock = struct { + pos: struct { i32, i32, i32 }, + name: []const u8, + target: []const u8, + pool: []const u8, + final_state: []const u8, + joint: []const u8, + selection_priority: i32, + placement_priority: i32, +}; + +pub const SSetStructureBlock = struct { + location: struct { i32, i32, i32 }, + action: i32, + mode: i32, + name: []const u8, + offset_x: u8, + offset_y: u8, + offset_z: u8, + size_x: u8, + size_y: u8, + size_z: u8, + mirror: i32, + rotation: i32, + metadata: []const u8, + integrity: f32, + seed: i64, + flags: u8, +}; + +pub const TestBlockMode = enum(u8) { + start, + log, + fail, + accept, +}; + +pub const SSetTestBlock = struct { + position: struct { i32, i32, i32 }, + mode: TestBlockMode, + message: []const u8, +}; + +pub const SSpectateEntity = struct { + target: Uuid, +}; + +pub const SSwingArm = struct { + hand: i32, +}; + +pub const STeleportToEntity = struct { + target: Uuid, +}; + +pub const TestInstanceBlockAction = enum(u8) { + init, + query, + set, + reset, + save, + @"export", + run, +}; + +pub const VarIntVector3 = struct { + x: i32, + y: i32, + z: i32, +}; + +pub const TestInstanceBlockStatus = enum(u8) { + cleared, + running, + success, + failed, +}; + +pub const TestInstanceBlockData = struct { + @"test": ?[]const u8, + size: VarIntVector3, + rotation: []const u8, + ignore_entities: bool, + status: TestInstanceBlockStatus, + error_message: ?[]const u8, +}; + +pub const STestInstanceBlockAction = struct { + pos: struct { i32, i32, i32 }, + action: TestInstanceBlockAction, + data: TestInstanceBlockData, +}; + +pub const SUpdateSign = struct { + location: struct { i32, i32, i32 }, + is_front_text: bool, + line_1: []const u8, + line_2: []const u8, + line_3: []const u8, + line_4: []const u8, +}; + +pub const SUseItem = struct { + hand: i32, + sequence: i32, + yaw: f32, + pitch: f32, +}; + +pub const SUseItemOn = struct { + hand: i32, + position: struct { i32, i32, i32 }, + face: i32, + cursor_pos: struct { f64, f64, f64 }, + inside_block: bool, + is_against_world_border: bool, + sequence: i32, +}; + +pub const StatusSStatusPingRequest = struct { + payload: i64, +}; + +pub const ConfigCConfigAddResourcePack = struct { + uuid: Uuid, + url: []const u8, + hash: []const u8, + forced: bool, + prompt_message: ?[]const u8, +}; + +pub const ConfigCCodeOfConduct = struct { + code_of_conduct: []const u8, +}; + +pub const ConfigCConfigDisconnect = struct { + reason: []const u8, +}; + +pub const ConfigCCookieRequest = struct { + key: []const u8, +}; + +pub const ConfigCConfigCustomReportDetails = struct { + details: []const struct { []const u8, []const u8 }, +}; + +pub const ConfigCFeatureFlags = struct { + features: []const []const u8, +}; + +pub const ConfigCKnownPacks = struct { + known_packs: []const []const u8, +}; + +pub const ConfigCConfigPing = struct { + id: i32, +}; + +pub const ConfigCPluginMessage = struct { + channel: []const u8, + data: []const u8, +}; + +pub const ConfigCRegistryData = struct { + registry_id: []const u8, + entries: []const []const u8, +}; + +pub const ConfigCConfigRemoveResourcePack = struct { + uuid: ?Uuid, +}; + +pub const ConfigCConfigServerLinks = struct { + links: []const []const u8, +}; + +pub const ConfigCConfigShowDialog = struct { + dialog: []const u8, +}; + +pub const ConfigCStoreCookie = struct { + key: []const u8, + payload: []const u8, +}; + +pub const ConfigCTransfer = struct { + host: []const u8, + port: i32, +}; + +pub const ConfigCUpdateTags = struct { + tags: []const []const u8, +}; + +pub const LoginCLoginCookieRequest = struct { + key: []const u8, +}; + +pub const CEncryptionRequest = struct { + server_id: []const u8, + public_key: []const u8, + verify_token: []const u8, + should_authenticate: bool, +}; + +pub const LoginCLoginDisconnect = struct { + json_reason: []const u8, +}; + +pub const LoginCLoginPluginRequest = struct { + message_id: i32, + channel: []const u8, + data: []const u8, +}; + +pub const LoginCSetCompression = struct { + threshold: i32, +}; + +pub const CAcknowledgeBlockChange = struct { + sequence_id: i32, +}; + +pub const CActionBar = struct { + action_bar: []const u8, +}; + +pub const CAddResourcePack = struct { + uuid: Uuid, + url: []const u8, + hash: []const u8, + forced: bool, + prompt_message: ?[]const u8, +}; + +pub const Statistic = struct { + category_id: i32, + statistic_id: i32, + value: i32, +}; + +pub const CAwardStats = struct { + stats: []const Statistic, +}; + +pub const CSetBlockDestroyStage = struct { + entity_id: i32, + location: struct { i32, i32, i32 }, + destroy_stage: u8, +}; + +pub const CBlockEntityData = struct { + location: struct { i32, i32, i32 }, + r_type: i32, + nbt_data: []const u8, +}; + +pub const CBlockEvent = struct { + location: struct { i32, i32, i32 }, + action_id: u8, + action_parameter: u8, + block_type: i32, +}; + +pub const CBlockUpdate = struct { + location: struct { i32, i32, i32 }, + state_id: i32, +}; + +pub const BosseventActionAdd = struct { + title: []const u8, + health: f32, + color: i32, + division: i32, + flags: u8, +}; + +pub const BosseventActionUpdateStyle = struct { + color: i32, + dividers: i32, +}; + +pub const BosseventAction = union(enum) { + add: BosseventActionAdd, + remove, + update_health: f32, + update_tile: []const u8, + update_style: BosseventActionUpdateStyle, + update_flags: u8, +}; + +pub const CBossEvent = struct { + uuid: Uuid, + action: BosseventAction, +}; + +pub const CCenterChunk = struct { + chunk_x: i32, + chunk_z: i32, +}; + +pub const CChangeDifficulty = struct { + difficulty: u8, + locked: bool, +}; + +pub const CChunkBatchEnd = struct { + batch_size: i32, +}; + +pub const ChunkBiomeEntry = struct { + chunk_x: i32, + chunk_z: i32, + data: []const u8, +}; + +pub const CChunksBiomes = struct { + chunks: []const ChunkBiomeEntry, +}; + +pub const CClearTitle = struct { + reset: bool, +}; + +pub const CCloseContainer = struct { + sync_id: i32, +}; + +pub const CCombatDeath = struct { + player_id: i32, + message: []const u8, +}; + +pub const CCombatEnd = struct { + duration_ticks: i32, +}; + +pub const CommandSuggestion = struct { + suggestion: []const u8, + tooltip: ?[]const u8, +}; + +pub const CCommandSuggestions = struct { + id: i32, + start: i32, + length: i32, + matches: []const CommandSuggestion, +}; + +pub const ProtoNodeTypeLiteral = struct { + name: []const u8, + is_executable: bool, + redirect_target: ?i32, + restricted: bool, +}; + +pub const ArgumentTypeFloat = struct { + min: ?f32, + max: ?f32, +}; + +pub const ArgumentTypeDouble = struct { + min: ?f64, + max: ?f64, +}; + +pub const ArgumentTypeInteger = struct { + min: ?i32, + max: ?i32, +}; + +pub const ArgumentTypeLong = struct { + min: ?i64, + max: ?i64, +}; + +pub const ArgumentTypeEntity = struct { + flags: u8, +}; + +pub const ArgumentTypeScoreHolder = struct { + flags: u8, +}; + +pub const ArgumentTypeTime = struct { + min: i32, +}; + +pub const ArgumentTypeResourceOrTag = struct { + identifier: []const u8, +}; + +pub const ArgumentTypeResourceOrTagKey = struct { + identifier: []const u8, +}; + +pub const ArgumentTypeResource = struct { + identifier: []const u8, +}; + +pub const ArgumentTypeResourceKey = struct { + identifier: []const u8, +}; + +pub const StringProtoArgBehavior = enum(u8) { + single_word, + quotable_phrase, + greedy_phrase, +}; + +pub const ArgumentType = union(enum) { + bool, + float: ArgumentTypeFloat, + double: ArgumentTypeDouble, + integer: ArgumentTypeInteger, + long: ArgumentTypeLong, + string: StringProtoArgBehavior, + entity: ArgumentTypeEntity, + game_profile, + block_pos, + column_pos, + vec3, + vec2, + block_state, + block_predicate, + item_stack, + item_predicate, + color, + hex_color, + component, + style, + message, + nbt_compound, + nbt_tag, + nbt_path, + objective, + objective_criteria, + operation, + particle, + angle, + rotation, + scoreboard_slot, + score_holder: ArgumentTypeScoreHolder, + swizzle, + team, + item_slot, + item_slots, + resource_location, + function, + entity_anchor, + int_range, + float_range, + dimension, + gamemode, + time: ArgumentTypeTime, + resource_or_tag: ArgumentTypeResourceOrTag, + resource_or_tag_key: ArgumentTypeResourceOrTagKey, + resource: ArgumentTypeResource, + resource_key: ArgumentTypeResourceKey, + resource_selector, + template_mirror, + template_rotation, + heightmap, + loot_table, + loot_predicate, + loot_modifier, + dialog, + uuid, +}; + +pub const SuggestionProviders = enum(u8) { + ask_server, + all_recipes, + available_sounds, + summonable_entities, +}; + +pub const ProtoNodeTypeArgument = struct { + name: []const u8, + is_executable: bool, + redirect_target: ?i32, + parser: ArgumentType, + override_suggestion_type: ?SuggestionProviders, + restricted: bool, +}; + +pub const ProtoNodeType = union(enum) { + root, + literal: ProtoNodeTypeLiteral, + argument: ProtoNodeTypeArgument, +}; + +pub const ProtoNode = struct { + children: []const i32, + node_type: ProtoNodeType, +}; + +pub const CCommands = struct { + nodes: []const ProtoNode, + root_node_index: i32, +}; + +pub const CPlayCookieRequest = struct { + key: []const u8, +}; + +pub const CCustomChatCompletions = struct { + action: i32, + entries: []const []const u8, +}; + +pub const CCustomPayload = struct { + channel: []const u8, + data: []const u8, +}; + +pub const CPlayCustomReportDetails = struct { + details: []const struct { []const u8, []const u8 }, +}; + +pub const CDamageEvent = struct { + entity_id: i32, + source_type_id: i32, + source_cause_id: i32, + source_direct_id: i32, + source_position: ?struct { f64, f64, f64 }, +}; + +pub const CDebugBlockValue = struct { + pos: struct { i32, i32, i32 }, + name: []const u8, + value: []const u8, +}; + +pub const CDebugChunkValue = struct { + chunk_pos: struct { f64, f64 }, + name: []const u8, + value: []const u8, +}; + +pub const CDebugEntityValue = struct { + entity_id: i32, + name: []const u8, + value: []const u8, +}; + +pub const CDebugEvent = struct { + name: []const u8, + data: []const u8, +}; + +pub const CDebugSample = struct { + sample: []const i64, + sample_type: i32, +}; + +pub const CDeleteChat = struct { + signature_id: i32, + signature: ?[]const u8, +}; + +pub const CPlayDisconnect = struct { + reason: []const u8, +}; + +pub const CDisguisedChatMessage = struct { + message: []const u8, + chat_type: i32, + sender_name: []const u8, + target_name: ?[]const u8, +}; + +pub const CDisplayObjective = struct { + position: i32, + score_name: []const u8, +}; + +pub const CEntityAnimation = struct { + entity_id: i32, + animation: u8, +}; + +pub const Animation = enum(u8) { + swing_main_arm, + leave_bed, + swing_offhand, + critical_effect, + magic_criticaleffect, +}; + +pub const CSetEntityMetadata = struct { + entity_id: i32, + metadata: []const u8, +}; + +pub const CEntityPositionSync = struct { + entity_id: i32, + position: struct { f64, f64, f64 }, + delta: struct { f64, f64, f64 }, + yaw: f32, + pitch: f32, + on_ground: bool, +}; + +pub const CEntitySoundEffect = struct { + sound_event: []const u8, + sound_category: i32, + entity_id: i32, + volume: f32, + pitch: f32, + seed: i64, +}; + +pub const CEntityStatus = struct { + entity_id: i32, + entity_status: u8, +}; + +pub const CEntityVelocity = struct { + entity_id: i32, + velocity: []const u8, +}; + +pub const CExplosion = struct { + center: struct { f64, f64, f64 }, + radius: f32, + block_count: i32, + knockback: ?struct { f64, f64, f64 }, + particle: i32, + sound: []const u8, + block_particles_pool_size: i32, +}; + +pub const CGameEvent = struct { + event: u8, + value: f32, +}; + +pub const GameEvent = enum(u8) { + no_respawn_block_available, + begin_raining, + end_raining, + change_game_mode, + win_game, + demo_event, + arrow_hit_player, + rain_level_change, + thunder_level_change, + play_pufferfish_string_sound, + play_elder_guardian_mob_appearance, + enabled_respawn_screen, + limited_crafting, + start_waiting_chunks, +}; + +pub const CGameRuleValues = struct { + rules: []const struct { []const u8, []const u8 }, +}; + +pub const CGameTestHighlightPos = struct { + pos: struct { i32, i32, i32 }, + color: i32, + label: []const u8, + duration_ms: i32, +}; + +pub const CHeadRot = struct { + entity_id: i32, + head_yaw: u8, +}; + +pub const CHurtAnimation = struct { + entity_id: i32, + yaw: f32, +}; + +pub const CInitializeWorldBorder = struct { + x: f64, + z: f64, + old_diameter: f64, + new_diameter: f64, + speed: i64, + portal_teleport_boundary: i32, + warning_blocks: i32, + warning_time: i32, +}; + +pub const CItemCooldown = struct { + group: []const u8, + cooldown: i32, +}; + +pub const CKeepAlive = struct { + keep_alive_id: i64, +}; + +pub const CLevelEvent = struct { + event: i32, + location: struct { i32, i32, i32 }, + data: i32, + disable_relative_volume: bool, +}; + +pub const LightData = struct { + trust_edges: bool, + sky_light_mask: []const i64, + block_light_mask: []const i64, + empty_sky_light_mask: []const i64, + empty_block_light_mask: []const i64, + sky_light_arrays: []const []const u8, + block_light_arrays: []const []const u8, +}; + +pub const CLightUpdate = struct { + chunk_x: i32, + chunk_z: i32, + light_data: LightData, +}; + +pub const MapIcon = struct { + icon_type: i32, + x: u8, + z: u8, + direction: u8, + display_name: ?[]const u8, +}; + +pub const MapPatch = struct { + columns: u8, + rows: u8, + x: u8, + z: u8, + data: []const u8, +}; + +pub const CMapItemData = struct { + map_id: i32, + scale: u8, + tracking_position: bool, + locked: bool, + icons: ?[]const MapIcon, + data: ?MapPatch, +}; + +pub const MerchantOffer = struct { + base_cost_a: []const u8, + output: []const u8, + cost_b: ?[]const u8, + reward_exp: bool, + uses: i32, + max_uses: i32, + xp: i32, + special_price: i32, + price_multiplier: f32, + demand: i32, +}; + +pub const CMerchantOffers = struct { + window_id: i32, + offers: []const MerchantOffer, + villager_level: i32, + experience: i32, + is_regular_villager: bool, + can_restock: bool, +}; + +pub const MinecartStep = struct { + position: struct { f64, f64, f64 }, + movement: struct { f64, f64, f64 }, + yaw: f32, + pitch: f32, + weight: f32, +}; + +pub const CMoveMinecartAlongTrack = struct { + entity_id: i32, + steps: []const MinecartStep, +}; + +pub const CMoveVehicle = struct { + x: f64, + y: f64, + z: f64, + yaw: f32, + pitch: f32, +}; + +pub const CMultiBlockUpdate = struct { + chunk_section: struct { f64, f64, f64 }, + suppress_light_updates: bool, + updates: []const struct { struct { i32, i32, i32 }, []const u8 }, +}; + +pub const COpenBook = struct { + hand: i32, +}; + +pub const COpenMountScreen = struct { + window_id: u8, + slot_count: i32, + entity_id: i32, +}; + +pub const COpenScreen = struct { + sync_id: i32, + window_type: i32, + window_title: []const u8, +}; + +pub const COpenSignEditor = struct { + location: struct { i32, i32, i32 }, + is_front_text: bool, +}; + +pub const CParticle = struct { + force_spawn: bool, + important: bool, + position: struct { f64, f64, f64 }, + offset: struct { f64, f64, f64 }, + max_speed: f32, + particle_count: i32, + particle_id: i32, + data: []const u8, +}; + +pub const CPlayPing = struct { + id: i32, +}; + +pub const CPingResponse = struct { + payload: i64, +}; + +pub const CPlaceGhostRecipe = struct { + window_id: u8, + recipe_id: []const u8, +}; + +pub const CPlayerAbilities = struct { + flags: u8, + flying_speed: f32, + field_of_view: f32, +}; + +pub const InitChat = struct { + session_id: Uuid, + expires_at: i64, + public_key: []const u8, + signature: []const u8, +}; + +pub const PreviousMessage = struct { + id: i32, + signature: ?[]const u8, +}; + +pub const FilterType = union(enum) { + pass_through, + fully_filtered, + partially_filtered: []const i64, +}; + +pub const CPlayerChatMessage = struct { + global_index: i32, + sender: Uuid, + index: i32, + message_signature: ?[]const u8, + message: []const u8, + timestamp: i64, + salt: i64, + previous_messages: []const PreviousMessage, + unsigned_content: ?[]const u8, + filter_type: FilterType, + chat_type: i32, + sender_name: []const u8, + target_name: ?[]const u8, +}; + +pub const CPlayerLookAt = struct { + from_anchor: i32, + target_x: f64, + target_y: f64, + target_z: f64, + entity: ?struct { i32, i32 }, +}; + +pub const CPlayerPosition = struct { + teleport_id: i32, + position: struct { f64, f64, f64 }, + delta: struct { f64, f64, f64 }, + yaw: f32, + pitch: f32, + relatives: []const []const u8, +}; + +pub const CRemovePlayerInfo = struct { + players: []const Uuid, +}; + +pub const CPlayerRotation = struct { + yaw: f32, + pitch: f32, +}; + +pub const PlayerSpawnData = struct { + dimension: []const u8, + hashed_seed: i64, + game_mode: u8, + previous_gamemode: u8, + debug: bool, + is_flat: bool, + death_dimension_name: ?struct { []const u8, struct { i32, i32, i32 } }, + portal_cooldown: i32, + sealevel: i32, +}; + +pub const CLogin = struct { + entity_id: i32, + is_hardcore: bool, + dimension_names: []const []const u8, + max_players: i32, + view_distance: i32, + simulated_distance: i32, + reduced_debug_info: bool, + enabled_respawn_screen: bool, + limited_crafting: bool, + spawn_data: PlayerSpawnData, + online_mode: bool, + enforce_secure_chat: bool, +}; + +pub const CPlayerSpawnPosition = struct { + dimension_name: []const u8, + location: struct { i32, i32, i32 }, + yaw: f32, + pitch: f32, +}; + +pub const CProjectilePower = struct { + entity_id: i32, + x_power: f64, + y_power: f64, + z_power: f64, +}; + +pub const CRecipeBookAdd = struct { + replace: bool, +}; + +pub const CRecipeBookRemove = struct { + recipes: []const i32, +}; + +pub const CRecipeBookSettings = struct { + crafting_open: bool, + crafting_filtering: bool, + furnace_open: bool, + furnace_filtering: bool, + blast_furnace_open: bool, + blast_furnace_filtering: bool, + smoker_open: bool, + smoker_filtering: bool, +}; + +pub const CRemoveEntities = struct { + entity_ids: []const i32, +}; + +pub const CRemoveMobEffect = struct { + entity_id: i32, + effect_id: i32, +}; + +pub const CRemoveResourcePack = struct { + uuid: ?Uuid, +}; + +pub const CResetScore = struct { + entity_name: []const u8, + objective_name: ?[]const u8, +}; + +pub const CRespawn = struct { + player_spawn_info: PlayerSpawnData, + data_kept: u8, +}; + +pub const CSelectAdvancementsTab = struct { + tab_id: ?[]const u8, +}; + +pub const CServerData = struct { + motd: []const u8, + icon_base64: ?[]const u8, +}; + +pub const CPlayServerLinks = struct { + links: []const []const u8, +}; + +pub const CSetBorderCenter = struct { + x: f64, + z: f64, +}; + +pub const CSetBorderLerpSize = struct { + old_diameter: f64, + new_diameter: f64, + speed: i64, +}; + +pub const CSetBorderSize = struct { + diameter: f64, +}; + +pub const CSetBorderWarningDelay = struct { + warning_time: i32, +}; + +pub const CSetBorderWarningDistance = struct { + warning_blocks: i32, +}; + +pub const CSetCamera = struct { + camera_id: i32, +}; + +pub const CSetChunkCacheRadius = struct { + radius: i32, +}; + +pub const CSetContainerContent = struct { + window_id: i32, + state_id: i32, + slot_data: []const []const u8, + carried_item: []const u8, +}; + +pub const CSetContainerProperty = struct { + window_id: i32, + property: i32, + value: i32, +}; + +pub const CSetContainerSlot = struct { + window_id: u8, + state_id: i32, + slot: i32, + slot_data: []const u8, +}; + +pub const CSetCursorItem = struct { + stack: []const u8, +}; + +pub const CSetEntityLink = struct { + attached_entity_id: i32, + holding_entity_id: i32, + leash: bool, +}; + +pub const CSetEquipment = struct { + entity_id: i32, + equipment: []const struct { u8, []const u8 }, +}; + +pub const CSetExperience = struct { + progress: f32, + level: i32, + total_experience: i32, +}; + +pub const CSetHealth = struct { + health: f32, + food: i32, + food_saturation: f32, +}; + +pub const CSetSelectedSlot = struct { + slot: u8, +}; + +pub const CSetPassengers = struct { + entity_id: i32, + passengers: []const i32, +}; + +pub const CSetPlayerInventory = struct { + slot: i32, + item: []const u8, +}; + +pub const TeamMethod = enum(u8) { + create, + remove, + update, + add_players, + remove_players, +}; + +pub const TeamParameters = struct { + display_name: []const u8, + options: u8, + nametag_visibility: []const u8, + collision_rule: []const u8, + color: i32, + player_prefix: []const u8, + player_suffix: []const u8, +}; + +pub const CSetPlayerTeam = struct { + team_name: []const u8, + method: TeamMethod, + parameters: ?TeamParameters, + players: []const []const u8, +}; + +pub const CSetSimulationDistance = struct { + simulation_distance: i32, +}; + +pub const CUpdateTime = struct { + game_time: i64, + clock_updates: []const struct { i32, i64, f32, f32 }, +}; + +pub const CTitleText = struct { + title: []const u8, +}; + +pub const CTitleAnimation = struct { + fade_in_ticks: i32, + stay_ticks: i32, + fade_out_ticks: i32, +}; + +pub const CPlayShowDialog = struct { + dialog: []const u8, +}; + +pub const CSoundEffect = struct { + sound_event: []const u8, + sound_category: i32, + position: struct { f64, f64, f64 }, + volume: f32, + pitch: f32, + seed: f64, +}; + +pub const CSpawnEntity = struct { + entity_id: i32, + entity_uuid: Uuid, + r_type: i32, + position: struct { f64, f64, f64 }, + velocity: []const u8, + pitch: u8, + yaw: u8, + head_yaw: u8, + data: i32, +}; + +pub const CSpawnLivingEntity = struct { + entity_id: i32, + entity_uuid: Uuid, + r_type: i32, + position: struct { f64, f64, f64 }, + yaw: u8, + pitch: u8, + head_yaw: u8, + velocity: []const u8, + metadata: ?[]const u8, +}; + +pub const CSpawnPainting = struct { + entity_id: i32, + uuid: Uuid, + title: []const u8, + variant: i32, + location: struct { i32, i32, i32 }, + direction: u8, +}; + +pub const CStopSound = struct { + sound_id: ?[]const u8, + category: ?[]const u8, +}; + +pub const CStoreCookie = struct { + key: []const u8, + payload: []const u8, +}; + +pub const CSubtitle = struct { + subtitle: []const u8, +}; + +pub const CSystemChatMessage = struct { + content: []const u8, + overlay: bool, +}; + +pub const CTabList = struct { + header: []const u8, + footer: []const u8, +}; + +pub const CTagQueryResponse = struct { + transaction_id: i32, + nbt_bytes: []const u8, +}; + +pub const CTakeItemEntity = struct { + entity_id: i32, + collector_entity_id: i32, + stack_amount: i32, +}; + +pub const CTeleportEntity = struct { + entity_id: i32, + position: struct { f64, f64, f64 }, + delta: struct { f64, f64, f64 }, + yaw: f32, + pitch: f32, + relatives: []const []const u8, + on_ground: bool, +}; + +pub const CTestInstanceBlockStatus = struct { + pos: struct { i32, i32, i32 }, + status: i32, + message: ?[]const u8, +}; + +pub const CTickingState = struct { + tick_rate: f32, + is_frozen: bool, +}; + +pub const CTickingStep = struct { + tick_steps: i32, +}; + +pub const CTransfer = struct { + host: []const u8, + port: i32, +}; + +pub const CUnloadChunk = struct { + x: i32, + z: i32, +}; + +pub const CUpdateAdvancements = struct { + reset: bool, + added: []const []const u8, + removed: []const []const u8, + progress: []const []const u8, + show_advancements: bool, +}; + +pub const AttributeModifier = struct { + id: []const u8, + amount: f64, + operation: u8, +}; + +pub const Property = struct { + id: i32, + value: f64, + modifiers: []const AttributeModifier, +}; + +pub const CLoginSuccess = struct { + uuid: Uuid, + username: []const u8, + properties: []const Property, + strict_error_handling: bool, + session_id: Uuid, +}; + +pub const PlayerActionAddPlayer = struct { + name: []const u8, + properties: []const Property, +}; + +pub const PlayerAction = union(enum) { + add_player: PlayerActionAddPlayer, + initialize_chat: ?InitChat, + update_game_mode: i32, + update_listed: bool, + update_latency: i32, + update_display_name: ?[]const u8, + update_list_order: i32, + update_hat: bool, +}; + +pub const Player = struct { + uuid: Uuid, + actions: []const PlayerAction, +}; + +pub const CPlayerInfoUpdate = struct { + actions: u8, + players: []const Player, +}; + +pub const CUpdateAttributes = struct { + entity_id: i32, + properties: []const Property, +}; + +pub const CUpdateEntityPos = struct { + entity_id: i32, + delta: struct { f64, f64, f64 }, + on_ground: bool, +}; + +pub const CUpdateEntityPosRot = struct { + entity_id: i32, + delta: struct { f64, f64, f64 }, + yaw: u8, + pitch: u8, + on_ground: bool, +}; + +pub const CUpdateEntityRot = struct { + entity_id: i32, + yaw: u8, + pitch: u8, + on_ground: bool, +}; + +pub const CUpdateMobEffect = struct { + entity_id: i32, + effect_id: i32, + amplifier: i32, + duration: i32, + flags: u8, +}; + +pub const CUpdateObjectives = struct { + objective_name: []const u8, + mode: u8, + display_name: []const u8, + render_type: i32, + number_format: ?[]const u8, +}; + +pub const Mode = enum(u8) { + add, + remove, + update, +}; + +pub const RenderType = enum(u8) { + integer, + hearts, +}; + +pub const CUpdateRecipes = struct { + raw_data: []const u8, +}; + +pub const CUpdateScore = struct { + entity_name: []const u8, + objective_name: []const u8, + value: i32, + display_name: ?[]const u8, + number_format: ?[]const u8, +}; + +pub const CUpdateTagsPlay = struct { + tags: []const []const u8, +}; + +pub const CUseBed = struct { + entity_id: i32, + location: struct { i32, i32, i32 }, +}; + +pub const WaypointOperation = enum(u8) { + track, + untrack, + update, +}; + +pub const WaypointTargetChunk = struct { + x: i32, + z: i32, +}; + +pub const WaypointTarget = union(enum) { + position: struct { i32, i32, i32 }, + chunk: WaypointTargetChunk, + azimuth: f32, + empty, +}; + +pub const WaypointIcon = struct { + style: ?[]const u8, + color: i32, +}; + +pub const TrackedWaypoint = struct { + identifier: Uuid, + icon: ?WaypointIcon, + target: WaypointTarget, +}; + +pub const CWaypoint = struct { + operation: WaypointOperation, + waypoint: TrackedWaypoint, +}; + +pub const CWorldEvent = struct { + event: i32, + location: struct { i32, i32, i32 }, + data: i32, + disable_relative_volume: bool, +}; + +pub const StatusCPingResponse = struct { + payload: i64, +}; + +pub const StatusCStatusResponse = struct { + json_response: []const u8, +}; + +pub const ServerboundPacket = union(enum) { + config_s_accept_code_of_conduct, + config_s_acknowledge_finish_config, + config_s_client_information_config: ConfigSClientInformationConfig, + config_s_config_cookie_response: ConfigSConfigCookieResponse, + config_s_custom_click_action: ConfigSCustomClickAction, + config_s_keep_alive: ConfigSKeepAlive, + config_s_known_packs: ConfigSKnownPacks, + config_s_plugin_message: ConfigSPluginMessage, + config_s_config_pong: ConfigSConfigPong, + config_s_config_resource_pack: ConfigSConfigResourcePack, + login_s_login_cookie_response: LoginSLoginCookieResponse, + login_s_login_acknowledged, + login_s_login_start: LoginSLoginStart, + login_s_login_plugin_response: LoginSLoginPluginResponse, + s_attack: SAttack, + s_block_entity_tag_query: SBlockEntityTagQuery, + s_bundle_item_selected: SBundleItemSelected, + s_change_difficulty: SChangeDifficulty, + s_change_game_mode: SChangeGameMode, + s_chat_ack: SChatAck, + s_chat_command: SChatCommand, + s_chat_command_signed: SChatCommandSigned, + s_chat_message: SChatMessage, + s_chunk_batch: SChunkBatch, + s_click_slot: SClickSlot, + s_client_command: SClientCommand, + s_client_information_play: SClientInformationPlay, + s_client_tick_end, + s_close_container: SCloseContainer, + s_command_suggestion: SCommandSuggestion, + s_configuration_acknowledged, + s_container_button_click: SContainerButtonClick, + s_container_slot_state_changed: SContainerSlotStateChanged, + s_cookie_response: SCookieResponse, + s_custom_click_action: SCustomClickAction, + s_custom_payload: SCustomPayload, + s_debug_sample_subscription: SDebugSampleSubscription, + s_debug_subscription_request: SDebugSubscriptionRequest, + s_edit_book: SEditBook, + s_entity_tag_query: SEntityTagQuery, + s_interact: SInteract, + s_jigsaw_generate: SJigsawGenerate, + s_keep_alive: SKeepAlive, + s_lock_difficulty: SLockDifficulty, + s_move_vehicle: SMoveVehicle, + s_paddle_boat: SPaddleBoat, + s_pick_item_from_block: SPickItemFromBlock, + s_pick_item_from_entity: SPickItemFromEntity, + s_play_ping_request: SPlayPingRequest, + s_place_recipe: SPlaceRecipe, + s_player_abilities: SPlayerAbilities, + s_player_action: SPlayerAction, + s_player_command: SPlayerCommand, + s_set_player_ground: SSetPlayerGround, + s_player_input: SPlayerInput, + s_player_loaded, + s_player_position: SPlayerPosition, + s_player_position_rotation: SPlayerPositionRotation, + s_player_rotation: SPlayerRotation, + s_player_session: SPlayerSession, + s_play_pong: SPlayPong, + s_recipe_book_change_settings: SRecipeBookChangeSettings, + s_recipe_book_seen_recipe: SRecipeBookSeenRecipe, + s_rename_item: SRenameItem, + s_play_resource_pack: SPlayResourcePack, + s_seen_advancement: SSeenAdvancement, + s_select_trade: SSelectTrade, + s_set_beacon: SSetBeacon, + s_set_command_block: SSetCommandBlock, + s_set_command_minecart: SSetCommandMinecart, + s_set_creative_slot: SSetCreativeSlot, + s_set_game_rule: SSetGameRule, + s_set_held_item: SSetHeldItem, + s_set_jigsaw_block: SSetJigsawBlock, + s_set_structure_block: SSetStructureBlock, + s_set_test_block: SSetTestBlock, + s_spectate_entity: SSpectateEntity, + s_swing_arm: SSwingArm, + s_teleport_to_entity: STeleportToEntity, + s_test_instance_block_action: STestInstanceBlockAction, + s_update_sign: SUpdateSign, + s_use_item: SUseItem, + s_use_item_on: SUseItemOn, + status_s_status_ping_request: StatusSStatusPingRequest, + status_s_status_request, + unknown, +}; + +pub const ClientboundPacket = union(enum) { + config_c_config_add_resource_pack: ConfigCConfigAddResourcePack, + config_c_config_clear_dialog, + config_c_code_of_conduct: ConfigCCodeOfConduct, + config_c_config_disconnect: ConfigCConfigDisconnect, + config_c_cookie_request: ConfigCCookieRequest, + config_c_config_custom_report_details: ConfigCConfigCustomReportDetails, + config_c_feature_flags: ConfigCFeatureFlags, + config_c_finish_config, + config_c_known_packs: ConfigCKnownPacks, + config_c_config_ping: ConfigCConfigPing, + config_c_plugin_message: ConfigCPluginMessage, + config_c_registry_data: ConfigCRegistryData, + config_c_config_remove_resource_pack: ConfigCConfigRemoveResourcePack, + config_c_config_reset_chat, + config_c_config_server_links: ConfigCConfigServerLinks, + config_c_config_show_dialog: ConfigCConfigShowDialog, + config_c_store_cookie: ConfigCStoreCookie, + config_c_transfer: ConfigCTransfer, + config_c_update_tags: ConfigCUpdateTags, + login_c_login_cookie_request: LoginCLoginCookieRequest, + login_c_login_disconnect: LoginCLoginDisconnect, + login_c_login_plugin_request: LoginCLoginPluginRequest, + login_c_set_compression: LoginCSetCompression, + c_acknowledge_block_change: CAcknowledgeBlockChange, + c_action_bar: CActionBar, + c_add_resource_pack: CAddResourcePack, + c_award_stats: CAwardStats, + c_set_block_destroy_stage: CSetBlockDestroyStage, + c_block_entity_data: CBlockEntityData, + c_block_event: CBlockEvent, + c_block_update: CBlockUpdate, + c_boss_event: CBossEvent, + c_bundle_delimiter, + c_center_chunk: CCenterChunk, + c_change_difficulty: CChangeDifficulty, + c_chunk_batch_end: CChunkBatchEnd, + c_chunk_batch_start, + c_chunks_biomes: CChunksBiomes, + c_play_clear_dialog, + c_clear_title: CClearTitle, + c_close_container: CCloseContainer, + c_combat_death: CCombatDeath, + c_combat_enter, + c_combat_end: CCombatEnd, + c_command_suggestions: CCommandSuggestions, + c_commands: CCommands, + c_play_cookie_request: CPlayCookieRequest, + c_custom_chat_completions: CCustomChatCompletions, + c_custom_payload: CCustomPayload, + c_play_custom_report_details: CPlayCustomReportDetails, + c_damage_event: CDamageEvent, + c_debug_block_value: CDebugBlockValue, + c_debug_chunk_value: CDebugChunkValue, + c_debug_entity_value: CDebugEntityValue, + c_debug_event: CDebugEvent, + c_debug_sample: CDebugSample, + c_delete_chat: CDeleteChat, + c_play_disconnect: CPlayDisconnect, + c_disguised_chat_message: CDisguisedChatMessage, + c_display_objective: CDisplayObjective, + c_entity_animation: CEntityAnimation, + c_set_entity_metadata: CSetEntityMetadata, + c_entity_sound_effect: CEntitySoundEffect, + c_entity_status: CEntityStatus, + c_entity_velocity: CEntityVelocity, + c_explosion: CExplosion, + c_game_event: CGameEvent, + c_game_rule_values: CGameRuleValues, + c_game_test_highlight_pos: CGameTestHighlightPos, + c_head_rot: CHeadRot, + c_hurt_animation: CHurtAnimation, + c_initialize_world_border: CInitializeWorldBorder, + c_item_cooldown: CItemCooldown, + c_keep_alive: CKeepAlive, + c_level_event: CLevelEvent, + c_light_update: CLightUpdate, + c_login: CLogin, + c_low_disk_space_warning, + c_map_item_data: CMapItemData, + c_merchant_offers: CMerchantOffers, + c_move_minecart_along_track: CMoveMinecartAlongTrack, + c_move_vehicle: CMoveVehicle, + c_multi_block_update: CMultiBlockUpdate, + c_open_book: COpenBook, + c_open_mount_screen: COpenMountScreen, + c_open_screen: COpenScreen, + c_open_sign_editor: COpenSignEditor, + c_particle: CParticle, + c_play_ping: CPlayPing, + c_ping_response: CPingResponse, + c_place_ghost_recipe: CPlaceGhostRecipe, + c_player_abilities: CPlayerAbilities, + c_player_chat_message: CPlayerChatMessage, + c_player_info_update: CPlayerInfoUpdate, + c_player_look_at: CPlayerLookAt, + c_player_position: CPlayerPosition, + c_remove_player_info: CRemovePlayerInfo, + c_player_rotation: CPlayerRotation, + c_player_spawn_position: CPlayerSpawnPosition, + c_projectile_power: CProjectilePower, + c_recipe_book_add: CRecipeBookAdd, + c_recipe_book_remove: CRecipeBookRemove, + c_recipe_book_settings: CRecipeBookSettings, + c_remove_entities: CRemoveEntities, + c_remove_mob_effect: CRemoveMobEffect, + c_remove_resource_pack: CRemoveResourcePack, + c_reset_score: CResetScore, + c_respawn: CRespawn, + c_select_advancements_tab: CSelectAdvancementsTab, + c_server_data: CServerData, + c_play_server_links: CPlayServerLinks, + c_set_border_center: CSetBorderCenter, + c_set_border_lerp_size: CSetBorderLerpSize, + c_set_border_size: CSetBorderSize, + c_set_border_warning_delay: CSetBorderWarningDelay, + c_set_border_warning_distance: CSetBorderWarningDistance, + c_set_camera: CSetCamera, + c_set_chunk_cache_radius: CSetChunkCacheRadius, + c_set_container_content: CSetContainerContent, + c_set_container_property: CSetContainerProperty, + c_set_container_slot: CSetContainerSlot, + c_set_cursor_item: CSetCursorItem, + c_set_entity_link: CSetEntityLink, + c_set_equipment: CSetEquipment, + c_set_experience: CSetExperience, + c_set_health: CSetHealth, + c_set_passengers: CSetPassengers, + c_set_player_inventory: CSetPlayerInventory, + c_set_player_team: CSetPlayerTeam, + c_set_simulation_distance: CSetSimulationDistance, + c_update_time: CUpdateTime, + c_title_text: CTitleText, + c_title_animation: CTitleAnimation, + c_play_show_dialog: CPlayShowDialog, + c_sound_effect: CSoundEffect, + c_spawn_entity: CSpawnEntity, + c_spawn_living_entity: CSpawnLivingEntity, + c_spawn_painting: CSpawnPainting, + c_start_configuration, + c_stop_sound: CStopSound, + c_store_cookie: CStoreCookie, + c_subtitle: CSubtitle, + c_tab_list: CTabList, + c_tag_query_response: CTagQueryResponse, + c_take_item_entity: CTakeItemEntity, + c_teleport_entity: CTeleportEntity, + c_test_instance_block_status: CTestInstanceBlockStatus, + c_ticking_state: CTickingState, + c_ticking_step: CTickingStep, + c_transfer: CTransfer, + c_unload_chunk: CUnloadChunk, + c_update_advancements: CUpdateAdvancements, + c_update_attributes: CUpdateAttributes, + c_update_entity_pos: CUpdateEntityPos, + c_update_entity_pos_rot: CUpdateEntityPosRot, + c_update_entity_rot: CUpdateEntityRot, + c_update_mob_effect: CUpdateMobEffect, + c_update_objectives: CUpdateObjectives, + c_update_recipes: CUpdateRecipes, + c_update_score: CUpdateScore, + c_use_bed: CUseBed, + c_waypoint: CWaypoint, + c_world_event: CWorldEvent, + status_c_ping_response: StatusCPingResponse, + status_c_status_response: StatusCStatusResponse, + unknown, +}; diff --git a/src/wit/logging.zig b/src/wit/logging.zig new file mode 100644 index 0000000..a9ea075 --- /dev/null +++ b/src/wit/logging.zig @@ -0,0 +1,26 @@ +// Generated by tools/gen.zig, do not edit. + +const abi = @import("../abi.zig"); + +pub const Level = enum(u8) { + trace, + debug, + info, + warn, + @"error", +}; + +/// log any general purpose message +pub fn log(level: Level, message: []const u8) void { + return abi.call(raw.log, void, .{ level, message }); +} + +/// This function is meant to be used by the tracing crate. +pub fn logTracing(event: []const u8) void { + return abi.call(raw.@"log-tracing", void, .{event}); +} + +const raw = struct { + extern "pumpkin:plugin/logging@0.1.0" fn log(i32, i32, i32) void; + extern "pumpkin:plugin/logging@0.1.0" fn @"log-tracing"(i32, i32) void; +}; diff --git a/src/wit/metadata.zig b/src/wit/metadata.zig new file mode 100644 index 0000000..92258f5 --- /dev/null +++ b/src/wit/metadata.zig @@ -0,0 +1,16 @@ +// Generated by tools/gen.zig, do not edit. + +pub const PluginMetadata = struct { + /// Name of the plugin. + name: []const u8, + /// Plugin version (semver). + version: []const u8, + /// Plugin authors. + authors: []const []const u8, + /// Short description of the plugin. + description: []const u8, + /// Plugin dependencies. + dependencies: []const []const u8, + /// Permissions requested by the plugin. + permissions: []const []const u8, +}; diff --git a/src/wit/particles.zig b/src/wit/particles.zig new file mode 100644 index 0000000..85b2cc5 --- /dev/null +++ b/src/wit/particles.zig @@ -0,0 +1,129 @@ +// Generated by tools/gen.zig, do not edit. + +pub const Particle = enum(u8) { + angry_villager, + block, + block_marker, + bubble, + sulfur_bubbles, + noxious_gas, + noxious_gas_cloud, + geyser, + geyser_base, + geyser_poof, + geyser_plume, + cloud, + copper_fire_flame, + crit, + damage_indicator, + dragon_breath, + dripping_lava, + falling_lava, + landing_lava, + dripping_water, + falling_water, + dust, + dust_color_transition, + effect, + elder_guardian, + enchanted_hit, + enchant, + end_rod, + entity_effect, + explosion_emitter, + explosion, + gust, + small_gust, + gust_emitter_large, + gust_emitter_small, + sonic_boom, + falling_dust, + firework, + fishing, + flame, + infested, + cherry_leaves, + pale_oak_leaves, + tinted_leaves, + sculk_soul, + sculk_charge, + sculk_charge_pop, + soul_fire_flame, + soul, + flash, + happy_villager, + composter, + heart, + instant_effect, + item, + vibration, + trail, + pause_mob_growth, + reset_mob_growth, + item_slime, + item_cobweb, + item_snowball, + large_smoke, + lava, + mycelium, + note, + poof, + portal, + rain, + smoke, + white_smoke, + sneeze, + spit, + squid_ink, + sweep_attack, + totem_of_undying, + underwater, + splash, + witch, + bubble_pop, + current_down, + bubble_column_up, + nautilus, + dolphin, + campfire_cosy_smoke, + campfire_signal_smoke, + dripping_honey, + falling_honey, + landing_honey, + falling_nectar, + falling_spore_blossom, + ash, + crimson_spore, + warped_spore, + spore_blossom_air, + dripping_obsidian_tear, + falling_obsidian_tear, + landing_obsidian_tear, + reverse_portal, + white_ash, + small_flame, + snowflake, + dripping_dripstone_lava, + falling_dripstone_lava, + dripping_dripstone_water, + falling_dripstone_water, + glow_squid_ink, + glow, + wax_on, + wax_off, + electric_spark, + scrape, + shriek, + egg_crack, + dust_plume, + trial_spawner_detection, + trial_spawner_detection_ominous, + vault_connection, + dust_pillar, + ominous_spawning, + raid_omen, + trial_omen, + block_crumble, + firefly, + sulfur_cube_goo, +}; diff --git a/src/wit/permission.zig b/src/wit/permission.zig new file mode 100644 index 0000000..c608a97 --- /dev/null +++ b/src/wit/permission.zig @@ -0,0 +1,46 @@ +// Generated by tools/gen.zig, do not edit. + +/// Represents the player's permission level +/// +/// Permission levels determine the player's access to commands and server operations. +/// Each numeric level corresponds to a specific role: +/// - `Zero`: `normal`: Player can use basic commands. +/// - `One`: `moderator`: Player can bypass spawn protection. +/// - `Two`: `gamemaster`: Player or executor can use more commands and player can use command blocks. +/// - `Three`: `admin`: Player or executor can use commands related to multiplayer management. +/// - `Four`: `owner`: Player or executor can use all of the commands, including commands related to server management. +pub const PermissionLevel = enum(u8) { + zero, + one, + two, + three, + four, +}; + +/// Describes the default behavior for permissions +pub const PermissionDefault = union(enum) { + /// Permission is not granted by default + deny, + /// Permission is granted by default + allow, + /// Permission is granted by default to operators + op: PermissionLevel, +}; + +/// A child permission entry +pub const PermissionChild = struct { + node: []const u8, + value: bool, +}; + +/// Defines a permission node in the system +pub const Permission = struct { + /// The full node name (e.g., "minecraft:command.gamemode") + node: []const u8, + /// Description of what this permission does + description: []const u8, + /// The default value of this permission + default: PermissionDefault, + /// Children nodes that are affected by this permission + children: []const PermissionChild, +}; diff --git a/src/wit/player.zig b/src/wit/player.zig new file mode 100644 index 0000000..8c511df --- /dev/null +++ b/src/wit/player.zig @@ -0,0 +1,2193 @@ +// Generated by tools/gen.zig, do not edit. + +const abi = @import("../abi.zig"); +const common = @import("common.zig"); +const item_stack = @import("item_stack.zig"); +const world = @import("world.zig"); +const permission = @import("permission.zig"); +const text = @import("text.zig"); +const gui = @import("gui.zig"); +const forms = @import("forms.zig"); +const java_dialogs = @import("java_dialogs.zig"); +const java_packets = @import("java_packets.zig"); +const bedrock_packets = @import("bedrock_packets.zig"); +const uuid = @import("uuid.zig"); +const status_effect = @import("status_effect.zig"); +const scoreboard = @import("scoreboard.zig"); +const advancement = @import("advancement.zig"); +const damage_types = @import("damage_types.zig"); +const statistics = @import("statistics.zig"); +const inventory = @import("inventory.zig"); +const sounds = @import("sounds.zig"); +const particles = @import("particles.zig"); +const entity_statuses = @import("entity_statuses.zig"); + +pub const Hand = common.Hand; +pub const Position = common.Position; +pub const GameMode = common.GameMode; +pub const BlockPos = common.BlockPos; +pub const ItemStack = item_stack.ItemStack; +pub const World = world.World; +pub const Entity = world.Entity; +pub const RayTraceBlockResult = world.RayTraceBlockResult; +pub const RayTraceEntityResult = world.RayTraceEntityResult; +pub const PermissionLevel = permission.PermissionLevel; +pub const TextComponent = text.TextComponent; +pub const Gui = gui.Gui; +pub const Form = forms.Form; +pub const Dialog = java_dialogs.Dialog; +pub const JavaPacket = java_packets.ClientboundPacket; +pub const BedrockPacket = bedrock_packets.ClientboundPacket; +pub const Uuid = uuid.Uuid; +pub const StatusEffectType = status_effect.StatusEffectType; +pub const StatusEffectInstance = status_effect.StatusEffectInstance; +pub const Scoreboard = scoreboard.Scoreboard; +pub const BedrockScoreboard = scoreboard.BedrockScoreboard; +pub const AdvancementProgress = advancement.AdvancementProgress; +pub const DamageType = damage_types.DamageType; +pub const StatisticCategory = statistics.StatisticCategory; +pub const CustomStatistic = statistics.CustomStatistic; +pub const Inventory = inventory.Inventory; +pub const PlayerInventory = inventory.PlayerInventory; +pub const Sound = sounds.Sound; +pub const SoundCategory = sounds.SoundCategory; +pub const Particle = particles.Particle; +pub const EntityStatus = entity_statuses.EntityStatus; + +/// Represents per-player weather condition overrides. +pub const PlayerWeather = enum(u8) { + clear, + downfall, +}; + +/// Types of projectiles that can be launched by a player. +pub const ProjectileType = enum(u8) { + arrow, + snowball, + egg, + ender_pearl, + splash_potion, + fireball, + small_fireball, + trident, + wind_charge, +}; + +/// Types of clientbound game events. +pub const ClientGameEvent = enum(u8) { + no_respawn_block_available, + begin_raining, + end_raining, + change_game_mode, + win_game, + demo_event, + arrow_hit_player, + rain_level_change, + thunder_level_change, + play_pufferfish_string_sound, + play_elder_guardian_mob_appearance, + enabled_respawn_screen, + limited_crafting, + start_waiting_chunks, +}; + +/// Built-in known server link types displayed in the client Escape pause menu. +pub const KnownServerLink = enum(u8) { + bug_report, + community_guidelines, + support, + status, + feedback, + community, + website, + forums, + news, + announcements, +}; + +/// Label for a server link: either a built-in standard link type or a custom text component. +pub const ServerLinkLabel = union(enum) { + known: KnownServerLink, + custom: TextComponent, +}; + +/// Represents a server link entry with a label and destination URL. +pub const ServerLink = struct { + label: ServerLinkLabel, + url: []const u8, +}; + +/// Various abilities a player can have. +pub const PlayerAbilities = struct { + /// Whether the player is invulnerable to damage. + invulnerable: bool, + /// Whether the player is currently flying. + flying: bool, + /// Whether the player is allowed to fly. + allow_flying: bool, + /// Whether the player is in creative mode. + creative: bool, + /// Whether the player can modify the world. + allow_modify_world: bool, + /// The speed at which the player flies. + fly_speed: f32, + /// The speed at which the player walks. + walk_speed: f32, +}; + +/// Represents a player's skin textures and metadata. +pub const PlayerSkin = struct { + /// The base64-encoded texture data (usually JSON containing skin/cape URLs). + value: []const u8, + /// The optional signature for the texture data. + signature: ?[]const u8, +}; + +/// Represents which skin parts are visible. +pub const SkinParts = packed struct(u8) { + cape: bool = false, + jacket: bool = false, + left_sleeve: bool = false, + right_sleeve: bool = false, + left_pants_leg: bool = false, + right_pants_leg: bool = false, + hat: bool = false, + _: u1 = 0, +}; + +/// Represents the various abilities a Bedrock Edition player can have. +pub const BedrockAbility = enum(u8) { + /// Whether the player can build. + build, + /// Whether the player can mine blocks. + mine, + /// Whether the player can use doors and switches. + doors_and_switches, + /// Whether the player can open containers. + open_containers, + /// Whether the player can attack other players. + attack_players, + /// Whether the player can attack mobs. + attack_mobs, + /// Whether the player can use operator commands. + operator_commands, + /// Whether the player can teleport. + teleport, + /// Whether the player is invulnerable. + invulnerable, + /// Whether the player is currently flying. + flying, + /// Whether the player is allowed to fly. + may_fly, + /// Whether the player has instant build (creative). + instabuild, + /// Whether the player can use lightning-related abilities. + lightning, + /// The speed at which the player flies. + fly_speed, + /// The speed at which the player walks. + walk_speed, + /// Whether the player is muted. + muted, + /// Whether the player is a world builder. + world_builder, + /// Whether the player has no-clip enabled. + no_clip, + /// Whether the player is a privileged builder. + privileged_builder, + /// The speed at which the player flies vertically. + vertical_fly_speed, +}; + +/// Represents the various status flags a Bedrock Edition entity can have. +/// These flags control client-side rendering and behavior. +pub const BedrockStatusFlag = enum(u8) { + /// Whether the entity is currently on fire. + on_fire, + /// Whether the entity is sneaking. + sneaking, + /// Whether the entity is riding another entity. + riding, + /// Whether the entity is sprinting. + sprinting, + /// Whether the entity is using an item (e.g., eating, blocking). + using_item, + /// Whether the entity is invisible. + invisible, + /// Whether the entity is tempted by an item. + tempted, + /// Whether the entity is in love (breeding). + in_love, + /// Whether the entity is saddled. + saddled, + /// Whether the entity is powered (e.g., charged creeper). + powered, + /// Whether the entity is ignited. + ignited, + /// Whether the entity is a baby. + baby, + /// Whether the entity is currently converting to another type. + converting, + /// Whether the entity is in a critical state. + critical, + /// Whether to show the entity's name tag. + show_name, + /// Whether to always show the entity's name tag. + always_show_name, + /// Whether the entity has no AI. + no_ai, + /// Whether the entity is silent. + silent, + /// Whether the entity is climbing a wall. + wall_climbing, + /// Whether the entity is climbing. + climb, + /// Whether the entity is swimming. + swim, + /// Whether the entity is flying. + fly, + /// Whether the entity is walking. + walk, + /// Whether the entity is resting. + resting, + /// Whether the entity is sitting. + sitting, + /// Whether the entity is angry. + angry, + /// Whether the entity is interested. + interested, + /// Whether the entity is charged. + charged, + /// Whether the entity is tamed. + tamed, + /// Whether the entity is orphaned. + orphaned, + /// Whether the entity is leashed. + leashed, + /// Whether the entity is sheared. + sheared, + /// Whether the entity is gliding (elytra). + gliding, + /// Whether the entity is an elder (e.g., elder guardian). + elder, + /// Whether the entity is moving. + moving, + /// Whether the entity is breathing. + breathing, + /// Whether the entity has a chest (e.g., donkey). + chested, + /// Whether the entity is stackable. + stackable, + /// Whether to show the bottom of the entity. + show_bottom, + /// Whether the entity is standing. + standing, + /// Whether the entity is shaking. + shaking, + /// Whether the entity is idling. + idling, + /// Whether the entity is casting (e.g., evoker). + casting, + /// Whether the entity is charging an attack. + charging, + /// Whether the entity is controlled by a keyboard. + keyboard_controlled, + /// Whether the entity is performing a power jump. + power_jump, + /// Whether the entity is dashing. + dash, + /// Whether the entity is lingering. + lingering, + /// Whether the entity has collision. + has_collision, + /// Whether the entity has gravity. + has_gravity, + /// Whether the entity is immune to fire. + fire_immune, + /// Whether the entity is dancing. + dancing, + /// Whether the entity is enchanted. + enchanted, + /// Whether a trident will return to the entity. + return_trident, + /// Whether the container is private. + container_private, + /// Whether the entity is transforming. + transforming, + /// Whether the entity damages nearby mobs. + damage_nearby_mobs, + /// Whether the entity is swimming. + swimming, + /// Whether the entity has been bribed. + bribed, + /// Whether the entity is pregnant. + pregnant, + /// Whether the entity is laying an egg. + laying_egg, + /// Whether a passenger can pick up the entity. + passenger_can_pick, + /// Whether the entity is transitioning to sitting. + transition_sitting, + /// Whether the entity is eating. + eating, + /// Whether the entity is laying down. + laying_down, + /// Whether the entity is sneezing. + sneezing, + /// Whether the entity is trusting. + trusting, + /// Whether the entity is rolling. + rolling, + /// Whether the entity is scared. + scared, + /// Whether the entity is in scaffolding. + in_scaffolding, + /// Whether the entity is over scaffolding. + over_scaffolding, + /// Whether the entity is descending through a block. + descend_through_block, + /// Whether the entity is blocking. + blocking, + /// Whether the entity is transitioning to blocking. + transition_blocking, + /// Whether the entity is blocked using a shield. + blocked_using_shield, + /// Whether the entity is blocked using a damaged shield. + blocked_using_damaged_shield, + /// Whether the entity is sleeping. + sleeping, + /// Whether the entity wants to wake up. + wants_to_wake, + /// Whether the entity shows interest in trading. + trade_interest, + /// Whether the entity can break doors. + door_breaker, + /// Whether the entity is breaking an obstruction. + breaking_obstruction, + /// Whether the entity can open doors. + door_opener, + /// Whether the entity is a captain (raid). + captain, + /// Whether the entity is stunned. + stunned, + /// Whether the entity is roaring. + roaring, + /// Whether the entity has a delayed attack. + delayed_attack, + /// Whether the entity is avoiding mobs. + avoiding_mobs, + /// Whether the entity is avoiding a block. + avoiding_block, + /// Whether the entity is facing a target for a ranged attack. + facing_target_to_range_attack, + /// Whether the entity is hidden when invisible. + hidden_when_invisible, + /// Whether the entity is in a UI. + in_ui, + /// Whether the entity is stalking. + stalking, + /// Whether the entity is emoting. + emoting, + /// Whether the entity is celebrating. + celebrating, + /// Whether the entity is admiring (piglin). + admiring, + /// Whether the entity is celebrating a special event. + celebrating_special, + /// Whether the entity is out of control. + out_of_control, + /// Whether the entity is performing a ram attack. + ram_attack, + /// Whether the entity is playing dead. + playing_dead, + /// Whether the entity is in an ascending block. + in_ascending_block, + /// Whether the entity is over a descending block. + over_descending_block, + /// Whether the entity is croaking (frog). + croaking, + /// Whether the entity is digesting a mob. + digest_mob, + /// Whether the entity has a jump goal. + jump_goal, + /// Whether the entity is emerging. + emerging, + /// Whether the entity is sniffing. + sniffing, + /// Whether the entity is digging. + digging, + /// Whether the entity is performing a sonic boom. + sonic_boom, + /// Whether the entity has a dash timeout. + has_dash_timeout, + /// Whether the entity is pushed towards the closest space. + push_towards_closest_space, + /// Whether the entity is scenting. + scenting, + /// Whether the entity is rising. + rising, + /// Whether the entity is feeling happy. + feeling_happy, + /// Whether the entity is searching. + searching, + /// Whether the entity is crawling. + crawling, + /// Whether the entity's body rotation is blocked. + body_rotation_blocked, + /// Whether the entity is rendered when invisible. + render_when_invisible, + /// Whether the entity's body rotation is axis-aligned. + body_rotation_axis_aligned, + /// Whether the entity is collidable. + collidable, + /// Whether the entity is air-controlled via WASD. + wasd_air_controlled, + /// Whether only the server can authorize a dismount. + does_server_auth_only_dismount, + /// Whether the body rotation always follows the head. + body_rotation_always_follows_head, + /// Whether the entity can use vertical movement actions. + can_use_vertical_movement_action, + /// Whether rotation is locked to the vehicle. + rotation_locked_to_vehicle, +}; + +/// Represents a specific version of the Minecraft Java Edition protocol. +pub const JavaMinecraftVersion = enum(u8) { + v_1_7_2, + v_1_7_6, + v_1_8, + v_1_9, + v_1_9_1, + v_1_9_2, + v_1_9_3, + v_1_10, + v_1_11, + v_1_11_1, + v_1_12, + v_1_12_1, + v_1_12_2, + v_1_13, + v_1_13_1, + v_1_13_2, + v_1_14, + v_1_14_1, + v_1_14_2, + v_1_14_3, + v_1_14_4, + v_1_15, + v_1_15_1, + v_1_15_2, + v_1_16, + v_1_16_1, + v_1_16_2, + v_1_16_3, + v_1_16_4, + v_1_17, + v_1_17_1, + v_1_18, + v_1_18_2, + v_1_19, + v_1_19_1, + v_1_19_3, + v_1_19_4, + v_1_20, + v_1_20_2, + v_1_20_3, + v_1_20_5, + v_1_21, + v_1_21_2, + v_1_21_4, + v_1_21_5, + v_1_21_6, + v_1_21_7, + v_1_21_9, + v_1_21_11, + v_26_1, + v_26_2, + unknown, +}; + +/// Represents a specific version of the Minecraft Bedrock Edition protocol. +pub const BedrockMinecraftVersion = enum(u8) { + v_1_21, + v_1_26_30, + unknown, +}; + +/// The chat visibility settings for a player. +pub const ChatMode = enum(u8) { + /// Chat is fully enabled. + enabled, + /// Only system messages and commands are shown. + commands_only, + /// Chat is completely hidden. + hidden, +}; + +/// Represents settings for a Java Edition player. +pub const JavaPlayerSettings = struct { + /// The player's preferred language (e.g., \"en_us\"). + locale: []const u8, + /// The maximum distance at which chunks are rendered. + view_distance: u8, + /// The player's chat visibility settings. + chat_mode: ChatMode, + /// Whether chat colors are enabled. + chat_colors: bool, + /// The player's skin configuration options. + skin_parts: SkinParts, + /// The player's dominant hand (left or right). + main_hand: Hand, + /// Whether text filtering is enabled. + text_filtering: bool, + /// Whether the player wants to appear in the server list. + server_listing: bool, +}; + +/// Represents the operating system of a Bedrock Edition client. +pub const BedrockDeviceOs = enum(u8) { + android, + ios, + osx, + amazon, + gear_vr, + holo_lens, + windows_10, + win_32, + dedicated, + tv_os, + playstation, + nintendo, + xbox, + windows_phone, + linux, + /// Fallback for unrecognized operating systems. + unknown, +}; + +/// Represents the input mode used by a Bedrock Edition client. +pub const BedrockInputMode = enum(u8) { + /// Unknown input mode. + unknown, + /// Mouse and keyboard. + mouse, + /// Touch screen. + touch, + /// Game controller. + game_pad, + /// Motion-based controller. + motion_controller, +}; + +/// Represents the UI profile used by a Bedrock Edition client. +pub const BedrockUiProfile = enum(u8) { + /// Classic desktop UI. + classic, + /// Pocket/Mobile optimized UI. + pocket, + /// Unknown UI profile. + unknown, +}; + +/// Represents the graphics mode used by a Bedrock Edition client. +pub const BedrockGraphicsMode = enum(u8) { + simple, + fancy, + ray_traced, + unknown, +}; + +/// Represents settings and client data for a Bedrock Edition player. +pub const BedrockPlayerSettings = struct { + /// The client's specific game version string. + game_version: []const u8, + /// The operating system of the client device. + device_os: BedrockDeviceOs, + /// A unique identifier for the client device. + device_id: []const u8, + /// The model name of the client device. + device_model: []const u8, + /// The player's preferred language code (e.g., \"en_US\"). + language_code: []const u8, + /// The input mode currently used by the player. + current_input_mode: BedrockInputMode, + /// The default input mode for the client device. + default_input_mode: BedrockInputMode, + /// The UI layout profile used by the client. + ui_profile: BedrockUiProfile, + /// The current GUI scale setting. + gui_scale: i32, + /// Whether the player is in Editor mode. + is_editor_mode: bool, + /// The maximum view distance the client supports. + max_view_distance: i32, + /// The memory tier of the client device (indicates performance level). + memory_tier: i32, + /// The graphics mode used by the client. + graphics_mode: BedrockGraphicsMode, + /// The player's unique PlayFab identifier. + playfab_id: []const u8, + /// A random 64-bit ID generated by the client. + client_random_id: i64, + /// Platform-specific offline identifier. + platform_offline_id: []const u8, + /// Platform-specific online identifier. + platform_online_id: []const u8, + /// The unique ID of the player's current skin. + skin_id: []const u8, + /// The model arm size (e.g., \"wide\" or \"slim\"). + arm_size: []const u8, + /// Whether the player is using a Character Creator (Persona) skin. + is_persona_skin: bool, + /// Whether the skin is a premium (paid) skin. + is_premium_skin: bool, + /// Whether the skin is from a trusted source. + is_trusted_skin: bool, +}; + +/// Protocol-level disconnect reasons for Minecraft Bedrock Edition. +pub const BedrockDisconnectReason = enum(u8) { + unknown, + cant_connect_no_internet, + no_permissions, + unrecoverable_error, + third_party_blocked, + third_party_no_internet, + third_party_bad_ip, + third_party_no_server_or_server_locked, + version_mismatch, + skin_issue, + invite_session_not_found, + edu_level_settings_missing, + local_server_not_found, + legacy_disconnect, + user_leave_game_attempted, + platform_locked_skins_error, + realms_world_unassigned, + realms_server_cant_connect, + realms_server_hidden, + realms_server_disabled_beta, + realms_server_disabled, + cross_platform_disabled, + cant_connect, + session_not_found, + client_settings_incompatible_with_server, + server_full, + invalid_platform_skin, + edition_version_mismatch, + edition_mismatch, + level_newer_than_exe_version, + no_fail_occurred, + banned_skin, + timeout, + server_not_found, + outdated_server, + outdated_client, + no_premium_platform, + multiplayer_disabled, + no_wifi, + world_corruption, + no_reason, + disconnected, + invalid_player, + logged_in_other_location, + server_id_conflict, + not_allowed, + not_authenticated, + invalid_tenant, + unknown_packet, + unexpected_packet, + invalid_command_request_packet, + host_suspended, + login_packet_no_request, + login_packet_no_cert, + missing_client, + kicked, + kicked_for_exploit, + kicked_for_idle, + resource_pack_problem, + incompatible_pack, + out_of_storage, + invalid_level, + disconnect_packet, + block_mismatch, + invalid_heights, + invalid_widths, + connection_lost, + zombie_connection, + shutdown, + reason_not_set, + loading_state_timeout, + resource_pack_loading_failed, + searching_for_session_loading_screen_failed, + nether_net_protocol_version, + subsystem_status_error, + empty_auth_from_discovery, + empty_url_from_discovery, + expired_auth_from_discovery, + unknown_signal_service_sign_in_failure, + xbl_join_lobby_failure, + unspecified_client_instance_disconnection, + nether_net_session_not_found, + nether_net_create_peer_connection, + nether_net_ice, + nether_net_connect_request, + nether_net_connect_response, + nether_net_negotiation_timeout, + nether_net_inactivity_timeout, + stale_connection_being_replaced, + realms_session_not_found, + bad_packet, + nether_net_failed_to_create_offer, + nether_net_failed_to_create_answer, + nether_net_failed_to_set_local_description, + nether_net_failed_to_set_remote_description, + nether_net_negotiation_timeout_waiting_for_response, + nether_net_negotiation_timeout_waiting_for_accept, + nether_net_incoming_connection_ignored, + nether_net_signaling_parsing_failure, + nether_net_signaling_unknown_error, + nether_net_signaling_unicast_delivery_failed, + nether_net_signaling_broadcast_delivery_failed, + nether_net_signaling_generic_delivery_failed, + editor_mismatch_editor_world, + editor_mismatch_vanilla_world, + world_transfer_not_primary_client, + request_server_shutdown, + client_game_setup_cancelled, + client_game_setup_failed, + no_venue, + nether_net_signaling_signin_failed, + session_access_denied, + service_signin_issue, + nether_net_no_signaling_channel, + nether_net_not_logged_in, + nether_net_client_signaling_error, + sub_client_login_disabled, + deep_link_trying_to_open_demo_world_while_signed_in, + async_join_task_denied, + realms_timeline_required, + guest_without_host, + failed_to_join_experience, + nether_net_data_channel_closed, + discovery_environment_mismatch, + host_without_keys, + host_signed_out, + script_watchdog_exception, + script_memory_limit_exceeded, + storage_low_during_gameplay, + storage_full_during_gameplay, + level_storage_corruption, + edition_mismatch_vanilla_to_edu, + edition_mismatch_edu_to_vanilla, + editor_mismatch_editor_to_vanilla, + editor_mismatch_vanilla_to_editor, + deny_listed, + nonce_missing, + nonce_not_found, + nonce_expired, + nonce_not_valid, + host_disconnected, + editor_join_intent_policy_failure, + nether_net_identity_not_allowed, + invalid_name, + expired_token, + host_accepts_no_type_of_auth, + not_authenticated_fast_fail, + editor_not_allowed, +}; + +/// Policy for tearing down the player's network connection. +pub const SocketTeardownPolicy = enum(u8) { + /// Send the disconnect packet and gracefully close the connection. + graceful, + /// Send the disconnect packet and close the socket immediately. + immediate_close, + /// Terminate the connection immediately without sending any disconnect packet. + drop_connection, +}; + +/// Options for disconnecting a Java Edition player. +pub const JavaKickOptions = struct { + /// The formatted text component displayed on the Java disconnect screen. + reason: TextComponent, + /// Whether to log the kick in the server console (default: true). + log_to_console: bool, + /// How the connection is closed (default: graceful). + teardown_policy: SocketTeardownPolicy, +}; + +/// Options for disconnecting a Bedrock Edition player. +pub const BedrockKickOptions = struct { + /// Protocol level disconnect code (default: kicked). + reason: BedrockDisconnectReason, + /// Message displayed on the Bedrock disconnect screen (default: ""). + message: []const u8, + /// Whether to suppress the disconnect message on the client screen (default: false). + skip_message: bool, + /// Filtered message string for safety/parental filters (default: ""). + filtered_message: []const u8, + /// Whether to log the kick in the server console (default: true). + log_to_console: bool, + /// How the connection is closed (default: graceful). + teardown_policy: SocketTeardownPolicy, +}; + +/// Options for banning a player. +pub const BanPlayerOptions = struct { + /// Ban reason displayed to the player and stored in the ban list. + reason: ?TextComponent, + /// Source or authority responsible for the ban (default: "Plugin"). + source: ?[]const u8, + /// Ban expiration in RFC-3339 format, if temporary. + expires_at_utc: ?[]const u8, + /// Ban duration in seconds from now, if temporary. + duration_seconds: ?u64, + /// Whether to immediately kick the player if currently online (default: true). + kick_if_online: bool, + /// Whether to log the ban action to the server console (default: true). + log_to_console: bool, +}; + +/// Options for banning an IP address. +pub const BanIpOptions = struct { + /// Ban reason stored in the IP ban list. + reason: ?TextComponent, + /// Source or authority responsible for the ban (default: "Plugin"). + source: ?[]const u8, + /// Ban expiration in RFC-3339 format, if temporary. + expires_at_utc: ?[]const u8, + /// Ban duration in seconds from now, if temporary. + duration_seconds: ?u64, + /// Whether to immediately kick all online players with this IP (default: true). + kick_matching_players: bool, + /// Whether to log the IP ban action to the server console (default: true). + log_to_console: bool, +}; + +/// A handle to a player on the server. +pub const Player = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]player"; + + /// Returns the player as an entity. + pub fn asEntity(self: Player) Entity { + return abi.call(raw.@"[method]player.as-entity", Entity, .{abi.borrow(self)}); + } + + /// Returns the player's unique UUID as a string. + pub fn getId(self: Player) Uuid { + return abi.call(raw.@"[method]player.get-id", Uuid, .{abi.borrow(self)}); + } + + /// Returns the player's username. + pub fn getName(self: Player) []const u8 { + return abi.call(raw.@"[method]player.get-name", []const u8, .{abi.borrow(self)}); + } + + /// Basic state + /// Returns the player's current position in the world. + pub fn getPosition(self: Player) Position { + return abi.call(raw.@"[method]player.get-position", Position, .{abi.borrow(self)}); + } + + /// Returns the player's current yaw (horizontal rotation). + pub fn getYaw(self: Player) f32 { + return abi.call(raw.@"[method]player.get-yaw", f32, .{abi.borrow(self)}); + } + + /// Returns the player's current pitch (vertical rotation). + pub fn getPitch(self: Player) f32 { + return abi.call(raw.@"[method]player.get-pitch", f32, .{abi.borrow(self)}); + } + + /// Returns the world the player is currently in. + pub fn getWorld(self: Player) World { + return abi.call(raw.@"[method]player.get-world", World, .{abi.borrow(self)}); + } + + /// Returns the player's current game mode. + pub fn getGamemode(self: Player) GameMode { + return abi.call(raw.@"[method]player.get-gamemode", GameMode, .{abi.borrow(self)}); + } + + /// Changes the player's game mode. Returns true if successful. + pub fn setGamemode(self: Player, mode: GameMode) bool { + return abi.call(raw.@"[method]player.set-gamemode", bool, .{ abi.borrow(self), mode }); + } + + /// Returns the player's locale (e.g., \"en_us\"). + pub fn getLocale(self: Player) []const u8 { + return abi.call(raw.@"[method]player.get-locale", []const u8, .{abi.borrow(self)}); + } + + /// Returns the player's current ping in milliseconds. + pub fn getPing(self: Player) u32 { + return abi.call(raw.@"[method]player.get-ping", u32, .{abi.borrow(self)}); + } + + /// Permissions & metadata + /// Returns the player's permission level (0-4). + pub fn getPermissionLevel(self: Player) PermissionLevel { + return abi.call(raw.@"[method]player.get-permission-level", PermissionLevel, .{abi.borrow(self)}); + } + + /// Sets the player's permission level. + pub fn setPermissionLevel(self: Player, level: PermissionLevel) void { + return abi.call(raw.@"[method]player.set-permission-level", void, .{ abi.borrow(self), level }); + } + + /// Grants or denies a specific permission node for the player. + pub fn setPermission(self: Player, node: []const u8, value: bool) void { + return abi.call(raw.@"[method]player.set-permission", void, .{ abi.borrow(self), node, value }); + } + + /// Removes an explicitly set permission node from the player. + pub fn unsetPermission(self: Player, node: []const u8) void { + return abi.call(raw.@"[method]player.unset-permission", void, .{ abi.borrow(self), node }); + } + + /// Returns `Some(true)` if granted, `Some(false)` if denied, or `None` if not set. + pub fn hasPermissionSet(self: Player, node: []const u8) ?bool { + return abi.call(raw.@"[method]player.has-permission-set", ?bool, .{ abi.borrow(self), node }); + } + + /// Checks if the player has a specific permission node. + pub fn hasPermission(self: Player, node: []const u8) bool { + return abi.call(raw.@"[method]player.has-permission", bool, .{ abi.borrow(self), node }); + } + + /// Returns the player's display name, which may include formatting. + pub fn getDisplayName(self: Player) TextComponent { + return abi.call(raw.@"[method]player.get-display-name", TextComponent, .{abi.borrow(self)}); + } + + /// Sets the player's display name. + /// + /// Consumes `display_name`. + pub fn setDisplayName(self: Player, display_name: TextComponent) void { + return abi.call(raw.@"[method]player.set-display-name", void, .{ abi.borrow(self), display_name }); + } + + /// Gets the player's custom tab list name. + pub fn getTabListName(self: Player) ?TextComponent { + return abi.call(raw.@"[method]player.get-tab-list-name", ?TextComponent, .{abi.borrow(self)}); + } + + /// Sets the player's custom tab list name. + pub fn setTabListName(self: Player, name: ?TextComponent) void { + return abi.call(raw.@"[method]player.set-tab-list-name", void, .{ abi.borrow(self), name }); + } + + /// Messaging & titles + /// Sends a system message to the player's chat. + /// + /// Consumes `text_`. + pub fn sendSystemMessage(self: Player, text_: TextComponent, overlay: bool) void { + return abi.call(raw.@"[method]player.send-system-message", void, .{ abi.borrow(self), text_, overlay }); + } + + /// Deletes a signed chat message from the player's chat window using its 256-byte signature. + pub fn deleteMessageBySignature(self: Player, signature: []const u8) void { + return abi.call(raw.@"[method]player.delete-message-by-signature", void, .{ abi.borrow(self), signature }); + } + + /// Deletes a signed chat message from the player's chat window using its signature cache ID. + pub fn deleteMessageById(self: Player, signature_id: i32) void { + return abi.call(raw.@"[method]player.delete-message-by-id", void, .{ abi.borrow(self), signature_id }); + } + + /// Sets the header and footer of the player's Tab list. + /// + /// Consumes `header`. + /// Consumes `footer`. + pub fn setTabListHeaderFooter(self: Player, header: TextComponent, footer: TextComponent) void { + return abi.call(raw.@"[method]player.set-tab-list-header-footer", void, .{ abi.borrow(self), header, footer }); + } + + /// Sets the sorting order of the player in the Tab list. + pub fn setTabListOrder(self: Player, order: i32) void { + return abi.call(raw.@"[method]player.set-tab-list-order", void, .{ abi.borrow(self), order }); + } + + /// Sets the latency (ping) shown for the player in the Tab list. + pub fn setTabListLatency(self: Player, latency: i32) void { + return abi.call(raw.@"[method]player.set-tab-list-latency", void, .{ abi.borrow(self), latency }); + } + + /// Sets whether the player is visible in the Tab list. + pub fn setTabListListed(self: Player, listed: bool) void { + return abi.call(raw.@"[method]player.set-tab-list-listed", void, .{ abi.borrow(self), listed }); + } + + /// Shows a large title on the player's screen. + /// + /// Consumes `text_`. + pub fn showTitle(self: Player, text_: TextComponent) void { + return abi.call(raw.@"[method]player.show-title", void, .{ abi.borrow(self), text_ }); + } + + /// Shows a smaller subtitle on the player's screen. + /// + /// Consumes `text_`. + pub fn showSubtitle(self: Player, text_: TextComponent) void { + return abi.call(raw.@"[method]player.show-subtitle", void, .{ abi.borrow(self), text_ }); + } + + /// Shows a message in the action bar area. + /// + /// Consumes `text_`. + pub fn showActionbar(self: Player, text_: TextComponent) void { + return abi.call(raw.@"[method]player.show-actionbar", void, .{ abi.borrow(self), text_ }); + } + + /// Sets the fade-in, stay, and fade-out times for titles. + pub fn sendTitleAnimation(self: Player, fade_in: i32, stay: i32, fade_out: i32) void { + return abi.call(raw.@"[method]player.send-title-animation", void, .{ abi.borrow(self), fade_in, stay, fade_out }); + } + + /// Camera & Spectating + /// Sets the player's camera to view from the perspective of another entity. + /// If `entity` is `none`, the camera is reset back to the player. + pub fn setCamera(self: Player, entity: ?Entity) void { + return abi.call(raw.@"[method]player.set-camera", void, .{ abi.borrow(self), entity }); + } + + /// Sets the player's camera to view from the perspective of an entity with the given entity ID. + /// If `entity-id` is the player's own entity ID, the camera is reset back to the player. + pub fn setCameraEntityId(self: Player, entity_id: u32) void { + return abi.call(raw.@"[method]player.set-camera-entity-id", void, .{ abi.borrow(self), entity_id }); + } + + /// Gets the entity ID of the entity that the player's camera is currently attached to, + /// or the player's own entity ID if the camera has not been overridden. + pub fn getCameraEntityId(self: Player) u32 { + return abi.call(raw.@"[method]player.get-camera-entity-id", u32, .{abi.borrow(self)}); + } + + /// Resets the player's camera back to their own perspective. + pub fn resetCamera(self: Player) void { + return abi.call(raw.@"[method]player.reset-camera", void, .{abi.borrow(self)}); + } + + /// Audio & Particles + /// Plays a sound effect for this player at their current location. + pub fn playSound(self: Player, sound: Sound, category: SoundCategory, volume: f32, pitch: f32) void { + return abi.call(raw.@"[method]player.play-sound", void, .{ abi.borrow(self), sound, category, volume, pitch }); + } + + /// Plays a sound effect for this player at a specific location. + pub fn playSoundAt(self: Player, pos: Position, sound: Sound, category: SoundCategory, volume: f32, pitch: f32) void { + return abi.call(raw.@"[method]player.play-sound-at", void, .{ abi.borrow(self), pos, sound, category, volume, pitch }); + } + + /// Stops a sound effect from playing for this player. + pub fn stopSound(self: Player, sound: ?Sound, category: ?SoundCategory) void { + return abi.call(raw.@"[method]player.stop-sound", void, .{ abi.borrow(self), sound, category }); + } + + /// Plays a custom resource pack sound identifier for this player at their current location. + pub fn playCustomSound(self: Player, sound_name: []const u8, category: SoundCategory, volume: f32, pitch: f32) void { + return abi.call(raw.@"[method]player.play-custom-sound", void, .{ abi.borrow(self), sound_name, category, volume, pitch }); + } + + /// Plays a custom resource pack sound identifier for this player at a specific location. + pub fn playCustomSoundAt(self: Player, pos: Position, sound_name: []const u8, category: SoundCategory, volume: f32, pitch: f32) void { + return abi.call(raw.@"[method]player.play-custom-sound-at", void, .{ abi.borrow(self), pos, sound_name, category, volume, pitch }); + } + + /// Stops a custom sound identifier from playing for this player. + pub fn stopCustomSound(self: Player, sound_name: ?[]const u8, category: ?SoundCategory) void { + return abi.call(raw.@"[method]player.stop-custom-sound", void, .{ abi.borrow(self), sound_name, category }); + } + + /// Spawns particles visible only to this player. + pub fn spawnParticles(self: Player, particle: Particle, pos: Position, count: u32, offset: Position, max_speed: f32) void { + return abi.call(raw.@"[method]player.spawn-particles", void, .{ abi.borrow(self), particle, pos, count, offset, max_speed }); + } + + /// Visuals & Client Overrides + /// Sends a temporary fake block change to the player's client without modifying the server world. + pub fn sendBlockChange(self: Player, pos: BlockPos, block_id: u16) void { + return abi.call(raw.@"[method]player.send-block-change", void, .{ abi.borrow(self), pos, block_id }); + } + + /// Resets a temporary fake block change by resending the actual world block at that position. + pub fn resetBlockChange(self: Player, pos: BlockPos) void { + return abi.call(raw.@"[method]player.reset-block-change", void, .{ abi.borrow(self), pos }); + } + + /// Sends a hurt / damage-tilt animation to the player's client (causes screen shake in the given yaw direction). + pub fn sendHurtAnimation(self: Player, yaw: f32) void { + return abi.call(raw.@"[method]player.send-hurt-animation", void, .{ abi.borrow(self), yaw }); + } + + /// Opens a written book interface for the player from the specified hand. + pub fn openBook(self: Player, hand: Hand) void { + return abi.call(raw.@"[method]player.open-book", void, .{ abi.borrow(self), hand }); + } + + /// Forces the sign text editor to open for the player at the specified sign block position. + pub fn openSignEditor(self: Player, pos: BlockPos, is_front_text: bool) void { + return abi.call(raw.@"[method]player.open-sign-editor", void, .{ abi.borrow(self), pos, is_front_text }); + } + + /// Velocity & Physics + /// Sets the player's velocity / motion vector. + pub fn setVelocity(self: Player, velocity: Position) void { + return abi.call(raw.@"[method]player.set-velocity", void, .{ abi.borrow(self), velocity }); + } + + /// Applies directional knockback impulse to the player. + pub fn applyKnockback(self: Player, strength: f64, x: f64, z: f64) void { + return abi.call(raw.@"[method]player.apply-knockback", void, .{ abi.borrow(self), strength, x, z }); + } + + /// Movement Lock & Freezing + /// Sets whether the player's movement is locked (frozen in place) for cutscenes and NPC dialogues. + pub fn setMovementLocked(self: Player, locked: bool) void { + return abi.call(raw.@"[method]player.set-movement-locked", void, .{ abi.borrow(self), locked }); + } + + /// Returns whether the player's movement is currently locked. + pub fn isMovementLocked(self: Player) bool { + return abi.call(raw.@"[method]player.is-movement-locked", bool, .{abi.borrow(self)}); + } + + /// Sets the number of freeze ticks on the player (controlling the powdered snow / frostbite screen vignette). + pub fn setFreezeTicks(self: Player, ticks: i32) void { + return abi.call(raw.@"[method]player.set-freeze-ticks", void, .{ abi.borrow(self), ticks }); + } + + /// Returns the current number of freeze ticks on the player. + pub fn getFreezeTicks(self: Player) i32 { + return abi.call(raw.@"[method]player.get-freeze-ticks", i32, .{abi.borrow(self)}); + } + + /// Sends custom server links to the player (displayed in the client Esc pause menu in 1.21+). + pub fn setServerLinks(self: Player, links: []const ServerLink) void { + return abi.call(raw.@"[method]player.set-server-links", void, .{ abi.borrow(self), links }); + } + + /// Teleport & kick + /// Teleports the player to a position in a world. + /// + /// Consumes `world_`. + pub fn teleport(self: Player, position: Position, yaw: ?f32, pitch: ?f32, world_: World) void { + return abi.call(raw.@"[method]player.teleport", void, .{ abi.borrow(self), position, yaw, pitch, world_ }); + } + + /// Teleports the player to another world at a specific position. + /// + /// Consumes `world_ref`. + pub fn teleportWorld(self: Player, world_ref: World, position: Position, yaw: ?f32, pitch: ?f32) void { + return abi.call(raw.@"[method]player.teleport-world", void, .{ abi.borrow(self), world_ref, position, yaw, pitch }); + } + + /// Forces the player to respawn. + pub fn respawn(self: Player) void { + return abi.call(raw.@"[method]player.respawn", void, .{abi.borrow(self)}); + } + + /// Opens a GUI for the player. + /// + /// Consumes `gui_ref`. + pub fn openGui(self: Player, gui_ref: Gui) void { + return abi.call(raw.@"[method]player.open-gui", void, .{ abi.borrow(self), gui_ref }); + } + + /// Bans the player with the specified options. + pub fn ban(self: Player, options: BanPlayerOptions) void { + return abi.call(raw.@"[method]player.ban", void, .{ abi.borrow(self), options }); + } + + /// Bans the player's IP address with the specified options. + pub fn banIp(self: Player, options: BanIpOptions) void { + return abi.call(raw.@"[method]player.ban-ip", void, .{ abi.borrow(self), options }); + } + + /// Transfers the player to another server. + pub fn transfer(self: Player, host: []const u8, port: u16) void { + return abi.call(raw.@"[method]player.transfer", void, .{ abi.borrow(self), host, port }); + } + + /// Status Effects + /// Gives a status effect to the player. + pub fn addEffect(self: Player, effect: StatusEffectInstance) void { + return abi.call(raw.@"[method]player.add-effect", void, .{ abi.borrow(self), effect }); + } + + /// Removes a status effect from the player. + pub fn removeEffect(self: Player, effect: StatusEffectType) void { + return abi.call(raw.@"[method]player.remove-effect", void, .{ abi.borrow(self), effect }); + } + + /// Clears all active status effects from the player. + pub fn clearEffects(self: Player) void { + return abi.call(raw.@"[method]player.clear-effects", void, .{abi.borrow(self)}); + } + + /// Checks if a status effect is currently applied to the player. + pub fn hasEffect(self: Player, effect: StatusEffectType) bool { + return abi.call(raw.@"[method]player.has-effect", bool, .{ abi.borrow(self), effect }); + } + + /// Returns the status effect instance applied to the player, if any. + pub fn getEffect(self: Player, effect: StatusEffectType) ?StatusEffectInstance { + return abi.call(raw.@"[method]player.get-effect", ?StatusEffectInstance, .{ abi.borrow(self), effect }); + } + + /// Returns all status effects currently applied to the player. + pub fn getActiveEffects(self: Player) []const StatusEffectInstance { + return abi.call(raw.@"[method]player.get-active-effects", []const StatusEffectInstance, .{abi.borrow(self)}); + } + + /// Health & Damage + /// Heals the player by a specified amount. + pub fn heal(self: Player, amount: f32) void { + return abi.call(raw.@"[method]player.heal", void, .{ abi.borrow(self), amount }); + } + + /// Deals damage to the player by a specified amount with a damage type. + pub fn damage(self: Player, amount: f32, damage_type: DamageType) void { + return abi.call(raw.@"[method]player.damage", void, .{ abi.borrow(self), amount, damage_type }); + } + + /// Kills the player instantly. + pub fn kill(self: Player) void { + return abi.call(raw.@"[method]player.kill", void, .{abi.borrow(self)}); + } + + /// Statistics + /// Gets the value of a statistic for this player in the given category and ID. + pub fn getStatistic(self: Player, category: StatisticCategory, stat_id: i32) i32 { + return abi.call(raw.@"[method]player.get-statistic", i32, .{ abi.borrow(self), category, stat_id }); + } + + /// Sets the value of a statistic for this player in the given category and ID. + pub fn setStatistic(self: Player, category: StatisticCategory, stat_id: i32, value: i32) void { + return abi.call(raw.@"[method]player.set-statistic", void, .{ abi.borrow(self), category, stat_id, value }); + } + + /// Increments the value of a statistic for this player in the given category and ID. + pub fn incrementStatistic(self: Player, category: StatisticCategory, stat_id: i32, amount: i32) void { + return abi.call(raw.@"[method]player.increment-statistic", void, .{ abi.borrow(self), category, stat_id, amount }); + } + + /// Gets the value of a custom statistic for this player. + pub fn getCustomStatistic(self: Player, stat: CustomStatistic) i32 { + return abi.call(raw.@"[method]player.get-custom-statistic", i32, .{ abi.borrow(self), stat }); + } + + /// Sets the value of a custom statistic for this player. + pub fn setCustomStatistic(self: Player, stat: CustomStatistic, value: i32) void { + return abi.call(raw.@"[method]player.set-custom-statistic", void, .{ abi.borrow(self), stat, value }); + } + + /// Increments the value of a custom statistic for this player. + pub fn incrementCustomStatistic(self: Player, stat: CustomStatistic, amount: i32) void { + return abi.call(raw.@"[method]player.increment-custom-statistic", void, .{ abi.borrow(self), stat, amount }); + } + + /// Sends the player's updated statistics packet to the client. + pub fn sendStats(self: Player) void { + return abi.call(raw.@"[method]player.send-stats", void, .{abi.borrow(self)}); + } + + /// Gets the team name that this player belongs to on their active scoreboard, if any. + pub fn getTeam(self: Player) ?[]const u8 { + return abi.call(raw.@"[method]player.get-team", ?[]const u8, .{abi.borrow(self)}); + } + + /// Cooldowns + /// Starts an item cooldown for a specific item group name. + pub fn startCooldown(self: Player, group: []const u8, duration_ticks: i32) void { + return abi.call(raw.@"[method]player.start-cooldown", void, .{ abi.borrow(self), group, duration_ticks }); + } + + /// Returns the cooldown progress (0.0 to 1.0) for a specific item group. + pub fn getCooldown(self: Player, group: []const u8) f32 { + return abi.call(raw.@"[method]player.get-cooldown", f32, .{ abi.borrow(self), group }); + } + + /// Checks if a specific item group is currently on cooldown. + pub fn isOnCooldown(self: Player, group: []const u8) bool { + return abi.call(raw.@"[method]player.is-on-cooldown", bool, .{ abi.borrow(self), group }); + } + + /// Abilities & Flight + /// Sets whether the player is allowed to fly. + pub fn setAllowFlight(self: Player, allowed: bool) void { + return abi.call(raw.@"[method]player.set-allow-flight", void, .{ abi.borrow(self), allowed }); + } + + /// Sets the player's flying speed. + pub fn setFlySpeed(self: Player, speed: f32) void { + return abi.call(raw.@"[method]player.set-fly-speed", void, .{ abi.borrow(self), speed }); + } + + /// Sets the player's walking speed. + pub fn setWalkSpeed(self: Player, speed: f32) void { + return abi.call(raw.@"[method]player.set-walk-speed", void, .{ abi.borrow(self), speed }); + } + + /// Sets whether the player is invulnerable to damage. + pub fn setInvulnerable(self: Player, invulnerable: bool) void { + return abi.call(raw.@"[method]player.set-invulnerable", void, .{ abi.borrow(self), invulnerable }); + } + + /// Inventory + /// Returns the player's inventory handle for managing main storage, armor, and equipment. + pub fn getInventory(self: Player) PlayerInventory { + return abi.call(raw.@"[method]player.get-inventory", PlayerInventory, .{abi.borrow(self)}); + } + + /// Returns the player's ender chest inventory handle. + pub fn getEnderChest(self: Player) Inventory { + return abi.call(raw.@"[method]player.get-ender-chest", Inventory, .{abi.borrow(self)}); + } + + /// Returns the index of the currently selected hotbar slot (0-8). + pub fn getSelectedSlot(self: Player) u8 { + return abi.call(raw.@"[method]player.get-selected-slot", u8, .{abi.borrow(self)}); + } + + /// Returns the item currently in the specified hand. + pub fn getItemInHand(self: Player, hand: Hand) ?ItemStack { + return abi.call(raw.@"[method]player.get-item-in-hand", ?ItemStack, .{ abi.borrow(self), hand }); + } + + /// Returns the item in the specified inventory slot. + pub fn getInventoryItem(self: Player, slot: u8) ?ItemStack { + return abi.call(raw.@"[method]player.get-inventory-item", ?ItemStack, .{ abi.borrow(self), slot }); + } + + /// Sets the item in the specified hand. + pub fn setItemInHand(self: Player, hand: Hand, stack: ?ItemStack) void { + return abi.call(raw.@"[method]player.set-item-in-hand", void, .{ abi.borrow(self), hand, stack }); + } + + /// Sets the item in the specified inventory slot. + pub fn setInventoryItem(self: Player, slot: u8, stack: ?ItemStack) void { + return abi.call(raw.@"[method]player.set-inventory-item", void, .{ abi.borrow(self), slot, stack }); + } + + /// Ender Chest Inventory + /// Returns the item in the specified ender chest slot (0-26). + pub fn getEnderChestItem(self: Player, slot: u8) ?ItemStack { + return abi.call(raw.@"[method]player.get-ender-chest-item", ?ItemStack, .{ abi.borrow(self), slot }); + } + + /// Sets the item in the specified ender chest slot (0-26). + pub fn setEnderChestItem(self: Player, slot: u8, stack: ?ItemStack) void { + return abi.call(raw.@"[method]player.set-ender-chest-item", void, .{ abi.borrow(self), slot, stack }); + } + + /// Clears all items from the player's ender chest. + pub fn clearEnderChest(self: Player) void { + return abi.call(raw.@"[method]player.clear-ender-chest", void, .{abi.borrow(self)}); + } + + /// Opens the player's ender chest inventory screen for them. + pub fn openEnderChest(self: Player) void { + return abi.call(raw.@"[method]player.open-ender-chest", void, .{abi.borrow(self)}); + } + + /// Status + /// Returns the player's current health. + pub fn getHealth(self: Player) f32 { + return abi.call(raw.@"[method]player.get-health", f32, .{abi.borrow(self)}); + } + + /// Sets the player's current health. + pub fn setHealth(self: Player, health: f32) void { + return abi.call(raw.@"[method]player.set-health", void, .{ abi.borrow(self), health }); + } + + /// Returns the player's maximum health. + pub fn getMaxHealth(self: Player) f32 { + return abi.call(raw.@"[method]player.get-max-health", f32, .{abi.borrow(self)}); + } + + /// Sets the player's maximum health. + pub fn setMaxHealth(self: Player, max_health: f32) void { + return abi.call(raw.@"[method]player.set-max-health", void, .{ abi.borrow(self), max_health }); + } + + /// Returns the player's food level (0-20). + pub fn getFoodLevel(self: Player) u8 { + return abi.call(raw.@"[method]player.get-food-level", u8, .{abi.borrow(self)}); + } + + /// Sets the player's food level. + pub fn setFoodLevel(self: Player, food_level: u8) void { + return abi.call(raw.@"[method]player.set-food-level", void, .{ abi.borrow(self), food_level }); + } + + /// Returns the player's food saturation level. + pub fn getSaturation(self: Player) f32 { + return abi.call(raw.@"[method]player.get-saturation", f32, .{abi.borrow(self)}); + } + + /// Sets the player's food saturation level. + pub fn setSaturation(self: Player, saturation: f32) void { + return abi.call(raw.@"[method]player.set-saturation", void, .{ abi.borrow(self), saturation }); + } + + /// Returns the player's food exhaustion level. + pub fn getExhaustion(self: Player) f32 { + return abi.call(raw.@"[method]player.get-exhaustion", f32, .{abi.borrow(self)}); + } + + /// Sets the player's food exhaustion level. + pub fn setExhaustion(self: Player, exhaustion: f32) void { + return abi.call(raw.@"[method]player.set-exhaustion", void, .{ abi.borrow(self), exhaustion }); + } + + /// Returns the player's current absorption amount. + pub fn getAbsorption(self: Player) f32 { + return abi.call(raw.@"[method]player.get-absorption", f32, .{abi.borrow(self)}); + } + + /// Sets the player's current absorption amount. + pub fn setAbsorption(self: Player, absorption: f32) void { + return abi.call(raw.@"[method]player.set-absorption", void, .{ abi.borrow(self), absorption }); + } + + /// Returns the player's total experience level. + pub fn getExperienceLevel(self: Player) i32 { + return abi.call(raw.@"[method]player.get-experience-level", i32, .{abi.borrow(self)}); + } + + /// Returns the player's progress toward the next level (0.0 to 1.0). + pub fn getExperienceProgress(self: Player) f32 { + return abi.call(raw.@"[method]player.get-experience-progress", f32, .{abi.borrow(self)}); + } + + /// Returns the total experience points the player has. + pub fn getExperiencePoints(self: Player) i32 { + return abi.call(raw.@"[method]player.get-experience-points", i32, .{abi.borrow(self)}); + } + + /// Sets the player's total experience level. + pub fn setExperienceLevel(self: Player, level: i32) void { + return abi.call(raw.@"[method]player.set-experience-level", void, .{ abi.borrow(self), level }); + } + + /// Sets the player's progress toward the next level. + pub fn setExperienceProgress(self: Player, progress: f32) void { + return abi.call(raw.@"[method]player.set-experience-progress", void, .{ abi.borrow(self), progress }); + } + + /// Sets the player's total experience points. + pub fn setExperiencePoints(self: Player, points: i32) void { + return abi.call(raw.@"[method]player.set-experience-points", void, .{ abi.borrow(self), points }); + } + + /// Adds experience levels to the player. + pub fn addExperienceLevels(self: Player, levels: i32) void { + return abi.call(raw.@"[method]player.add-experience-levels", void, .{ abi.borrow(self), levels }); + } + + /// Adds experience points to the player. + pub fn addExperiencePoints(self: Player, points: i32) void { + return abi.call(raw.@"[method]player.add-experience-points", void, .{ abi.borrow(self), points }); + } + + /// Returns whether the player is currently flying. + pub fn isFlying(self: Player) bool { + return abi.call(raw.@"[method]player.is-flying", bool, .{abi.borrow(self)}); + } + + /// Sets whether the player should be flying. + pub fn setFlying(self: Player, flying: bool) void { + return abi.call(raw.@"[method]player.set-flying", void, .{ abi.borrow(self), flying }); + } + + /// Returns the player's current abilities. + pub fn getAbilities(self: Player) PlayerAbilities { + return abi.call(raw.@"[method]player.get-abilities", PlayerAbilities, .{abi.borrow(self)}); + } + + /// Updates the player's abilities. + pub fn setAbilities(self: Player, abilities: PlayerAbilities) void { + return abi.call(raw.@"[method]player.set-abilities", void, .{ abi.borrow(self), abilities }); + } + + /// Returns the player's IP address. + pub fn getIp(self: Player) []const u8 { + return abi.call(raw.@"[method]player.get-ip", []const u8, .{abi.borrow(self)}); + } + + /// Returns the player's current skin textures. + pub fn getSkin(self: Player) ?PlayerSkin { + return abi.call(raw.@"[method]player.get-skin", ?PlayerSkin, .{abi.borrow(self)}); + } + + /// Updates the player's skin textures. + /// Note: this only updates the fields, it doesn't reload the skin. + pub fn setSkin(self: Player, skin: PlayerSkin) void { + return abi.call(raw.@"[method]player.set-skin", void, .{ abi.borrow(self), skin }); + } + + /// Returns which skin parts are visible. + pub fn getSkinParts(self: Player) SkinParts { + return abi.call(raw.@"[method]player.get-skin-parts", SkinParts, .{abi.borrow(self)}); + } + + /// Sets which skin parts are visible. + pub fn setSkinParts(self: Player, parts: SkinParts) void { + return abi.call(raw.@"[method]player.set-skin-parts", void, .{ abi.borrow(self), parts }); + } + + /// Per-Player Environment & Overrides + /// Overrides the time of day shown to this player. + pub fn setPlayerTime(self: Player, time: u64, relative: bool) void { + return abi.call(raw.@"[method]player.set-player-time", void, .{ abi.borrow(self), time, relative }); + } + + /// Resets the player's time to sync with the server world time. + pub fn resetPlayerTime(self: Player) void { + return abi.call(raw.@"[method]player.reset-player-time", void, .{abi.borrow(self)}); + } + + /// Returns the custom time set for this player, if any. + pub fn getPlayerTime(self: Player) ?u64 { + return abi.call(raw.@"[method]player.get-player-time", ?u64, .{abi.borrow(self)}); + } + + /// Checks if the custom player time is relative to the world time. + pub fn isPlayerTimeRelative(self: Player) bool { + return abi.call(raw.@"[method]player.is-player-time-relative", bool, .{abi.borrow(self)}); + } + + /// Overrides the weather condition shown to this player. + pub fn setPlayerWeather(self: Player, weather: PlayerWeather) void { + return abi.call(raw.@"[method]player.set-player-weather", void, .{ abi.borrow(self), weather }); + } + + /// Resets the player's weather to match the server world weather. + pub fn resetPlayerWeather(self: Player) void { + return abi.call(raw.@"[method]player.reset-player-weather", void, .{abi.borrow(self)}); + } + + /// Returns the custom weather set for this player, if any. + pub fn getPlayerWeather(self: Player) ?PlayerWeather { + return abi.call(raw.@"[method]player.get-player-weather", ?PlayerWeather, .{abi.borrow(self)}); + } + + /// Sets the position where the player's compass points. + pub fn setCompassTarget(self: Player, pos: Position) void { + return abi.call(raw.@"[method]player.set-compass-target", void, .{ abi.borrow(self), pos }); + } + + /// Returns the position where the player's compass currently points. + pub fn getCompassTarget(self: Player) Position { + return abi.call(raw.@"[method]player.get-compass-target", Position, .{abi.borrow(self)}); + } + + /// Sets the player's custom respawn / bed location. + pub fn setRespawnLocation(self: Player, pos: Position) void { + return abi.call(raw.@"[method]player.set-respawn-location", void, .{ abi.borrow(self), pos }); + } + + /// Returns the player's custom respawn / bed location, if set. + pub fn getRespawnLocation(self: Player) ?Position { + return abi.call(raw.@"[method]player.get-respawn-location", ?Position, .{abi.borrow(self)}); + } + + /// Hides another player from this player's view (vanish). + /// + /// Consumes `other`. + pub fn hidePlayer(self: Player, other: Player) void { + return abi.call(raw.@"[method]player.hide-player", void, .{ abi.borrow(self), other }); + } + + /// Shows a previously hidden player to this player. + /// + /// Consumes `other`. + pub fn showPlayer(self: Player, other: Player) void { + return abi.call(raw.@"[method]player.show-player", void, .{ abi.borrow(self), other }); + } + + /// Checks if this player can see another specified player. + /// + /// Consumes `other`. + pub fn canSee(self: Player, other: Player) bool { + return abi.call(raw.@"[method]player.can-see", bool, .{ abi.borrow(self), other }); + } + + /// Checks if this player can see another specified player. + /// + /// Consumes `other`. + pub fn canSeePlayer(self: Player, other: Player) bool { + return abi.call(raw.@"[method]player.can-see-player", bool, .{ abi.borrow(self), other }); + } + + /// Sets the tab list ping / latency indicator in milliseconds. + pub fn setTabListPing(self: Player, latency_ms: i32) void { + return abi.call(raw.@"[method]player.set-tab-list-ping", void, .{ abi.borrow(self), latency_ms }); + } + + /// Sets a client-side item cooldown overlay. + pub fn setItemCooldown(self: Player, item_id: []const u8, ticks: i32) void { + return abi.call(raw.@"[method]player.set-item-cooldown", void, .{ abi.borrow(self), item_id, ticks }); + } + + /// Returns the remaining cooldown ticks for an item, if active. + pub fn getItemCooldown(self: Player, item_id: []const u8) ?i32 { + return abi.call(raw.@"[method]player.get-item-cooldown", ?i32, .{ abi.borrow(self), item_id }); + } + + /// Checks if an item is currently on cooldown. + pub fn hasItemCooldown(self: Player, item_id: []const u8) bool { + return abi.call(raw.@"[method]player.has-item-cooldown", bool, .{ abi.borrow(self), item_id }); + } + + /// Performs a ray-trace from the player's eye position in looking direction to find the targeted block. + pub fn rayTraceBlock(self: Player, max_distance: f64, include_fluids: bool) ?RayTraceBlockResult { + return abi.call(raw.@"[method]player.ray-trace-block", ?RayTraceBlockResult, .{ abi.borrow(self), max_distance, include_fluids }); + } + + /// Performs a ray-trace from the player's eye position in looking direction to find the targeted entity. + pub fn rayTraceEntity(self: Player, max_distance: f64) ?RayTraceEntityResult { + return abi.call(raw.@"[method]player.ray-trace-entity", ?RayTraceEntityResult, .{ abi.borrow(self), max_distance }); + } + + /// Returns the entity currently targeted in the looking direction within the specified distance. + pub fn getTargetEntity(self: Player, max_distance: f64) ?Entity { + return abi.call(raw.@"[method]player.get-target-entity", ?Entity, .{ abi.borrow(self), max_distance }); + } + + /// Raycasts from the player's eyes to find the block being targeted. + pub fn getTargetBlock(self: Player, max_distance: u32) ?Position { + return abi.call(raw.@"[method]player.get-target-block", ?Position, .{ abi.borrow(self), max_distance }); + } + + /// Performs a raycast from the player's eyes to find the exact block and face being targeted. + pub fn getTargetBlockExact(self: Player, max_distance: f64, include_fluids: bool) ?RayTraceBlockResult { + return abi.call(raw.@"[method]player.get-target-block-exact", ?RayTraceBlockResult, .{ abi.borrow(self), max_distance, include_fluids }); + } + + /// Launches a projectile from the player's eyes in their line of sight. + pub fn launchProjectile(self: Player, @"type": ProjectileType) ?Entity { + return abi.call(raw.@"[method]player.launch-projectile", ?Entity, .{ abi.borrow(self), @"type" }); + } + + /// Advancements + /// Returns the progress of the specified advancement for this player, if the advancement exists. + pub fn getAdvancementProgress(self: Player, advancement_id: []const u8) ?AdvancementProgress { + return abi.call(raw.@"[method]player.get-advancement-progress", ?AdvancementProgress, .{ abi.borrow(self), advancement_id }); + } + + /// Awards a specific criterion of an advancement to the player. + /// Returns true if the criterion was successfully awarded (was not already completed). + pub fn awardAdvancementCriterion(self: Player, advancement_id: []const u8, criterion: []const u8) bool { + return abi.call(raw.@"[method]player.award-advancement-criterion", bool, .{ abi.borrow(self), advancement_id, criterion }); + } + + /// Revokes a specific criterion of an advancement from the player. + /// Returns true if the criterion was successfully revoked (was previously completed). + pub fn revokeAdvancementCriterion(self: Player, advancement_id: []const u8, criterion: []const u8) bool { + return abi.call(raw.@"[method]player.revoke-advancement-criterion", bool, .{ abi.borrow(self), advancement_id, criterion }); + } + + /// Awards all criteria of the specified advancement to the player. + /// Returns true if any criterion was newly awarded. + pub fn awardAdvancement(self: Player, advancement_id: []const u8) bool { + return abi.call(raw.@"[method]player.award-advancement", bool, .{ abi.borrow(self), advancement_id }); + } + + /// Revokes all criteria of the specified advancement from the player. + /// Returns true if any criterion was newly revoked. + pub fn revokeAdvancement(self: Player, advancement_id: []const u8) bool { + return abi.call(raw.@"[method]player.revoke-advancement", bool, .{ abi.borrow(self), advancement_id }); + } + + /// Checks whether the player has completed the specified advancement. + pub fn hasAdvancement(self: Player, advancement_id: []const u8) bool { + return abi.call(raw.@"[method]player.has-advancement", bool, .{ abi.borrow(self), advancement_id }); + } + + /// Returns a list of all advancement IDs completed by this player. + pub fn getCompletedAdvancements(self: Player) []const []const u8 { + return abi.call(raw.@"[method]player.get-completed-advancements", []const []const u8, .{abi.borrow(self)}); + } + + /// Returns the ID of the currently selected advancement tab for this player, if any. + pub fn getSelectedAdvancementTab(self: Player) ?[]const u8 { + return abi.call(raw.@"[method]player.get-selected-advancement-tab", ?[]const u8, .{abi.borrow(self)}); + } + + /// Sets the selected advancement tab for this player (must be a root advancement ID). + pub fn setSelectedAdvancementTab(self: Player, tab_id: ?[]const u8) void { + return abi.call(raw.@"[method]player.set-selected-advancement-tab", void, .{ abi.borrow(self), tab_id }); + } + + /// Returns a Java-specific player handle, if the player is connected via Java Edition. + /// + /// This allows access to Java-exclusive features like sending specific packets + /// or retrieving the client brand. + pub fn asJava(self: Player) ?JavaPlayer { + return abi.call(raw.@"[method]player.as-java", ?JavaPlayer, .{abi.borrow(self)}); + } + + /// Returns a Bedrock-specific player handle, if the player is connected via Bedrock Edition. + /// + /// This allows access to Bedrock-exclusive features like custom forms + /// or detailed device information. + pub fn asBedrock(self: Player) ?BedrockPlayer { + return abi.call(raw.@"[method]player.as-bedrock", ?BedrockPlayer, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: Player) void { + abi.keep(Player, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: Player) void { + abi.drop(Player, self); + } +}; + +/// Represents a resource pack sent to a Java Edition player. +pub const JavaResourcePack = struct { + /// Unique identifier for the resource pack. + id: Uuid, + /// The URL to the resource pack file. + url: []const u8, + /// The SHA1 hash (40-character hex string) of the pack. + hash: []const u8, + /// Whether the player is forced to accept the pack. + forced: bool, + /// Optional prompt message displayed in the pack acceptance screen. + prompt_message: ?TextComponent, +}; + +/// Represents an individual Bedrock Edition resource pack entry. +pub const BedrockResourcePackEntry = struct { + /// Unique identifier for the Bedrock pack. + id: Uuid, + /// Version string of the Bedrock pack (e.g., "1.0.0"). + version: []const u8, + /// Size of the pack in bytes. + size: u64, + /// Download URL for remote Bedrock packs. + download_url: []const u8, + /// Optional encryption content key for encrypted packs. + content_key: ?[]const u8, + /// Optional sub-pack name inside the archive. + sub_pack_name: ?[]const u8, + /// Optional content identifier. + content_id: ?[]const u8, + /// Whether the pack contains client scripts. + has_scripts: bool, + /// Whether the pack is marked as an addon pack. + addon_pack: bool, + /// Whether Ray Tracing / RTX features are enabled for the pack. + rtx_enabled: bool, +}; + +/// Represents the resource packs information payload sent to Bedrock clients. +pub const BedrockResourcePacksInfo = struct { + /// If true, players cannot join without accepting packs. + required: bool, + /// Whether the server offers addon packs. + has_addon_packs: bool, + /// Whether any of the packs contain client scripts. + has_scripts: bool, + /// Whether vibrant visuals should be forced disabled. + is_vibrant_visuals_force_disabled: bool, + /// World template ID, if any. + world_template_id: ?Uuid, + /// World template version, if any. + world_template_version: ?[]const u8, + /// List of resource packs to send to the player. + packs: []const BedrockResourcePackEntry, +}; + +/// A handle to a player connected via the Java Edition. +pub const JavaPlayer = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]java-player"; + + /// Returns the Minecraft Java Edition version of the player. + pub fn getVersion(self: JavaPlayer) JavaMinecraftVersion { + return abi.call(raw.@"[method]java-player.get-version", JavaMinecraftVersion, .{abi.borrow(self)}); + } + + /// Returns the brand of the player's client (e.g., \"vanilla\", \"fabric\"). + pub fn getBrand(self: JavaPlayer) []const u8 { + return abi.call(raw.@"[method]java-player.get-brand", []const u8, .{abi.borrow(self)}); + } + + /// Returns the server address the player used to connect. + pub fn getServerAddress(self: JavaPlayer) []const u8 { + return abi.call(raw.@"[method]java-player.get-server-address", []const u8, .{abi.borrow(self)}); + } + + /// Returns the player's configuration settings. + pub fn getSettings(self: JavaPlayer) JavaPlayerSettings { + return abi.call(raw.@"[method]java-player.get-settings", JavaPlayerSettings, .{abi.borrow(self)}); + } + + /// Sends a Java-specific clientbound packet to the player. + pub fn sendPacket(self: JavaPlayer, packet: JavaPacket) void { + return abi.call(raw.@"[method]java-player.send-packet", void, .{ abi.borrow(self), packet }); + } + + /// Sends a custom payload packet (plugin message) to the player. + pub fn sendCustomPayload(self: JavaPlayer, channel: []const u8, data: []const u8) void { + return abi.call(raw.@"[method]java-player.send-custom-payload", void, .{ abi.borrow(self), channel, data }); + } + + /// Shows a dialog to the player. + pub fn showDialog(self: JavaPlayer, dialog: Dialog) void { + return abi.call(raw.@"[method]java-player.show-dialog", void, .{ abi.borrow(self), dialog }); + } + + /// Clears any currently shown dialog for the player. + pub fn clearDialog(self: JavaPlayer) void { + return abi.call(raw.@"[method]java-player.clear-dialog", void, .{abi.borrow(self)}); + } + + /// Returns the Java scoreboard handle for this player. + pub fn getScoreboard(self: JavaPlayer) Scoreboard { + return abi.call(raw.@"[method]java-player.get-scoreboard", Scoreboard, .{abi.borrow(self)}); + } + + /// Resets the player's custom Java scoreboard back to the world scoreboard. + pub fn resetScoreboard(self: JavaPlayer) void { + return abi.call(raw.@"[method]java-player.reset-scoreboard", void, .{abi.borrow(self)}); + } + + /// Sends a resource pack to the Java player. + pub fn sendResourcePack(self: JavaPlayer, pack: JavaResourcePack) void { + return abi.call(raw.@"[method]java-player.send-resource-pack", void, .{ abi.borrow(self), pack }); + } + + /// Removes a specific resource pack by UUID for the Java player. + pub fn removeResourcePack(self: JavaPlayer, id: Uuid) void { + return abi.call(raw.@"[method]java-player.remove-resource-pack", void, .{ abi.borrow(self), id }); + } + + /// Clears all custom resource packs for the Java player. + pub fn clearResourcePacks(self: JavaPlayer) void { + return abi.call(raw.@"[method]java-player.clear-resource-packs", void, .{abi.borrow(self)}); + } + + /// Kicks the Java player with the specified options. + pub fn kick(self: JavaPlayer, options: JavaKickOptions) void { + return abi.call(raw.@"[method]java-player.kick", void, .{ abi.borrow(self), options }); + } + + /// Sends a clientbound GameEvent packet to the Java player. + pub fn sendGameEvent(self: JavaPlayer, event: ClientGameEvent, value: f32) void { + return abi.call(raw.@"[method]java-player.send-game-event", void, .{ abi.borrow(self), event, value }); + } + + /// Sends an entity status / animation event packet to the Java player for a specific entity ID. + pub fn sendEntityStatus(self: JavaPlayer, entity_id: i32, status: EntityStatus) void { + return abi.call(raw.@"[method]java-player.send-entity-status", void, .{ abi.borrow(self), entity_id, status }); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: JavaPlayer) void { + abi.keep(JavaPlayer, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: JavaPlayer) void { + abi.drop(JavaPlayer, self); + } +}; + +/// A handle to a player connected via the Bedrock Edition. +pub const BedrockPlayer = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]bedrock-player"; + + /// Returns the Minecraft Bedrock Edition version of the player. + pub fn getVersion(self: BedrockPlayer) BedrockMinecraftVersion { + return abi.call(raw.@"[method]bedrock-player.get-version", BedrockMinecraftVersion, .{abi.borrow(self)}); + } + + /// Returns the player's configuration settings. + pub fn getSettings(self: BedrockPlayer) BedrockPlayerSettings { + return abi.call(raw.@"[method]bedrock-player.get-settings", BedrockPlayerSettings, .{abi.borrow(self)}); + } + + /// Returns whether a specific Bedrock-only ability is enabled for the player. + pub fn getAbility(self: BedrockPlayer, ability: BedrockAbility) bool { + return abi.call(raw.@"[method]bedrock-player.get-ability", bool, .{ abi.borrow(self), ability }); + } + + /// Sets whether a specific Bedrock-only ability is enabled for the player. + pub fn setAbility(self: BedrockPlayer, ability: BedrockAbility, value: bool) void { + return abi.call(raw.@"[method]bedrock-player.set-ability", void, .{ abi.borrow(self), ability, value }); + } + + /// Returns whether a specific Bedrock-only status flag is enabled for the player. + /// + /// Status flags control things like whether the player is on fire, sneaking, + /// sprinting, or has specific visual effects. + pub fn getStatusFlag(self: BedrockPlayer, flag: BedrockStatusFlag) bool { + return abi.call(raw.@"[method]bedrock-player.get-status-flag", bool, .{ abi.borrow(self), flag }); + } + + /// Sets whether a specific Bedrock-only status flag is enabled for the player. + /// + /// This can be used to manually trigger client-side visual states. + pub fn setStatusFlag(self: BedrockPlayer, flag: BedrockStatusFlag, value: bool) void { + return abi.call(raw.@"[method]bedrock-player.set-status-flag", void, .{ abi.borrow(self), flag, value }); + } + + /// Sends a Bedrock-specific clientbound packet to the player. + pub fn sendPacket(self: BedrockPlayer, packet: BedrockPacket) void { + return abi.call(raw.@"[method]bedrock-player.send-packet", void, .{ abi.borrow(self), packet }); + } + + /// Opens a Bedrock custom form for the player. + pub fn openForm(self: BedrockPlayer, form: Form) u32 { + return abi.call(raw.@"[method]bedrock-player.open-form", u32, .{ abi.borrow(self), form }); + } + + /// Returns the Bedrock scoreboard handle for this player. + pub fn getScoreboard(self: BedrockPlayer) BedrockScoreboard { + return abi.call(raw.@"[method]bedrock-player.get-scoreboard", BedrockScoreboard, .{abi.borrow(self)}); + } + + /// Resets the player's custom Bedrock scoreboard back to the world scoreboard. + pub fn resetScoreboard(self: BedrockPlayer) void { + return abi.call(raw.@"[method]bedrock-player.reset-scoreboard", void, .{abi.borrow(self)}); + } + + /// Sends resource packs information to the Bedrock player. + pub fn sendResourcePacksInfo(self: BedrockPlayer, info: BedrockResourcePacksInfo) void { + return abi.call(raw.@"[method]bedrock-player.send-resource-packs-info", void, .{ abi.borrow(self), info }); + } + + /// Kicks the Bedrock player with the specified options. + pub fn kick(self: BedrockPlayer, options: BedrockKickOptions) void { + return abi.call(raw.@"[method]bedrock-player.kick", void, .{ abi.borrow(self), options }); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: BedrockPlayer) void { + abi.keep(BedrockPlayer, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: BedrockPlayer) void { + abi.drop(BedrockPlayer, self); + } +}; + +/// Returns a list of all players in a specific world. +/// +/// Consumes `world_ref`. +pub fn getWorldPlayers(world_ref: World) []const Player { + return abi.call(raw.@"get-world-players", []const Player, .{world_ref}); +} + +const raw = struct { + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.as-entity"(i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-id"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-name"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-position"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-yaw"(i32) f32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-pitch"(i32) f32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-world"(i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-gamemode"(i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-gamemode"(i32, i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-locale"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-ping"(i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-permission-level"(i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-permission-level"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-permission"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.unset-permission"(i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.has-permission-set"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.has-permission"(i32, i32, i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-display-name"(i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-display-name"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-tab-list-name"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-tab-list-name"(i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.send-system-message"(i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.delete-message-by-signature"(i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.delete-message-by-id"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-tab-list-header-footer"(i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-tab-list-order"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-tab-list-latency"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-tab-list-listed"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.show-title"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.show-subtitle"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.show-actionbar"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.send-title-animation"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-camera"(i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-camera-entity-id"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-camera-entity-id"(i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.reset-camera"(i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.play-sound"(i32, i32, i32, f32, f32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.play-sound-at"(i32, f64, f64, f64, i32, i32, f32, f32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.stop-sound"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.play-custom-sound"(i32, i32, i32, i32, f32, f32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.play-custom-sound-at"(i32, f64, f64, f64, i32, i32, i32, f32, f32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.stop-custom-sound"(i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.spawn-particles"(i32, i32, f64, f64, f64, i32, f64, f64, f64, f32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.send-block-change"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.reset-block-change"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.send-hurt-animation"(i32, f32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.open-book"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.open-sign-editor"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-velocity"(i32, f64, f64, f64) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.apply-knockback"(i32, f64, f64, f64) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-movement-locked"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.is-movement-locked"(i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-freeze-ticks"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-freeze-ticks"(i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-server-links"(i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.teleport"(i32, f64, f64, f64, i32, f32, i32, f32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.teleport-world"(i32, i32, f64, f64, f64, i32, f32, i32, f32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.respawn"(i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.open-gui"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.ban"(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i64, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.ban-ip"(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i64, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.transfer"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.add-effect"(i32, i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.remove-effect"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.clear-effects"(i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.has-effect"(i32, i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-effect"(i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-active-effects"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.heal"(i32, f32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.damage"(i32, f32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.kill"(i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-statistic"(i32, i32, i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-statistic"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.increment-statistic"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-custom-statistic"(i32, i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-custom-statistic"(i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.increment-custom-statistic"(i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.send-stats"(i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-team"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.start-cooldown"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-cooldown"(i32, i32, i32) f32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.is-on-cooldown"(i32, i32, i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-allow-flight"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-fly-speed"(i32, f32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-walk-speed"(i32, f32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-invulnerable"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-inventory"(i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-ender-chest"(i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-selected-slot"(i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-item-in-hand"(i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-inventory-item"(i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-item-in-hand"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-inventory-item"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-ender-chest-item"(i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-ender-chest-item"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.clear-ender-chest"(i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.open-ender-chest"(i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-health"(i32) f32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-health"(i32, f32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-max-health"(i32) f32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-max-health"(i32, f32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-food-level"(i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-food-level"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-saturation"(i32) f32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-saturation"(i32, f32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-exhaustion"(i32) f32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-exhaustion"(i32, f32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-absorption"(i32) f32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-absorption"(i32, f32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-experience-level"(i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-experience-progress"(i32) f32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-experience-points"(i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-experience-level"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-experience-progress"(i32, f32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-experience-points"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.add-experience-levels"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.add-experience-points"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.is-flying"(i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-flying"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-abilities"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-abilities"(i32, i32, i32, i32, i32, i32, f32, f32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-ip"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-skin"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-skin"(i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-skin-parts"(i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-skin-parts"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-player-time"(i32, i64, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.reset-player-time"(i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-player-time"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.is-player-time-relative"(i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-player-weather"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.reset-player-weather"(i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-player-weather"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-compass-target"(i32, f64, f64, f64) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-compass-target"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-respawn-location"(i32, f64, f64, f64) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-respawn-location"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.hide-player"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.show-player"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.can-see"(i32, i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.can-see-player"(i32, i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-tab-list-ping"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-item-cooldown"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-item-cooldown"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.has-item-cooldown"(i32, i32, i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.ray-trace-block"(i32, f64, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.ray-trace-entity"(i32, f64, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-target-entity"(i32, f64, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-target-block"(i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-target-block-exact"(i32, f64, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.launch-projectile"(i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-advancement-progress"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.award-advancement-criterion"(i32, i32, i32, i32, i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.revoke-advancement-criterion"(i32, i32, i32, i32, i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.award-advancement"(i32, i32, i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.revoke-advancement"(i32, i32, i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.has-advancement"(i32, i32, i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-completed-advancements"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.get-selected-advancement-tab"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.set-selected-advancement-tab"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.as-java"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]player.as-bedrock"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]java-player.get-version"(i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]java-player.get-brand"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]java-player.get-server-address"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]java-player.get-settings"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]java-player.send-packet"(i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]java-player.send-custom-payload"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]java-player.show-dialog"(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]java-player.clear-dialog"(i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]java-player.get-scoreboard"(i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]java-player.reset-scoreboard"(i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]java-player.send-resource-pack"(i32, i64, i64, i32, i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]java-player.remove-resource-pack"(i32, i64, i64) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]java-player.clear-resource-packs"(i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]java-player.kick"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]java-player.send-game-event"(i32, i32, f32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]java-player.send-entity-status"(i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]bedrock-player.get-version"(i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]bedrock-player.get-settings"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]bedrock-player.get-ability"(i32, i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]bedrock-player.set-ability"(i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]bedrock-player.get-status-flag"(i32, i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]bedrock-player.set-status-flag"(i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]bedrock-player.send-packet"(i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]bedrock-player.open-form"(i32, i32, i32, i32, i32, i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]bedrock-player.get-scoreboard"(i32) i32; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]bedrock-player.reset-scoreboard"(i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]bedrock-player.send-resource-packs-info"(i32, i32, i32, i32, i32, i32, i64, i64, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[method]bedrock-player.kick"(i32, i32, i32, i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"get-world-players"(i32, i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[resource-drop]player"(i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[resource-drop]java-player"(i32) void; + extern "pumpkin:plugin/player@0.1.0" fn @"[resource-drop]bedrock-player"(i32) void; +}; diff --git a/src/wit/potions.zig b/src/wit/potions.zig new file mode 100644 index 0000000..46e8278 --- /dev/null +++ b/src/wit/potions.zig @@ -0,0 +1,50 @@ +// Generated by tools/gen.zig, do not edit. + +pub const PotionType = enum(u8) { + water, + mundane, + thick, + awkward, + night_vision, + long_night_vision, + invisibility, + long_invisibility, + leaping, + long_leaping, + strong_leaping, + fire_resistance, + long_fire_resistance, + swiftness, + long_swiftness, + strong_swiftness, + slowness, + long_slowness, + strong_slowness, + turtle_master, + long_turtle_master, + strong_turtle_master, + water_breathing, + long_water_breathing, + healing, + strong_healing, + harming, + strong_harming, + poison, + long_poison, + strong_poison, + regeneration, + long_regeneration, + strong_regeneration, + strength, + long_strength, + strong_strength, + weakness, + long_weakness, + luck, + slow_falling, + long_slow_falling, + wind_charged, + weaving, + oozing, + infested, +}; diff --git a/src/wit/recipe.zig b/src/wit/recipe.zig new file mode 100644 index 0000000..e0db83a --- /dev/null +++ b/src/wit/recipe.zig @@ -0,0 +1,117 @@ +// Generated by tools/gen.zig, do not edit. + +const abi = @import("../abi.zig"); +const item_stack = @import("item_stack.zig"); + +pub const ItemStack = item_stack.ItemStack; + +/// Recipe category for the recipe book. +pub const RecipeCategory = enum(u8) { + building, + redstone, + equipment, + misc, + food, + blocks, +}; + +/// Represents an ingredient in a recipe. +pub const Ingredient = union(enum) { + /// A specific item (e.g. "minecraft:diamond"). + item: []const u8, + /// A tag group of items (e.g., "minecraft:logs"). + tag: []const u8, + /// One of multiple specific items. + one_of: []const []const u8, +}; + +/// Represents a shaped crafting recipe. +pub const ShapedRecipe = struct { + /// The pattern of the recipe (e.g., ["# #", " s ", "# #"]). + pattern: []const []const u8, + /// Mapping of characters in the pattern to ingredients. + key: []const struct { []const u8, Ingredient }, + /// The resulting item stack. + output: ItemStack, + /// The recipe group (optional). + group: ?[]const u8, + /// The recipe category in the recipe book. + category: ?RecipeCategory, + /// Whether to show a toast notification when the recipe is unlocked. + show_notification: ?bool, +}; + +/// Represents a shapeless crafting recipe. +pub const ShapelessRecipe = struct { + /// The list of ingredients required. + ingredients: []const Ingredient, + /// The resulting item stack. + output: ItemStack, + /// The recipe group (optional). + group: ?[]const u8, + /// The recipe category in the recipe book. + category: ?RecipeCategory, +}; + +/// Represents a cooking recipe (Smelting, Blasting, Smoking, Campfire). +pub const CookingRecipe = struct { + /// The ingredient to cook. + ingredient: Ingredient, + /// The resulting item stack. + output: ItemStack, + /// Experience points awarded. + experience: f32, + /// Cooking time in ticks. + cooking_time: u32, + /// The recipe group (optional). + group: ?[]const u8, + /// The recipe category in the recipe book. + category: ?RecipeCategory, +}; + +/// Types of cooking stations. +pub const CookingType = enum(u8) { + smelting, + blasting, + smoking, + campfire, +}; + +/// Common interface for registering recipes. +pub const RecipeManager = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]recipe-manager"; + + /// Registers a shaped crafting recipe. + pub fn registerShaped(self: RecipeManager, id: []const u8, recipe: ShapedRecipe) void { + return abi.call(raw.@"[method]recipe-manager.register-shaped", void, .{ abi.borrow(self), id, recipe }); + } + + /// Registers a shapeless crafting recipe. + pub fn registerShapeless(self: RecipeManager, id: []const u8, recipe: ShapelessRecipe) void { + return abi.call(raw.@"[method]recipe-manager.register-shapeless", void, .{ abi.borrow(self), id, recipe }); + } + + /// Registers a cooking recipe. + pub fn registerCooking(self: RecipeManager, id: []const u8, station_type: CookingType, recipe: CookingRecipe) void { + return abi.call(raw.@"[method]recipe-manager.register-cooking", void, .{ abi.borrow(self), id, station_type, recipe }); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: RecipeManager) void { + abi.keep(RecipeManager, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: RecipeManager) void { + abi.drop(RecipeManager, self); + } +}; + +const raw = struct { + extern "pumpkin:plugin/recipe@0.1.0" fn @"[method]recipe-manager.register-shaped"(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/recipe@0.1.0" fn @"[method]recipe-manager.register-shapeless"(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/recipe@0.1.0" fn @"[method]recipe-manager.register-cooking"(i32, i32, i32, i32, i32, i32, i32, i32, f32, i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/recipe@0.1.0" fn @"[resource-drop]recipe-manager"(i32) void; +}; diff --git a/src/wit/scheduler.zig b/src/wit/scheduler.zig new file mode 100644 index 0000000..ec78e77 --- /dev/null +++ b/src/wit/scheduler.zig @@ -0,0 +1,37 @@ +// Generated by tools/gen.zig, do not edit. + +const abi = @import("../abi.zig"); + +/// Schedules a task to be executed once after the specified number of ticks. +/// +/// * `handler-id`: The unique ID of the handler to call when the task executes. +/// * `delay-ticks`: The number of game ticks to wait before execution (20 ticks = 1 second). +/// +/// Returns a unique task ID that can be used to cancel the task. +pub fn scheduleDelayedTask(handler_id: u32, delay_ticks: u64) u32 { + return abi.call(raw.@"schedule-delayed-task", u32, .{ handler_id, delay_ticks }); +} + +/// Schedules a task to be executed repeatedly. +/// +/// * `handler-id`: The unique ID of the handler to call when the task executes. +/// * `delay-ticks`: The number of game ticks to wait before the first execution. +/// * `period-ticks`: The number of game ticks between subsequent executions. +/// +/// Returns a unique task ID that can be used to cancel the task. +pub fn scheduleRepeatingTask(handler_id: u32, delay_ticks: u64, period_ticks: u64) u32 { + return abi.call(raw.@"schedule-repeating-task", u32, .{ handler_id, delay_ticks, period_ticks }); +} + +/// Cancels a scheduled task if it hasn't finished yet. +/// +/// * `task-id`: The ID of the task to cancel. +pub fn cancelTask(task_id: u32) void { + return abi.call(raw.@"cancel-task", void, .{task_id}); +} + +const raw = struct { + extern "pumpkin:plugin/scheduler@0.1.0" fn @"schedule-delayed-task"(i32, i64) i32; + extern "pumpkin:plugin/scheduler@0.1.0" fn @"schedule-repeating-task"(i32, i64, i64) i32; + extern "pumpkin:plugin/scheduler@0.1.0" fn @"cancel-task"(i32) void; +}; diff --git a/src/wit/scoreboard.zig b/src/wit/scoreboard.zig new file mode 100644 index 0000000..d7dfc30 --- /dev/null +++ b/src/wit/scoreboard.zig @@ -0,0 +1,255 @@ +// Generated by tools/gen.zig, do not edit. + +const abi = @import("../abi.zig"); +const text = @import("text.zig"); +const common = @import("common.zig"); + +pub const TextComponent = text.TextComponent; +pub const NamedColor = common.NamedColor; + +pub const RenderType = enum(u8) { + integer, + hearts, +}; + +pub const NumberFormat = union(enum) { + blank, + fixed: TextComponent, +}; + +pub const DisplaySlot = enum(u8) { + player_list, + sidebar, + below_name, + sidebar_team_black, + sidebar_team_dark_blue, + sidebar_team_dark_green, + sidebar_team_dark_aqua, + sidebar_team_dark_red, + sidebar_team_dark_purple, + sidebar_team_gold, + sidebar_team_gray, + sidebar_team_dark_gray, + sidebar_team_blue, + sidebar_team_green, + sidebar_team_aqua, + sidebar_team_red, + sidebar_team_light_purple, + sidebar_team_yellow, + sidebar_team_white, +}; + +pub const NametagVisibility = enum(u8) { + always, + never, + hide_for_other_teams, + hide_for_own_team, +}; + +pub const CollisionRule = enum(u8) { + always, + never, + push_other_teams, + push_own_team, +}; + +pub const TeamSettings = struct { + display_name: TextComponent, + friendly_fire: bool, + see_friendly_invisibles: bool, + nametag_visibility: NametagVisibility, + collision_rule: CollisionRule, + color: NamedColor, + prefix: TextComponent, + suffix: TextComponent, +}; + +pub const Scoreboard = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]scoreboard"; + + /// Consumes `display_name`. + pub fn addObjective(self: Scoreboard, name: []const u8, display_name: TextComponent, render_type: RenderType, number_format: ?NumberFormat) void { + return abi.call(raw.@"[method]scoreboard.add-objective", void, .{ abi.borrow(self), name, display_name, render_type, number_format }); + } + + /// Consumes `display_name`. + pub fn updateObjective(self: Scoreboard, name: []const u8, display_name: TextComponent, render_type: RenderType, number_format: ?NumberFormat) void { + return abi.call(raw.@"[method]scoreboard.update-objective", void, .{ abi.borrow(self), name, display_name, render_type, number_format }); + } + + pub fn removeObjective(self: Scoreboard, name: []const u8) void { + return abi.call(raw.@"[method]scoreboard.remove-objective", void, .{ abi.borrow(self), name }); + } + + pub fn setDisplaySlot(self: Scoreboard, slot: DisplaySlot, objective_name: []const u8) void { + return abi.call(raw.@"[method]scoreboard.set-display-slot", void, .{ abi.borrow(self), slot, objective_name }); + } + + pub fn clearDisplaySlot(self: Scoreboard, slot: DisplaySlot) void { + return abi.call(raw.@"[method]scoreboard.clear-display-slot", void, .{ abi.borrow(self), slot }); + } + + pub fn updateScore(self: Scoreboard, entity_name: []const u8, objective_name: []const u8, value: i32, number_format: ?NumberFormat) void { + return abi.call(raw.@"[method]scoreboard.update-score", void, .{ abi.borrow(self), entity_name, objective_name, value, number_format }); + } + + pub fn addScore(self: Scoreboard, entity_name: []const u8, objective_name: []const u8, delta: i32) i32 { + return abi.call(raw.@"[method]scoreboard.add-score", i32, .{ abi.borrow(self), entity_name, objective_name, delta }); + } + + pub fn removeScore(self: Scoreboard, entity_name: []const u8, objective_name: []const u8) void { + return abi.call(raw.@"[method]scoreboard.remove-score", void, .{ abi.borrow(self), entity_name, objective_name }); + } + + pub fn resetEntityScores(self: Scoreboard, entity_name: []const u8) void { + return abi.call(raw.@"[method]scoreboard.reset-entity-scores", void, .{ abi.borrow(self), entity_name }); + } + + pub fn createTeam(self: Scoreboard, name: []const u8, settings: TeamSettings) void { + return abi.call(raw.@"[method]scoreboard.create-team", void, .{ abi.borrow(self), name, settings }); + } + + pub fn removeTeam(self: Scoreboard, name: []const u8) void { + return abi.call(raw.@"[method]scoreboard.remove-team", void, .{ abi.borrow(self), name }); + } + + pub fn updateTeam(self: Scoreboard, name: []const u8, settings: TeamSettings) void { + return abi.call(raw.@"[method]scoreboard.update-team", void, .{ abi.borrow(self), name, settings }); + } + + pub fn addPlayerToTeam(self: Scoreboard, team_name: []const u8, player_name: []const u8) void { + return abi.call(raw.@"[method]scoreboard.add-player-to-team", void, .{ abi.borrow(self), team_name, player_name }); + } + + pub fn removePlayerFromTeam(self: Scoreboard, team_name: []const u8, player_name: []const u8) void { + return abi.call(raw.@"[method]scoreboard.remove-player-from-team", void, .{ abi.borrow(self), team_name, player_name }); + } + + pub fn clearTeamPlayers(self: Scoreboard, team_name: []const u8) void { + return abi.call(raw.@"[method]scoreboard.clear-team-players", void, .{ abi.borrow(self), team_name }); + } + + pub fn getTeams(self: Scoreboard) []const []const u8 { + return abi.call(raw.@"[method]scoreboard.get-teams", []const []const u8, .{abi.borrow(self)}); + } + + pub fn getTeam(self: Scoreboard, name: []const u8) ?TeamSettings { + return abi.call(raw.@"[method]scoreboard.get-team", ?TeamSettings, .{ abi.borrow(self), name }); + } + + pub fn getTeamPlayers(self: Scoreboard, team_name: []const u8) []const []const u8 { + return abi.call(raw.@"[method]scoreboard.get-team-players", []const []const u8, .{ abi.borrow(self), team_name }); + } + + pub fn getPlayerTeam(self: Scoreboard, player_name: []const u8) ?[]const u8 { + return abi.call(raw.@"[method]scoreboard.get-player-team", ?[]const u8, .{ abi.borrow(self), player_name }); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: Scoreboard) void { + abi.keep(Scoreboard, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: Scoreboard) void { + abi.drop(Scoreboard, self); + } +}; + +pub const BedrockSortOrder = enum(u8) { + ascending, + descending, +}; + +pub const BedrockDisplaySlot = enum(u8) { + player_list, + sidebar, + below_name, +}; + +pub const BedrockScoreboard = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]bedrock-scoreboard"; + + pub fn addObjective(self: BedrockScoreboard, name: []const u8, display_name: []const u8, sort_order: BedrockSortOrder) void { + return abi.call(raw.@"[method]bedrock-scoreboard.add-objective", void, .{ abi.borrow(self), name, display_name, sort_order }); + } + + pub fn updateObjective(self: BedrockScoreboard, name: []const u8, display_name: []const u8, sort_order: BedrockSortOrder) void { + return abi.call(raw.@"[method]bedrock-scoreboard.update-objective", void, .{ abi.borrow(self), name, display_name, sort_order }); + } + + pub fn removeObjective(self: BedrockScoreboard, name: []const u8) void { + return abi.call(raw.@"[method]bedrock-scoreboard.remove-objective", void, .{ abi.borrow(self), name }); + } + + pub fn setDisplaySlot(self: BedrockScoreboard, slot: BedrockDisplaySlot, objective_name: []const u8) void { + return abi.call(raw.@"[method]bedrock-scoreboard.set-display-slot", void, .{ abi.borrow(self), slot, objective_name }); + } + + pub fn clearDisplaySlot(self: BedrockScoreboard, slot: BedrockDisplaySlot) void { + return abi.call(raw.@"[method]bedrock-scoreboard.clear-display-slot", void, .{ abi.borrow(self), slot }); + } + + pub fn updateScore(self: BedrockScoreboard, entity_name: []const u8, objective_name: []const u8, value: i32) void { + return abi.call(raw.@"[method]bedrock-scoreboard.update-score", void, .{ abi.borrow(self), entity_name, objective_name, value }); + } + + pub fn addScore(self: BedrockScoreboard, entity_name: []const u8, objective_name: []const u8, delta: i32) i32 { + return abi.call(raw.@"[method]bedrock-scoreboard.add-score", i32, .{ abi.borrow(self), entity_name, objective_name, delta }); + } + + pub fn removeScore(self: BedrockScoreboard, entity_name: []const u8, objective_name: []const u8) void { + return abi.call(raw.@"[method]bedrock-scoreboard.remove-score", void, .{ abi.borrow(self), entity_name, objective_name }); + } + + pub fn resetEntityScores(self: BedrockScoreboard, entity_name: []const u8) void { + return abi.call(raw.@"[method]bedrock-scoreboard.reset-entity-scores", void, .{ abi.borrow(self), entity_name }); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: BedrockScoreboard) void { + abi.keep(BedrockScoreboard, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: BedrockScoreboard) void { + abi.drop(BedrockScoreboard, self); + } +}; + +const raw = struct { + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]scoreboard.add-objective"(i32, i32, i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]scoreboard.update-objective"(i32, i32, i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]scoreboard.remove-objective"(i32, i32, i32) void; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]scoreboard.set-display-slot"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]scoreboard.clear-display-slot"(i32, i32) void; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]scoreboard.update-score"(i32, i32, i32, i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]scoreboard.add-score"(i32, i32, i32, i32, i32, i32) i32; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]scoreboard.remove-score"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]scoreboard.reset-entity-scores"(i32, i32, i32) void; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]scoreboard.create-team"(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]scoreboard.remove-team"(i32, i32, i32) void; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]scoreboard.update-team"(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]scoreboard.add-player-to-team"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]scoreboard.remove-player-from-team"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]scoreboard.clear-team-players"(i32, i32, i32) void; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]scoreboard.get-teams"(i32, i32) void; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]scoreboard.get-team"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]scoreboard.get-team-players"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]scoreboard.get-player-team"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]bedrock-scoreboard.add-objective"(i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]bedrock-scoreboard.update-objective"(i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]bedrock-scoreboard.remove-objective"(i32, i32, i32) void; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]bedrock-scoreboard.set-display-slot"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]bedrock-scoreboard.clear-display-slot"(i32, i32) void; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]bedrock-scoreboard.update-score"(i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]bedrock-scoreboard.add-score"(i32, i32, i32, i32, i32, i32) i32; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]bedrock-scoreboard.remove-score"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[method]bedrock-scoreboard.reset-entity-scores"(i32, i32, i32) void; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[resource-drop]scoreboard"(i32) void; + extern "pumpkin:plugin/scoreboard@0.1.0" fn @"[resource-drop]bedrock-scoreboard"(i32) void; +}; diff --git a/src/wit/screens.zig b/src/wit/screens.zig new file mode 100644 index 0000000..33e095a --- /dev/null +++ b/src/wit/screens.zig @@ -0,0 +1,29 @@ +// Generated by tools/gen.zig, do not edit. + +pub const Screen = enum(u8) { + generic_9x1, + generic_9x2, + generic_9x3, + generic_9x4, + generic_9x5, + generic_9x6, + generic_3x3, + crafter_3x3, + anvil, + beacon, + blast_furnace, + brewing_stand, + crafting, + enchantment, + furnace, + grindstone, + hopper, + lectern, + loom, + merchant, + shulker_box, + smithing, + smoker, + cartography_table, + stonecutter, +}; diff --git a/src/wit/server.zig b/src/wit/server.zig new file mode 100644 index 0000000..9aaee85 --- /dev/null +++ b/src/wit/server.zig @@ -0,0 +1,567 @@ +// Generated by tools/gen.zig, do not edit. + +const abi = @import("../abi.zig"); +const player = @import("player.zig"); +const common = @import("common.zig"); +const world = @import("world.zig"); +const text = @import("text.zig"); +const uuid = @import("uuid.zig"); +const recipe = @import("recipe.zig"); +const enchantments = @import("enchantments.zig"); +const permission = @import("permission.zig"); +const advancement = @import("advancement.zig"); +const datapack = @import("datapack.zig"); + +pub const Player = player.Player; +pub const BanPlayerOptions = player.BanPlayerOptions; +pub const BanIpOptions = player.BanIpOptions; +pub const ServerLink = player.ServerLink; +pub const KnownServerLink = player.KnownServerLink; +pub const ServerLinkLabel = player.ServerLinkLabel; +pub const GameMode = common.GameMode; +pub const World = world.World; +pub const TextComponent = text.TextComponent; +pub const Uuid = uuid.Uuid; +pub const RecipeManager = recipe.RecipeManager; +pub const EnchantmentManager = enchantments.EnchantmentManager; +pub const CustomEnchantment = enchantments.CustomEnchantment; +pub const PermissionLevel = permission.PermissionLevel; +pub const AdvancementInfo = advancement.AdvancementInfo; +pub const DatapackManager = datapack.DatapackManager; +pub const DatapackInfo = datapack.DatapackInfo; + +/// Represents an operator entry in the ops configuration. +pub const OpEntry = struct { + uuid: Uuid, + name: []const u8, + level: PermissionLevel, + bypasses_player_limit: bool, +}; + +/// Interface for querying and managing server operators. +pub const OpManager = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]op-manager"; + + /// Checks if a player UUID is currently an operator. + pub fn isOp(self: OpManager, id: Uuid) bool { + return abi.call(raw.@"[method]op-manager.is-op", bool, .{ abi.borrow(self), id }); + } + + /// Retrieves the operator entry for a player UUID, if present. + pub fn getOp(self: OpManager, id: Uuid) ?OpEntry { + return abi.call(raw.@"[method]op-manager.get-op", ?OpEntry, .{ abi.borrow(self), id }); + } + + /// Gets the effective permission level for a player UUID (returns zero if not op). + pub fn getPermissionLevel(self: OpManager, id: Uuid) PermissionLevel { + return abi.call(raw.@"[method]op-manager.get-permission-level", PermissionLevel, .{ abi.borrow(self), id }); + } + + /// Grants operator status to a player (online or offline) with the specified level and bypass setting. + pub fn opPlayer(self: OpManager, name: []const u8, id: Uuid, level: PermissionLevel, bypasses_player_limit: bool) void { + return abi.call(raw.@"[method]op-manager.op-player", void, .{ abi.borrow(self), name, id, level, bypasses_player_limit }); + } + + /// Revokes operator status from a player (online or offline). Returns true if the player was previously op. + pub fn deopPlayer(self: OpManager, id: Uuid) bool { + return abi.call(raw.@"[method]op-manager.deop-player", bool, .{ abi.borrow(self), id }); + } + + /// Returns a list of all operator entries on the server. + pub fn listOps(self: OpManager) []const OpEntry { + return abi.call(raw.@"[method]op-manager.list-ops", []const OpEntry, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: OpManager) void { + abi.keep(OpManager, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: OpManager) void { + abi.drop(OpManager, self); + } +}; + +/// Represents a banned player entry in the ban list. +pub const BannedPlayerEntry = struct { + uuid: Uuid, + name: []const u8, + created: []const u8, + source: []const u8, + expires: ?[]const u8, + reason: []const u8, +}; + +/// Represents a banned IP entry in the IP ban list. +pub const BannedIpEntry = struct { + ip: []const u8, + created: []const u8, + source: []const u8, + expires: ?[]const u8, + reason: []const u8, +}; + +/// Global manager for player and IP bans. +pub const BanManager = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]ban-manager"; + + /// Checks if a player UUID is currently banned. + pub fn isPlayerBanned(self: BanManager, id: Uuid) bool { + return abi.call(raw.@"[method]ban-manager.is-player-banned", bool, .{ abi.borrow(self), id }); + } + + /// Retrieves the ban entry for a player UUID, if banned. + pub fn getPlayerBan(self: BanManager, id: Uuid) ?BannedPlayerEntry { + return abi.call(raw.@"[method]ban-manager.get-player-ban", ?BannedPlayerEntry, .{ abi.borrow(self), id }); + } + + /// Bans a player by name and UUID with the specified options (works for online and offline players). + pub fn banPlayer(self: BanManager, name: []const u8, id: Uuid, options: BanPlayerOptions) void { + return abi.call(raw.@"[method]ban-manager.ban-player", void, .{ abi.borrow(self), name, id, options }); + } + + /// Removes a player ban by UUID. Returns true if the player was banned. + pub fn unbanPlayer(self: BanManager, id: Uuid) bool { + return abi.call(raw.@"[method]ban-manager.unban-player", bool, .{ abi.borrow(self), id }); + } + + /// Returns all currently active player bans. + pub fn listPlayerBans(self: BanManager) []const BannedPlayerEntry { + return abi.call(raw.@"[method]ban-manager.list-player-bans", []const BannedPlayerEntry, .{abi.borrow(self)}); + } + + /// Checks if an IP address is currently banned. + pub fn isIpBanned(self: BanManager, ip: []const u8) bool { + return abi.call(raw.@"[method]ban-manager.is-ip-banned", bool, .{ abi.borrow(self), ip }); + } + + /// Retrieves the ban entry for an IP address, if banned. + pub fn getIpBan(self: BanManager, ip: []const u8) ?BannedIpEntry { + return abi.call(raw.@"[method]ban-manager.get-ip-ban", ?BannedIpEntry, .{ abi.borrow(self), ip }); + } + + /// Bans an IP address with the specified options. + pub fn banIp(self: BanManager, ip: []const u8, options: BanIpOptions) void { + return abi.call(raw.@"[method]ban-manager.ban-ip", void, .{ abi.borrow(self), ip, options }); + } + + /// Removes an IP ban. Returns true if the IP was banned. + pub fn unbanIp(self: BanManager, ip: []const u8) bool { + return abi.call(raw.@"[method]ban-manager.unban-ip", bool, .{ abi.borrow(self), ip }); + } + + /// Returns all currently active IP bans. + pub fn listIpBans(self: BanManager) []const BannedIpEntry { + return abi.call(raw.@"[method]ban-manager.list-ip-bans", []const BannedIpEntry, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: BanManager) void { + abi.keep(BanManager, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: BanManager) void { + abi.drop(BanManager, self); + } +}; + +/// Represents a player entry in the server whitelist. +pub const WhitelistEntry = struct { + uuid: Uuid, + name: []const u8, +}; + +/// Global manager for the server whitelist. +pub const WhitelistManager = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]whitelist-manager"; + + /// Returns whether the whitelist is currently enabled. + pub fn isEnabled(self: WhitelistManager) bool { + return abi.call(raw.@"[method]whitelist-manager.is-enabled", bool, .{abi.borrow(self)}); + } + + /// Enables or disables the server whitelist. If enabled and enforce-whitelist is set, kicks non-whitelisted players. + pub fn setEnabled(self: WhitelistManager, enabled: bool) void { + return abi.call(raw.@"[method]whitelist-manager.set-enabled", void, .{ abi.borrow(self), enabled }); + } + + /// Checks if a player UUID is on the whitelist. + pub fn isWhitelisted(self: WhitelistManager, id: Uuid) bool { + return abi.call(raw.@"[method]whitelist-manager.is-whitelisted", bool, .{ abi.borrow(self), id }); + } + + /// Adds a player to the whitelist (online or offline). Returns true if newly added. + pub fn addPlayer(self: WhitelistManager, name: []const u8, id: Uuid) bool { + return abi.call(raw.@"[method]whitelist-manager.add-player", bool, .{ abi.borrow(self), name, id }); + } + + /// Removes a player from the whitelist. Returns true if the player was on the whitelist. + pub fn removePlayer(self: WhitelistManager, id: Uuid) bool { + return abi.call(raw.@"[method]whitelist-manager.remove-player", bool, .{ abi.borrow(self), id }); + } + + /// Returns all whitelisted player entries. + pub fn listEntries(self: WhitelistManager) []const WhitelistEntry { + return abi.call(raw.@"[method]whitelist-manager.list-entries", []const WhitelistEntry, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: WhitelistManager) void { + abi.keep(WhitelistManager, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: WhitelistManager) void { + abi.drop(WhitelistManager, self); + } +}; + +/// Represents the difficulty setting of a Minecraft server. +pub const Difficulty = enum(u8) { + /// Hostile mobs do not spawn. Players regain health automatically. + peaceful, + /// Hostile mobs deal less damage. + easy, + /// Standard Minecraft difficulty. + normal, + /// Hostile mobs deal more damage. + hard, +}; + +/// Represents the three main Minecraft dimensions. +pub const Dimension = enum(u8) { + overworld, + nether, + end, +}; + +pub const SysInfo = struct { + cpu_count: ?u32, + total_memory: ?u64, + used_memory: ?u64, + os_name: ?[]const u8, + os_version: ?[]const u8, + pumpkin_version: []const u8, +}; + +pub const CommandSender = union(enum) { + console, + player: Player, +}; + +/// Represents the global server instance. +pub const Server = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]server"; + + /// Returns system information (CPU, Memory, OS). + /// Fields are returned only if the plugin has the corresponding permissions. + pub fn getSysInfo(self: Server) SysInfo { + return abi.call(raw.@"[method]server.get-sys-info", SysInfo, .{abi.borrow(self)}); + } + + /// Returns the current difficulty level of the server. + pub fn getDifficulty(self: Server) Difficulty { + return abi.call(raw.@"[method]server.get-difficulty", Difficulty, .{abi.borrow(self)}); + } + + /// Returns the total number of players currently connected to the server. + pub fn getPlayerCount(self: Server) u32 { + return abi.call(raw.@"[method]server.get-player-count", u32, .{abi.borrow(self)}); + } + + /// Returns the rolling average Milliseconds Per Tick (MSPT). + /// A value below 50.0 is required for a stable 20 TPS. + pub fn getMspt(self: Server) f64 { + return abi.call(raw.@"[method]server.get-mspt", f64, .{abi.borrow(self)}); + } + + /// Returns the effective Ticks Per Second (TPS). + /// Ideal value is 20.0. + pub fn getTps(self: Server) f64 { + return abi.call(raw.@"[method]server.get-tps", f64, .{abi.borrow(self)}); + } + + /// Returns a list of all online players across all worlds. + pub fn getAllPlayers(self: Server) []const Player { + return abi.call(raw.@"[method]server.get-all-players", []const Player, .{abi.borrow(self)}); + } + + /// Searches for a player by their exact name. + pub fn getPlayerByName(self: Server, name: []const u8) ?Player { + return abi.call(raw.@"[method]server.get-player-by-name", ?Player, .{ abi.borrow(self), name }); + } + + /// Searches for a player by their UUID string. + pub fn getPlayerByUuid(self: Server, id: Uuid) ?Player { + return abi.call(raw.@"[method]server.get-player-by-uuid", ?Player, .{ abi.borrow(self), id }); + } + + /// Returns a list of all worlds on this server. + pub fn getAllWorlds(self: Server) []const World { + return abi.call(raw.@"[method]server.get-all-worlds", []const World, .{abi.borrow(self)}); + } + + /// Gets a world by its dimension name (e.g., "minecraft:overworld") or custom world name (e.g., "world", "arena_1"). + pub fn getWorldByName(self: Server, name: []const u8) ?World { + return abi.call(raw.@"[method]server.get-world-by-name", ?World, .{ abi.borrow(self), name }); + } + + /// Checks if a world exists by name or dimension. + pub fn hasWorld(self: Server, name: []const u8) bool { + return abi.call(raw.@"[method]server.has-world", bool, .{ abi.borrow(self), name }); + } + + pub fn executeCommand(self: Server, command: []const u8, sender: CommandSender) void { + return abi.call(raw.@"[method]server.execute-command", void, .{ abi.borrow(self), command, sender }); + } + + /// Creates or loads a world by its name and dimension. + /// If a world with the given name already exists, it will be returned. + pub fn createWorld(self: Server, name: []const u8, dimension: Dimension) World { + return abi.call(raw.@"[method]server.create-world", World, .{ abi.borrow(self), name, dimension }); + } + + /// Unloads and saves a world by its name or dimension. + /// Returns an error if the world cannot be found, is the primary/default world, or still has players inside. + pub fn unloadWorld(self: Server, name: []const u8) abi.Result(void, []const u8) { + return abi.call(raw.@"[method]server.unload-world", abi.Result(void, []const u8), .{ abi.borrow(self), name }); + } + + /// Saves all players, player advancements, and loaded worlds to disk. + pub fn saveAll(self: Server) abi.Result(void, []const u8) { + return abi.call(raw.@"[method]server.save-all", abi.Result(void, []const u8), .{abi.borrow(self)}); + } + + /// Returns a list of all online players in a specific world. + /// + /// Consumes `world_ref`. + pub fn getPlayersInWorld(self: Server, world_ref: World) []const Player { + return abi.call(raw.@"[method]server.get-players-in-world", []const Player, .{ abi.borrow(self), world_ref }); + } + + /// Returns the number of online players in a specific world. + /// + /// Consumes `world_ref`. + pub fn getPlayerCountInWorld(self: Server, world_ref: World) u32 { + return abi.call(raw.@"[method]server.get-player-count-in-world", u32, .{ abi.borrow(self), world_ref }); + } + + /// Broadcasts a system chat message to all players. + pub fn broadcast(self: Server, message: []const u8) void { + return abi.call(raw.@"[method]server.broadcast", void, .{ abi.borrow(self), message }); + } + + /// Deletes a signed chat message from all players' chat windows using its 256-byte signature. + pub fn deleteMessageBySignature(self: Server, signature: []const u8) void { + return abi.call(raw.@"[method]server.delete-message-by-signature", void, .{ abi.borrow(self), signature }); + } + + /// Deletes a signed chat message from all players' chat windows using its signature cache ID. + pub fn deleteMessageById(self: Server, signature_id: i32) void { + return abi.call(raw.@"[method]server.delete-message-by-id", void, .{ abi.borrow(self), signature_id }); + } + + /// Broadcasts a tab list header and footer to all players. + /// + /// Consumes `header`. + /// Consumes `footer`. + pub fn broadcastTabListHeaderFooter(self: Server, header: TextComponent, footer: TextComponent) void { + return abi.call(raw.@"[method]server.broadcast-tab-list-header-footer", void, .{ abi.borrow(self), header, footer }); + } + + /// Returns the maximum number of players allowed on the server. + pub fn getMaxPlayers(self: Server) u32 { + return abi.call(raw.@"[method]server.get-max-players", u32, .{abi.borrow(self)}); + } + + /// Returns whether the server is in hardcore mode. + pub fn isHardcore(self: Server) bool { + return abi.call(raw.@"[method]server.is-hardcore", bool, .{abi.borrow(self)}); + } + + /// Returns whether the server is in online mode (authenticates with Mojang). + pub fn isOnlineMode(self: Server) bool { + return abi.call(raw.@"[method]server.is-online-mode", bool, .{abi.borrow(self)}); + } + + /// Returns the server's Message of the Day (MOTD). + pub fn getMotd(self: Server) []const u8 { + return abi.call(raw.@"[method]server.get-motd", []const u8, .{abi.borrow(self)}); + } + + /// Returns whether the server has a whitelist enabled. + pub fn hasWhitelist(self: Server) bool { + return abi.call(raw.@"[method]server.has-whitelist", bool, .{abi.borrow(self)}); + } + + /// Returns whether the server allows the Nether dimension. + pub fn getAllowNether(self: Server) bool { + return abi.call(raw.@"[method]server.get-allow-nether", bool, .{abi.borrow(self)}); + } + + /// Returns whether the server allows the End dimension. + pub fn getAllowEnd(self: Server) bool { + return abi.call(raw.@"[method]server.get-allow-end", bool, .{abi.borrow(self)}); + } + + /// Returns the server's maximum view distance. + pub fn getViewDistance(self: Server) u8 { + return abi.call(raw.@"[method]server.get-view-distance", u8, .{abi.borrow(self)}); + } + + /// Returns the server's maximum simulation distance. + pub fn getSimulationDistance(self: Server) u8 { + return abi.call(raw.@"[method]server.get-simulation-distance", u8, .{abi.borrow(self)}); + } + + /// Returns the server's default gamemode. + pub fn getDefaultGamemode(self: Server) GameMode { + return abi.call(raw.@"[method]server.get-default-gamemode", GameMode, .{abi.borrow(self)}); + } + + /// Returns the recipe manager to register custom recipes. + pub fn getRecipeManager(self: Server) RecipeManager { + return abi.call(raw.@"[method]server.get-recipe-manager", RecipeManager, .{abi.borrow(self)}); + } + + /// Returns the operator manager to query or modify server operators. + pub fn getOpManager(self: Server) OpManager { + return abi.call(raw.@"[method]server.get-op-manager", OpManager, .{abi.borrow(self)}); + } + + /// Returns the global ban manager for querying and modifying player and IP bans. + pub fn getBanManager(self: Server) BanManager { + return abi.call(raw.@"[method]server.get-ban-manager", BanManager, .{abi.borrow(self)}); + } + + /// Returns the global whitelist manager for querying and modifying the server whitelist. + pub fn getWhitelistManager(self: Server) WhitelistManager { + return abi.call(raw.@"[method]server.get-whitelist-manager", WhitelistManager, .{abi.borrow(self)}); + } + + /// Returns detailed information about an advancement by its ID (e.g., "minecraft:story/mine_stone" or "story/mine_stone"). + pub fn getAdvancement(self: Server, id: []const u8) ?AdvancementInfo { + return abi.call(raw.@"[method]server.get-advancement", ?AdvancementInfo, .{ abi.borrow(self), id }); + } + + /// Returns a list of all registered advancement IDs on the server. + pub fn getAllAdvancementIds(self: Server) []const []const u8 { + return abi.call(raw.@"[method]server.get-all-advancement-ids", []const []const u8, .{abi.borrow(self)}); + } + + /// Returns the global enchantment manager for registering and querying custom enchantments. + pub fn getEnchantmentManager(self: Server) EnchantmentManager { + return abi.call(raw.@"[method]server.get-enchantment-manager", EnchantmentManager, .{abi.borrow(self)}); + } + + /// Returns information about an enchantment by its ID (vanilla or custom). + pub fn getEnchantment(self: Server, id: []const u8) ?CustomEnchantment { + return abi.call(raw.@"[method]server.get-enchantment", ?CustomEnchantment, .{ abi.borrow(self), id }); + } + + /// Returns a list of all registered enchantment IDs (custom and vanilla) on the server. + pub fn getAllEnchantmentIds(self: Server) []const []const u8 { + return abi.call(raw.@"[method]server.get-all-enchantment-ids", []const []const u8, .{abi.borrow(self)}); + } + + /// Returns the global datapack manager for inspecting, enabling, disabling, and reloading datapacks. + pub fn getDatapackManager(self: Server) DatapackManager { + return abi.call(raw.@"[method]server.get-datapack-manager", DatapackManager, .{abi.borrow(self)}); + } + + /// Broadcasts custom server links to all connected players (displayed in the client Esc pause menu in 1.21+). + pub fn setServerLinks(self: Server, links: []const ServerLink) void { + return abi.call(raw.@"[method]server.set-server-links", void, .{ abi.borrow(self), links }); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: Server) void { + abi.keep(Server, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: Server) void { + abi.drop(Server, self); + } +}; + +const raw = struct { + extern "pumpkin:plugin/server@0.1.0" fn @"[method]op-manager.is-op"(i32, i64, i64) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]op-manager.get-op"(i32, i64, i64, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]op-manager.get-permission-level"(i32, i64, i64) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]op-manager.op-player"(i32, i32, i32, i64, i64, i32, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]op-manager.deop-player"(i32, i64, i64) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]op-manager.list-ops"(i32, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]ban-manager.is-player-banned"(i32, i64, i64) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]ban-manager.get-player-ban"(i32, i64, i64, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]ban-manager.ban-player"(i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]ban-manager.unban-player"(i32, i64, i64) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]ban-manager.list-player-bans"(i32, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]ban-manager.is-ip-banned"(i32, i32, i32) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]ban-manager.get-ip-ban"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]ban-manager.ban-ip"(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i64, i32, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]ban-manager.unban-ip"(i32, i32, i32) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]ban-manager.list-ip-bans"(i32, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]whitelist-manager.is-enabled"(i32) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]whitelist-manager.set-enabled"(i32, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]whitelist-manager.is-whitelisted"(i32, i64, i64) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]whitelist-manager.add-player"(i32, i32, i32, i64, i64) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]whitelist-manager.remove-player"(i32, i64, i64) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]whitelist-manager.list-entries"(i32, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-sys-info"(i32, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-difficulty"(i32) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-player-count"(i32) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-mspt"(i32) f64; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-tps"(i32) f64; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-all-players"(i32, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-player-by-name"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-player-by-uuid"(i32, i64, i64, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-all-worlds"(i32, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-world-by-name"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.has-world"(i32, i32, i32) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.execute-command"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.create-world"(i32, i32, i32, i32) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.unload-world"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.save-all"(i32, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-players-in-world"(i32, i32, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-player-count-in-world"(i32, i32) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.broadcast"(i32, i32, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.delete-message-by-signature"(i32, i32, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.delete-message-by-id"(i32, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.broadcast-tab-list-header-footer"(i32, i32, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-max-players"(i32) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.is-hardcore"(i32) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.is-online-mode"(i32) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-motd"(i32, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.has-whitelist"(i32) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-allow-nether"(i32) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-allow-end"(i32) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-view-distance"(i32) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-simulation-distance"(i32) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-default-gamemode"(i32) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-recipe-manager"(i32) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-op-manager"(i32) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-ban-manager"(i32) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-whitelist-manager"(i32) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-advancement"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-all-advancement-ids"(i32, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-enchantment-manager"(i32) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-enchantment"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-all-enchantment-ids"(i32, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.get-datapack-manager"(i32) i32; + extern "pumpkin:plugin/server@0.1.0" fn @"[method]server.set-server-links"(i32, i32, i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[resource-drop]op-manager"(i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[resource-drop]ban-manager"(i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[resource-drop]whitelist-manager"(i32) void; + extern "pumpkin:plugin/server@0.1.0" fn @"[resource-drop]server"(i32) void; +}; diff --git a/src/wit/sounds.zig b/src/wit/sounds.zig new file mode 100644 index 0000000..75a6800 --- /dev/null +++ b/src/wit/sounds.zig @@ -0,0 +1,1986 @@ +// Generated by tools/gen.zig, do not edit. + +pub const SoundCategory = enum(u8) { + master, + music, + records, + weather, + blocks, + hostile, + neutral, + players, + ambient, + voice, + ui, +}; + +pub const Sound = enum(u16) { + entity_allay_ambient_with_item, + entity_allay_ambient_without_item, + entity_allay_death, + entity_allay_hurt, + entity_allay_item_given, + entity_allay_item_taken, + entity_allay_item_thrown, + ambient_cave, + ambient_basalt_deltas_additions, + ambient_basalt_deltas_loop, + ambient_basalt_deltas_mood, + ambient_crimson_forest_additions, + ambient_crimson_forest_loop, + ambient_crimson_forest_mood, + ambient_nether_wastes_additions, + ambient_nether_wastes_loop, + ambient_nether_wastes_mood, + ambient_soul_sand_valley_additions, + ambient_soul_sand_valley_loop, + ambient_soul_sand_valley_mood, + ambient_warped_forest_additions, + ambient_warped_forest_loop, + ambient_warped_forest_mood, + ambient_underwater_enter, + ambient_underwater_exit, + ambient_underwater_loop, + ambient_underwater_loop_additions, + ambient_underwater_loop_additions_rare, + ambient_underwater_loop_additions_ultra_rare, + block_amethyst_block_break, + block_amethyst_block_chime, + block_amethyst_block_fall, + block_amethyst_block_hit, + block_amethyst_block_place, + block_amethyst_block_resonate, + block_amethyst_block_step, + block_amethyst_cluster_break, + block_amethyst_cluster_fall, + block_amethyst_cluster_hit, + block_amethyst_cluster_place, + block_amethyst_cluster_step, + block_ancient_debris_break, + block_ancient_debris_step, + block_ancient_debris_place, + block_ancient_debris_hit, + block_ancient_debris_fall, + block_anvil_break, + block_anvil_destroy, + block_anvil_fall, + block_anvil_hit, + block_anvil_land, + block_anvil_place, + block_anvil_step, + block_anvil_use, + entity_armadillo_eat, + entity_armadillo_hurt, + entity_armadillo_hurt_reduced, + entity_armadillo_ambient, + entity_armadillo_step, + entity_armadillo_death, + entity_armadillo_roll, + entity_armadillo_land, + entity_armadillo_scute_drop, + entity_armadillo_unroll_finish, + entity_armadillo_peek, + entity_armadillo_unroll_start, + entity_armadillo_brush, + item_armor_equip_chain, + item_armor_equip_diamond, + item_armor_equip_elytra, + item_armor_equip_generic, + item_armor_equip_gold, + item_armor_equip_iron, + item_armor_equip_leather, + item_armor_equip_copper, + item_armor_equip_netherite, + item_armor_equip_turtle, + item_armor_equip_wolf, + item_armor_unequip_wolf, + item_armor_equip_nautilus, + item_armor_unequip_nautilus, + entity_armor_stand_break, + entity_armor_stand_fall, + entity_armor_stand_hit, + entity_armor_stand_place, + entity_arrow_hit, + entity_arrow_hit_player, + entity_arrow_shoot, + item_axe_strip, + item_axe_scrape, + item_axe_wax_off, + entity_axolotl_attack, + entity_axolotl_death, + entity_axolotl_hurt, + entity_axolotl_idle_air, + entity_axolotl_idle_water, + entity_axolotl_splash, + entity_axolotl_swim, + block_azalea_break, + block_azalea_fall, + block_azalea_hit, + block_azalea_place, + block_azalea_step, + block_azalea_leaves_break, + block_azalea_leaves_fall, + block_azalea_leaves_hit, + block_azalea_leaves_place, + block_azalea_leaves_step, + entity_baby_nautilus_ambient, + entity_baby_nautilus_ambient_land, + entity_baby_nautilus_death, + entity_baby_nautilus_death_land, + entity_baby_nautilus_eat, + entity_baby_nautilus_hurt, + entity_baby_nautilus_hurt_land, + entity_nautilus_riding, + entity_baby_nautilus_swim, + block_bamboo_break, + block_bamboo_fall, + block_bamboo_hit, + block_bamboo_place, + block_bamboo_step, + block_bamboo_sapling_break, + block_bamboo_sapling_hit, + block_bamboo_sapling_place, + block_bamboo_wood_break, + block_bamboo_wood_fall, + block_bamboo_wood_hit, + block_bamboo_wood_place, + block_bamboo_wood_step, + block_bamboo_wood_door_close, + block_bamboo_wood_door_open, + block_bamboo_wood_trapdoor_close, + block_bamboo_wood_trapdoor_open, + block_bamboo_wood_button_click_off, + block_bamboo_wood_button_click_on, + block_bamboo_wood_pressure_plate_click_off, + block_bamboo_wood_pressure_plate_click_on, + block_bamboo_wood_fence_gate_close, + block_bamboo_wood_fence_gate_open, + block_barrel_close, + block_barrel_open, + block_basalt_break, + block_basalt_step, + block_basalt_place, + block_basalt_hit, + block_basalt_fall, + entity_bat_ambient, + entity_bat_death, + entity_bat_hurt, + entity_bat_loop, + entity_bat_takeoff, + block_beacon_activate, + block_beacon_ambient, + block_beacon_deactivate, + block_beacon_power_select, + entity_bee_death, + entity_bee_hurt, + entity_bee_loop_aggressive, + entity_bee_loop, + entity_bee_sting, + entity_bee_pollinate, + block_beehive_drip, + block_beehive_enter, + block_beehive_exit, + block_beehive_shear, + block_beehive_work, + block_bell_use, + block_bell_resonate, + block_big_dripleaf_break, + block_big_dripleaf_fall, + block_big_dripleaf_hit, + block_big_dripleaf_place, + block_big_dripleaf_step, + entity_blaze_ambient, + entity_blaze_burn, + entity_blaze_death, + entity_blaze_hurt, + entity_blaze_shoot, + entity_boat_paddle_land, + entity_boat_paddle_water, + entity_bogged_ambient, + entity_bogged_death, + entity_bogged_hurt, + entity_bogged_shear, + entity_bogged_step, + block_bone_block_break, + block_bone_block_fall, + block_bone_block_hit, + block_bone_block_place, + block_bone_block_step, + item_bone_meal_use, + item_book_page_turn, + item_book_put, + block_blastfurnace_fire_crackle, + item_bottle_empty, + item_bottle_fill, + item_bottle_fill_dragonbreath, + entity_breeze_charge, + entity_breeze_deflect, + entity_breeze_inhale, + entity_breeze_idle_ground, + entity_breeze_idle_air, + entity_breeze_shoot, + entity_breeze_jump, + entity_breeze_land, + entity_breeze_slide, + entity_breeze_death, + entity_breeze_hurt, + entity_breeze_whirl, + entity_breeze_wind_burst, + block_brewing_stand_brew, + item_brush_brushing_generic, + item_brush_brushing_sand, + item_brush_brushing_gravel, + item_brush_brushing_sand_complete, + item_brush_brushing_gravel_complete, + block_bubble_column_bubble_pop, + block_bubble_column_upwards_ambient, + block_bubble_column_upwards_inside, + block_bubble_column_whirlpool_ambient, + block_bubble_column_whirlpool_inside, + ui_hud_bubble_pop, + item_bucket_empty, + item_bucket_empty_axolotl, + item_bucket_empty_fish, + item_bucket_empty_lava, + item_bucket_empty_powder_snow, + item_bucket_empty_sulfur_cube, + item_bucket_empty_tadpole, + item_bucket_fill, + item_bucket_fill_axolotl, + item_bucket_fill_fish, + item_bucket_fill_lava, + item_bucket_fill_powder_snow, + item_bucket_fill_sulfur_cube, + item_bucket_fill_tadpole, + item_bundle_drop_contents, + item_bundle_insert, + item_bundle_insert_fail, + item_bundle_remove_one, + block_cactus_flower_break, + block_cactus_flower_place, + block_cake_add_candle, + block_calcite_break, + block_calcite_step, + block_calcite_place, + block_calcite_hit, + block_calcite_fall, + entity_camel_husk_ambient, + entity_camel_husk_dash, + entity_camel_husk_dash_ready, + entity_camel_husk_death, + entity_camel_husk_eat, + entity_camel_husk_hurt, + entity_camel_husk_saddle, + entity_camel_husk_sit, + entity_camel_husk_stand, + entity_camel_husk_step, + entity_camel_husk_step_sand, + entity_camel_ambient, + entity_camel_dash, + entity_camel_dash_ready, + entity_camel_death, + entity_camel_eat, + entity_camel_hurt, + entity_camel_saddle, + entity_camel_sit, + entity_camel_stand, + entity_camel_step, + entity_camel_step_sand, + block_campfire_crackle, + block_candle_ambient, + block_candle_break, + block_candle_extinguish, + block_candle_fall, + block_candle_hit, + block_candle_place, + block_candle_step, + entity_baby_cat_ambient, + entity_baby_cat_stray_ambient, + entity_baby_cat_death, + entity_baby_cat_eat, + entity_baby_cat_hiss, + entity_baby_cat_beg_for_food, + entity_baby_cat_hurt, + entity_baby_cat_purr, + entity_baby_cat_purreow, + entity_cat_ambient, + entity_cat_stray_ambient, + entity_cat_hiss, + entity_cat_hurt, + entity_cat_death, + entity_cat_eat, + entity_cat_beg_for_food, + entity_cat_purr, + entity_cat_purreow, + entity_cat_royal_ambient, + entity_cat_royal_stray_ambient, + entity_cat_royal_hiss, + entity_cat_royal_hurt, + entity_cat_royal_death, + entity_cat_royal_eat, + entity_cat_royal_beg_for_food, + entity_cat_royal_purr, + entity_cat_royal_purreow, + block_cave_vines_break, + block_cave_vines_fall, + block_cave_vines_hit, + block_cave_vines_place, + block_cave_vines_step, + block_cave_vines_pick_berries, + block_chain_break, + block_chain_fall, + block_chain_hit, + block_chain_place, + block_chain_step, + block_cherry_wood_break, + block_cherry_wood_fall, + block_cherry_wood_hit, + block_cherry_wood_place, + block_cherry_wood_step, + block_cherry_sapling_break, + block_cherry_sapling_fall, + block_cherry_sapling_hit, + block_cherry_sapling_place, + block_cherry_sapling_step, + block_cherry_leaves_break, + block_cherry_leaves_fall, + block_cherry_leaves_hit, + block_cherry_leaves_place, + block_cherry_leaves_step, + block_cherry_wood_hanging_sign_step, + block_cherry_wood_hanging_sign_break, + block_cherry_wood_hanging_sign_fall, + block_cherry_wood_hanging_sign_hit, + block_cherry_wood_hanging_sign_place, + block_cherry_wood_door_close, + block_cherry_wood_door_open, + block_cherry_wood_trapdoor_close, + block_cherry_wood_trapdoor_open, + block_cherry_wood_button_click_off, + block_cherry_wood_button_click_on, + block_cherry_wood_pressure_plate_click_off, + block_cherry_wood_pressure_plate_click_on, + block_cherry_wood_fence_gate_close, + block_cherry_wood_fence_gate_open, + block_chest_close, + block_chest_locked, + block_chest_open, + entity_baby_chicken_ambient, + entity_baby_chicken_death, + entity_chicken_egg, + entity_baby_chicken_hurt, + entity_chicken_step, + entity_baby_chicken_step, + entity_chicken_ambient, + entity_chicken_hurt, + entity_chicken_death, + entity_chicken_picky_ambient, + entity_chicken_picky_hurt, + entity_chicken_picky_death, + block_chiseled_bookshelf_break, + block_chiseled_bookshelf_fall, + block_chiseled_bookshelf_hit, + block_chiseled_bookshelf_insert, + block_chiseled_bookshelf_insert_enchanted, + block_chiseled_bookshelf_step, + block_chiseled_bookshelf_pickup, + block_chiseled_bookshelf_pickup_enchanted, + block_chiseled_bookshelf_place, + block_chorus_flower_death, + block_chorus_flower_grow, + item_chorus_fruit_teleport, + block_cobweb_break, + block_cobweb_step, + block_cobweb_place, + block_cobweb_hit, + block_cobweb_fall, + entity_cod_ambient, + entity_cod_death, + entity_cod_flop, + entity_cod_hurt, + block_comparator_click, + block_composter_empty, + block_composter_fill, + block_composter_fill_success, + block_composter_ready, + block_conduit_activate, + block_conduit_ambient, + block_conduit_ambient_short, + block_conduit_attack_target, + block_conduit_deactivate, + block_copper_bulb_break, + block_copper_bulb_step, + block_copper_bulb_place, + block_copper_bulb_hit, + block_copper_bulb_fall, + block_copper_bulb_turn_on, + block_copper_bulb_turn_off, + block_copper_break, + block_copper_step, + block_copper_place, + block_copper_hit, + block_copper_fall, + block_copper_chest_close, + block_copper_chest_open, + block_copper_chest_weathered_close, + block_copper_chest_weathered_open, + block_copper_chest_oxidized_close, + block_copper_chest_oxidized_open, + block_copper_door_close, + block_copper_door_open, + entity_copper_golem_step, + entity_copper_golem_hurt, + entity_copper_golem_death, + entity_copper_golem_weathered_step, + entity_copper_golem_weathered_hurt, + entity_copper_golem_weathered_death, + entity_copper_golem_oxidized_step, + entity_copper_golem_oxidized_hurt, + entity_copper_golem_oxidized_death, + entity_copper_golem_spin, + entity_copper_golem_weathered_spin, + entity_copper_golem_oxidized_spin, + entity_copper_golem_no_item_get, + entity_copper_golem_no_item_no_get, + entity_copper_golem_item_drop, + entity_copper_golem_item_no_drop, + entity_copper_golem_become_statue, + block_copper_golem_statue_break, + block_copper_golem_statue_place, + block_copper_golem_statue_hit, + block_copper_golem_statue_step, + block_copper_golem_statue_fall, + entity_copper_golem_spawn, + entity_copper_golem_shear, + block_copper_grate_break, + block_copper_grate_step, + block_copper_grate_place, + block_copper_grate_hit, + block_copper_grate_fall, + block_copper_trapdoor_close, + block_copper_trapdoor_open, + block_coral_block_break, + block_coral_block_fall, + block_coral_block_hit, + block_coral_block_place, + block_coral_block_step, + entity_cow_milk, + entity_cow_ambient, + entity_cow_hurt, + entity_cow_death, + entity_cow_step, + entity_cow_moody_ambient, + entity_cow_moody_hurt, + entity_cow_moody_death, + entity_cow_moody_step, + block_crafter_craft, + block_crafter_fail, + entity_creaking_ambient, + entity_creaking_activate, + entity_creaking_deactivate, + entity_creaking_attack, + entity_creaking_death, + entity_creaking_step, + entity_creaking_freeze, + entity_creaking_unfreeze, + entity_creaking_spawn, + entity_creaking_sway, + entity_creaking_twitch, + block_creaking_heart_break, + block_creaking_heart_fall, + block_creaking_heart_hit, + block_creaking_heart_hurt, + block_creaking_heart_place, + block_creaking_heart_step, + block_creaking_heart_idle, + block_creaking_heart_spawn, + entity_creeper_death, + entity_creeper_hurt, + entity_creeper_primed, + block_crop_break, + item_crop_plant, + item_crossbow_hit, + item_crossbow_loading_end, + item_crossbow_loading_middle, + item_crossbow_loading_start, + item_crossbow_quick_charge_1, + item_crossbow_quick_charge_2, + item_crossbow_quick_charge_3, + item_crossbow_shoot, + block_deadbush_idle, + block_decorated_pot_break, + block_decorated_pot_fall, + block_decorated_pot_hit, + block_decorated_pot_insert, + block_decorated_pot_insert_fail, + block_decorated_pot_step, + block_decorated_pot_place, + block_decorated_pot_shatter, + block_deepslate_bricks_break, + block_deepslate_bricks_fall, + block_deepslate_bricks_hit, + block_deepslate_bricks_place, + block_deepslate_bricks_step, + block_deepslate_break, + block_deepslate_fall, + block_deepslate_hit, + block_deepslate_place, + block_deepslate_step, + block_deepslate_tiles_break, + block_deepslate_tiles_fall, + block_deepslate_tiles_hit, + block_deepslate_tiles_place, + block_deepslate_tiles_step, + block_dispenser_dispense, + block_dispenser_fail, + block_dispenser_launch, + entity_dolphin_ambient, + entity_dolphin_ambient_water, + entity_dolphin_attack, + entity_dolphin_death, + entity_dolphin_eat, + entity_dolphin_hurt, + entity_dolphin_jump, + entity_dolphin_play, + entity_dolphin_splash, + entity_dolphin_swim, + entity_donkey_ambient, + entity_donkey_angry, + entity_donkey_chest, + entity_donkey_death, + entity_donkey_eat, + entity_donkey_hurt, + entity_donkey_jump, + block_dried_ghast_break, + block_dried_ghast_step, + block_dried_ghast_fall, + block_dried_ghast_ambient, + block_dried_ghast_ambient_water, + block_dried_ghast_place, + block_dried_ghast_place_in_water, + block_dried_ghast_transition, + block_dripstone_block_break, + block_dripstone_block_step, + block_dripstone_block_place, + block_dripstone_block_hit, + block_dripstone_block_fall, + block_dry_grass_ambient, + block_pointed_dripstone_break, + block_pointed_dripstone_step, + block_pointed_dripstone_place, + block_pointed_dripstone_hit, + block_pointed_dripstone_fall, + block_pointed_dripstone_land, + block_pointed_dripstone_drip_lava, + block_pointed_dripstone_drip_water, + block_pointed_dripstone_drip_lava_into_cauldron, + block_pointed_dripstone_drip_water_into_cauldron, + block_big_dripleaf_tilt_down, + block_big_dripleaf_tilt_up, + entity_drowned_ambient, + entity_drowned_ambient_water, + entity_drowned_death, + entity_drowned_death_water, + entity_drowned_hurt, + entity_drowned_hurt_water, + entity_drowned_shoot, + entity_drowned_step, + entity_drowned_swim, + item_dye_use, + entity_egg_throw, + entity_elder_guardian_ambient, + entity_elder_guardian_ambient_land, + entity_elder_guardian_curse, + entity_elder_guardian_death, + entity_elder_guardian_death_land, + entity_elder_guardian_flop, + entity_elder_guardian_hurt, + entity_elder_guardian_hurt_land, + item_elytra_flying, + block_enchantment_table_use, + block_ender_chest_close, + block_ender_chest_open, + entity_ender_dragon_ambient, + entity_ender_dragon_death, + entity_dragon_fireball_explode, + entity_ender_dragon_flap, + entity_ender_dragon_growl, + entity_ender_dragon_hurt, + entity_ender_dragon_shoot, + entity_ender_eye_death, + entity_ender_eye_launch, + entity_enderman_ambient, + entity_enderman_death, + entity_enderman_hurt, + entity_enderman_scream, + entity_enderman_stare, + entity_enderman_teleport, + entity_endermite_ambient, + entity_endermite_death, + entity_endermite_hurt, + entity_endermite_step, + entity_ender_pearl_throw, + block_end_gateway_spawn, + block_end_portal_frame_fill, + block_end_portal_spawn, + entity_evoker_ambient, + entity_evoker_cast_spell, + entity_evoker_celebrate, + entity_evoker_death, + entity_evoker_fangs_attack, + entity_evoker_hurt, + entity_evoker_prepare_attack, + entity_evoker_prepare_summon, + entity_evoker_prepare_wololo, + entity_experience_bottle_throw, + entity_experience_orb_pickup, + block_eyeblossom_open_long, + block_eyeblossom_open, + block_eyeblossom_close_long, + block_eyeblossom_close, + block_eyeblossom_idle, + block_fence_gate_close, + block_fence_gate_open, + item_firecharge_use, + block_firefly_bush_idle, + entity_firework_rocket_blast, + entity_firework_rocket_blast_far, + entity_firework_rocket_large_blast, + entity_firework_rocket_large_blast_far, + entity_firework_rocket_launch, + entity_firework_rocket_shoot, + entity_firework_rocket_twinkle, + entity_firework_rocket_twinkle_far, + block_fire_ambient, + block_fire_extinguish, + entity_fish_swim, + entity_fishing_bobber_retrieve, + entity_fishing_bobber_splash, + entity_fishing_bobber_throw, + item_flintandsteel_use, + block_flowering_azalea_break, + block_flowering_azalea_fall, + block_flowering_azalea_hit, + block_flowering_azalea_place, + block_flowering_azalea_step, + entity_fox_aggro, + entity_fox_ambient, + entity_fox_bite, + entity_fox_death, + entity_fox_eat, + entity_fox_hurt, + entity_fox_screech, + entity_fox_sleep, + entity_fox_sniff, + entity_fox_spit, + entity_fox_teleport, + block_suspicious_sand_break, + block_suspicious_sand_step, + block_suspicious_sand_place, + block_suspicious_sand_hit, + block_suspicious_sand_fall, + block_suspicious_gravel_break, + block_suspicious_gravel_step, + block_suspicious_gravel_place, + block_suspicious_gravel_hit, + block_suspicious_gravel_fall, + block_froglight_break, + block_froglight_fall, + block_froglight_hit, + block_froglight_place, + block_froglight_step, + block_frogspawn_step, + block_frogspawn_break, + block_frogspawn_fall, + block_frogspawn_hatch, + block_frogspawn_hit, + block_frogspawn_place, + entity_frog_ambient, + entity_frog_death, + entity_frog_eat, + entity_frog_hurt, + entity_frog_lay_spawn, + entity_frog_long_jump, + entity_frog_step, + entity_frog_tongue, + block_roots_break, + block_roots_step, + block_roots_place, + block_roots_hit, + block_roots_fall, + block_furnace_fire_crackle, + entity_generic_big_fall, + entity_generic_burn, + entity_generic_death, + entity_generic_drink, + entity_generic_eat, + entity_generic_explode, + entity_generic_extinguish_fire, + entity_generic_hurt, + entity_generic_small_fall, + entity_generic_splash, + entity_generic_swim, + entity_ghast_ambient, + entity_ghast_death, + entity_ghast_hurt, + entity_ghast_scream, + entity_ghast_shoot, + entity_ghast_warn, + entity_ghastling_ambient, + entity_ghastling_death, + entity_ghastling_hurt, + entity_ghastling_spawn, + block_gilded_blackstone_break, + block_gilded_blackstone_fall, + block_gilded_blackstone_hit, + block_gilded_blackstone_place, + block_gilded_blackstone_step, + block_glass_break, + block_glass_fall, + block_glass_hit, + block_glass_place, + block_glass_step, + item_glow_ink_sac_use, + entity_glow_item_frame_add_item, + entity_glow_item_frame_break, + entity_glow_item_frame_place, + entity_glow_item_frame_remove_item, + entity_glow_item_frame_rotate_item, + entity_glow_squid_ambient, + entity_glow_squid_death, + entity_glow_squid_hurt, + entity_glow_squid_squirt, + entity_goat_ambient, + entity_goat_death, + entity_goat_eat, + entity_goat_hurt, + entity_goat_long_jump, + entity_goat_milk, + entity_goat_prepare_ram, + entity_goat_ram_impact, + entity_goat_horn_break, + entity_goat_screaming_ambient, + entity_goat_screaming_death, + entity_goat_screaming_eat, + entity_goat_screaming_hurt, + entity_goat_screaming_long_jump, + entity_goat_screaming_milk, + entity_goat_screaming_prepare_ram, + entity_goat_screaming_ram_impact, + entity_goat_step, + item_golden_dandelion_use, + item_golden_dandelion_unuse, + block_grass_break, + block_grass_fall, + block_grass_hit, + block_grass_place, + block_grass_step, + block_gravel_break, + block_gravel_fall, + block_gravel_hit, + block_gravel_place, + block_gravel_step, + block_grindstone_use, + block_growing_plant_crop, + entity_guardian_ambient, + entity_guardian_ambient_land, + entity_guardian_attack, + entity_guardian_death, + entity_guardian_death_land, + entity_guardian_flop, + entity_guardian_hurt, + entity_guardian_hurt_land, + block_hanging_roots_break, + block_hanging_roots_fall, + block_hanging_roots_hit, + block_hanging_roots_place, + block_hanging_roots_step, + block_hanging_sign_step, + block_hanging_sign_break, + block_hanging_sign_fall, + block_hanging_sign_hit, + block_hanging_sign_place, + entity_happy_ghast_ambient, + entity_happy_ghast_death, + entity_happy_ghast_hurt, + entity_happy_ghast_riding, + block_heavy_core_break, + block_heavy_core_fall, + block_heavy_core_hit, + block_heavy_core_place, + block_heavy_core_step, + block_nether_wood_hanging_sign_step, + block_nether_wood_hanging_sign_break, + block_nether_wood_hanging_sign_fall, + block_nether_wood_hanging_sign_hit, + block_nether_wood_hanging_sign_place, + block_bamboo_wood_hanging_sign_step, + block_bamboo_wood_hanging_sign_break, + block_bamboo_wood_hanging_sign_fall, + block_bamboo_wood_hanging_sign_hit, + block_bamboo_wood_hanging_sign_place, + block_trial_spawner_break, + block_trial_spawner_step, + block_trial_spawner_place, + block_trial_spawner_hit, + block_trial_spawner_fall, + block_trial_spawner_spawn_mob, + block_trial_spawner_about_to_spawn_item, + block_trial_spawner_spawn_item, + block_trial_spawner_spawn_item_begin, + block_trial_spawner_detect_player, + block_trial_spawner_ominous_activate, + block_trial_spawner_ambient, + block_trial_spawner_ambient_ominous, + block_trial_spawner_open_shutter, + block_trial_spawner_close_shutter, + block_trial_spawner_eject_item, + entity_happy_ghast_equip, + entity_happy_ghast_unequip, + entity_happy_ghast_harness_goggles_up, + entity_happy_ghast_harness_goggles_down, + item_hoe_till, + entity_hoglin_ambient, + entity_hoglin_angry, + entity_hoglin_attack, + entity_hoglin_converted_to_zombified, + entity_hoglin_death, + entity_hoglin_hurt, + entity_hoglin_retreat, + entity_hoglin_step, + block_honey_block_break, + block_honey_block_fall, + block_honey_block_hit, + block_honey_block_place, + block_honey_block_slide, + block_honey_block_step, + item_honeycomb_wax_on, + item_honey_bottle_drink, + item_goat_horn_sound_0, + item_goat_horn_sound_1, + item_goat_horn_sound_2, + item_goat_horn_sound_3, + item_goat_horn_sound_4, + item_goat_horn_sound_5, + item_goat_horn_sound_6, + item_goat_horn_sound_7, + entity_horse_ambient, + entity_baby_horse_ambient, + entity_horse_angry, + entity_baby_horse_angry, + entity_horse_armor, + item_horse_armor_unequip, + entity_horse_breathe, + entity_baby_horse_breathe, + entity_horse_death, + entity_baby_horse_death, + entity_horse_eat, + entity_baby_horse_eat, + entity_horse_gallop, + entity_horse_hurt, + entity_baby_horse_hurt, + entity_horse_jump, + entity_horse_land, + entity_baby_horse_land, + entity_horse_saddle, + entity_horse_step, + entity_baby_horse_step, + entity_horse_step_wood, + entity_hostile_big_fall, + entity_hostile_death, + entity_hostile_hurt, + entity_hostile_small_fall, + entity_hostile_splash, + entity_hostile_swim, + entity_husk_ambient, + entity_husk_converted_to_zombie, + entity_husk_death, + entity_husk_hurt, + entity_husk_step, + entity_illusioner_ambient, + entity_illusioner_cast_spell, + entity_illusioner_death, + entity_illusioner_hurt, + entity_illusioner_mirror_move, + entity_illusioner_prepare_blindness, + entity_illusioner_prepare_mirror, + item_ink_sac_use, + block_iron_break, + block_iron_step, + block_iron_place, + block_iron_hit, + block_iron_fall, + block_iron_door_close, + block_iron_door_open, + entity_iron_golem_attack, + entity_iron_golem_damage, + entity_iron_golem_death, + entity_iron_golem_hurt, + entity_iron_golem_repair, + entity_iron_golem_step, + block_iron_trapdoor_close, + block_iron_trapdoor_open, + entity_item_frame_add_item, + entity_item_frame_break, + entity_item_frame_place, + entity_item_frame_remove_item, + entity_item_frame_rotate_item, + entity_item_break, + entity_item_pickup, + block_ladder_break, + block_ladder_fall, + block_ladder_hit, + block_ladder_place, + block_ladder_step, + block_lantern_break, + block_lantern_fall, + block_lantern_hit, + block_lantern_place, + block_lantern_step, + block_large_amethyst_bud_break, + block_large_amethyst_bud_place, + block_lava_ambient, + block_lava_extinguish, + block_lava_pop, + block_leaf_litter_break, + block_leaf_litter_step, + block_leaf_litter_place, + block_leaf_litter_hit, + block_leaf_litter_fall, + item_lead_untied, + item_lead_tied, + item_lead_break, + block_lever_click, + entity_lightning_bolt_impact, + entity_lightning_bolt_thunder, + entity_lingering_potion_throw, + entity_llama_ambient, + entity_llama_angry, + entity_llama_chest, + entity_llama_death, + entity_llama_eat, + entity_llama_hurt, + entity_llama_spit, + entity_llama_step, + entity_llama_swag, + item_llama_carpet_unequip, + entity_magma_cube_death_small, + block_lodestone_break, + block_lodestone_step, + block_lodestone_place, + block_lodestone_hit, + block_lodestone_fall, + item_lodestone_compass_lock, + item_spear_lunge_1, + item_spear_lunge_2, + item_spear_lunge_3, + item_mace_smash_air, + item_mace_smash_ground, + item_mace_smash_ground_heavy, + entity_magma_cube_death, + entity_magma_cube_hurt, + entity_magma_cube_hurt_small, + entity_magma_cube_jump, + entity_magma_cube_squish, + entity_magma_cube_squish_small, + block_mangrove_roots_break, + block_mangrove_roots_fall, + block_mangrove_roots_hit, + block_mangrove_roots_place, + block_mangrove_roots_step, + block_medium_amethyst_bud_break, + block_medium_amethyst_bud_place, + block_metal_break, + block_metal_fall, + block_metal_hit, + block_metal_place, + block_metal_pressure_plate_click_off, + block_metal_pressure_plate_click_on, + block_metal_step, + entity_minecart_inside_underwater, + entity_minecart_inside, + entity_minecart_riding, + entity_mooshroom_convert, + entity_mooshroom_eat, + entity_mooshroom_milk, + entity_mooshroom_suspicious_milk, + entity_mooshroom_shear, + block_moss_carpet_break, + block_moss_carpet_fall, + block_moss_carpet_hit, + block_moss_carpet_place, + block_moss_carpet_step, + block_pink_petals_break, + block_pink_petals_fall, + block_pink_petals_hit, + block_pink_petals_place, + block_pink_petals_step, + block_moss_break, + block_moss_fall, + block_moss_hit, + block_moss_place, + block_moss_step, + block_mud_break, + block_mud_fall, + block_mud_hit, + block_mud_place, + block_mud_step, + block_mud_bricks_break, + block_mud_bricks_fall, + block_mud_bricks_hit, + block_mud_bricks_place, + block_mud_bricks_step, + block_muddy_mangrove_roots_break, + block_muddy_mangrove_roots_fall, + block_muddy_mangrove_roots_hit, + block_muddy_mangrove_roots_place, + block_muddy_mangrove_roots_step, + entity_mule_ambient, + entity_mule_angry, + entity_mule_chest, + entity_mule_death, + entity_mule_eat, + entity_mule_hurt, + entity_mule_jump, + music_creative, + music_credits, + music_disc_5, + music_disc_11, + music_disc_13, + music_disc_blocks, + music_disc_bounce, + music_disc_cat, + music_disc_chirp, + music_disc_far, + music_disc_lava_chicken, + music_disc_mall, + music_disc_mellohi, + music_disc_pigstep, + music_disc_stal, + music_disc_strad, + music_disc_wait, + music_disc_ward, + music_disc_otherside, + music_disc_relic, + music_disc_creator, + music_disc_creator_music_box, + music_disc_precipice, + music_disc_tears, + music_dragon, + music_end, + music_game, + music_menu, + music_nether_basalt_deltas, + music_nether_crimson_forest, + music_overworld_deep_dark, + music_overworld_dripstone_caves, + music_overworld_grove, + music_overworld_jagged_peaks, + music_overworld_lush_caves, + music_overworld_swamp, + music_overworld_forest, + music_overworld_old_growth_taiga, + music_overworld_meadow, + music_overworld_cherry_grove, + music_nether_nether_wastes, + music_overworld_frozen_peaks, + music_overworld_snowy_slopes, + music_nether_soul_sand_valley, + music_overworld_stony_peaks, + music_nether_warped_forest, + music_overworld_flower_forest, + music_overworld_desert, + music_overworld_badlands, + music_overworld_jungle, + music_overworld_sparse_jungle, + music_overworld_bamboo_jungle, + music_overworld_sulfur_caves, + music_under_water, + entity_nautilus_ambient, + entity_nautilus_ambient_land, + entity_nautilus_dash, + entity_nautilus_dash_land, + entity_nautilus_dash_ready, + entity_nautilus_dash_ready_land, + entity_nautilus_death, + entity_nautilus_death_land, + entity_nautilus_eat, + entity_nautilus_hurt, + entity_nautilus_hurt_land, + entity_nautilus_swim, + block_nether_bricks_break, + block_nether_bricks_step, + block_nether_bricks_place, + block_nether_bricks_hit, + block_nether_bricks_fall, + block_nether_wart_break, + item_nether_wart_plant, + block_nether_wood_break, + block_nether_wood_fall, + block_nether_wood_hit, + block_nether_wood_place, + block_nether_wood_step, + block_nether_wood_door_close, + block_nether_wood_door_open, + block_nether_wood_trapdoor_close, + block_nether_wood_trapdoor_open, + block_nether_wood_button_click_off, + block_nether_wood_button_click_on, + block_nether_wood_pressure_plate_click_off, + block_nether_wood_pressure_plate_click_on, + block_nether_wood_fence_gate_close, + block_nether_wood_fence_gate_open, + intentionally_empty, + block_packed_mud_break, + block_packed_mud_fall, + block_packed_mud_hit, + block_packed_mud_place, + block_packed_mud_step, + block_stem_break, + block_stem_step, + block_stem_place, + block_stem_hit, + block_stem_fall, + block_nylium_break, + block_nylium_step, + block_nylium_place, + block_nylium_hit, + block_nylium_fall, + block_nether_sprouts_break, + block_nether_sprouts_step, + block_nether_sprouts_place, + block_nether_sprouts_hit, + block_nether_sprouts_fall, + block_fungus_break, + block_fungus_step, + block_fungus_place, + block_fungus_hit, + block_fungus_fall, + block_weeping_vines_break, + block_weeping_vines_step, + block_weeping_vines_place, + block_weeping_vines_hit, + block_weeping_vines_fall, + block_wart_block_break, + block_wart_block_step, + block_wart_block_place, + block_wart_block_hit, + block_wart_block_fall, + block_netherite_block_break, + block_netherite_block_step, + block_netherite_block_place, + block_netherite_block_hit, + block_netherite_block_fall, + block_netherrack_break, + block_netherrack_step, + block_netherrack_place, + block_netherrack_hit, + block_netherrack_fall, + block_note_block_basedrum, + block_note_block_bass, + block_note_block_bell, + block_note_block_chime, + block_note_block_flute, + block_note_block_guitar, + block_note_block_harp, + block_note_block_hat, + block_note_block_pling, + block_note_block_snare, + block_note_block_trumpet, + block_note_block_trumpet_exposed, + block_note_block_trumpet_oxidized, + block_note_block_trumpet_weathered, + block_note_block_xylophone, + block_note_block_iron_xylophone, + block_note_block_cow_bell, + block_note_block_didgeridoo, + block_note_block_bit, + block_note_block_banjo, + block_note_block_imitate_zombie, + block_note_block_imitate_skeleton, + block_note_block_imitate_creeper, + block_note_block_imitate_ender_dragon, + block_note_block_imitate_wither_skeleton, + block_note_block_imitate_piglin, + entity_ocelot_hurt, + entity_ocelot_ambient, + entity_ocelot_death, + item_ominous_bottle_dispose, + entity_painting_break, + entity_painting_place, + block_pale_hanging_moss_idle, + entity_panda_pre_sneeze, + entity_panda_sneeze, + entity_panda_ambient, + entity_panda_death, + entity_panda_eat, + entity_panda_step, + entity_panda_cant_breed, + entity_panda_aggressive_ambient, + entity_panda_worried_ambient, + entity_panda_hurt, + entity_panda_bite, + entity_parched_ambient, + entity_parched_death, + entity_parched_hurt, + entity_parched_step, + entity_parrot_ambient, + entity_parrot_death, + entity_parrot_eat, + entity_parrot_fly, + entity_parrot_hurt, + entity_parrot_imitate_blaze, + entity_parrot_imitate_bogged, + entity_parrot_imitate_breeze, + entity_parrot_imitate_camel_husk, + entity_parrot_imitate_creaking, + entity_parrot_imitate_creeper, + entity_parrot_imitate_drowned, + entity_parrot_imitate_elder_guardian, + entity_parrot_imitate_ender_dragon, + entity_parrot_imitate_endermite, + entity_parrot_imitate_evoker, + entity_parrot_imitate_ghast, + entity_parrot_imitate_guardian, + entity_parrot_imitate_hoglin, + entity_parrot_imitate_husk, + entity_parrot_imitate_illusioner, + entity_parrot_imitate_magma_cube, + entity_parrot_imitate_phantom, + entity_parrot_imitate_parched, + entity_parrot_imitate_piglin, + entity_parrot_imitate_piglin_brute, + entity_parrot_imitate_pillager, + entity_parrot_imitate_ravager, + entity_parrot_imitate_shulker, + entity_parrot_imitate_silverfish, + entity_parrot_imitate_skeleton, + entity_parrot_imitate_slime, + entity_parrot_imitate_spider, + entity_parrot_imitate_stray, + entity_parrot_imitate_vex, + entity_parrot_imitate_vindicator, + entity_parrot_imitate_warden, + entity_parrot_imitate_witch, + entity_parrot_imitate_wither, + entity_parrot_imitate_wither_skeleton, + entity_parrot_imitate_zoglin, + entity_parrot_imitate_zombie, + entity_parrot_imitate_zombie_horse, + entity_parrot_imitate_zombie_nautilus, + entity_parrot_imitate_zombie_villager, + entity_parrot_step, + entity_phantom_ambient, + entity_phantom_bite, + entity_phantom_death, + entity_phantom_flap, + entity_phantom_hurt, + entity_phantom_swoop, + entity_pig_saddle, + entity_pig_step, + entity_baby_pig_step, + entity_baby_pig_ambient, + entity_baby_pig_eat, + entity_baby_pig_hurt, + entity_baby_pig_death, + entity_pig_ambient, + entity_pig_hurt, + entity_pig_death, + entity_pig_eat, + entity_pig_mini_ambient, + entity_pig_mini_hurt, + entity_pig_mini_death, + entity_pig_mini_eat, + entity_pig_big_ambient, + entity_pig_big_hurt, + entity_pig_big_death, + entity_pig_big_eat, + entity_piglin_admiring_item, + entity_piglin_ambient, + entity_piglin_angry, + entity_piglin_celebrate, + entity_piglin_death, + entity_piglin_jealous, + entity_piglin_hurt, + entity_piglin_retreat, + entity_piglin_step, + entity_piglin_converted_to_zombified, + entity_piglin_brute_ambient, + entity_piglin_brute_angry, + entity_piglin_brute_death, + entity_piglin_brute_hurt, + entity_piglin_brute_step, + entity_piglin_brute_converted_to_zombified, + entity_pillager_ambient, + entity_pillager_celebrate, + entity_pillager_death, + entity_pillager_hurt, + block_piston_contract, + block_piston_extend, + entity_player_attack_crit, + entity_player_attack_knockback, + entity_player_attack_nodamage, + entity_player_attack_strong, + entity_player_attack_sweep, + entity_player_attack_weak, + entity_player_big_fall, + entity_player_breath, + entity_player_burp, + entity_player_death, + entity_player_hurt, + entity_player_hurt_drown, + entity_player_hurt_freeze, + entity_player_hurt_on_fire, + entity_player_hurt_sweet_berry_bush, + entity_player_levelup, + entity_player_small_fall, + entity_player_splash, + entity_player_splash_high_speed, + entity_player_swim, + entity_player_teleport, + entity_polar_bear_ambient, + entity_polar_bear_ambient_baby, + entity_polar_bear_death, + entity_polar_bear_hurt, + entity_polar_bear_step, + entity_polar_bear_warning, + block_polished_deepslate_break, + block_polished_deepslate_fall, + block_polished_deepslate_hit, + block_polished_deepslate_place, + block_polished_deepslate_step, + block_portal_ambient, + block_portal_travel, + block_portal_trigger, + block_powder_snow_break, + block_powder_snow_fall, + block_powder_snow_hit, + block_powder_snow_place, + block_powder_snow_step, + entity_puffer_fish_blow_out, + entity_puffer_fish_blow_up, + entity_puffer_fish_death, + entity_puffer_fish_flop, + entity_puffer_fish_hurt, + entity_puffer_fish_sting, + block_pumpkin_carve, + entity_rabbit_ambient, + entity_rabbit_attack, + entity_rabbit_death, + entity_rabbit_hurt, + entity_rabbit_jump, + event_raid_horn, + entity_ravager_ambient, + entity_ravager_attack, + entity_ravager_celebrate, + entity_ravager_death, + entity_ravager_hurt, + entity_ravager_step, + entity_ravager_stunned, + entity_ravager_roar, + block_nether_gold_ore_break, + block_nether_gold_ore_fall, + block_nether_gold_ore_hit, + block_nether_gold_ore_place, + block_nether_gold_ore_step, + block_nether_ore_break, + block_nether_ore_fall, + block_nether_ore_hit, + block_nether_ore_place, + block_nether_ore_step, + block_redstone_torch_burnout, + block_resin_break, + block_resin_fall, + block_resin_place, + block_resin_step, + block_resin_bricks_break, + block_resin_bricks_fall, + block_resin_bricks_hit, + block_resin_bricks_place, + block_resin_bricks_step, + block_respawn_anchor_ambient, + block_respawn_anchor_charge, + block_respawn_anchor_deplete, + block_respawn_anchor_set_spawn, + block_rooted_dirt_break, + block_rooted_dirt_fall, + block_rooted_dirt_hit, + block_rooted_dirt_place, + block_rooted_dirt_step, + entity_salmon_ambient, + entity_salmon_death, + entity_salmon_flop, + entity_salmon_hurt, + block_sand_break, + block_sand_fall, + block_sand_hit, + block_sand_place, + block_sand_step, + block_sand_idle, + block_scaffolding_break, + block_scaffolding_fall, + block_scaffolding_hit, + block_scaffolding_place, + block_scaffolding_step, + block_sculk_spread, + block_sculk_charge, + block_sculk_break, + block_sculk_fall, + block_sculk_hit, + block_sculk_place, + block_sculk_step, + block_sculk_catalyst_bloom, + block_sculk_catalyst_break, + block_sculk_catalyst_fall, + block_sculk_catalyst_hit, + block_sculk_catalyst_place, + block_sculk_catalyst_step, + block_sculk_sensor_clicking, + block_sculk_sensor_clicking_stop, + block_sculk_sensor_break, + block_sculk_sensor_fall, + block_sculk_sensor_hit, + block_sculk_sensor_place, + block_sculk_sensor_step, + block_sculk_shrieker_break, + block_sculk_shrieker_fall, + block_sculk_shrieker_hit, + block_sculk_shrieker_place, + block_sculk_shrieker_shriek, + block_sculk_shrieker_step, + block_sculk_vein_break, + block_sculk_vein_fall, + block_sculk_vein_hit, + block_sculk_vein_place, + block_sculk_vein_step, + entity_sheep_ambient, + entity_sheep_death, + entity_sheep_hurt, + entity_sheep_shear, + entity_sheep_step, + item_shears_snip, + block_shelf_activate, + block_shelf_break, + block_shelf_deactivate, + block_shelf_fall, + block_shelf_hit, + block_shelf_multi_swap, + block_shelf_place, + block_shelf_place_item, + block_shelf_single_swap, + block_shelf_step, + block_shelf_take_item, + item_shield_block, + item_shield_break, + block_shroomlight_break, + block_shroomlight_step, + block_shroomlight_place, + block_shroomlight_hit, + block_shroomlight_fall, + item_shovel_flatten, + entity_shulker_ambient, + block_shulker_box_close, + block_shulker_box_open, + entity_shulker_bullet_hit, + entity_shulker_bullet_hurt, + entity_shulker_close, + entity_shulker_death, + entity_shulker_hurt, + entity_shulker_hurt_closed, + entity_shulker_open, + entity_shulker_shoot, + entity_shulker_teleport, + entity_silverfish_ambient, + entity_silverfish_death, + entity_silverfish_hurt, + entity_silverfish_step, + entity_skeleton_ambient, + entity_skeleton_converted_to_stray, + entity_skeleton_death, + entity_skeleton_horse_ambient, + entity_skeleton_horse_death, + entity_skeleton_horse_hurt, + entity_skeleton_horse_swim, + entity_skeleton_horse_ambient_water, + entity_skeleton_horse_gallop_water, + entity_skeleton_horse_jump_water, + entity_skeleton_horse_step_water, + entity_skeleton_hurt, + entity_skeleton_shoot, + entity_skeleton_step, + entity_slime_attack, + entity_slime_death, + entity_slime_hurt, + entity_slime_jump, + entity_slime_squish, + block_slime_block_break, + block_slime_block_fall, + block_slime_block_hit, + block_slime_block_place, + block_slime_block_step, + block_small_amethyst_bud_break, + block_small_amethyst_bud_place, + block_small_dripleaf_break, + block_small_dripleaf_fall, + block_small_dripleaf_hit, + block_small_dripleaf_place, + block_small_dripleaf_step, + block_soul_sand_break, + block_soul_sand_step, + block_soul_sand_place, + block_soul_sand_hit, + block_soul_sand_fall, + block_soul_soil_break, + block_soul_soil_step, + block_soul_soil_place, + block_soul_soil_hit, + block_soul_soil_fall, + particle_soul_escape, + block_spawner_break, + block_spawner_fall, + block_spawner_hit, + block_spawner_place, + block_spawner_step, + item_spear_use, + item_spear_hit, + item_spear_attack, + item_spear_wood_use, + item_spear_wood_hit, + item_spear_wood_attack, + block_spore_blossom_break, + block_spore_blossom_fall, + block_spore_blossom_hit, + block_spore_blossom_place, + block_spore_blossom_step, + entity_strider_ambient, + entity_strider_happy, + entity_strider_retreat, + entity_strider_death, + entity_strider_hurt, + entity_strider_step, + entity_strider_step_lava, + entity_strider_eat, + entity_strider_saddle, + entity_slime_death_small, + entity_slime_hurt_small, + entity_slime_jump_small, + entity_slime_squish_small, + block_smithing_table_use, + block_smoker_smoke, + entity_sniffer_step, + entity_sniffer_eat, + entity_sniffer_idle, + entity_sniffer_hurt, + entity_sniffer_death, + entity_sniffer_drop_seed, + entity_sniffer_scenting, + entity_sniffer_sniffing, + entity_sniffer_searching, + entity_sniffer_digging, + entity_sniffer_digging_stop, + entity_sniffer_happy, + block_sniffer_egg_plop, + block_sniffer_egg_crack, + block_sniffer_egg_hatch, + entity_snowball_throw, + block_snow_break, + block_snow_fall, + entity_snow_golem_ambient, + entity_snow_golem_death, + entity_snow_golem_hurt, + entity_snow_golem_shoot, + entity_snow_golem_shear, + block_snow_hit, + block_snow_place, + block_snow_step, + entity_spider_ambient, + entity_spider_death, + entity_spider_hurt, + entity_spider_step, + entity_splash_potion_break, + entity_splash_potion_throw, + block_sponge_break, + block_sponge_fall, + block_sponge_hit, + block_sponge_place, + block_sponge_step, + block_sponge_absorb, + item_spyglass_use, + item_spyglass_stop_using, + entity_squid_ambient, + entity_squid_death, + entity_squid_hurt, + entity_squid_squirt, + block_stone_break, + block_stone_button_click_off, + block_stone_button_click_on, + block_stone_fall, + block_stone_hit, + block_stone_place, + block_stone_pressure_plate_click_off, + block_stone_pressure_plate_click_on, + block_stone_step, + entity_stray_ambient, + entity_stray_death, + entity_stray_hurt, + entity_stray_step, + block_sulfur_spike_break, + block_sulfur_spike_step, + block_sulfur_spike_place, + block_sulfur_spike_hit, + block_sulfur_spike_fall, + block_sulfur_spike_land, + block_sweet_berry_bush_break, + block_sweet_berry_bush_place, + block_sweet_berry_bush_pick_berries, + entity_tadpole_death, + entity_tadpole_flop, + entity_tadpole_grow_up, + entity_tadpole_hurt, + enchant_thorns_hit, + entity_tnt_primed, + item_totem_use, + item_trident_hit, + item_trident_hit_ground, + item_trident_return, + item_trident_riptide_1, + item_trident_riptide_2, + item_trident_riptide_3, + item_trident_throw, + item_trident_thunder, + block_tripwire_attach, + block_tripwire_click_off, + block_tripwire_click_on, + block_tripwire_detach, + entity_tropical_fish_ambient, + entity_tropical_fish_death, + entity_tropical_fish_flop, + entity_tropical_fish_hurt, + block_tuff_break, + block_tuff_step, + block_tuff_place, + block_tuff_hit, + block_tuff_fall, + block_tuff_bricks_break, + block_tuff_bricks_fall, + block_tuff_bricks_hit, + block_tuff_bricks_place, + block_tuff_bricks_step, + block_polished_tuff_break, + block_polished_tuff_fall, + block_polished_tuff_hit, + block_polished_tuff_place, + block_polished_tuff_step, + entity_turtle_ambient_land, + entity_turtle_death, + entity_turtle_death_baby, + entity_turtle_egg_break, + entity_turtle_egg_crack, + entity_turtle_egg_hatch, + entity_turtle_hurt, + entity_turtle_hurt_baby, + entity_turtle_lay_egg, + entity_turtle_shamble, + entity_turtle_shamble_baby, + entity_turtle_swim, + ui_button_click, + ui_loom_select_pattern, + ui_loom_take_result, + ui_cartography_table_take_result, + ui_stonecutter_take_result, + ui_stonecutter_select_recipe, + ui_toast_challenge_complete, + ui_toast_in, + ui_toast_out, + block_vault_activate, + block_vault_ambient, + block_vault_break, + block_vault_close_shutter, + block_vault_deactivate, + block_vault_eject_item, + block_vault_reject_rewarded_player, + block_vault_fall, + block_vault_hit, + block_vault_insert_item, + block_vault_insert_item_fail, + block_vault_open_shutter, + block_vault_place, + block_vault_step, + entity_vex_ambient, + entity_vex_charge, + entity_vex_death, + entity_vex_hurt, + entity_villager_ambient, + entity_villager_celebrate, + entity_villager_death, + entity_villager_hurt, + entity_villager_no, + entity_villager_trade, + entity_villager_yes, + entity_villager_work_armorer, + entity_villager_work_butcher, + entity_villager_work_cartographer, + entity_villager_work_cleric, + entity_villager_work_farmer, + entity_villager_work_fisherman, + entity_villager_work_fletcher, + entity_villager_work_leatherworker, + entity_villager_work_librarian, + entity_villager_work_mason, + entity_villager_work_shepherd, + entity_villager_work_toolsmith, + entity_villager_work_weaponsmith, + entity_vindicator_ambient, + entity_vindicator_celebrate, + entity_vindicator_death, + entity_vindicator_hurt, + block_vine_break, + block_vine_fall, + block_vine_hit, + block_vine_place, + block_vine_step, + block_lily_pad_place, + entity_wandering_trader_ambient, + entity_wandering_trader_death, + entity_wandering_trader_disappeared, + entity_wandering_trader_drink_milk, + entity_wandering_trader_drink_potion, + entity_wandering_trader_hurt, + entity_wandering_trader_no, + entity_wandering_trader_reappeared, + entity_wandering_trader_trade, + entity_wandering_trader_yes, + entity_warden_agitated, + entity_warden_ambient, + entity_warden_angry, + entity_warden_attack_impact, + entity_warden_death, + entity_warden_dig, + entity_warden_emerge, + entity_warden_heartbeat, + entity_warden_hurt, + entity_warden_listening, + entity_warden_listening_angry, + entity_warden_nearby_close, + entity_warden_nearby_closer, + entity_warden_nearby_closest, + entity_warden_roar, + entity_warden_sniff, + entity_warden_sonic_boom, + entity_warden_sonic_charge, + entity_warden_step, + entity_warden_tendril_clicks, + block_hanging_sign_waxed_interact_fail, + block_sign_waxed_interact_fail, + block_water_ambient, + weather_end_flash, + weather_rain, + weather_rain_above, + block_wet_grass_break, + block_wet_grass_fall, + block_wet_grass_hit, + block_wet_grass_place, + block_wet_grass_step, + block_wet_sponge_break, + block_wet_sponge_dries, + block_wet_sponge_fall, + block_wet_sponge_hit, + block_wet_sponge_place, + block_wet_sponge_step, + entity_wind_charge_wind_burst, + entity_wind_charge_throw, + entity_witch_ambient, + entity_witch_celebrate, + entity_witch_death, + entity_witch_drink, + entity_witch_hurt, + entity_witch_throw, + entity_wither_ambient, + entity_wither_break_block, + entity_wither_death, + entity_wither_hurt, + entity_wither_shoot, + entity_wither_skeleton_ambient, + entity_wither_skeleton_death, + entity_wither_skeleton_hurt, + entity_wither_skeleton_step, + entity_wither_spawn, + item_wolf_armor_break, + entity_baby_wolf_ambient, + item_wolf_armor_crack, + item_wolf_armor_damage, + item_wolf_armor_repair, + entity_baby_wolf_death, + entity_baby_wolf_growl, + entity_baby_wolf_hurt, + entity_baby_wolf_pant, + entity_wolf_shake, + entity_wolf_step, + entity_baby_wolf_step, + entity_baby_wolf_whine, + entity_wolf_ambient, + entity_wolf_death, + entity_wolf_growl, + entity_wolf_hurt, + entity_wolf_pant, + entity_wolf_whine, + entity_wolf_puglin_ambient, + entity_wolf_puglin_death, + entity_wolf_puglin_growl, + entity_wolf_puglin_hurt, + entity_wolf_puglin_pant, + entity_wolf_puglin_whine, + entity_wolf_sad_ambient, + entity_wolf_sad_death, + entity_wolf_sad_growl, + entity_wolf_sad_hurt, + entity_wolf_sad_pant, + entity_wolf_sad_whine, + entity_wolf_angry_ambient, + entity_wolf_angry_death, + entity_wolf_angry_growl, + entity_wolf_angry_hurt, + entity_wolf_angry_pant, + entity_wolf_angry_whine, + entity_wolf_grumpy_ambient, + entity_wolf_grumpy_death, + entity_wolf_grumpy_growl, + entity_wolf_grumpy_hurt, + entity_wolf_grumpy_pant, + entity_wolf_grumpy_whine, + entity_wolf_big_ambient, + entity_wolf_big_death, + entity_wolf_big_growl, + entity_wolf_big_hurt, + entity_wolf_big_pant, + entity_wolf_big_whine, + entity_wolf_cute_ambient, + entity_wolf_cute_death, + entity_wolf_cute_growl, + entity_wolf_cute_hurt, + entity_wolf_cute_pant, + entity_wolf_cute_whine, + block_wooden_door_close, + block_wooden_door_open, + block_wooden_trapdoor_close, + block_wooden_trapdoor_open, + block_wooden_button_click_off, + block_wooden_button_click_on, + block_wooden_pressure_plate_click_off, + block_wooden_pressure_plate_click_on, + block_wood_break, + block_wood_fall, + block_wood_hit, + block_wood_place, + block_wood_step, + block_wool_break, + block_wool_fall, + block_wool_hit, + block_wool_place, + block_wool_step, + entity_zoglin_ambient, + entity_zoglin_angry, + entity_zoglin_attack, + entity_zoglin_death, + entity_zoglin_hurt, + entity_zoglin_step, + entity_zombie_ambient, + entity_zombie_attack_wooden_door, + entity_zombie_attack_iron_door, + entity_zombie_break_wooden_door, + entity_zombie_converted_to_drowned, + entity_zombie_death, + entity_zombie_destroy_egg, + entity_zombie_horse_ambient, + entity_zombie_horse_angry, + entity_zombie_horse_death, + entity_zombie_horse_eat, + entity_zombie_horse_hurt, + entity_zombie_hurt, + entity_zombie_infect, + entity_zombie_nautilus_ambient, + entity_zombie_nautilus_ambient_land, + entity_zombie_nautilus_dash, + entity_zombie_nautilus_dash_land, + entity_zombie_nautilus_dash_ready, + entity_zombie_nautilus_dash_ready_land, + entity_zombie_nautilus_death, + entity_zombie_nautilus_death_land, + entity_zombie_nautilus_eat, + entity_zombie_nautilus_hurt, + entity_zombie_nautilus_hurt_land, + entity_zombie_nautilus_swim, + entity_zombified_piglin_ambient, + entity_zombified_piglin_angry, + entity_zombified_piglin_death, + entity_zombified_piglin_hurt, + entity_zombie_step, + entity_zombie_villager_ambient, + entity_zombie_villager_converted, + entity_zombie_villager_cure, + entity_zombie_villager_death, + entity_zombie_villager_hurt, + entity_zombie_villager_step, + event_mob_effect_bad_omen, + event_mob_effect_trial_omen, + event_mob_effect_raid_omen, + item_saddle_unequip, + item_nautilus_saddle_underwater_equip, + item_nautilus_saddle_equip, + block_sulfur_break, + block_sulfur_step, + block_sulfur_place, + block_sulfur_hit, + block_sulfur_fall, + block_potent_sulfur_break, + block_potent_sulfur_step, + block_potent_sulfur_place, + block_potent_sulfur_hit, + block_potent_sulfur_fall, + block_potent_sulfur_geyser_eruption, + block_potent_sulfur_geyser_eruption_active, + block_potent_sulfur_geyser_continuous_eruption, + block_potent_sulfur_geyser_continuous_eruption_active, + block_cinnabar_break, + block_cinnabar_step, + block_cinnabar_place, + block_cinnabar_hit, + block_cinnabar_fall, + entity_sulfur_cube_absorb, + entity_sulfur_cube_bounce, + entity_sulfur_cube_death, + entity_sulfur_cube_eject, + entity_sulfur_cube_hurt, + entity_sulfur_cube_jump, + entity_sulfur_cube_regular_hit, + entity_sulfur_cube_regular_push, + entity_sulfur_cube_bouncy_hit, + entity_sulfur_cube_bouncy_push, + entity_sulfur_cube_slow_bouncy_hit, + entity_sulfur_cube_slow_bouncy_push, + entity_sulfur_cube_slow_flat_hit, + entity_sulfur_cube_slow_flat_push, + entity_sulfur_cube_fast_flat_hit, + entity_sulfur_cube_fast_flat_push, + entity_sulfur_cube_light_hit, + entity_sulfur_cube_light_push, + entity_sulfur_cube_fast_sliding_hit, + entity_sulfur_cube_fast_sliding_push, + entity_sulfur_cube_slow_sliding_hit, + entity_sulfur_cube_slow_sliding_push, + entity_sulfur_cube_sticky_hit, + entity_sulfur_cube_sticky_push, + entity_sulfur_cube_high_resistance_hit, + entity_sulfur_cube_high_resistance_push, + entity_sulfur_cube_explosive_hit, + entity_sulfur_cube_explosive_push, + entity_sulfur_cube_hot_hit, + entity_sulfur_cube_hot_push, + entity_sulfur_cube_squish, + block_potent_sulfur_noxious_gas, + entity_small_sulfur_cube_death, + entity_small_sulfur_cube_hurt, + entity_small_sulfur_cube_jump, + entity_small_sulfur_cube_squish, + entity_small_sulfur_cube_eat, +}; diff --git a/src/wit/statistics.zig b/src/wit/statistics.zig new file mode 100644 index 0000000..a5424eb --- /dev/null +++ b/src/wit/statistics.zig @@ -0,0 +1,93 @@ +// Generated by tools/gen.zig, do not edit. + +pub const StatisticCategory = enum(u8) { + mined, + crafted, + used, + broken, + picked_up, + dropped, + killed, + killed_by, + custom, +}; + +pub const CustomStatistic = enum(u8) { + leave_game, + play_time, + total_world_time, + time_since_death, + time_since_rest, + sneak_time, + walk_one_cm, + crouch_one_cm, + sprint_one_cm, + walk_on_water_one_cm, + fall_one_cm, + climb_one_cm, + fly_one_cm, + walk_under_water_one_cm, + minecart_one_cm, + boat_one_cm, + pig_one_cm, + happy_ghast_one_cm, + horse_one_cm, + aviate_one_cm, + swim_one_cm, + strider_one_cm, + nautilus_one_cm, + jump, + drop, + damage_dealt, + damage_dealt_absorbed, + damage_dealt_resisted, + damage_taken, + damage_blocked_by_shield, + damage_absorbed, + damage_resisted, + deaths, + mob_kills, + animals_bred, + player_kills, + fish_caught, + talked_to_villager, + traded_with_villager, + eat_cake_slice, + fill_cauldron, + use_cauldron, + clean_armor, + clean_banner, + clean_shulker_box, + interact_with_brewingstand, + interact_with_beacon, + inspect_dropper, + inspect_hopper, + inspect_dispenser, + play_noteblock, + tune_noteblock, + pot_flower, + trigger_trapped_chest, + open_enderchest, + enchant_item, + play_record, + interact_with_furnace, + interact_with_crafting_table, + open_chest, + sleep_in_bed, + open_shulker_box, + open_barrel, + interact_with_blast_furnace, + interact_with_smoker, + interact_with_lectern, + interact_with_campfire, + interact_with_cartography_table, + interact_with_loom, + interact_with_stonecutter, + bell_ring, + raid_trigger, + raid_win, + interact_with_anvil, + interact_with_grindstone, + target_hit, + interact_with_smithing_table, +}; diff --git a/src/wit/status_effect.zig b/src/wit/status_effect.zig new file mode 100644 index 0000000..a9acebf --- /dev/null +++ b/src/wit/status_effect.zig @@ -0,0 +1,52 @@ +// Generated by tools/gen.zig, do not edit. + +pub const StatusEffectType = enum(u8) { + speed, + slowness, + haste, + mining_fatigue, + strength, + instant_health, + instant_damage, + jump_boost, + nausea, + regeneration, + resistance, + fire_resistance, + water_breathing, + invisibility, + blindness, + night_vision, + hunger, + weakness, + poison, + wither, + health_boost, + absorption, + saturation, + glowing, + levitation, + luck, + unluck, + slow_falling, + conduit_power, + dolphins_grace, + bad_omen, + hero_of_the_village, + darkness, + trial_omen, + raid_omen, + wind_charged, + weaving, + oozing, + infested, +}; + +pub const StatusEffectInstance = struct { + effect_type: StatusEffectType, + duration: u32, + amplifier: u8, + ambient: bool, + show_particles: bool, + show_icon: bool, +}; diff --git a/src/wit/text.zig b/src/wit/text.zig new file mode 100644 index 0000000..9ac89ac --- /dev/null +++ b/src/wit/text.zig @@ -0,0 +1,231 @@ +// Generated by tools/gen.zig, do not edit. + +const abi = @import("../abi.zig"); +const common = @import("common.zig"); + +pub const NamedColor = common.NamedColor; +pub const RgbColor = common.RgbColor; +pub const ArgbColor = common.ArgbColor; + +pub const TextComponent = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]text-component"; + + /// Creates a plain text component. + pub fn text(plain: []const u8) TextComponent { + return abi.call(raw.@"[static]text-component.text", TextComponent, .{plain}); + } + + /// Creates a translation component. + pub fn translate(key: []const u8, with: []const TextComponent) TextComponent { + return abi.call(raw.@"[static]text-component.translate", TextComponent, .{ key, with }); + } + + /// Creates a translation component with a Bedrock-specific fallback key. + pub fn translateCross(java_key: []const u8, bedrock_key: []const u8, with: []const TextComponent) TextComponent { + return abi.call(raw.@"[static]text-component.translate-cross", TextComponent, .{ java_key, bedrock_key, with }); + } + + /// Creates an entity names / selector text component. + pub fn entityNames(selector: []const u8, separator: ?[]const u8) TextComponent { + return abi.call(raw.@"[static]text-component.entity-names", TextComponent, .{ selector, separator }); + } + + /// Creates a keybind text component (e.g., "key.jump"). + pub fn keybind(keybind_: []const u8) TextComponent { + return abi.call(raw.@"[static]text-component.keybind", TextComponent, .{keybind_}); + } + + /// Creates a custom translation component. + pub fn custom(namespace: []const u8, key: []const u8, locale: []const u8, with: []const TextComponent) TextComponent { + return abi.call(raw.@"[static]text-component.custom", TextComponent, .{ namespace, key, locale, with }); + } + + /// Parses a legacy Minecraft formatted string (using section signs '§' by default) into a text component. + pub fn fromLegacyString(input: []const u8) TextComponent { + return abi.call(raw.@"[static]text-component.from-legacy-string", TextComponent, .{input}); + } + + /// Parses a legacy formatted string using a custom color code symbol (e.g. '&' or '§'). + pub fn fromLegacyStringWithCode(input: []const u8, code_symbol: u21) TextComponent { + return abi.call(raw.@"[static]text-component.from-legacy-string-with-code", TextComponent, .{ input, code_symbol }); + } + + /// Parses a standard Minecraft JSON text component. + pub fn fromJson(json: []const u8) abi.Result(TextComponent, []const u8) { + return abi.call(raw.@"[static]text-component.from-json", abi.Result(TextComponent, []const u8), .{json}); + } + + /// Serializes the text component to JSON format. + pub fn toJson(self: TextComponent) []const u8 { + return abi.call(raw.@"[method]text-component.to-json", []const u8, .{abi.borrow(self)}); + } + + /// Consumes `child`. + pub fn addChild(self: TextComponent, child: TextComponent) void { + return abi.call(raw.@"[method]text-component.add-child", void, .{ abi.borrow(self), child }); + } + + pub fn addText(self: TextComponent, text_: []const u8) void { + return abi.call(raw.@"[method]text-component.add-text", void, .{ abi.borrow(self), text_ }); + } + + pub fn getText(self: TextComponent) []const u8 { + return abi.call(raw.@"[method]text-component.get-text", []const u8, .{abi.borrow(self)}); + } + + pub fn encode(self: TextComponent) []const u8 { + return abi.call(raw.@"[method]text-component.encode", []const u8, .{abi.borrow(self)}); + } + + pub fn toPrettyConsole(self: TextComponent) []const u8 { + return abi.call(raw.@"[method]text-component.to-pretty-console", []const u8, .{abi.borrow(self)}); + } + + /// Style + pub fn colorNamed(self: TextComponent, color: NamedColor) void { + return abi.call(raw.@"[method]text-component.color-named", void, .{ abi.borrow(self), color }); + } + + pub fn colorRgb(self: TextComponent, color: RgbColor) void { + return abi.call(raw.@"[method]text-component.color-rgb", void, .{ abi.borrow(self), color }); + } + + pub fn gradientNamed(self: TextComponent, colors: []const NamedColor) void { + return abi.call(raw.@"[method]text-component.gradient-named", void, .{ abi.borrow(self), colors }); + } + + pub fn gradient(self: TextComponent, colors: []const RgbColor) void { + return abi.call(raw.@"[method]text-component.gradient", void, .{ abi.borrow(self), colors }); + } + + pub fn rainbow(self: TextComponent) void { + return abi.call(raw.@"[method]text-component.rainbow", void, .{abi.borrow(self)}); + } + + pub fn bold(self: TextComponent, value: bool) void { + return abi.call(raw.@"[method]text-component.bold", void, .{ abi.borrow(self), value }); + } + + pub fn italic(self: TextComponent, value: bool) void { + return abi.call(raw.@"[method]text-component.italic", void, .{ abi.borrow(self), value }); + } + + pub fn underlined(self: TextComponent, value: bool) void { + return abi.call(raw.@"[method]text-component.underlined", void, .{ abi.borrow(self), value }); + } + + pub fn strikethrough(self: TextComponent, value: bool) void { + return abi.call(raw.@"[method]text-component.strikethrough", void, .{ abi.borrow(self), value }); + } + + pub fn obfuscated(self: TextComponent, value: bool) void { + return abi.call(raw.@"[method]text-component.obfuscated", void, .{ abi.borrow(self), value }); + } + + /// Text inserted into chat when shift-clicked + pub fn insertion(self: TextComponent, text_: []const u8) void { + return abi.call(raw.@"[method]text-component.insertion", void, .{ abi.borrow(self), text_ }); + } + + pub fn font(self: TextComponent, font_: []const u8) void { + return abi.call(raw.@"[method]text-component.font", void, .{ abi.borrow(self), font_ }); + } + + pub fn shadowColor(self: TextComponent, color: ArgbColor) void { + return abi.call(raw.@"[method]text-component.shadow-color", void, .{ abi.borrow(self), color }); + } + + /// Click events + pub fn clickOpenUrl(self: TextComponent, url: []const u8) void { + return abi.call(raw.@"[method]text-component.click-open-url", void, .{ abi.borrow(self), url }); + } + + pub fn clickOpenFile(self: TextComponent, path: []const u8) void { + return abi.call(raw.@"[method]text-component.click-open-file", void, .{ abi.borrow(self), path }); + } + + pub fn clickRunCommand(self: TextComponent, command: []const u8) void { + return abi.call(raw.@"[method]text-component.click-run-command", void, .{ abi.borrow(self), command }); + } + + pub fn clickSuggestCommand(self: TextComponent, command: []const u8) void { + return abi.call(raw.@"[method]text-component.click-suggest-command", void, .{ abi.borrow(self), command }); + } + + pub fn clickChangePage(self: TextComponent, page: u32) void { + return abi.call(raw.@"[method]text-component.click-change-page", void, .{ abi.borrow(self), page }); + } + + pub fn clickCopyToClipboard(self: TextComponent, text_: []const u8) void { + return abi.call(raw.@"[method]text-component.click-copy-to-clipboard", void, .{ abi.borrow(self), text_ }); + } + + /// Hover events + /// + /// Consumes `text_`. + pub fn hoverShowText(self: TextComponent, text_: TextComponent) void { + return abi.call(raw.@"[method]text-component.hover-show-text", void, .{ abi.borrow(self), text_ }); + } + + /// Item data as SNBT string + pub fn hoverShowItem(self: TextComponent, item: []const u8) void { + return abi.call(raw.@"[method]text-component.hover-show-item", void, .{ abi.borrow(self), item }); + } + + pub fn hoverShowEntity(self: TextComponent, entity_type: []const u8, id: []const u8, name: ?TextComponent) void { + return abi.call(raw.@"[method]text-component.hover-show-entity", void, .{ abi.borrow(self), entity_type, id, name }); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: TextComponent) void { + abi.keep(TextComponent, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: TextComponent) void { + abi.drop(TextComponent, self); + } +}; + +const raw = struct { + extern "pumpkin:plugin/text@0.1.0" fn @"[static]text-component.text"(i32, i32) i32; + extern "pumpkin:plugin/text@0.1.0" fn @"[static]text-component.translate"(i32, i32, i32, i32) i32; + extern "pumpkin:plugin/text@0.1.0" fn @"[static]text-component.translate-cross"(i32, i32, i32, i32, i32, i32) i32; + extern "pumpkin:plugin/text@0.1.0" fn @"[static]text-component.entity-names"(i32, i32, i32, i32, i32) i32; + extern "pumpkin:plugin/text@0.1.0" fn @"[static]text-component.keybind"(i32, i32) i32; + extern "pumpkin:plugin/text@0.1.0" fn @"[static]text-component.custom"(i32, i32, i32, i32, i32, i32, i32, i32) i32; + extern "pumpkin:plugin/text@0.1.0" fn @"[static]text-component.from-legacy-string"(i32, i32) i32; + extern "pumpkin:plugin/text@0.1.0" fn @"[static]text-component.from-legacy-string-with-code"(i32, i32, i32) i32; + extern "pumpkin:plugin/text@0.1.0" fn @"[static]text-component.from-json"(i32, i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.to-json"(i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.add-child"(i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.add-text"(i32, i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.get-text"(i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.encode"(i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.to-pretty-console"(i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.color-named"(i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.color-rgb"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.gradient-named"(i32, i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.gradient"(i32, i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.rainbow"(i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.bold"(i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.italic"(i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.underlined"(i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.strikethrough"(i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.obfuscated"(i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.insertion"(i32, i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.font"(i32, i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.shadow-color"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.click-open-url"(i32, i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.click-open-file"(i32, i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.click-run-command"(i32, i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.click-suggest-command"(i32, i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.click-change-page"(i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.click-copy-to-clipboard"(i32, i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.hover-show-text"(i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.hover-show-item"(i32, i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[method]text-component.hover-show-entity"(i32, i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/text@0.1.0" fn @"[resource-drop]text-component"(i32) void; +}; diff --git a/src/wit/uuid.zig b/src/wit/uuid.zig new file mode 100644 index 0000000..4912cf0 --- /dev/null +++ b/src/wit/uuid.zig @@ -0,0 +1,30 @@ +// Generated by tools/gen.zig, do not edit. + +const abi = @import("../abi.zig"); + +/// A 128-bit UUID represented as two 64-bit integers. +pub const Uuid = struct { + high: u64, + low: u64, +}; + +/// Generates a new random v4 UUID. +pub fn generate() Uuid { + return abi.call(raw.generate, Uuid, .{}); +} + +/// Parses a UUID from a string. Returns none if the string is not a valid UUID. +pub fn parse(s: []const u8) ?Uuid { + return abi.call(raw.parse, ?Uuid, .{s}); +} + +/// Converts a UUID to its standard string representation. +pub fn toString(id: Uuid) []const u8 { + return abi.call(raw.@"to-string", []const u8, .{id}); +} + +const raw = struct { + extern "pumpkin:plugin/uuid@0.1.0" fn generate(i32) void; + extern "pumpkin:plugin/uuid@0.1.0" fn parse(i32, i32, i32) void; + extern "pumpkin:plugin/uuid@0.1.0" fn @"to-string"(i64, i64, i32) void; +}; diff --git a/src/wit/world.zig b/src/wit/world.zig new file mode 100644 index 0000000..f32b8ed --- /dev/null +++ b/src/wit/world.zig @@ -0,0 +1,2055 @@ +// Generated by tools/gen.zig, do not edit. + +const abi = @import("../abi.zig"); +const common = @import("common.zig"); +const block_entity = @import("block_entity.zig"); +const text = @import("text.zig"); +const scoreboard = @import("scoreboard.zig"); +const particles = @import("particles.zig"); +const sounds = @import("sounds.zig"); +const entity_types = @import("entity_types.zig"); +const biomes = @import("biomes.zig"); +const attributes = @import("attributes.zig"); +const item_stack = @import("item_stack.zig"); +const damage_types = @import("damage_types.zig"); +const game_rules = @import("game_rules.zig"); +const uuid = @import("uuid.zig"); + +pub const Position = common.Position; +pub const EntityPose = common.EntityPose; +pub const BlockPos = common.BlockPos; +pub const NbtTree = common.NbtTree; +pub const BlockEntity = block_entity.BlockEntity; +pub const CommandBlockEntity = block_entity.CommandBlockEntity; +pub const BlockEntityType = block_entity.BlockEntityType; +pub const TextComponent = text.TextComponent; +pub const Scoreboard = scoreboard.Scoreboard; +pub const Particle = particles.Particle; +pub const Sound = sounds.Sound; +pub const SoundCategory = sounds.SoundCategory; +pub const EntityType = entity_types.EntityType; +pub const Biome = biomes.Biome; +pub const Attribute = attributes.Attribute; +pub const ModifierOperation = attributes.ModifierOperation; +pub const AttributeModifier = attributes.AttributeModifier; +pub const ItemStack = item_stack.ItemStack; +pub const DamageType = damage_types.DamageType; +pub const GameRule = game_rules.GameRule; +pub const GameRuleValue = game_rules.GameRuleValue; +pub const Uuid = uuid.Uuid; + +/// Equipment slots available on living entities (mobs, armor stands, players). +pub const EquipmentSlot = enum(u8) { + main_hand, + off_hand, + feet, + legs, + chest, + head, + body, + saddle, +}; + +/// Defines how a block reacts when pushed by a piston. +pub const PistonBehavior = enum(u8) { + /// Normal behavior; the block can be pushed and pulled. + normal, + /// The block is destroyed when pushed. + destroy, + /// The block cannot be pushed or pulled. + block, + /// The block is ignored by pistons. + ignore, + /// The block can only be pushed, not pulled. + push_only, +}; + +/// Predefined AI goals that can be added to mob entities. +pub const BuiltinAiGoal = union(enum) { + swim, + wander_around: f32, + melee_attack: f32, + look_at_player: f32, + look_around, + escape_danger: f32, + avoid_entity: f32, + blaze_attack, + creeper_ignite, + eat_grass, + zombie_attack: f32, +}; + +/// Node and terrain classification types evaluated during mob pathfinding. +pub const PathNodeType = enum(u8) { + blocked, + open, + walkable, + walkable_door, + trapdoor, + powder_snow, + danger_powder_snow, + fence, + lava, + water, + water_border, + rail, + unpassable_rail, + danger_fire, + damage_fire, + danger_other, + damage_other, + door_open, + door_wood_closed, + door_iron_closed, + breach, + leaves, + sticky_honey, + cocoa, + damage_cautious, + danger_trapdoor, +}; + +/// Minecraft 16 dye colors. +pub const DyeColor = enum(u8) { + white, + orange, + magenta, + light_blue, + yellow, + lime, + pink, + gray, + light_gray, + cyan, + purple, + blue, + brown, + green, + red, + black, +}; + +/// Villager profession identifiers. +pub const VillagerProfession = enum(u8) { + none, + armorer, + butcher, + cartographer, + cleric, + farmer, + fisherman, + fletcher, + leatherworker, + librarian, + mason, + nitwit, + shepherd, + toolsmith, + weaponsmith, +}; + +/// Specialized data for sheep entities. +pub const SheepData = struct { + color: DyeColor, + is_sheared: bool, +}; + +/// Specialized data for wolf entities. +pub const WolfData = struct { + is_tamed: bool, + owner: ?Uuid, + is_sitting: bool, + collar_color: DyeColor, + is_angry: bool, + is_begging: bool, +}; + +/// Specialized data for cat entities. +pub const CatData = struct { + is_tamed: bool, + owner: ?Uuid, + is_sitting: bool, + collar_color: DyeColor, +}; + +/// Specialized data for villager entities. +pub const VillagerData = struct { + profession: VillagerProfession, + level: u8, + experience: u32, +}; + +/// Specialized data for creeper entities. +pub const CreeperData = struct { + is_powered: bool, + fuse: i32, + is_ignited: bool, + explosion_radius: u8, +}; + +/// Specialized data for slime and magma cube entities. +pub const SlimeData = struct { + size: i32, +}; + +/// Specialized data for enderman entities. +pub const EndermanData = struct { + carried_block_state: ?u16, + is_screaming: bool, + is_staring: bool, +}; + +/// Specialized data for iron golem entities. +pub const IronGolemData = struct { + is_player_created: bool, +}; + +/// Specialized data for fox entities. +pub const FoxData = struct { + is_sitting: bool, + is_sleeping: bool, + is_crouching: bool, +}; + +/// Specialized data for ageable animal mobs. +pub const AgeableData = struct { + is_baby: bool, + age: i32, + in_love_ticks: i32, +}; + +/// Specialized data for zombie entities. +pub const ZombieData = struct { + is_baby: bool, + can_break_doors: bool, +}; + +/// Defines how an explosion interacts with blocks in the world. +pub const ExplosionInteraction = enum(u8) { + /// No interaction with blocks. + none, + /// Blocks are destroyed and may drop loot. + block, + /// Interaction typical for mob-caused explosions. + mob, + /// Interaction typical for TNT explosions. + tnt, + /// Triggers specific block behaviors. + trigger, +}; + +/// Flags used to control block updates and notifications. +pub const BlockFlags = packed struct(u8) { + /// Notifies neighbor blocks of the change. + notify_neighbors: bool = false, + /// Notifies client listeners of the change. + notify_listeners: bool = false, + /// Forces the block state even if it's the same. + force_state: bool = false, + /// Skips dropping items when the block is removed. + skip_drops: bool = false, + /// Indicates the block was moved (e.g., by a piston). + moved: bool = false, + /// Skips state replacement for redstone wires. + skip_redstone_wire_state_replacement: bool = false, + /// Skips the callback when a block entity is replaced. + skip_block_entity_replaced_callback: bool = false, + /// Skips the callback when a block is added. + skip_block_added_callback: bool = false, +}; + +/// Flammability properties of a block. +pub const Flammable = struct { + spread_chance: u8, + burn_chance: u8, +}; + +/// Musical instruments used by note blocks. +pub const NoteblockInstrument = enum(u8) { + harp, + basedrum, + snare, + hat, + bass, + flute, + bell, + guitar, + chime, + xylophone, + iron_xylophone, + cow_bell, + didgeridoo, + bit, + banjo, + pling, + trumpet, + trumpet_exposed, + trumpet_oxidized, + trumpet_weathered, + zombie, + skeleton, + creeper, + dragon, + wither_skeleton, + piglin, + custom_head, +}; + +/// Static definition of a Minecraft block type. +pub const Block = struct { + /// The internal numerical ID of the block type. + id: u16, + /// The unique namespaced ID (e.g., "minecraft:stone"). + name: []const u8, + /// How hard the block is to break (-1.0 for unbreakable blocks). + hardness: f32, + /// Resistance to explosions. + blast_resistance: f32, + /// The color of this block when displayed on a map. + map_color: u8, + /// The friction coefficient (0.6 default, 0.98 for ice). + slipperiness: f32, + /// How much this block affects entity walk speed. + velocity_multiplier: f32, + /// How much this block affects entity jump height. + jump_velocity_multiplier: f32, + /// The item ID associated with this block in inventory/drops. + item_id: u16, + /// The default block state ID when placed without extra properties. + default_state_id: u16, + /// All valid state IDs belonging to this block type. + state_ids: []const u16, + /// Whether this block is solid by default. + is_solid: bool, + /// Whether this block is considered air. + is_air: bool, + /// Whether this block is flammable. + is_flammable: bool, + /// Flammability details if flammable. + flammable: ?Flammable, +}; + +/// A simple wrapper for a block state ID. +pub const BlockStateId = struct { + id: u16, +}; + +pub const Entity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]entity"; + + pub fn getId(self: Entity) u32 { + return abi.call(raw.@"[method]entity.get-id", u32, .{abi.borrow(self)}); + } + + pub fn getUuid(self: Entity) Uuid { + return abi.call(raw.@"[method]entity.get-uuid", Uuid, .{abi.borrow(self)}); + } + + pub fn getType(self: Entity) EntityType { + return abi.call(raw.@"[method]entity.get-type", EntityType, .{abi.borrow(self)}); + } + + pub fn getPosition(self: Entity) Position { + return abi.call(raw.@"[method]entity.get-position", Position, .{abi.borrow(self)}); + } + + pub fn getWorld(self: Entity) World { + return abi.call(raw.@"[method]entity.get-world", World, .{abi.borrow(self)}); + } + + pub fn getYaw(self: Entity) f32 { + return abi.call(raw.@"[method]entity.get-yaw", f32, .{abi.borrow(self)}); + } + + pub fn getPitch(self: Entity) f32 { + return abi.call(raw.@"[method]entity.get-pitch", f32, .{abi.borrow(self)}); + } + + pub fn getHeadYaw(self: Entity) f32 { + return abi.call(raw.@"[method]entity.get-head-yaw", f32, .{abi.borrow(self)}); + } + + /// Consumes `world_ref`. + pub fn teleport(self: Entity, pos: Position, world_ref: World) void { + return abi.call(raw.@"[method]entity.teleport", void, .{ abi.borrow(self), pos, world_ref }); + } + + pub fn setVelocity(self: Entity, velocity: Position) void { + return abi.call(raw.@"[method]entity.set-velocity", void, .{ abi.borrow(self), velocity }); + } + + pub fn getVelocity(self: Entity) Position { + return abi.call(raw.@"[method]entity.get-velocity", Position, .{abi.borrow(self)}); + } + + pub fn getPose(self: Entity) EntityPose { + return abi.call(raw.@"[method]entity.get-pose", EntityPose, .{abi.borrow(self)}); + } + + pub fn getName(self: Entity) TextComponent { + return abi.call(raw.@"[method]entity.get-name", TextComponent, .{abi.borrow(self)}); + } + + /// Consumes `name`. + pub fn setCustomName(self: Entity, name: TextComponent) void { + return abi.call(raw.@"[method]entity.set-custom-name", void, .{ abi.borrow(self), name }); + } + + pub fn getCustomName(self: Entity) ?TextComponent { + return abi.call(raw.@"[method]entity.get-custom-name", ?TextComponent, .{abi.borrow(self)}); + } + + pub fn setCustomNameVisible(self: Entity, visible: bool) void { + return abi.call(raw.@"[method]entity.set-custom-name-visible", void, .{ abi.borrow(self), visible }); + } + + pub fn isCustomNameVisible(self: Entity) bool { + return abi.call(raw.@"[method]entity.is-custom-name-visible", bool, .{abi.borrow(self)}); + } + + pub fn isInvulnerable(self: Entity) bool { + return abi.call(raw.@"[method]entity.is-invulnerable", bool, .{abi.borrow(self)}); + } + + pub fn setInvulnerable(self: Entity, invulnerable: bool) void { + return abi.call(raw.@"[method]entity.set-invulnerable", void, .{ abi.borrow(self), invulnerable }); + } + + pub fn getFireTicks(self: Entity) i32 { + return abi.call(raw.@"[method]entity.get-fire-ticks", i32, .{abi.borrow(self)}); + } + + pub fn setFireTicks(self: Entity, ticks: i32) void { + return abi.call(raw.@"[method]entity.set-fire-ticks", void, .{ abi.borrow(self), ticks }); + } + + pub fn getFallDistance(self: Entity) f32 { + return abi.call(raw.@"[method]entity.get-fall-distance", f32, .{abi.borrow(self)}); + } + + pub fn setFallDistance(self: Entity, distance: f32) void { + return abi.call(raw.@"[method]entity.set-fall-distance", void, .{ abi.borrow(self), distance }); + } + + pub fn getTicksLived(self: Entity) i32 { + return abi.call(raw.@"[method]entity.get-ticks-lived", i32, .{abi.borrow(self)}); + } + + pub fn setTicksLived(self: Entity, ticks: i32) void { + return abi.call(raw.@"[method]entity.set-ticks-lived", void, .{ abi.borrow(self), ticks }); + } + + pub fn isSneaking(self: Entity) bool { + return abi.call(raw.@"[method]entity.is-sneaking", bool, .{abi.borrow(self)}); + } + + pub fn setSneaking(self: Entity, sneaking: bool) void { + return abi.call(raw.@"[method]entity.set-sneaking", void, .{ abi.borrow(self), sneaking }); + } + + pub fn isSprinting(self: Entity) bool { + return abi.call(raw.@"[method]entity.is-sprinting", bool, .{abi.borrow(self)}); + } + + pub fn setSprinting(self: Entity, sprinting: bool) void { + return abi.call(raw.@"[method]entity.set-sprinting", void, .{ abi.borrow(self), sprinting }); + } + + pub fn isSwimming(self: Entity) bool { + return abi.call(raw.@"[method]entity.is-swimming", bool, .{abi.borrow(self)}); + } + + pub fn setSwimming(self: Entity, swimming: bool) void { + return abi.call(raw.@"[method]entity.set-swimming", void, .{ abi.borrow(self), swimming }); + } + + pub fn isInvisible(self: Entity) bool { + return abi.call(raw.@"[method]entity.is-invisible", bool, .{abi.borrow(self)}); + } + + pub fn setInvisible(self: Entity, invisible: bool) void { + return abi.call(raw.@"[method]entity.set-invisible", void, .{ abi.borrow(self), invisible }); + } + + pub fn isGlowing(self: Entity) bool { + return abi.call(raw.@"[method]entity.is-glowing", bool, .{abi.borrow(self)}); + } + + pub fn setGlowing(self: Entity, glowing: bool) void { + return abi.call(raw.@"[method]entity.set-glowing", void, .{ abi.borrow(self), glowing }); + } + + pub fn isFallFlying(self: Entity) bool { + return abi.call(raw.@"[method]entity.is-fall-flying", bool, .{abi.borrow(self)}); + } + + pub fn setFallFlying(self: Entity, fall_flying: bool) void { + return abi.call(raw.@"[method]entity.set-fall-flying", void, .{ abi.borrow(self), fall_flying }); + } + + pub fn isSilent(self: Entity) bool { + return abi.call(raw.@"[method]entity.is-silent", bool, .{abi.borrow(self)}); + } + + pub fn setSilent(self: Entity, silent: bool) void { + return abi.call(raw.@"[method]entity.set-silent", void, .{ abi.borrow(self), silent }); + } + + pub fn hasGravity(self: Entity) bool { + return abi.call(raw.@"[method]entity.has-gravity", bool, .{abi.borrow(self)}); + } + + pub fn setHasGravity(self: Entity, gravity: bool) void { + return abi.call(raw.@"[method]entity.set-has-gravity", void, .{ abi.borrow(self), gravity }); + } + + pub fn getWidth(self: Entity) f32 { + return abi.call(raw.@"[method]entity.get-width", f32, .{abi.borrow(self)}); + } + + pub fn getHeight(self: Entity) f32 { + return abi.call(raw.@"[method]entity.get-height", f32, .{abi.borrow(self)}); + } + + pub fn setRotation(self: Entity, yaw: f32, pitch: f32) void { + return abi.call(raw.@"[method]entity.set-rotation", void, .{ abi.borrow(self), yaw, pitch }); + } + + pub fn isOnGround(self: Entity) bool { + return abi.call(raw.@"[method]entity.is-on-ground", bool, .{abi.borrow(self)}); + } + + pub fn isOnFire(self: Entity) bool { + return abi.call(raw.@"[method]entity.is-on-fire", bool, .{abi.borrow(self)}); + } + + pub fn setOnFire(self: Entity, on_fire: bool) void { + return abi.call(raw.@"[method]entity.set-on-fire", void, .{ abi.borrow(self), on_fire }); + } + + pub fn hasVisualFire(self: Entity) bool { + return abi.call(raw.@"[method]entity.has-visual-fire", bool, .{abi.borrow(self)}); + } + + pub fn setVisualFire(self: Entity, visual_fire: bool) void { + return abi.call(raw.@"[method]entity.set-visual-fire", void, .{ abi.borrow(self), visual_fire }); + } + + pub fn getPortalCooldown(self: Entity) u32 { + return abi.call(raw.@"[method]entity.get-portal-cooldown", u32, .{abi.borrow(self)}); + } + + pub fn setPortalCooldown(self: Entity, cooldown: u32) void { + return abi.call(raw.@"[method]entity.set-portal-cooldown", void, .{ abi.borrow(self), cooldown }); + } + + pub fn getRemainingAir(self: Entity) i32 { + return abi.call(raw.@"[method]entity.get-remaining-air", i32, .{abi.borrow(self)}); + } + + pub fn setRemainingAir(self: Entity, air: i32) void { + return abi.call(raw.@"[method]entity.set-remaining-air", void, .{ abi.borrow(self), air }); + } + + pub fn getMaxAir(self: Entity) i32 { + return abi.call(raw.@"[method]entity.get-max-air", i32, .{abi.borrow(self)}); + } + + pub fn getEyeHeight(self: Entity) f32 { + return abi.call(raw.@"[method]entity.get-eye-height", f32, .{abi.borrow(self)}); + } + + pub fn getEyePosition(self: Entity) Position { + return abi.call(raw.@"[method]entity.get-eye-position", Position, .{abi.borrow(self)}); + } + + pub fn getNearbyEntities(self: Entity, x: f64, y: f64, z: f64) []const Entity { + return abi.call(raw.@"[method]entity.get-nearby-entities", []const Entity, .{ abi.borrow(self), x, y, z }); + } + + pub fn getVehicle(self: Entity) ?Entity { + return abi.call(raw.@"[method]entity.get-vehicle", ?Entity, .{abi.borrow(self)}); + } + + pub fn setVehicle(self: Entity, vehicle: ?Entity) void { + return abi.call(raw.@"[method]entity.set-vehicle", void, .{ abi.borrow(self), vehicle }); + } + + pub fn getPassengers(self: Entity) []const Entity { + return abi.call(raw.@"[method]entity.get-passengers", []const Entity, .{abi.borrow(self)}); + } + + /// Consumes `passenger`. + pub fn addPassenger(self: Entity, passenger: Entity) void { + return abi.call(raw.@"[method]entity.add-passenger", void, .{ abi.borrow(self), passenger }); + } + + /// Consumes `passenger`. + pub fn removePassenger(self: Entity, passenger: Entity) void { + return abi.call(raw.@"[method]entity.remove-passenger", void, .{ abi.borrow(self), passenger }); + } + + pub fn ejectPassengers(self: Entity) void { + return abi.call(raw.@"[method]entity.eject-passengers", void, .{abi.borrow(self)}); + } + + pub fn getBoundingBox(self: Entity) BoundingBox { + return abi.call(raw.@"[method]entity.get-bounding-box", BoundingBox, .{abi.borrow(self)}); + } + + pub fn isInWater(self: Entity) bool { + return abi.call(raw.@"[method]entity.is-in-water", bool, .{abi.borrow(self)}); + } + + pub fn isInLava(self: Entity) bool { + return abi.call(raw.@"[method]entity.is-in-lava", bool, .{abi.borrow(self)}); + } + + pub fn remove(self: Entity) void { + return abi.call(raw.@"[method]entity.remove", void, .{abi.borrow(self)}); + } + + /// Performs a raycast from the entity's eye position in its looking direction. + pub fn raycast(self: Entity, max_distance: f64, fluid_handling: bool) ?RaycastResult { + return abi.call(raw.@"[method]entity.raycast", ?RaycastResult, .{ abi.borrow(self), max_distance, fluid_handling }); + } + + /// Performs a ray-trace from the entity's eye position in its looking direction to find the targeted block. + pub fn rayTraceBlock(self: Entity, max_distance: f64, include_fluids: bool) ?RayTraceBlockResult { + return abi.call(raw.@"[method]entity.ray-trace-block", ?RayTraceBlockResult, .{ abi.borrow(self), max_distance, include_fluids }); + } + + /// Performs a ray-trace from the entity's eye position in its looking direction to find the targeted entity. + pub fn rayTraceEntity(self: Entity, max_distance: f64) ?RayTraceEntityResult { + return abi.call(raw.@"[method]entity.ray-trace-entity", ?RayTraceEntityResult, .{ abi.borrow(self), max_distance }); + } + + /// Returns the entity currently targeted in the looking direction within the specified distance. + pub fn getTargetEntity(self: Entity, max_distance: f64) ?Entity { + return abi.call(raw.@"[method]entity.get-target-entity", ?Entity, .{ abi.borrow(self), max_distance }); + } + + /// Sets a namespaced custom data value on this entity. + pub fn setCustomData(self: Entity, namespace: []const u8, key: []const u8, value: NbtTree) void { + return abi.call(raw.@"[method]entity.set-custom-data", void, .{ abi.borrow(self), namespace, key, value }); + } + + /// Returns a namespaced custom data value from this entity, if set. + pub fn getCustomData(self: Entity, namespace: []const u8, key: []const u8) ?NbtTree { + return abi.call(raw.@"[method]entity.get-custom-data", ?NbtTree, .{ abi.borrow(self), namespace, key }); + } + + /// Removes a namespaced custom data value from this entity. + pub fn removeCustomData(self: Entity, namespace: []const u8, key: []const u8) void { + return abi.call(raw.@"[method]entity.remove-custom-data", void, .{ abi.borrow(self), namespace, key }); + } + + /// Returns whether this entity has a namespaced custom data value. + pub fn hasCustomData(self: Entity, namespace: []const u8, key: []const u8) bool { + return abi.call(raw.@"[method]entity.has-custom-data", bool, .{ abi.borrow(self), namespace, key }); + } + + /// Returns this entity as a living-entity if it has health and attributes, or none otherwise. + pub fn asLiving(self: Entity) ?LivingEntity { + return abi.call(raw.@"[method]entity.as-living", ?LivingEntity, .{abi.borrow(self)}); + } + + /// Returns this entity as a mob if it is an AI-driven mob entity, or none otherwise. + pub fn asMob(self: Entity) ?Mob { + return abi.call(raw.@"[method]entity.as-mob", ?Mob, .{abi.borrow(self)}); + } + + /// Returns whether this entity is a living entity. + pub fn isLiving(self: Entity) bool { + return abi.call(raw.@"[method]entity.is-living", bool, .{abi.borrow(self)}); + } + + /// Returns whether this entity is an AI-driven mob. + pub fn isMob(self: Entity) bool { + return abi.call(raw.@"[method]entity.is-mob", bool, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: Entity) void { + abi.keep(Entity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: Entity) void { + abi.drop(Entity, self); + } +}; + +/// Represents a living entity with health, combat stats, attributes, and equipment (mobs, players, armor stands). +pub const LivingEntity = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]living-entity"; + + /// Converts back to the base entity handle. + pub fn asEntity(self: LivingEntity) Entity { + return abi.call(raw.@"[method]living-entity.as-entity", Entity, .{abi.borrow(self)}); + } + + /// Returns this living entity as a mob if it has AI/navigation, or none otherwise. + pub fn asMob(self: LivingEntity) ?Mob { + return abi.call(raw.@"[method]living-entity.as-mob", ?Mob, .{abi.borrow(self)}); + } + + /// Returns whether this living entity is an AI-driven mob. + pub fn isMob(self: LivingEntity) bool { + return abi.call(raw.@"[method]living-entity.is-mob", bool, .{abi.borrow(self)}); + } + + /// Health & Combat + pub fn getHealth(self: LivingEntity) f32 { + return abi.call(raw.@"[method]living-entity.get-health", f32, .{abi.borrow(self)}); + } + + pub fn setHealth(self: LivingEntity, health: f32) void { + return abi.call(raw.@"[method]living-entity.set-health", void, .{ abi.borrow(self), health }); + } + + pub fn getMaxHealth(self: LivingEntity) f32 { + return abi.call(raw.@"[method]living-entity.get-max-health", f32, .{abi.borrow(self)}); + } + + pub fn setMaxHealth(self: LivingEntity, max_health: f32) void { + return abi.call(raw.@"[method]living-entity.set-max-health", void, .{ abi.borrow(self), max_health }); + } + + pub fn damage(self: LivingEntity, amount: f32, damage_type: DamageType) void { + return abi.call(raw.@"[method]living-entity.damage", void, .{ abi.borrow(self), amount, damage_type }); + } + + pub fn isDead(self: LivingEntity) bool { + return abi.call(raw.@"[method]living-entity.is-dead", bool, .{abi.borrow(self)}); + } + + pub fn getAbsorption(self: LivingEntity) f32 { + return abi.call(raw.@"[method]living-entity.get-absorption", f32, .{abi.borrow(self)}); + } + + pub fn setAbsorption(self: LivingEntity, amount: f32) void { + return abi.call(raw.@"[method]living-entity.set-absorption", void, .{ abi.borrow(self), amount }); + } + + /// Attributes + pub fn getAttributeValue(self: LivingEntity, attr: Attribute) f64 { + return abi.call(raw.@"[method]living-entity.get-attribute-value", f64, .{ abi.borrow(self), attr }); + } + + pub fn getAttributeBase(self: LivingEntity, attr: Attribute) f64 { + return abi.call(raw.@"[method]living-entity.get-attribute-base", f64, .{ abi.borrow(self), attr }); + } + + pub fn setAttributeBase(self: LivingEntity, attr: Attribute, value: f64) void { + return abi.call(raw.@"[method]living-entity.set-attribute-base", void, .{ abi.borrow(self), attr, value }); + } + + pub fn addAttributeModifier(self: LivingEntity, attr: Attribute, modifier: AttributeModifier) void { + return abi.call(raw.@"[method]living-entity.add-attribute-modifier", void, .{ abi.borrow(self), attr, modifier }); + } + + pub fn removeAttributeModifier(self: LivingEntity, attr: Attribute, id: []const u8) void { + return abi.call(raw.@"[method]living-entity.remove-attribute-modifier", void, .{ abi.borrow(self), attr, id }); + } + + pub fn getAttributeModifiers(self: LivingEntity, attr: Attribute) []const AttributeModifier { + return abi.call(raw.@"[method]living-entity.get-attribute-modifiers", []const AttributeModifier, .{ abi.borrow(self), attr }); + } + + pub fn resetAttribute(self: LivingEntity, attr: Attribute) void { + return abi.call(raw.@"[method]living-entity.reset-attribute", void, .{ abi.borrow(self), attr }); + } + + pub fn resetAllAttributes(self: LivingEntity) void { + return abi.call(raw.@"[method]living-entity.reset-all-attributes", void, .{abi.borrow(self)}); + } + + /// Equipment + pub fn getEquipment(self: LivingEntity, slot: EquipmentSlot) ?ItemStack { + return abi.call(raw.@"[method]living-entity.get-equipment", ?ItemStack, .{ abi.borrow(self), slot }); + } + + pub fn setEquipment(self: LivingEntity, slot: EquipmentSlot, stack: ?ItemStack) void { + return abi.call(raw.@"[method]living-entity.set-equipment", void, .{ abi.borrow(self), slot, stack }); + } + + pub fn clearEquipment(self: LivingEntity) void { + return abi.call(raw.@"[method]living-entity.clear-equipment", void, .{abi.borrow(self)}); + } + + pub fn getAge(self: LivingEntity) i32 { + return abi.call(raw.@"[method]living-entity.get-age", i32, .{abi.borrow(self)}); + } + + pub fn setAge(self: LivingEntity, age: i32) void { + return abi.call(raw.@"[method]living-entity.set-age", void, .{ abi.borrow(self), age }); + } + + /// Consumes `message`. + pub fn sendSystemMessage(self: LivingEntity, message: TextComponent) void { + return abi.call(raw.@"[method]living-entity.send-system-message", void, .{ abi.borrow(self), message }); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: LivingEntity) void { + abi.keep(LivingEntity, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: LivingEntity) void { + abi.drop(LivingEntity, self); + } +}; + +/// Represents an AI-driven mob entity with goals, targeting, and pathfinding navigation (e.g. zombies, villagers). +pub const Mob = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]mob"; + + /// Converts back to the base entity handle. + pub fn asEntity(self: Mob) Entity { + return abi.call(raw.@"[method]mob.as-entity", Entity, .{abi.borrow(self)}); + } + + /// Converts to the living-entity handle. + pub fn asLiving(self: Mob) LivingEntity { + return abi.call(raw.@"[method]mob.as-living", LivingEntity, .{abi.borrow(self)}); + } + + /// Goals & Targeting + pub fn addAiGoal(self: Mob, priority: u8, goal: BuiltinAiGoal) void { + return abi.call(raw.@"[method]mob.add-ai-goal", void, .{ abi.borrow(self), priority, goal }); + } + + pub fn addCustomAiGoal(self: Mob, priority: u8, goal_id: u32) void { + return abi.call(raw.@"[method]mob.add-custom-ai-goal", void, .{ abi.borrow(self), priority, goal_id }); + } + + pub fn clearAiGoals(self: Mob) void { + return abi.call(raw.@"[method]mob.clear-ai-goals", void, .{abi.borrow(self)}); + } + + pub fn setAiDisabled(self: Mob, disabled: bool) void { + return abi.call(raw.@"[method]mob.set-ai-disabled", void, .{ abi.borrow(self), disabled }); + } + + pub fn isAiDisabled(self: Mob) bool { + return abi.call(raw.@"[method]mob.is-ai-disabled", bool, .{abi.borrow(self)}); + } + + pub fn setTarget(self: Mob, target: ?Entity) void { + return abi.call(raw.@"[method]mob.set-target", void, .{ abi.borrow(self), target }); + } + + pub fn getTarget(self: Mob) ?Entity { + return abi.call(raw.@"[method]mob.get-target", ?Entity, .{abi.borrow(self)}); + } + + /// Pathfinding & Navigation + pub fn navigateToPos(self: Mob, pos: Position, speed: f64) bool { + return abi.call(raw.@"[method]mob.navigate-to-pos", bool, .{ abi.borrow(self), pos, speed }); + } + + /// Consumes `target`. + pub fn navigateToEntity(self: Mob, target: Entity, speed: f64) bool { + return abi.call(raw.@"[method]mob.navigate-to-entity", bool, .{ abi.borrow(self), target, speed }); + } + + pub fn stopNavigation(self: Mob) void { + return abi.call(raw.@"[method]mob.stop-navigation", void, .{abi.borrow(self)}); + } + + pub fn isNavigating(self: Mob) bool { + return abi.call(raw.@"[method]mob.is-navigating", bool, .{abi.borrow(self)}); + } + + pub fn hasReachedDestination(self: Mob) bool { + return abi.call(raw.@"[method]mob.has-reached-destination", bool, .{abi.borrow(self)}); + } + + pub fn setNavigationSpeed(self: Mob, speed: f64) void { + return abi.call(raw.@"[method]mob.set-navigation-speed", void, .{ abi.borrow(self), speed }); + } + + pub fn canReach(self: Mob, pos: Position, max_distance: f32) bool { + return abi.call(raw.@"[method]mob.can-reach", bool, .{ abi.borrow(self), pos, max_distance }); + } + + pub fn setPathfindingMalus(self: Mob, node_type: PathNodeType, malus: f32) void { + return abi.call(raw.@"[method]mob.set-pathfinding-malus", void, .{ abi.borrow(self), node_type, malus }); + } + + pub fn getPathfindingMalus(self: Mob, node_type: PathNodeType) f32 { + return abi.call(raw.@"[method]mob.get-pathfinding-malus", f32, .{ abi.borrow(self), node_type }); + } + + pub fn lookAt(self: Mob, pos: Position) void { + return abi.call(raw.@"[method]mob.look-at", void, .{ abi.borrow(self), pos }); + } + + /// Consumes `target`. + pub fn lookAtEntity(self: Mob, target: Entity) void { + return abi.call(raw.@"[method]mob.look-at-entity", void, .{ abi.borrow(self), target }); + } + + /// Returns the specialized mob-specific data for this mob. + pub fn getMobData(self: Mob) MobData { + return abi.call(raw.@"[method]mob.get-mob-data", MobData, .{abi.borrow(self)}); + } + + /// Sets the specialized mob-specific data for this mob. + /// Returns false if the provided data variant is incompatible with this mob. + pub fn setMobData(self: Mob, data: MobData) bool { + return abi.call(raw.@"[method]mob.set-mob-data", bool, .{ abi.borrow(self), data }); + } + + /// Sets the number of freeze ticks on this entity (0 to 140). + pub fn setFreezeTicks(self: Mob, ticks: i32) void { + return abi.call(raw.@"[method]mob.set-freeze-ticks", void, .{ abi.borrow(self), ticks }); + } + + /// Returns the number of freeze ticks currently on this entity. + pub fn getFreezeTicks(self: Mob) i32 { + return abi.call(raw.@"[method]mob.get-freeze-ticks", i32, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: Mob) void { + abi.keep(Mob, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: Mob) void { + abi.drop(Mob, self); + } +}; + +/// Result of an entity ray-trace operation. +pub const RayTraceEntityResult = struct { + /// The entity that was hit. + entity: Entity, + /// The exact hit coordinates in world space. + hit_pos: Position, + /// The distance from the ray start to the hit position. + distance: f64, +}; + +pub const Chunk = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]chunk"; + + /// Gets the chunk's X coordinate. + pub fn getX(self: Chunk) i32 { + return abi.call(raw.@"[method]chunk.get-x", i32, .{abi.borrow(self)}); + } + + /// Gets the chunk's Z coordinate. + pub fn getZ(self: Chunk) i32 { + return abi.call(raw.@"[method]chunk.get-z", i32, .{abi.borrow(self)}); + } + + /// Gets the block state ID at the specified position relative to the chunk. + /// X and Z must be in the range [0, 15]. + pub fn getBlockStateId(self: Chunk, pos: BlockPos) u16 { + return abi.call(raw.@"[method]chunk.get-block-state-id", u16, .{ abi.borrow(self), pos }); + } + + /// Gets detailed block state information at the specified position relative to the chunk. + /// X and Z must be in the range [0, 15]. + pub fn getBlockState(self: Chunk, pos: BlockPos) BlockState { + return abi.call(raw.@"[method]chunk.get-block-state", BlockState, .{ abi.borrow(self), pos }); + } + + /// Sets the block state at the specified position relative to the chunk. + /// X and Z must be in the range [0, 15]. + pub fn setBlockState(self: Chunk, pos: BlockPos, state: u16) void { + return abi.call(raw.@"[method]chunk.set-block-state", void, .{ abi.borrow(self), pos, state }); + } + + /// Gets the block at the specified position relative to the chunk. + /// X and Z must be in the range [0, 15]. + pub fn getBlock(self: Chunk, pos: BlockPos) Block { + return abi.call(raw.@"[method]chunk.get-block", Block, .{ abi.borrow(self), pos }); + } + + /// Sets the block at the specified position relative to the chunk using its default state. + /// X and Z must be in the range [0, 15]. + pub fn setBlock(self: Chunk, pos: BlockPos, block: Block) void { + return abi.call(raw.@"[method]chunk.set-block", void, .{ abi.borrow(self), pos, block }); + } + + /// Sets the block by block ID at the specified position relative to the chunk using its default state. + /// X and Z must be in the range [0, 15]. + pub fn setBlockById(self: Chunk, pos: BlockPos, block_id: u16) void { + return abi.call(raw.@"[method]chunk.set-block-by-id", void, .{ abi.borrow(self), pos, block_id }); + } + + /// Gets the biome at the specified position relative to the chunk. + /// X and Z must be in the range [0, 15]. + pub fn getBiome(self: Chunk, pos: BlockPos) Biome { + return abi.call(raw.@"[method]chunk.get-biome", Biome, .{ abi.borrow(self), pos }); + } + + /// Gets the block entity at the specified position relative to the chunk, if any. + /// X and Z must be in the range [0, 15]. + pub fn getBlockEntity(self: Chunk, pos: BlockPos) ?BlockEntityType { + return abi.call(raw.@"[method]chunk.get-block-entity", ?BlockEntityType, .{ abi.borrow(self), pos }); + } + + /// Gets the highest non-air block Y coordinate at the specified X and Z relative to the chunk. + /// X and Z must be in the range [0, 15]. + pub fn getTopBlockY(self: Chunk, x: i32, z: i32) i32 { + return abi.call(raw.@"[method]chunk.get-top-block-y", i32, .{ abi.borrow(self), x, z }); + } + + /// Gets the sky light level at the specified position relative to the chunk. + /// X and Z must be in the range [0, 15]. + pub fn getSkyLight(self: Chunk, pos: BlockPos) u8 { + return abi.call(raw.@"[method]chunk.get-sky-light", u8, .{ abi.borrow(self), pos }); + } + + /// Gets the block light level at the specified position relative to the chunk. + /// X and Z must be in the range [0, 15]. + pub fn getBlockLight(self: Chunk, pos: BlockPos) u8 { + return abi.call(raw.@"[method]chunk.get-block-light", u8, .{ abi.borrow(self), pos }); + } + + /// Sets a namespaced custom data value on this chunk. + pub fn setCustomData(self: Chunk, namespace: []const u8, key: []const u8, value: NbtTree) void { + return abi.call(raw.@"[method]chunk.set-custom-data", void, .{ abi.borrow(self), namespace, key, value }); + } + + /// Returns a namespaced custom data value from this chunk, if set. + pub fn getCustomData(self: Chunk, namespace: []const u8, key: []const u8) ?NbtTree { + return abi.call(raw.@"[method]chunk.get-custom-data", ?NbtTree, .{ abi.borrow(self), namespace, key }); + } + + /// Removes a namespaced custom data value from this chunk. + pub fn removeCustomData(self: Chunk, namespace: []const u8, key: []const u8) void { + return abi.call(raw.@"[method]chunk.remove-custom-data", void, .{ abi.borrow(self), namespace, key }); + } + + /// Returns whether this chunk has a namespaced custom data value. + pub fn hasCustomData(self: Chunk, namespace: []const u8, key: []const u8) bool { + return abi.call(raw.@"[method]chunk.has-custom-data", bool, .{ abi.borrow(self), namespace, key }); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: Chunk) void { + abi.keep(Chunk, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: Chunk) void { + abi.drop(Chunk, self); + } +}; + +/// Represents the boundaries of a world. +pub const WorldBorder = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]world-border"; + + /// Gets the center X coordinate of the border. + pub fn getCenterX(self: WorldBorder) f64 { + return abi.call(raw.@"[method]world-border.get-center-x", f64, .{abi.borrow(self)}); + } + + /// Gets the center Z coordinate of the border. + pub fn getCenterZ(self: WorldBorder) f64 { + return abi.call(raw.@"[method]world-border.get-center-z", f64, .{abi.borrow(self)}); + } + + /// Gets the center position of the border. + pub fn getCenter(self: WorldBorder) Position { + return abi.call(raw.@"[method]world-border.get-center", Position, .{abi.borrow(self)}); + } + + /// Sets the center coordinates of the border. + pub fn setCenter(self: WorldBorder, x: f64, z: f64) void { + return abi.call(raw.@"[method]world-border.set-center", void, .{ abi.borrow(self), x, z }); + } + + /// Gets the current diameter of the border. + pub fn getDiameter(self: WorldBorder) f64 { + return abi.call(raw.@"[method]world-border.get-diameter", f64, .{abi.borrow(self)}); + } + + /// Gets the current diameter of the border (alias for get-diameter). + pub fn getSize(self: WorldBorder) f64 { + return abi.call(raw.@"[method]world-border.get-size", f64, .{abi.borrow(self)}); + } + + /// Sets the diameter of the border, optionally with a speed (in ticks) for lerping. + pub fn setDiameter(self: WorldBorder, diameter: f64, speed: ?u64) void { + return abi.call(raw.@"[method]world-border.set-diameter", void, .{ abi.borrow(self), diameter, speed }); + } + + /// Sets the size of the border instantly. + pub fn setSize(self: WorldBorder, size: f64) void { + return abi.call(raw.@"[method]world-border.set-size", void, .{ abi.borrow(self), size }); + } + + /// Sets the size of the border with a transition duration in seconds. + pub fn setSizeTransition(self: WorldBorder, new_size: f64, time_seconds: u64) void { + return abi.call(raw.@"[method]world-border.set-size-transition", void, .{ abi.borrow(self), new_size, time_seconds }); + } + + /// Gets the target diameter when lerping/transitioning. + pub fn getTargetDiameter(self: WorldBorder) f64 { + return abi.call(raw.@"[method]world-border.get-target-diameter", f64, .{abi.borrow(self)}); + } + + /// Gets the target transition duration/speed in ticks. + pub fn getTargetSpeed(self: WorldBorder) i64 { + return abi.call(raw.@"[method]world-border.get-target-speed", i64, .{abi.borrow(self)}); + } + + /// Gets the distance from the border where warning effects start (in blocks). + pub fn getWarningDistance(self: WorldBorder) i32 { + return abi.call(raw.@"[method]world-border.get-warning-distance", i32, .{abi.borrow(self)}); + } + + /// Sets the warning distance (in blocks). + pub fn setWarningDistance(self: WorldBorder, distance: i32) void { + return abi.call(raw.@"[method]world-border.set-warning-distance", void, .{ abi.borrow(self), distance }); + } + + /// Gets the time before a player hitting the border is warned (in seconds). + pub fn getWarningDelay(self: WorldBorder) i32 { + return abi.call(raw.@"[method]world-border.get-warning-delay", i32, .{abi.borrow(self)}); + } + + /// Sets the warning delay (in seconds). + pub fn setWarningDelay(self: WorldBorder, delay: i32) void { + return abi.call(raw.@"[method]world-border.set-warning-delay", void, .{ abi.borrow(self), delay }); + } + + /// Gets the warning time (alias for get-warning-delay). + pub fn getWarningTime(self: WorldBorder) i32 { + return abi.call(raw.@"[method]world-border.get-warning-time", i32, .{abi.borrow(self)}); + } + + /// Sets the warning time (alias for set-warning-delay). + pub fn setWarningTime(self: WorldBorder, time: i32) void { + return abi.call(raw.@"[method]world-border.set-warning-time", void, .{ abi.borrow(self), time }); + } + + /// Gets the safe damage buffer distance outside the border (in blocks). + pub fn getDamageBuffer(self: WorldBorder) f64 { + return abi.call(raw.@"[method]world-border.get-damage-buffer", f64, .{abi.borrow(self)}); + } + + /// Sets the safe damage buffer distance outside the border (in blocks). + pub fn setDamageBuffer(self: WorldBorder, buffer: f64) void { + return abi.call(raw.@"[method]world-border.set-damage-buffer", void, .{ abi.borrow(self), buffer }); + } + + /// Gets the damage amount inflicted per block per second when outside the buffer. + pub fn getDamageAmount(self: WorldBorder) f64 { + return abi.call(raw.@"[method]world-border.get-damage-amount", f64, .{abi.borrow(self)}); + } + + /// Sets the damage amount inflicted per block per second when outside the buffer. + pub fn setDamageAmount(self: WorldBorder, damage: f64) void { + return abi.call(raw.@"[method]world-border.set-damage-amount", void, .{ abi.borrow(self), damage }); + } + + /// Returns whether the specified coordinates are within the border. + pub fn contains(self: WorldBorder, x: f64, z: f64) bool { + return abi.call(raw.@"[method]world-border.contains", bool, .{ abi.borrow(self), x, z }); + } + + /// Returns whether the specified position is within the border. + pub fn containsPos(self: WorldBorder, pos: Position) bool { + return abi.call(raw.@"[method]world-border.contains-pos", bool, .{ abi.borrow(self), pos }); + } + + /// Resets the world border to vanilla default settings. + pub fn reset(self: WorldBorder) void { + return abi.call(raw.@"[method]world-border.reset", void, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: WorldBorder) void { + abi.keep(WorldBorder, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: WorldBorder) void { + abi.drop(WorldBorder, self); + } +}; + +/// Represents an axis-aligned bounding box. +pub const BoundingBox = struct { + min: Position, + max: Position, +}; + +/// Detailed information about a block's state. +pub const BlockState = struct { + /// The internal numerical ID of the block state. + id: u16, + /// The numerical ID of the parent block type. + block_id: u16, + /// The namespaced identifier of the parent block type. + block_name: []const u8, + /// The light level emitted by this block (0-15). + luminance: u8, + /// How much light this block blocks. + opacity: u8, + /// The hardness of the block, determining mining speed. + hardness: f32, + /// Whether this block is considered air. + is_air: bool, + /// Whether this block is a liquid. + is_liquid: bool, + /// Whether this block is a solid. + is_solid: bool, + /// Whether this block occupies a full cube. + is_full_cube: bool, + /// How this block behaves when pushed by a piston. + piston_behavior: PistonBehavior, + /// Whether this block receives random ticks. + has_random_ticks: bool, + /// Whether this block can catch fire. + burnable: bool, + /// Whether a specific tool is required to mine this block and get drops. + tool_required: bool, + /// Whether this block has transparency on its sides. + sided_transparency: bool, + /// Whether this block can be replaced by another block (e.g., grass). + replaceable: bool, + /// Whether this block is considered a solid block for redstone purposes. + is_solid_block: bool, + /// The numerical ID of the block entity type, if any. + block_entity_type: u16, + /// The instrument used for note blocks when placed on top of this block. + instrument: NoteblockInstrument, + /// The collision shapes of this block. + collision_shapes: []const BoundingBox, + /// The outline shapes of this block. + outline_shapes: []const BoundingBox, + /// Whether the bottom side of the block is solid. + down_side_solid: bool, + /// Whether the top side of the block is solid. + up_side_solid: bool, + /// Whether the north side of the block is solid. + north_side_solid: bool, + /// Whether the south side of the block is solid. + south_side_solid: bool, + /// Whether the west side of the block is solid. + west_side_solid: bool, + /// Whether the east side of the block is solid. + east_side_solid: bool, + /// Whether the center of the bottom side is solid. + down_center_solid: bool, + /// Whether the center of the top side is solid. + up_center_solid: bool, + /// The color of this block when displayed on a map. + map_color: u8, + /// The block state's property key-value pairs (e.g. facing=north). + properties: []const struct { []const u8, []const u8 }, +}; + +/// Represents the configured shared spawn location for a world. +pub const WorldSpawnLocation = struct { + /// The block position of the shared world spawn. + pos: BlockPos, + /// The yaw players should face when spawning here. + yaw: f32, + /// The pitch players should use when spawning here. + pitch: f32, +}; + +/// Represents a cardinal direction or block face. +pub const BlockDirection = enum(u8) { + down, + up, + north, + south, + west, + east, +}; + +/// Specialized data for shulker entities. +pub const ShulkerData = struct { + attached_face: BlockDirection, + peek_amount: u8, + color: ?DyeColor, +}; + +/// Tagged variant holding specialized data for specific mob types. +pub const MobData = union(enum) { + sheep: SheepData, + wolf: WolfData, + cat: CatData, + villager: VillagerData, + creeper: CreeperData, + slime: SlimeData, + enderman: EndermanData, + iron_golem: IronGolemData, + fox: FoxData, + ageable: AgeableData, + zombie: ZombieData, + shulker: ShulkerData, + generic, +}; + +/// Result of a raycast operation. +pub const RaycastResult = struct { + /// The block position that was hit. + pos: BlockPos, + /// The face of the block that was hit. + face: BlockDirection, +}; + +/// Detailed result of a block ray-trace operation. +pub const RayTraceBlockResult = struct { + /// The block position that was hit. + pos: BlockPos, + /// The face of the block that was hit. + face: BlockDirection, + /// The exact hit coordinates in world space. + hit_pos: Position, +}; + +/// Represents a Minecraft world (dimension). +pub const World = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]world"; + + /// Returns the unique identifier of this world. + pub fn getId(self: World) []const u8 { + return abi.call(raw.@"[method]world.get-id", []const u8, .{abi.borrow(self)}); + } + + /// Gets the world border associated with this world (alias for get-world-border). + pub fn getBorder(self: World) WorldBorder { + return abi.call(raw.@"[method]world.get-border", WorldBorder, .{abi.borrow(self)}); + } + + /// Gets the world border associated with this world. + pub fn getWorldBorder(self: World) WorldBorder { + return abi.call(raw.@"[method]world.get-world-border", WorldBorder, .{abi.borrow(self)}); + } + + /// Gets the chunk at the specified chunk coordinates. + pub fn getChunk(self: World, x: i32, z: i32) ?Chunk { + return abi.call(raw.@"[method]world.get-chunk", ?Chunk, .{ abi.borrow(self), x, z }); + } + + /// Gets the block state ID at the specified position. + pub fn getBlockStateId(self: World, pos: BlockPos) u16 { + return abi.call(raw.@"[method]world.get-block-state-id", u16, .{ abi.borrow(self), pos }); + } + + /// Gets detailed block state information at the specified position. + pub fn getBlockState(self: World, pos: BlockPos) BlockState { + return abi.call(raw.@"[method]world.get-block-state", BlockState, .{ abi.borrow(self), pos }); + } + + /// Sets the block state at the specified position. + pub fn setBlockState(self: World, pos: BlockPos, state: u16, update_flags: BlockFlags) void { + return abi.call(raw.@"[method]world.set-block-state", void, .{ abi.borrow(self), pos, state, update_flags }); + } + + /// Gets the block type at the specified position. + pub fn getBlock(self: World, pos: BlockPos) Block { + return abi.call(raw.@"[method]world.get-block", Block, .{ abi.borrow(self), pos }); + } + + /// Gets the numerical block ID at the specified position. + pub fn getBlockId(self: World, pos: BlockPos) u16 { + return abi.call(raw.@"[method]world.get-block-id", u16, .{ abi.borrow(self), pos }); + } + + /// Sets the block at the specified position using its default state. + pub fn setBlock(self: World, pos: BlockPos, block: Block, update_flags: BlockFlags) void { + return abi.call(raw.@"[method]world.set-block", void, .{ abi.borrow(self), pos, block, update_flags }); + } + + /// Sets the block at the specified position by numerical block ID using its default state. + pub fn setBlockById(self: World, pos: BlockPos, block_id: u16, update_flags: BlockFlags) void { + return abi.call(raw.@"[method]world.set-block-by-id", void, .{ abi.borrow(self), pos, block_id, update_flags }); + } + + /// Sets the block at the specified position by namespaced name using its default state. + /// Returns true if the block was recognized and set. + pub fn setBlockByName(self: World, pos: BlockPos, name: []const u8, update_flags: BlockFlags) bool { + return abi.call(raw.@"[method]world.set-block-by-name", bool, .{ abi.borrow(self), pos, name, update_flags }); + } + + /// Returns the current time of day in ticks. + pub fn getTimeOfDay(self: World) u64 { + return abi.call(raw.@"[method]world.get-time-of-day", u64, .{abi.borrow(self)}); + } + + /// Sets the current time of day in ticks. + pub fn setTimeOfDay(self: World, time: u64) void { + return abi.call(raw.@"[method]world.set-time-of-day", void, .{ abi.borrow(self), time }); + } + + /// Returns the total age of the world in ticks. + pub fn getWorldAge(self: World) u64 { + return abi.call(raw.@"[method]world.get-world-age", u64, .{abi.borrow(self)}); + } + + /// Returns the dimension type (e.g., \"minecraft:overworld\"). + pub fn getDimension(self: World) []const u8 { + return abi.call(raw.@"[method]world.get-dimension", []const u8, .{abi.borrow(self)}); + } + + /// Returns the configured shared spawn location for this world. + pub fn getSpawnLocation(self: World) WorldSpawnLocation { + return abi.call(raw.@"[method]world.get-spawn-location", WorldSpawnLocation, .{abi.borrow(self)}); + } + + /// Gets the highest non-air block Y coordinate at the specified X and Z. + pub fn getTopBlockY(self: World, x: i32, z: i32) i32 { + return abi.call(raw.@"[method]world.get-top-block-y", i32, .{ abi.borrow(self), x, z }); + } + + /// Gets the highest motion-blocking block Y coordinate. + pub fn getMotionBlockingHeight(self: World, x: i32, z: i32) i32 { + return abi.call(raw.@"[method]world.get-motion-blocking-height", i32, .{ abi.borrow(self), x, z }); + } + + /// Returns whether it is currently raining or snowing. + pub fn isRaining(self: World) bool { + return abi.call(raw.@"[method]world.is-raining", bool, .{abi.borrow(self)}); + } + + /// Sets whether it should be raining or snowing. + pub fn setRaining(self: World, raining: bool) void { + return abi.call(raw.@"[method]world.set-raining", void, .{ abi.borrow(self), raining }); + } + + /// Returns whether there is currently a thunderstorm. + pub fn isThundering(self: World) bool { + return abi.call(raw.@"[method]world.is-thundering", bool, .{abi.borrow(self)}); + } + + /// Sets whether there should be a thunderstorm. + pub fn setThundering(self: World, thundering: bool) void { + return abi.call(raw.@"[method]world.set-thundering", void, .{ abi.borrow(self), thundering }); + } + + /// Broadcasts a system message to all players in this world. + /// + /// Consumes `message`. + pub fn broadcastSystemMessage(self: World, message: TextComponent, overlay: bool) void { + return abi.call(raw.@"[method]world.broadcast-system-message", void, .{ abi.borrow(self), message, overlay }); + } + + /// Returns the scoreboard associated with this world. + pub fn getScoreboard(self: World) Scoreboard { + return abi.call(raw.@"[method]world.get-scoreboard", Scoreboard, .{abi.borrow(self)}); + } + + /// Plays a sound at the specified position for all players in the world. + pub fn playSound(self: World, sound: Sound, category: SoundCategory, pos: Position, volume: f32, pitch: f32) void { + return abi.call(raw.@"[method]world.play-sound", void, .{ abi.borrow(self), sound, category, pos, volume, pitch }); + } + + /// Plays a custom resource pack sound identifier at the specified position for all players in the world. + pub fn playCustomSound(self: World, sound_name: []const u8, category: SoundCategory, pos: Position, volume: f32, pitch: f32) void { + return abi.call(raw.@"[method]world.play-custom-sound", void, .{ abi.borrow(self), sound_name, category, pos, volume, pitch }); + } + + /// Spawns particles at the specified position. + pub fn spawnParticle(self: World, particle: Particle, pos: Position, offset: Position, max_speed: f32, count: i32) void { + return abi.call(raw.@"[method]world.spawn-particle", void, .{ abi.borrow(self), particle, pos, offset, max_speed, count }); + } + + /// Creates an explosion at the specified position. + pub fn createExplosion(self: World, pos: Position, power: f32, create_fire: bool, interaction: ExplosionInteraction) void { + return abi.call(raw.@"[method]world.create-explosion", void, .{ abi.borrow(self), pos, power, create_fire, interaction }); + } + + /// Returns the sea level of this world. + pub fn getSeaLevel(self: World) i32 { + return abi.call(raw.@"[method]world.get-sea-level", i32, .{abi.borrow(self)}); + } + + /// Returns the minimum Y coordinate (bottom of the world). + pub fn getMinY(self: World) i32 { + return abi.call(raw.@"[method]world.get-min-y", i32, .{abi.borrow(self)}); + } + + /// Returns the sky light level at the specified position. + pub fn getSkyLight(self: World, pos: BlockPos) u8 { + return abi.call(raw.@"[method]world.get-sky-light", u8, .{ abi.borrow(self), pos }); + } + + /// Sets the sky light level at the specified position. + pub fn setSkyLight(self: World, pos: BlockPos, level: u8) void { + return abi.call(raw.@"[method]world.set-sky-light", void, .{ abi.borrow(self), pos, level }); + } + + /// Returns the block light level at the specified position. + pub fn getBlockLight(self: World, pos: BlockPos) u8 { + return abi.call(raw.@"[method]world.get-block-light", u8, .{ abi.borrow(self), pos }); + } + + /// Sets the block light level at the specified position. + pub fn setBlockLight(self: World, pos: BlockPos, level: u8) void { + return abi.call(raw.@"[method]world.set-block-light", void, .{ abi.borrow(self), pos, level }); + } + + /// Returns the biome at the specified position. + pub fn getBiome(self: World, pos: BlockPos) Biome { + return abi.call(raw.@"[method]world.get-biome", Biome, .{ abi.borrow(self), pos }); + } + + /// Spawns an entity of the specified type at the given position. + pub fn spawnEntity(self: World, entity_type: EntityType, pos: Position) Entity { + return abi.call(raw.@"[method]world.spawn-entity", Entity, .{ abi.borrow(self), entity_type, pos }); + } + + /// Returns a list of all entities in this world. + pub fn getEntities(self: World) []const Entity { + return abi.call(raw.@"[method]world.get-entities", []const Entity, .{abi.borrow(self)}); + } + + /// Spawns a lightning bolt at the specified position. + pub fn strikeLightning(self: World, pos: Position, effect_only: bool) void { + return abi.call(raw.@"[method]world.strike-lightning", void, .{ abi.borrow(self), pos, effect_only }); + } + + /// Performs a raycast from start position to end position to hit blocks. + pub fn rayTraceBlocks(self: World, start: Position, end: Position) ?Position { + return abi.call(raw.@"[method]world.ray-trace-blocks", ?Position, .{ abi.borrow(self), start, end }); + } + + /// Performs a raycast from start position to end position to hit blocks, with optional fluid handling. + pub fn rayTraceBlock(self: World, start: Position, end: Position, include_fluids: bool) ?RayTraceBlockResult { + return abi.call(raw.@"[method]world.ray-trace-block", ?RayTraceBlockResult, .{ abi.borrow(self), start, end, include_fluids }); + } + + /// Performs a raycast from start position to end position to find the closest entity hit. + pub fn rayTraceEntity(self: World, start: Position, end: Position) ?RayTraceEntityResult { + return abi.call(raw.@"[method]world.ray-trace-entity", ?RayTraceEntityResult, .{ abi.borrow(self), start, end }); + } + + /// Performs a raycast from start position to end position to find all entities hit along the ray. + pub fn rayTraceEntities(self: World, start: Position, end: Position) []const RayTraceEntityResult { + return abi.call(raw.@"[method]world.ray-trace-entities", []const RayTraceEntityResult, .{ abi.borrow(self), start, end }); + } + + /// Returns the block entity at the specified position, if any. + pub fn getBlockEntity(self: World, pos: BlockPos) ?BlockEntityType { + return abi.call(raw.@"[method]world.get-block-entity", ?BlockEntityType, .{ abi.borrow(self), pos }); + } + + /// Returns the raw NBT bytes of the block entity at the given position, if any. + pub fn getBlockEntityNbt(self: World, pos: BlockPos) ?[]const u8 { + return abi.call(raw.@"[method]world.get-block-entity-nbt", ?[]const u8, .{ abi.borrow(self), pos }); + } + + /// Restores a block entity from raw NBT bytes at the given position. + /// The NBT must contain a valid "id" field (e.g. "minecraft:chest"). + pub fn setBlockEntityNbt(self: World, pos: BlockPos, nbt_data: []const u8) abi.Result(void, []const u8) { + return abi.call(raw.@"[method]world.set-block-entity-nbt", abi.Result(void, []const u8), .{ abi.borrow(self), pos, nbt_data }); + } + + /// Returns the name of this world (e.g. "world", "world_nether", "arena_1"). + pub fn getName(self: World) []const u8 { + return abi.call(raw.@"[method]world.get-name", []const u8, .{abi.borrow(self)}); + } + + /// Saves all chunk data, block entities, and entities for this world to disk. + pub fn save(self: World) abi.Result(void, []const u8) { + return abi.call(raw.@"[method]world.save", abi.Result(void, []const u8), .{abi.borrow(self)}); + } + + /// Sets a custom chunk generator for this world using a registered generator ID. + pub fn setChunkGenerator(self: World, generator_id: u32) void { + return abi.call(raw.@"[method]world.set-chunk-generator", void, .{ abi.borrow(self), generator_id }); + } + + /// Sets a namespaced custom data value on this world. + pub fn setCustomData(self: World, namespace: []const u8, key: []const u8, value: NbtTree) void { + return abi.call(raw.@"[method]world.set-custom-data", void, .{ abi.borrow(self), namespace, key, value }); + } + + /// Returns a namespaced custom data value from this world, if set. + pub fn getCustomData(self: World, namespace: []const u8, key: []const u8) ?NbtTree { + return abi.call(raw.@"[method]world.get-custom-data", ?NbtTree, .{ abi.borrow(self), namespace, key }); + } + + /// Removes a namespaced custom data value from this world. + pub fn removeCustomData(self: World, namespace: []const u8, key: []const u8) void { + return abi.call(raw.@"[method]world.remove-custom-data", void, .{ abi.borrow(self), namespace, key }); + } + + /// Returns whether this world has a namespaced custom data value. + pub fn hasCustomData(self: World, namespace: []const u8, key: []const u8) bool { + return abi.call(raw.@"[method]world.has-custom-data", bool, .{ abi.borrow(self), namespace, key }); + } + + /// Gets the value of a game rule in this world. + pub fn getGameRule(self: World, rule: GameRule) GameRuleValue { + return abi.call(raw.@"[method]world.get-game-rule", GameRuleValue, .{ abi.borrow(self), rule }); + } + + /// Sets the value of a game rule in this world. + pub fn setGameRule(self: World, rule: GameRule, value: GameRuleValue) void { + return abi.call(raw.@"[method]world.set-game-rule", void, .{ abi.borrow(self), rule, value }); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: World) void { + abi.keep(World, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: World) void { + abi.drop(World, self); + } +}; + +/// Generation phase for custom chunk generation. +pub const GenerationPhase = enum(u8) { + biomes, + noise, + surface, + features, +}; + +/// Mutable chunk buffer representing a 16x16 column during custom world generation. +pub const ChunkBuffer = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]chunk-buffer"; + + /// Returns the chunk X coordinate. + pub fn getX(self: ChunkBuffer) i32 { + return abi.call(raw.@"[method]chunk-buffer.get-x", i32, .{abi.borrow(self)}); + } + + /// Returns the chunk Z coordinate. + pub fn getZ(self: ChunkBuffer) i32 { + return abi.call(raw.@"[method]chunk-buffer.get-z", i32, .{abi.borrow(self)}); + } + + /// Returns the minimum Y coordinate for this world. + pub fn getMinY(self: ChunkBuffer) i32 { + return abi.call(raw.@"[method]chunk-buffer.get-min-y", i32, .{abi.borrow(self)}); + } + + /// Returns the height of the chunk in blocks. + pub fn getHeight(self: ChunkBuffer) u32 { + return abi.call(raw.@"[method]chunk-buffer.get-height", u32, .{abi.borrow(self)}); + } + + /// Sets the block state ID at local coordinates (0..16, y, 0..16). + pub fn setBlockStateId(self: ChunkBuffer, x: u8, y: i32, z: u8, state_id: u16) void { + return abi.call(raw.@"[method]chunk-buffer.set-block-state-id", void, .{ abi.borrow(self), x, y, z, state_id }); + } + + /// Gets the block state ID at local coordinates (0..16, y, 0..16). + pub fn getBlockStateId(self: ChunkBuffer, x: u8, y: i32, z: u8) u16 { + return abi.call(raw.@"[method]chunk-buffer.get-block-state-id", u16, .{ abi.borrow(self), x, y, z }); + } + + /// Fills an entire horizontal 16x16 layer at the given Y level with a block state ID. + pub fn fillLayer(self: ChunkBuffer, y: i32, state_id: u16) void { + return abi.call(raw.@"[method]chunk-buffer.fill-layer", void, .{ abi.borrow(self), y, state_id }); + } + + /// Fills a vertical column from min-y to max-y at local (x, z) with a block state ID. + pub fn fillRange(self: ChunkBuffer, x: u8, min_y: i32, max_y: i32, z: u8, state_id: u16) void { + return abi.call(raw.@"[method]chunk-buffer.fill-range", void, .{ abi.borrow(self), x, min_y, max_y, z, state_id }); + } + + /// Fills a 3D cuboid with a block state ID. + pub fn fillCuboid(self: ChunkBuffer, min_x: u8, min_y: i32, min_z: u8, max_x: u8, max_y: i32, max_z: u8, state_id: u16) void { + return abi.call(raw.@"[method]chunk-buffer.fill-cuboid", void, .{ abi.borrow(self), min_x, min_y, min_z, max_x, max_y, max_z, state_id }); + } + + /// Sets the biome at local coordinates (0..16, y, 0..16). + pub fn setBiome(self: ChunkBuffer, x: u8, y: i32, z: u8, biome: Biome) void { + return abi.call(raw.@"[method]chunk-buffer.set-biome", void, .{ abi.borrow(self), x, y, z, biome }); + } + + /// Fills the entire chunk with the given biome. + pub fn fillBiome(self: ChunkBuffer, biome: Biome) void { + return abi.call(raw.@"[method]chunk-buffer.fill-biome", void, .{ abi.borrow(self), biome }); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: ChunkBuffer) void { + abi.keep(ChunkBuffer, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: ChunkBuffer) void { + abi.drop(ChunkBuffer, self); + } +}; + +/// A block's registry name and its property key-value pairs for a state ID. +pub const BlockStateInfo = struct { + name: []const u8, + properties: []const struct { []const u8, []const u8 }, +}; + +/// Resolves a block name and optional properties to a block state ID. +/// Returns none if the block name is unknown. +pub fn resolveBlockState(name: []const u8, properties: []const struct { []const u8, []const u8 }) ?u16 { + return abi.call(raw.@"resolve-block-state", ?u16, .{ name, properties }); +} + +/// Resolves a block state ID back to its block name and properties. +/// Returns none if the state ID is unknown. +pub fn blockStateToInfo(state_id: u16) ?BlockStateInfo { + return abi.call(raw.@"block-state-to-info", ?BlockStateInfo, .{state_id}); +} + +/// Gets a block type by its numerical block ID. +pub fn getBlockById(id: u16) ?Block { + return abi.call(raw.@"get-block-by-id", ?Block, .{id}); +} + +/// Gets a block type by its namespaced name (e.g., "minecraft:stone" or "stone"). +pub fn getBlockByName(name: []const u8) ?Block { + return abi.call(raw.@"get-block-by-name", ?Block, .{name}); +} + +/// Gets all registered blocks. +pub fn getAllBlocks() []const Block { + return abi.call(raw.@"get-all-blocks", []const Block, .{}); +} + +/// Gets the names of all registered blocks. +pub fn getAllBlockNames() []const []const u8 { + return abi.call(raw.@"get-all-block-names", []const []const u8, .{}); +} + +/// Gets the total number of registered block types. +pub fn getBlockCount() u32 { + return abi.call(raw.@"get-block-count", u32, .{}); +} + +/// Gets the total number of registered block states. +pub fn getBlockStateCount() u32 { + return abi.call(raw.@"get-block-state-count", u32, .{}); +} + +/// Gets all valid block states for a block type. +pub fn getStatesForBlock(block: Block) []const BlockState { + return abi.call(raw.@"get-states-for-block", []const BlockState, .{block}); +} + +/// Gets all valid block states for a numerical block ID. +pub fn getStatesForBlockId(block_id: u16) []const BlockState { + return abi.call(raw.@"get-states-for-block-id", []const BlockState, .{block_id}); +} + +/// Gets all valid state IDs for a numerical block ID. +pub fn getStateIdsForBlockId(block_id: u16) []const u16 { + return abi.call(raw.@"get-state-ids-for-block-id", []const u16, .{block_id}); +} + +/// Gets property key-value pairs for a numerical block state ID. +pub fn getBlockProperties(state_id: u16) []const struct { []const u8, []const u8 } { + return abi.call(raw.@"get-block-properties", []const struct { []const u8, []const u8 }, .{state_id}); +} + +/// Gets the block type associated with a block state ID. +pub fn getBlockFromStateId(state_id: u16) ?Block { + return abi.call(raw.@"get-block-from-state-id", ?Block, .{state_id}); +} + +/// Gets the block type associated with a block state. +pub fn getBlockFromState(state: BlockState) Block { + return abi.call(raw.@"get-block-from-state", Block, .{state}); +} + +/// Gets the default block state for a block type. +pub fn getDefaultStateFromBlock(block: Block) BlockState { + return abi.call(raw.@"get-default-state-from-block", BlockState, .{block}); +} + +/// Gets the default block state for a numerical block ID. +pub fn getDefaultStateFromBlockId(block_id: u16) ?BlockState { + return abi.call(raw.@"get-default-state-from-block-id", ?BlockState, .{block_id}); +} + +/// Gets the detailed block state for a numerical block state ID. +pub fn getBlockStateById(state_id: u16) ?BlockState { + return abi.call(raw.@"get-block-state-by-id", ?BlockState, .{state_id}); +} + +const raw = struct { + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-id"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-uuid"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-type"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-position"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-world"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-yaw"(i32) f32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-pitch"(i32) f32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-head-yaw"(i32) f32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.teleport"(i32, f64, f64, f64, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.set-velocity"(i32, f64, f64, f64) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-velocity"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-pose"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-name"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.set-custom-name"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-custom-name"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.set-custom-name-visible"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.is-custom-name-visible"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.is-invulnerable"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.set-invulnerable"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-fire-ticks"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.set-fire-ticks"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-fall-distance"(i32) f32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.set-fall-distance"(i32, f32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-ticks-lived"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.set-ticks-lived"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.is-sneaking"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.set-sneaking"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.is-sprinting"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.set-sprinting"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.is-swimming"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.set-swimming"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.is-invisible"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.set-invisible"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.is-glowing"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.set-glowing"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.is-fall-flying"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.set-fall-flying"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.is-silent"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.set-silent"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.has-gravity"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.set-has-gravity"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-width"(i32) f32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-height"(i32) f32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.set-rotation"(i32, f32, f32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.is-on-ground"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.is-on-fire"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.set-on-fire"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.has-visual-fire"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.set-visual-fire"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-portal-cooldown"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.set-portal-cooldown"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-remaining-air"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.set-remaining-air"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-max-air"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-eye-height"(i32) f32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-eye-position"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-nearby-entities"(i32, f64, f64, f64, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-vehicle"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.set-vehicle"(i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-passengers"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.add-passenger"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.remove-passenger"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.eject-passengers"(i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-bounding-box"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.is-in-water"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.is-in-lava"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.remove"(i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.raycast"(i32, f64, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.ray-trace-block"(i32, f64, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.ray-trace-entity"(i32, f64, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-target-entity"(i32, f64, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.set-custom-data"(i32, i32, i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.get-custom-data"(i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.remove-custom-data"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.has-custom-data"(i32, i32, i32, i32, i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.as-living"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.as-mob"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.is-living"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]entity.is-mob"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]living-entity.as-entity"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]living-entity.as-mob"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]living-entity.is-mob"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]living-entity.get-health"(i32) f32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]living-entity.set-health"(i32, f32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]living-entity.get-max-health"(i32) f32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]living-entity.set-max-health"(i32, f32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]living-entity.damage"(i32, f32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]living-entity.is-dead"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]living-entity.get-absorption"(i32) f32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]living-entity.set-absorption"(i32, f32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]living-entity.get-attribute-value"(i32, i32) f64; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]living-entity.get-attribute-base"(i32, i32) f64; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]living-entity.set-attribute-base"(i32, i32, f64) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]living-entity.add-attribute-modifier"(i32, i32, i32, i32, f64, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]living-entity.remove-attribute-modifier"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]living-entity.get-attribute-modifiers"(i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]living-entity.reset-attribute"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]living-entity.reset-all-attributes"(i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]living-entity.get-equipment"(i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]living-entity.set-equipment"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]living-entity.clear-equipment"(i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]living-entity.get-age"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]living-entity.set-age"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]living-entity.send-system-message"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]mob.as-entity"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]mob.as-living"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]mob.add-ai-goal"(i32, i32, i32, f32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]mob.add-custom-ai-goal"(i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]mob.clear-ai-goals"(i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]mob.set-ai-disabled"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]mob.is-ai-disabled"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]mob.set-target"(i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]mob.get-target"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]mob.navigate-to-pos"(i32, f64, f64, f64, f64) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]mob.navigate-to-entity"(i32, i32, f64) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]mob.stop-navigation"(i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]mob.is-navigating"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]mob.has-reached-destination"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]mob.set-navigation-speed"(i32, f64) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]mob.can-reach"(i32, f64, f64, f64, f32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]mob.set-pathfinding-malus"(i32, i32, f32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]mob.get-pathfinding-malus"(i32, i32) f32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]mob.look-at"(i32, f64, f64, f64) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]mob.look-at-entity"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]mob.get-mob-data"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]mob.set-mob-data"(i32, i32, i32, i32, i64, i64, i32, i32, i32, i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]mob.set-freeze-ticks"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]mob.get-freeze-ticks"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk.get-x"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk.get-z"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk.get-block-state-id"(i32, i32, i32, i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk.get-block-state"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk.set-block-state"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk.get-block"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk.set-block"(i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk.set-block-by-id"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk.get-biome"(i32, i32, i32, i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk.get-block-entity"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk.get-top-block-y"(i32, i32, i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk.get-sky-light"(i32, i32, i32, i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk.get-block-light"(i32, i32, i32, i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk.set-custom-data"(i32, i32, i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk.get-custom-data"(i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk.remove-custom-data"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk.has-custom-data"(i32, i32, i32, i32, i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world-border.get-center-x"(i32) f64; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world-border.get-center-z"(i32) f64; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world-border.get-center"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world-border.set-center"(i32, f64, f64) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world-border.get-diameter"(i32) f64; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world-border.get-size"(i32) f64; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world-border.set-diameter"(i32, f64, i32, i64) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world-border.set-size"(i32, f64) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world-border.set-size-transition"(i32, f64, i64) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world-border.get-target-diameter"(i32) f64; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world-border.get-target-speed"(i32) i64; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world-border.get-warning-distance"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world-border.set-warning-distance"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world-border.get-warning-delay"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world-border.set-warning-delay"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world-border.get-warning-time"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world-border.set-warning-time"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world-border.get-damage-buffer"(i32) f64; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world-border.set-damage-buffer"(i32, f64) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world-border.get-damage-amount"(i32) f64; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world-border.set-damage-amount"(i32, f64) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world-border.contains"(i32, f64, f64) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world-border.contains-pos"(i32, f64, f64, f64) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world-border.reset"(i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.get-id"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.get-border"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.get-world-border"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.get-chunk"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.get-block-state-id"(i32, i32, i32, i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.get-block-state"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.set-block-state"(i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.get-block"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.get-block-id"(i32, i32, i32, i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.set-block"(i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.set-block-by-id"(i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.set-block-by-name"(i32, i32, i32, i32, i32, i32, i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.get-time-of-day"(i32) i64; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.set-time-of-day"(i32, i64) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.get-world-age"(i32) i64; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.get-dimension"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.get-spawn-location"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.get-top-block-y"(i32, i32, i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.get-motion-blocking-height"(i32, i32, i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.is-raining"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.set-raining"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.is-thundering"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.set-thundering"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.broadcast-system-message"(i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.get-scoreboard"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.play-sound"(i32, i32, i32, f64, f64, f64, f32, f32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.play-custom-sound"(i32, i32, i32, i32, f64, f64, f64, f32, f32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.spawn-particle"(i32, i32, f64, f64, f64, f64, f64, f64, f32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.create-explosion"(i32, f64, f64, f64, f32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.get-sea-level"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.get-min-y"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.get-sky-light"(i32, i32, i32, i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.set-sky-light"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.get-block-light"(i32, i32, i32, i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.set-block-light"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.get-biome"(i32, i32, i32, i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.spawn-entity"(i32, i32, f64, f64, f64) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.get-entities"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.strike-lightning"(i32, f64, f64, f64, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.ray-trace-blocks"(i32, f64, f64, f64, f64, f64, f64, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.ray-trace-block"(i32, f64, f64, f64, f64, f64, f64, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.ray-trace-entity"(i32, f64, f64, f64, f64, f64, f64, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.ray-trace-entities"(i32, f64, f64, f64, f64, f64, f64, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.get-block-entity"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.get-block-entity-nbt"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.set-block-entity-nbt"(i32, i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.get-name"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.save"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.set-chunk-generator"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.set-custom-data"(i32, i32, i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.get-custom-data"(i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.remove-custom-data"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.has-custom-data"(i32, i32, i32, i32, i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.get-game-rule"(i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]world.set-game-rule"(i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk-buffer.get-x"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk-buffer.get-z"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk-buffer.get-min-y"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk-buffer.get-height"(i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk-buffer.set-block-state-id"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk-buffer.get-block-state-id"(i32, i32, i32, i32) i32; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk-buffer.fill-layer"(i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk-buffer.fill-range"(i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk-buffer.fill-cuboid"(i32, i32, i32, i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk-buffer.set-biome"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[method]chunk-buffer.fill-biome"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"resolve-block-state"(i32, i32, i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"block-state-to-info"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"get-block-by-id"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"get-block-by-name"(i32, i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"get-all-blocks"(i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"get-all-block-names"(i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"get-block-count"() i32; + extern "pumpkin:plugin/world@0.1.0" fn @"get-block-state-count"() i32; + extern "pumpkin:plugin/world@0.1.0" fn @"get-states-for-block"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"get-states-for-block-id"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"get-state-ids-for-block-id"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"get-block-properties"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"get-block-from-state-id"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"get-block-from-state"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"get-default-state-from-block"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"get-default-state-from-block-id"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"get-block-state-by-id"(i32, i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[resource-drop]entity"(i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[resource-drop]living-entity"(i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[resource-drop]mob"(i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[resource-drop]chunk"(i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[resource-drop]world-border"(i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[resource-drop]world"(i32) void; + extern "pumpkin:plugin/world@0.1.0" fn @"[resource-drop]chunk-buffer"(i32) void; +}; diff --git a/tools/gen.zig b/tools/gen.zig new file mode 100644 index 0000000..97cd0fd --- /dev/null +++ b/tools/gen.zig @@ -0,0 +1,818 @@ +//! Generates the Zig bindings from the output of `wasm-tools component wit --json`. +//! +//! usage: gen +//! +//! Writes /wit.zig, one file per interface under /wit/ and +//! /wit/exports.zig for the world's exports. + +const std = @import("std"); +const Allocator = std.mem.Allocator; +const Value = std.json.Value; +const Writer = std.Io.Writer; + +pub const File = struct { + path: []const u8, + data: []const u8, +}; + +const header = "// Generated by tools/gen.zig, do not edit.\n\n"; + +fn fatal(comptime fmt: []const u8, args: anytype) noreturn { + std.debug.print("gen: " ++ fmt ++ "\n", args); + std.process.exit(1); +} + +fn oom() noreturn { + fatal("out of memory", .{}); +} + +fn maybe(value: Value, key: []const u8) ?Value { + if (value != .object) fatal("expected an object around '{s}'", .{key}); + const found = value.object.get(key) orelse return null; + return if (found == .null) null else found; +} + +fn member(value: Value, key: []const u8) Value { + return maybe(value, key) orelse fatal("missing '{s}'", .{key}); +} + +fn items(value: Value) []const Value { + if (value != .array) fatal("expected an array", .{}); + return value.array.items; +} + +fn text(value: Value) []const u8 { + if (value != .string) fatal("expected a string", .{}); + return value.string; +} + +fn index(value: Value) usize { + if (value != .integer) fatal("expected an index", .{}); + return @intCast(value.integer); +} + +const Kind = enum { + record, + variant, + @"enum", + flags, + tuple, + list, + option, + result, + handle, + resource, + /// `use` or `type x = y` + type, +}; + +const Def = struct { kind: Kind, payload: Value }; + +const Core = enum { i32, i64, f32, f64 }; + +const Signature = struct { + params: []const Core, + result: ?Core, + /// The result doesn't fit in a single value and goes through memory. + indirect: bool, +}; + +const Scope = std.StringArrayHashMapUnmanaged(void); + +const Gen = struct { + arena: Allocator, + types: []const Value, + interfaces: []const Value, + world: Value, + /// "pumpkin:plugin" + namespace: []const u8, + /// "0.1.0" + version: []const u8, + /// Interfaces the world imports. The rest only contribute types. + imports: std.AutoArrayHashMapUnmanaged(usize, void) = .empty, + + /// Interface being written, null for exports.zig. + current: ?usize = null, + /// Other interfaces the file being written refers to. + used: std.AutoArrayHashMapUnmanaged(usize, void) = .empty, + /// `used` of the previous pass over the same file. A parameter can't share + /// its name with an imported module, and the imports are only known once + /// the file has been written. + imported: std.AutoArrayHashMapUnmanaged(usize, void) = .empty, + + fn init(arena: Allocator, root: Value) Gen { + const packages = items(member(root, "packages")); + const worlds = items(member(root, "worlds")); + if (packages.len != 1) fatal("expected one package, found {d}", .{packages.len}); + if (worlds.len != 1) fatal("expected one world, found {d}", .{worlds.len}); + + const package = text(member(packages[0], "name")); + const at = std.mem.indexOfScalar(u8, package, '@') orelse fatal("package '{s}' has no version", .{package}); + + var g: Gen = .{ + .arena = arena, + .types = items(member(root, "types")), + .interfaces = items(member(root, "interfaces")), + .world = worlds[0], + .namespace = package[0..at], + .version = package[at + 1 ..], + }; + for (member(g.world, "imports").object.values()) |item| { + const iface = maybe(item, "interface") orelse continue; + g.imports.put(arena, index(member(iface, "id")), {}) catch oom(); + } + g.validate(); + return g; + } + + fn def(g: *const Gen, id: usize) Def { + if (id >= g.types.len) fatal("type {d} out of range", .{id}); + switch (member(g.types[id], "kind")) { + .string => |name| { + if (std.mem.eql(u8, name, "resource")) return .{ .kind = .resource, .payload = .null }; + fatal("unsupported type kind '{s}'", .{name}); + }, + .object => |o| { + const name = o.keys()[0]; + const kind = std.meta.stringToEnum(Kind, name) orelse fatal("unsupported type kind '{s}'", .{name}); + return .{ .kind = kind, .payload = o.values()[0] }; + }, + else => fatal("malformed type {d}", .{id}), + } + } + + fn nameOf(g: *const Gen, id: usize) ?[]const u8 { + const name = maybe(g.types[id], "name") orelse return null; + return text(name); + } + + fn ownerOf(g: *const Gen, id: usize) ?usize { + const owner = maybe(g.types[id], "owner") orelse return null; + if (owner != .object) return null; + return index(owner.object.get("interface") orelse return null); + } + + fn interfaceName(g: *const Gen, iface: usize) []const u8 { + return text(member(g.interfaces[iface], "name")); + } + + fn isBorrow(g: *const Gen, ref: Value) bool { + if (ref != .integer) return false; + const d = g.def(index(ref)); + return d.kind == .handle and d.payload.object.contains("borrow"); + } + + fn isOwn(g: *const Gen, ref: Value) bool { + if (ref != .integer) return false; + const d = g.def(index(ref)); + return d.kind == .handle and d.payload.object.contains("own"); + } + + /// The type references a definition is built from. + fn children(g: *const Gen, d: Def) []const Value { + var out: std.ArrayList(Value) = .empty; + switch (d.kind) { + .record => for (items(member(d.payload, "fields"))) |f| out.append(g.arena, member(f, "type")) catch oom(), + .variant => for (items(member(d.payload, "cases"))) |c| { + if (maybe(c, "type")) |t| out.append(g.arena, t) catch oom(); + }, + .tuple => out.appendSlice(g.arena, items(member(d.payload, "types"))) catch oom(), + .list, .option, .type => out.append(g.arena, d.payload) catch oom(), + .result => { + if (maybe(d.payload, "ok")) |t| out.append(g.arena, t) catch oom(); + if (maybe(d.payload, "err")) |t| out.append(g.arena, t) catch oom(); + }, + .@"enum", .flags, .handle, .resource => {}, + } + return out.items; + } + + /// Everything the generator or src/abi.zig can't express ends up here + /// instead of in bindings that are quietly wrong. + fn validate(g: *const Gen) void { + for (0..g.types.len) |id| { + const d = g.def(id); + const label = g.nameOf(id) orelse "(anonymous)"; + if (d.kind == .flags and items(member(d.payload, "flags")).len > 32) { + fatal("flags '{s}' has more than 32 members", .{label}); + } + if (d.kind == .resource) { + const owner = g.ownerOf(id) orelse fatal("resource '{s}' has no interface", .{label}); + if (!g.imports.contains(owner)) fatal("resource '{s}' is exported by the guest, which is not supported", .{label}); + } + for (g.children(d)) |child| { + if (g.isBorrow(child)) fatal("'{s}' contains a borrowed handle, only parameters may", .{label}); + } + } + + for (g.interfaces) |iface| { + var it = member(iface, "functions").object.iterator(); + while (it.next()) |entry| g.validateFunc(entry.key_ptr.*, entry.value_ptr.*); + } + + var it = member(g.world, "exports").object.iterator(); + while (it.next()) |entry| { + const func = maybe(entry.value_ptr.*, "function") orelse continue; + g.validateFunc(entry.key_ptr.*, func); + for (items(member(func, "params"))) |p| { + if (g.isBorrow(member(p, "type"))) fatal("export '{s}' borrows a handle, which is not supported", .{entry.key_ptr.*}); + } + } + } + + fn validateFunc(g: *const Gen, name: []const u8, func: Value) void { + const kind = switch (member(func, "kind")) { + .string => |s| s, + .object => |o| o.keys()[0], + else => fatal("malformed function '{s}'", .{name}), + }; + const known = [_][]const u8{ "freestanding", "method", "static", "constructor" }; + for (known) |k| { + if (std.mem.eql(u8, kind, k)) break; + } else fatal("function '{s}' is '{s}', which is not supported", .{ name, kind }); + + if (maybe(func, "result")) |result| { + if (g.isBorrow(result)) fatal("function '{s}' returns a borrowed handle", .{name}); + } + } + + // naming + + const Style = enum { snake, camel, title }; + + fn words(g: *const Gen, name: []const u8, style: Style) []const u8 { + var out: std.ArrayList(u8) = .empty; + var upper = style == .title; + for (name) |c| { + if (c == '-' or c == '.' or c == '_') { + if (style == .snake) out.append(g.arena, '_') catch oom() else upper = true; + continue; + } + out.append(g.arena, if (upper) std.ascii.toUpper(c) else c) catch oom(); + upper = false; + } + return out.items; + } + + fn moduleName(g: *const Gen, iface: usize) []const u8 { + return g.words(g.interfaceName(iface), .snake); + } + + fn funcName(g: *const Gen, func: Value) []const u8 { + const full = text(member(func, "name")); + if (std.mem.startsWith(u8, full, "[constructor]")) return "init"; + const base = if (std.mem.indexOfScalar(u8, full, '.')) |dot| full[dot + 1 ..] else full; + return g.words(base, .camel); + } + + fn declare(g: *const Gen, scope: *Scope, name: []const u8, where: []const u8) void { + const entry = scope.getOrPut(g.arena, name) catch oom(); + if (entry.found_existing) fatal("'{s}' is declared twice in {s}", .{ name, where }); + } + + fn print(g: *const Gen, comptime fmt: []const u8, args: anytype) []const u8 { + return std.fmt.allocPrint(g.arena, fmt, args) catch oom(); + } + + // type references + + fn primitive(name: []const u8) []const u8 { + const map = std.StaticStringMap([]const u8).initComptime(.{ + .{ "bool", "bool" }, .{ "string", "[]const u8" }, .{ "char", "u21" }, + .{ "u8", "u8" }, .{ "u16", "u16" }, .{ "u32", "u32" }, + .{ "u64", "u64" }, .{ "s8", "i8" }, .{ "s16", "i16" }, + .{ "s32", "i32" }, .{ "s64", "i64" }, .{ "f32", "f32" }, + .{ "f64", "f64" }, + }); + return map.get(name) orelse fatal("unknown primitive '{s}'", .{name}); + } + + fn writeRef(g: *Gen, w: *Writer, ref: ?Value) Writer.Error!void { + switch (ref orelse return w.writeAll("void")) { + .string => |s| try w.writeAll(primitive(s)), + .integer => try g.writeTypeId(w, index(ref.?)), + else => fatal("malformed type reference", .{}), + } + } + + fn writeTypeId(g: *Gen, w: *Writer, id: usize) Writer.Error!void { + const d = g.def(id); + if (g.nameOf(id)) |name| { + if (g.ownerOf(id)) |owner| { + if (g.current != owner) { + g.used.put(g.arena, owner, {}) catch oom(); + try w.print("{s}.", .{g.moduleName(owner)}); + } + return w.writeAll(g.words(name, .title)); + } + // Owned by the world, which only ever aliases interface types. + if (d.kind != .type) fatal("the world defines '{s}' itself, which is not supported", .{name}); + return g.writeRef(w, d.payload); + } + if (d.kind == .handle) return g.writeTypeId(w, index(d.payload.object.values()[0])); + try g.writeShape(w, d); + } + + /// list, option, result, tuple or an alias, the kinds that may be anonymous. + fn writeShape(g: *Gen, w: *Writer, d: Def) Writer.Error!void { + switch (d.kind) { + .type => try g.writeRef(w, d.payload), + .list => { + try w.writeAll("[]const "); + try g.writeRef(w, d.payload); + }, + .option => { + try w.writeAll("?"); + try g.writeRef(w, d.payload); + }, + .result => { + try w.writeAll("abi.Result("); + try g.writeRef(w, maybe(d.payload, "ok")); + try w.writeAll(", "); + try g.writeRef(w, maybe(d.payload, "err")); + try w.writeAll(")"); + }, + .tuple => { + try w.writeAll("struct { "); + for (items(member(d.payload, "types")), 0..) |item, i| { + if (i != 0) try w.writeAll(", "); + try g.writeRef(w, item); + } + try w.writeAll(" }"); + }, + else => fatal("'{s}' needs a name", .{@tagName(d.kind)}), + } + } + + // Flattening. src/abi.zig does the same from the Zig types at comptime and + // refuses to compile when the two disagree. + + fn join(a: Core, b: Core) Core { + if (a == b) return a; + if ((a == .i32 and b == .f32) or (a == .f32 and b == .i32)) return .i32; + return .i64; + } + + fn flatten(g: *const Gen, ref: ?Value, out: *std.ArrayList(Core)) void { + switch (ref orelse return) { + .string => |s| { + const eql = std.mem.eql; + if (eql(u8, s, "string")) return out.appendSlice(g.arena, &.{ .i32, .i32 }) catch oom(); + const core: Core = if (eql(u8, s, "u64") or eql(u8, s, "s64")) + .i64 + else if (eql(u8, s, "f32")) + .f32 + else if (eql(u8, s, "f64")) + .f64 + else + .i32; + out.append(g.arena, core) catch oom(); + }, + .integer => { + const d = g.def(index(ref.?)); + switch (d.kind) { + .type => g.flatten(d.payload, out), + .record, .tuple => for (g.children(d)) |child| g.flatten(child, out), + .list => out.appendSlice(g.arena, &.{ .i32, .i32 }) catch oom(), + .variant => { + var payloads: std.ArrayList(?Value) = .empty; + for (items(member(d.payload, "cases"))) |c| payloads.append(g.arena, maybe(c, "type")) catch oom(); + g.flattenCases(payloads.items, out); + }, + .option => g.flattenCases(&.{ null, d.payload }, out), + .result => g.flattenCases(&.{ maybe(d.payload, "ok"), maybe(d.payload, "err") }, out), + .@"enum", .flags, .handle, .resource => out.append(g.arena, .i32) catch oom(), + } + }, + else => fatal("malformed type reference", .{}), + } + } + + fn flattenCases(g: *const Gen, payloads: []const ?Value, out: *std.ArrayList(Core)) void { + var joined: std.ArrayList(Core) = .empty; + for (payloads) |payload| { + var flat: std.ArrayList(Core) = .empty; + g.flatten(payload, &flat); + for (flat.items, 0..) |c, i| { + if (i < joined.items.len) { + joined.items[i] = join(joined.items[i], c); + } else { + joined.append(g.arena, c) catch oom(); + } + } + } + out.append(g.arena, .i32) catch oom(); + out.appendSlice(g.arena, joined.items) catch oom(); + } + + fn signature(g: *const Gen, func: Value, side: enum { import, @"export" }) Signature { + var params: std.ArrayList(Core) = .empty; + for (items(member(func, "params"))) |p| g.flatten(member(p, "type"), ¶ms); + if (params.items.len > 16) { + params.clearRetainingCapacity(); + params.append(g.arena, .i32) catch oom(); + } + + var results: std.ArrayList(Core) = .empty; + g.flatten(maybe(func, "result"), &results); + if (results.items.len <= 1) { + const result = if (results.items.len == 1) results.items[0] else null; + return .{ .params = params.items, .result = result, .indirect = false }; + } + if (side == .import) { + params.append(g.arena, .i32) catch oom(); + return .{ .params = params.items, .result = null, .indirect = true }; + } + return .{ .params = params.items, .result = .i32, .indirect = true }; + } + + // declarations + + fn writeDocs(w: *Writer, item: Value, indent: []const u8) Writer.Error!void { + const docs = maybe(item, "docs") orelse return; + const contents = maybe(docs, "contents") orelse return; + var lines = std.mem.splitScalar(u8, text(contents), '\n'); + while (lines.next()) |line| { + const trimmed = std.mem.trimEnd(u8, line, " \r"); + if (trimmed.len == 0) try w.print("{s}///\n", .{indent}) else try w.print("{s}/// {s}\n", .{ indent, trimmed }); + } + } + + fn fieldName(g: *const Gen, item: Value) std.zig.FormatId { + return std.zig.fmtId(g.words(text(member(item, "name")), .snake)); + } + + fn isPlainAlias(g: *const Gen, id: usize) bool { + const d = g.def(id); + return d.kind == .type and d.payload == .integer and maybe(g.types[id], "docs") == null; + } + + fn writeType(g: *Gen, w: *Writer, id: usize, funcs: Value) Writer.Error!void { + const wit_name = g.nameOf(id).?; + const name = g.words(wit_name, .title); + const d = g.def(id); + + try writeDocs(w, g.types[id], ""); + try w.print("pub const {s} = ", .{name}); + + switch (d.kind) { + .record => { + try w.writeAll("struct {\n"); + for (items(member(d.payload, "fields"))) |f| { + try writeDocs(w, f, " "); + try w.print(" {f}: ", .{g.fieldName(f)}); + try g.writeRef(w, member(f, "type")); + try w.writeAll(",\n"); + } + try w.writeAll("};\n\n"); + }, + .variant => { + try w.writeAll("union(enum) {\n"); + for (items(member(d.payload, "cases"))) |c| { + try writeDocs(w, c, " "); + try w.print(" {f}", .{g.fieldName(c)}); + if (maybe(c, "type")) |t| { + try w.writeAll(": "); + try g.writeRef(w, t); + } + try w.writeAll(",\n"); + } + try w.writeAll("};\n\n"); + }, + .@"enum" => { + const cases = items(member(d.payload, "cases")); + const tag = if (cases.len <= 1 << 8) "u8" else if (cases.len <= 1 << 16) "u16" else "u32"; + try w.print("enum({s}) {{\n", .{tag}); + for (cases) |c| { + try writeDocs(w, c, " "); + try w.print(" {f},\n", .{g.fieldName(c)}); + } + try w.writeAll("};\n\n"); + }, + .flags => { + const flags = items(member(d.payload, "flags")); + const bits: usize = if (flags.len <= 8) 8 else if (flags.len <= 16) 16 else 32; + try w.print("packed struct(u{d}) {{\n", .{bits}); + for (flags) |f| { + try writeDocs(w, f, " "); + try w.print(" {f}: bool = false,\n", .{g.fieldName(f)}); + } + if (flags.len != bits) try w.print(" _: u{d} = 0,\n", .{bits - flags.len}); + try w.writeAll("};\n\n"); + }, + .resource => { + try w.print( + \\enum(u32) {{ + \\ _, + \\ + \\ pub const resource_drop = &raw.{f}; + \\ + \\ + , .{std.zig.fmtId(g.print("[resource-drop]{s}", .{wit_name}))}); + try g.writeMethods(w, id, name, funcs); + try w.print( + \\ /// Keeps the handle alive past the current callback. Release it with `deinit`. + \\ pub fn keep(self: {0s}) void {{ + \\ abi.keep({0s}, self); + \\ }} + \\ + \\ /// Releases the handle now instead of when the callback returns. + \\ pub fn deinit(self: {0s}) void {{ + \\ abi.drop({0s}, self); + \\ }} + \\}}; + \\ + \\ + , .{name}); + }, + .handle => fatal("'{s}' names a handle type", .{wit_name}), + .type, .list, .option, .result, .tuple => { + try g.writeShape(w, d); + try w.writeAll(if (g.isPlainAlias(id)) ";\n" else ";\n\n"); + }, + } + } + + fn methodOwner(func: Value) ?usize { + const kind = member(func, "kind"); + if (kind != .object) return null; + return index(kind.object.values()[0]); + } + + fn writeMethods(g: *Gen, w: *Writer, resource: usize, resource_name: []const u8, funcs: Value) Writer.Error!void { + var scope: Scope = .empty; + for ([_][]const u8{ "resource_drop", "keep", "deinit" }) |reserved| g.declare(&scope, reserved, resource_name); + + for (funcs.object.values()) |func| { + if (methodOwner(func) == resource) g.declare(&scope, g.funcName(func), resource_name); + } + for (funcs.object.values()) |func| { + if (methodOwner(func) == resource) try g.writeFunc(w, func, " ", resource_name, &scope); + } + } + + fn paramName(g: *const Gen, param: Value, scope: *const Scope) []const u8 { + const name = g.words(text(member(param, "name")), .snake); + if (scope.contains(name)) return g.print("{s}_", .{name}); + if (std.mem.eql(u8, name, "abi") or std.mem.eql(u8, name, "raw")) return g.print("{s}_", .{name}); + for (g.imported.keys()) |iface| { + if (std.mem.eql(u8, g.moduleName(iface), name)) return g.print("{s}_", .{name}); + } + return name; + } + + fn writeFunc( + g: *Gen, + w: *Writer, + func: Value, + indent: []const u8, + self_type: ?[]const u8, + scope: *const Scope, + ) Writer.Error!void { + const params = items(member(func, "params")); + const is_method = std.mem.startsWith(u8, text(member(func, "name")), "[method]"); + + var names: std.ArrayList([]const u8) = .empty; + for (params) |p| names.append(g.arena, g.paramName(p, scope)) catch oom(); + + try writeDocs(w, func, indent); + var consumes = false; + for (params, names.items) |p, name| { + if (!g.isOwn(member(p, "type"))) continue; + if (!consumes and maybe(func, "docs") != null) try w.print("{s}///\n", .{indent}); + consumes = true; + try w.print("{s}/// Consumes `{s}`.\n", .{ indent, name }); + } + + try w.print("{s}pub fn {f}(", .{ indent, std.zig.fmtId(g.funcName(func)) }); + for (params, names.items, 0..) |p, name, i| { + if (i != 0) try w.writeAll(", "); + try w.print("{f}: ", .{std.zig.fmtId(name)}); + if (is_method and i == 0) try w.writeAll(self_type.?) else try g.writeRef(w, member(p, "type")); + } + try w.writeAll(") "); + try g.writeRef(w, maybe(func, "result")); + + try w.print(" {{\n{s} return abi.call(raw.{f}, ", .{ indent, std.zig.fmtId(text(member(func, "name"))) }); + try g.writeRef(w, maybe(func, "result")); + try w.writeAll(if (params.len > 1) ", .{ " else ", .{"); + for (params, names.items, 0..) |p, name, i| { + if (i != 0) try w.writeAll(", "); + if (g.isBorrow(member(p, "type"))) { + try w.print("abi.borrow({f})", .{std.zig.fmtId(name)}); + } else { + try w.print("{f}", .{std.zig.fmtId(name)}); + } + } + try w.print("{s});\n{s}}}\n\n", .{ if (params.len > 1) " }" else "}", indent }); + } + + fn writeRaw(w: *Writer, module: []const u8, name: []const u8, sig: Signature) Writer.Error!void { + try w.print(" extern \"{s}\" fn {f}(", .{ module, std.zig.fmtId(name) }); + for (sig.params, 0..) |p, i| { + if (i != 0) try w.writeAll(", "); + try w.writeAll(@tagName(p)); + } + try w.print(") {s};\n", .{if (sig.result) |r| @tagName(r) else "void"}); + } + + fn writeImports(g: *const Gen, w: *Writer) Writer.Error!void { + for (g.used.keys()) |iface| { + const name = g.moduleName(iface); + try w.print("const {f} = @import(\"{s}.zig\");\n", .{ std.zig.fmtId(name), name }); + } + } + + // files + + fn interfaceFile(g: *Gen, iface: usize) Writer.Error![]const u8 { + g.current = iface; + g.imported = .empty; + _ = try g.interfacePass(iface); + g.imported = g.used; + return g.interfacePass(iface); + } + + fn interfacePass(g: *Gen, iface: usize) Writer.Error![]const u8 { + g.used = .empty; + const where = g.interfaceName(iface); + const types = member(g.interfaces[iface], "types").object; + const no_funcs: Value = .{ .object = .empty }; + const funcs = if (g.imports.contains(iface)) member(g.interfaces[iface], "functions") else no_funcs; + const module = g.print("{s}/{s}@{s}", .{ g.namespace, where, g.version }); + + var scope: Scope = .empty; + for (types.keys()) |name| g.declare(&scope, g.words(name, .title), where); + for (funcs.object.values()) |func| { + if (methodOwner(func) == null) g.declare(&scope, g.funcName(func), where); + } + + var body: Writer.Allocating = .init(g.arena); + const w = &body.writer; + + // `use`d types come first in the JSON, keep them together like an import block. + var in_aliases = false; + for (types.values()) |id| { + const is_alias = g.isPlainAlias(index(id)); + if (in_aliases and !is_alias) try w.writeAll("\n"); + in_aliases = is_alias; + try g.writeType(w, index(id), funcs); + } + if (in_aliases) try w.writeAll("\n"); + + for (funcs.object.values()) |func| { + if (methodOwner(func) == null) try g.writeFunc(w, func, "", null, &scope); + } + + var raw: Writer.Allocating = .init(g.arena); + for (funcs.object.keys(), funcs.object.values()) |name, func| { + try writeRaw(&raw.writer, module, name, g.signature(func, .import)); + } + for (types.keys(), types.values()) |name, id| { + if (g.def(index(id)).kind != .resource) continue; + const drop: Signature = .{ .params = &.{.i32}, .result = null, .indirect = false }; + try writeRaw(&raw.writer, module, g.print("[resource-drop]{s}", .{name}), drop); + } + + var out: Writer.Allocating = .init(g.arena); + try out.writer.writeAll(header); + const uses_abi = raw.written().len != 0 or std.mem.indexOf(u8, body.written(), "abi.") != null; + if (uses_abi) try out.writer.writeAll("const abi = @import(\"../abi.zig\");\n"); + try g.writeImports(&out.writer); + if (uses_abi or g.used.count() != 0) try out.writer.writeAll("\n"); + try out.writer.writeAll(body.written()); + if (raw.written().len != 0) try out.writer.print("const raw = struct {{\n{s}}};\n", .{raw.written()}); + return g.print("{s}\n", .{std.mem.trimEnd(u8, out.written(), "\n")}); + } + + fn writeExport(g: *Gen, w: *Writer, export_name: []const u8, func: Value) Writer.Error!void { + const sig = g.signature(func, .@"export"); + const params = items(member(func, "params")); + const base = if (std.mem.indexOfScalar(u8, export_name, '#')) |hash| export_name[hash + 1 ..] else export_name; + + try writeDocs(w, func, ""); + try w.print("pub fn {f}(comptime impl: fn (", .{std.zig.fmtId(g.words(base, .camel))}); + for (params, 0..) |p, i| { + if (i != 0) try w.writeAll(", "); + try g.writeRef(w, member(p, "type")); + } + try w.writeAll(") "); + try g.writeRef(w, maybe(func, "result")); + + try w.writeAll(") void {\n const glue = struct {\n fn call("); + for (sig.params, 0..) |p, i| { + if (i != 0) try w.writeAll(", "); + try w.print("p{d}: {s}", .{ i, @tagName(p) }); + } + try w.print(") callconv(.c) {s} {{\n", .{if (sig.result) |r| @tagName(r) else "void"}); + + try w.writeAll(" const args = abi.liftArgs(std.meta.ArgsTuple(@TypeOf(impl)), "); + try w.writeAll(if (sig.params.len > 1) ".{ " else ".{"); + for (sig.params, 0..) |_, i| { + if (i != 0) try w.writeAll(", "); + try w.print("p{d}", .{i}); + } + try w.writeAll(if (sig.params.len > 1) " });\n" else "});\n"); + + if (!sig.indirect) try w.writeAll(" defer abi.endCall();\n"); + try w.writeAll(" return abi.lowerReturn("); + try g.writeRef(w, maybe(func, "result")); + try w.writeAll(", @call(.auto, impl, args));\n }\n"); + + // The host reads an indirect result after we return, cleanup has to wait for post-return. + if (sig.indirect) try w.writeAll("\n fn post(_: i32) callconv(.c) void {\n abi.endCall();\n }\n"); + try w.print(" }};\n @export(&glue.call, .{{ .name = \"{s}\" }});\n", .{export_name}); + if (sig.indirect) try w.print(" @export(&glue.post, .{{ .name = \"cabi_post_{s}\" }});\n", .{export_name}); + try w.writeAll("}\n\n"); + } + + fn exportsFile(g: *Gen) Writer.Error![]const u8 { + g.current = null; + g.used = .empty; + g.imported = .empty; + + var scope: Scope = .empty; + var body: Writer.Allocating = .init(g.arena); + const exports = member(g.world, "exports").object; + for (exports.keys(), exports.values()) |name, item| { + if (maybe(item, "function")) |func| { + g.declare(&scope, g.words(name, .camel), "the world's exports"); + try g.writeExport(&body.writer, name, func); + continue; + } + const iface = index(member(member(item, "interface"), "id")); + const funcs = member(g.interfaces[iface], "functions").object; + for (funcs.keys(), funcs.values()) |func_name, func| { + g.declare(&scope, g.words(func_name, .camel), "the world's exports"); + const full = g.print("{s}/{s}@{s}#{s}", .{ g.namespace, g.interfaceName(iface), g.version, func_name }); + try g.writeExport(&body.writer, full, func); + } + } + + var out: Writer.Allocating = .init(g.arena); + try out.writer.writeAll(header ++ "const std = @import(\"std\");\nconst abi = @import(\"../abi.zig\");\n"); + try g.writeImports(&out.writer); + try out.writer.print("\n{s}\n", .{std.mem.trimEnd(u8, body.written(), "\n")}); + return out.written(); + } +}; + +/// Paths are relative to the source directory. +pub fn generate(arena: Allocator, source: []const u8) ![]const File { + const root = try std.json.parseFromSliceLeaky(Value, arena, source, .{}); + var g: Gen = .init(arena, root); + + var files: std.ArrayList(File) = .empty; + var root_file: Writer.Allocating = .init(arena); + try root_file.writer.writeAll(header); + + for (0..g.interfaces.len) |iface| { + const name = g.moduleName(iface); + if (std.mem.eql(u8, name, "exports")) fatal("an interface is called 'exports'", .{}); + try files.append(arena, .{ .path = g.print("wit/{s}.zig", .{name}), .data = try g.interfaceFile(iface) }); + try root_file.writer.print("pub const {f} = @import(\"wit/{s}.zig\");\n", .{ std.zig.fmtId(name), name }); + } + + try files.append(arena, .{ .path = "wit/exports.zig", .data = try g.exportsFile() }); + try root_file.writer.writeAll("pub const exports = @import(\"wit/exports.zig\");\n"); + try files.append(arena, .{ .path = "wit.zig", .data = root_file.written() }); + return files.items; +} + +pub fn main(init: std.process.Init) !void { + const arena = init.arena.allocator(); + const io = init.io; + const args = try init.minimal.args.toSlice(arena); + if (args.len != 3) fatal("usage: gen ", .{}); + + const cwd = std.Io.Dir.cwd(); + const source = cwd.readFileAlloc(io, args[1], arena, .unlimited) catch |err| { + fatal("can't read {s}: {t}", .{ args[1], err }); + }; + + const out = try cwd.createDirPathOpen(io, args[2], .{}); + try out.createDirPath(io, "wit"); + for (try generate(arena, source)) |file| { + try out.writeFile(io, .{ .sub_path = file.path, .data = file.data }); + } +} + +test "demo world" { + var arena_state: std.heap.ArenaAllocator = .init(std.testing.allocator); + defer arena_state.deinit(); + + const expected = [_]File{ + .{ .path = "wit/types.zig", .data = @embedFile("testdata/expected/wit/types.zig") }, + .{ .path = "wit/host.zig", .data = @embedFile("testdata/expected/wit/host.zig") }, + .{ .path = "wit/guest.zig", .data = @embedFile("testdata/expected/wit/guest.zig") }, + .{ .path = "wit/exports.zig", .data = @embedFile("testdata/expected/wit/exports.zig") }, + .{ .path = "wit.zig", .data = @embedFile("testdata/expected/wit.zig") }, + }; + + const files = try generate(arena_state.allocator(), @embedFile("testdata/demo.json")); + try std.testing.expectEqual(expected.len, files.len); + for (expected, files) |want, got| { + try std.testing.expectEqualStrings(want.path, got.path); + try std.testing.expectEqualStrings(want.data, got.data); + } +} diff --git a/tools/testdata/demo.json b/tools/testdata/demo.json new file mode 100644 index 0000000..07f2cac --- /dev/null +++ b/tools/testdata/demo.json @@ -0,0 +1,507 @@ +{ + "worlds": [ + { + "name": "plugin", + "imports": { + "interface-0": { + "interface": { + "id": 0 + } + }, + "interface-1": { + "interface": { + "id": 1 + } + }, + "canvas": { + "type": 17 + }, + "shape": { + "type": 18 + }, + "pair": { + "type": 19 + } + }, + "exports": { + "start": { + "function": { + "name": "start", + "kind": "freestanding", + "params": [ + { + "name": "canvas", + "type": 21 + } + ], + "result": 20 + } + }, + "measure": { + "function": { + "name": "measure", + "kind": "freestanding", + "params": [ + { + "name": "shape", + "type": 18 + }, + { + "name": "scale", + "type": 19 + } + ], + "result": "f32" + } + }, + "stop": { + "function": { + "name": "stop", + "kind": "freestanding", + "params": [] + } + }, + "interface-2": { + "interface": { + "id": 2 + } + } + }, + "package": 0 + } + ], + "interfaces": [ + { + "name": "types", + "types": { + "point": 1, + "color": 2, + "access": 3, + "shape": 5, + "pair": 6, + "names": 7 + }, + "functions": {}, + "package": 0 + }, + { + "name": "host", + "types": { + "point": 8, + "color": 9, + "shape": 10, + "access": 11, + "canvas": 12 + }, + "functions": { + "[constructor]canvas": { + "name": "[constructor]canvas", + "kind": { + "constructor": 12 + }, + "params": [ + { + "name": "width", + "type": "u32" + }, + { + "name": "height", + "type": "u32" + } + ], + "result": 13 + }, + "[static]canvas.open": { + "name": "[static]canvas.open", + "kind": { + "static": 12 + }, + "params": [ + { + "name": "path", + "type": "string" + } + ], + "result": 14, + "docs": { + "contents": "Opens a canvas stored on disk." + } + }, + "[method]canvas.draw": { + "name": "[method]canvas.draw", + "kind": { + "method": 12 + }, + "params": [ + { + "name": "self", + "type": 15 + }, + { + "name": "shape", + "type": 10 + }, + { + "name": "at", + "type": 8 + }, + { + "name": "color", + "type": 9 + } + ] + }, + "[method]canvas.blend": { + "name": "[method]canvas.blend", + "kind": { + "method": 12 + }, + "params": [ + { + "name": "self", + "type": 15 + }, + { + "name": "other", + "type": 15 + }, + { + "name": "types", + "type": 11 + } + ], + "docs": { + "contents": "Copies `other` on top of this canvas." + } + }, + "[method]canvas.name": { + "name": "[method]canvas.name", + "kind": { + "method": 12 + }, + "params": [ + { + "name": "self", + "type": 15 + } + ], + "result": 0 + }, + "present": { + "name": "present", + "kind": "freestanding", + "params": [ + { + "name": "canvas", + "type": 13 + } + ], + "result": "u64", + "docs": { + "contents": "Shows the canvas and closes it." + } + }, + "log": { + "name": "log", + "kind": "freestanding", + "params": [ + { + "name": "message", + "type": "string" + } + ] + } + }, + "package": 0 + }, + { + "name": "guest", + "types": { + "point": 16 + }, + "functions": { + "describe": { + "name": "describe", + "kind": "freestanding", + "params": [], + "result": 16 + } + }, + "package": 0 + } + ], + "types": [ + { + "name": null, + "kind": { + "option": "string" + }, + "owner": null + }, + { + "name": "point", + "kind": { + "record": { + "fields": [ + { + "name": "x", + "type": "s32" + }, + { + "name": "y", + "type": "s32" + }, + { + "name": "label", + "type": 0, + "docs": { + "contents": "Optional label." + } + } + ] + } + }, + "owner": { + "interface": 0 + }, + "docs": { + "contents": "Where something is." + } + }, + { + "name": "color", + "kind": { + "enum": { + "cases": [ + { + "name": "red" + }, + { + "name": "green" + }, + { + "name": "blue" + } + ] + } + }, + "owner": { + "interface": 0 + } + }, + { + "name": "access", + "kind": { + "flags": { + "flags": [ + { + "name": "read" + }, + { + "name": "write" + }, + { + "name": "exec" + } + ] + } + }, + "owner": { + "interface": 0 + } + }, + { + "name": null, + "kind": { + "list": 1 + }, + "owner": null + }, + { + "name": "shape", + "kind": { + "variant": { + "cases": [ + { + "name": "nothing", + "type": null + }, + { + "name": "circle", + "type": "f32" + }, + { + "name": "polygon", + "type": 4 + } + ] + } + }, + "owner": { + "interface": 0 + } + }, + { + "name": "pair", + "kind": { + "tuple": { + "types": [ + "u8", + "f64" + ] + } + }, + "owner": { + "interface": 0 + } + }, + { + "name": "names", + "kind": { + "list": "string" + }, + "owner": { + "interface": 0 + } + }, + { + "name": "point", + "kind": { + "type": 1 + }, + "owner": { + "interface": 1 + } + }, + { + "name": "color", + "kind": { + "type": 2 + }, + "owner": { + "interface": 1 + } + }, + { + "name": "shape", + "kind": { + "type": 5 + }, + "owner": { + "interface": 1 + } + }, + { + "name": "access", + "kind": { + "type": 3 + }, + "owner": { + "interface": 1 + } + }, + { + "name": "canvas", + "kind": "resource", + "owner": { + "interface": 1 + } + }, + { + "name": null, + "kind": { + "handle": { + "own": 12 + } + }, + "owner": null + }, + { + "name": null, + "kind": { + "result": { + "ok": 13, + "err": "string" + } + }, + "owner": null + }, + { + "name": null, + "kind": { + "handle": { + "borrow": 12 + } + }, + "owner": null + }, + { + "name": "point", + "kind": { + "type": 1 + }, + "owner": { + "interface": 2 + } + }, + { + "name": "canvas", + "kind": { + "type": 12 + }, + "owner": { + "world": 0 + } + }, + { + "name": "shape", + "kind": { + "type": 5 + }, + "owner": { + "world": 0 + } + }, + { + "name": "pair", + "kind": { + "type": 6 + }, + "owner": { + "world": 0 + } + }, + { + "name": null, + "kind": { + "result": { + "ok": null, + "err": "string" + } + }, + "owner": null + }, + { + "name": null, + "kind": { + "handle": { + "own": 17 + } + }, + "owner": null + } + ], + "packages": [ + { + "name": "demo:gen@1.2.0", + "interfaces": { + "types": 0, + "host": 1, + "guest": 2 + }, + "worlds": { + "plugin": 0 + } + } + ] +} \ No newline at end of file diff --git a/tools/testdata/expected/wit.zig b/tools/testdata/expected/wit.zig new file mode 100644 index 0000000..d9a420b --- /dev/null +++ b/tools/testdata/expected/wit.zig @@ -0,0 +1,6 @@ +// Generated by tools/gen.zig, do not edit. + +pub const types = @import("wit/types.zig"); +pub const host = @import("wit/host.zig"); +pub const guest = @import("wit/guest.zig"); +pub const exports = @import("wit/exports.zig"); diff --git a/tools/testdata/expected/wit/exports.zig b/tools/testdata/expected/wit/exports.zig new file mode 100644 index 0000000..4aac016 --- /dev/null +++ b/tools/testdata/expected/wit/exports.zig @@ -0,0 +1,59 @@ +// Generated by tools/gen.zig, do not edit. + +const std = @import("std"); +const abi = @import("../abi.zig"); +const host = @import("host.zig"); +const types = @import("types.zig"); +const guest = @import("guest.zig"); + +pub fn start(comptime impl: fn (host.Canvas) abi.Result(void, []const u8)) void { + const glue = struct { + fn call(p0: i32) callconv(.c) i32 { + const args = abi.liftArgs(std.meta.ArgsTuple(@TypeOf(impl)), .{p0}); + return abi.lowerReturn(abi.Result(void, []const u8), @call(.auto, impl, args)); + } + + fn post(_: i32) callconv(.c) void { + abi.endCall(); + } + }; + @export(&glue.call, .{ .name = "start" }); + @export(&glue.post, .{ .name = "cabi_post_start" }); +} + +pub fn measure(comptime impl: fn (types.Shape, types.Pair) f32) void { + const glue = struct { + fn call(p0: i32, p1: i32, p2: i32, p3: i32, p4: f64) callconv(.c) f32 { + const args = abi.liftArgs(std.meta.ArgsTuple(@TypeOf(impl)), .{ p0, p1, p2, p3, p4 }); + defer abi.endCall(); + return abi.lowerReturn(f32, @call(.auto, impl, args)); + } + }; + @export(&glue.call, .{ .name = "measure" }); +} + +pub fn stop(comptime impl: fn () void) void { + const glue = struct { + fn call() callconv(.c) void { + const args = abi.liftArgs(std.meta.ArgsTuple(@TypeOf(impl)), .{}); + defer abi.endCall(); + return abi.lowerReturn(void, @call(.auto, impl, args)); + } + }; + @export(&glue.call, .{ .name = "stop" }); +} + +pub fn describe(comptime impl: fn () guest.Point) void { + const glue = struct { + fn call() callconv(.c) i32 { + const args = abi.liftArgs(std.meta.ArgsTuple(@TypeOf(impl)), .{}); + return abi.lowerReturn(guest.Point, @call(.auto, impl, args)); + } + + fn post(_: i32) callconv(.c) void { + abi.endCall(); + } + }; + @export(&glue.call, .{ .name = "demo:gen/guest@1.2.0#describe" }); + @export(&glue.post, .{ .name = "cabi_post_demo:gen/guest@1.2.0#describe" }); +} diff --git a/tools/testdata/expected/wit/guest.zig b/tools/testdata/expected/wit/guest.zig new file mode 100644 index 0000000..cef2cee --- /dev/null +++ b/tools/testdata/expected/wit/guest.zig @@ -0,0 +1,5 @@ +// Generated by tools/gen.zig, do not edit. + +const types = @import("types.zig"); + +pub const Point = types.Point; diff --git a/tools/testdata/expected/wit/host.zig b/tools/testdata/expected/wit/host.zig new file mode 100644 index 0000000..cb452cf --- /dev/null +++ b/tools/testdata/expected/wit/host.zig @@ -0,0 +1,69 @@ +// Generated by tools/gen.zig, do not edit. + +const abi = @import("../abi.zig"); +const types = @import("types.zig"); + +pub const Point = types.Point; +pub const Color = types.Color; +pub const Shape = types.Shape; +pub const Access = types.Access; + +pub const Canvas = enum(u32) { + _, + + pub const resource_drop = &raw.@"[resource-drop]canvas"; + + pub fn init(width: u32, height: u32) Canvas { + return abi.call(raw.@"[constructor]canvas", Canvas, .{ width, height }); + } + + /// Opens a canvas stored on disk. + pub fn open(path: []const u8) abi.Result(Canvas, []const u8) { + return abi.call(raw.@"[static]canvas.open", abi.Result(Canvas, []const u8), .{path}); + } + + pub fn draw(self: Canvas, shape: Shape, at: Point, color: Color) void { + return abi.call(raw.@"[method]canvas.draw", void, .{ abi.borrow(self), shape, at, color }); + } + + /// Copies `other` on top of this canvas. + pub fn blend(self: Canvas, other: Canvas, types_: Access) void { + return abi.call(raw.@"[method]canvas.blend", void, .{ abi.borrow(self), abi.borrow(other), types_ }); + } + + pub fn name(self: Canvas) ?[]const u8 { + return abi.call(raw.@"[method]canvas.name", ?[]const u8, .{abi.borrow(self)}); + } + + /// Keeps the handle alive past the current callback. Release it with `deinit`. + pub fn keep(self: Canvas) void { + abi.keep(Canvas, self); + } + + /// Releases the handle now instead of when the callback returns. + pub fn deinit(self: Canvas) void { + abi.drop(Canvas, self); + } +}; + +/// Shows the canvas and closes it. +/// +/// Consumes `canvas`. +pub fn present(canvas: Canvas) u64 { + return abi.call(raw.present, u64, .{canvas}); +} + +pub fn log(message: []const u8) void { + return abi.call(raw.log, void, .{message}); +} + +const raw = struct { + extern "demo:gen/host@1.2.0" fn @"[constructor]canvas"(i32, i32) i32; + extern "demo:gen/host@1.2.0" fn @"[static]canvas.open"(i32, i32, i32) void; + extern "demo:gen/host@1.2.0" fn @"[method]canvas.draw"(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32) void; + extern "demo:gen/host@1.2.0" fn @"[method]canvas.blend"(i32, i32, i32) void; + extern "demo:gen/host@1.2.0" fn @"[method]canvas.name"(i32, i32) void; + extern "demo:gen/host@1.2.0" fn present(i32) i64; + extern "demo:gen/host@1.2.0" fn log(i32, i32) void; + extern "demo:gen/host@1.2.0" fn @"[resource-drop]canvas"(i32) void; +}; diff --git a/tools/testdata/expected/wit/types.zig b/tools/testdata/expected/wit/types.zig new file mode 100644 index 0000000..b6225a7 --- /dev/null +++ b/tools/testdata/expected/wit/types.zig @@ -0,0 +1,32 @@ +// Generated by tools/gen.zig, do not edit. + +/// Where something is. +pub const Point = struct { + x: i32, + y: i32, + /// Optional label. + label: ?[]const u8, +}; + +pub const Color = enum(u8) { + red, + green, + blue, +}; + +pub const Access = packed struct(u8) { + read: bool = false, + write: bool = false, + exec: bool = false, + _: u5 = 0, +}; + +pub const Shape = union(enum) { + nothing, + circle: f32, + polygon: []const Point, +}; + +pub const Pair = struct { u8, f64 }; + +pub const Names = []const []const u8; diff --git a/tools/testdata/wit/demo.wit b/tools/testdata/wit/demo.wit new file mode 100644 index 0000000..3a138ec --- /dev/null +++ b/tools/testdata/wit/demo.wit @@ -0,0 +1,60 @@ +package demo:gen@1.2.0; + +interface types { + /// Where something is. + record point { + x: s32, + y: s32, + /// Optional label. + label: option, + } + + enum color { red, green, blue } + + flags access { read, write, exec } + + variant shape { + nothing, + circle(f32), + polygon(list), + } + + type pair = tuple; + type names = list; +} + +interface host { + use types.{point, color, shape, access}; + + resource canvas { + constructor(width: u32, height: u32); + /// Opens a canvas stored on disk. + open: static func(path: string) -> result; + draw: func(shape: shape, at: point, color: color); + /// Copies `other` on top of this canvas. + blend: func(other: borrow, types: access); + name: func() -> option; + } + + /// Shows the canvas and closes it. + present: func(canvas: canvas) -> u64; + log: func(message: string); +} + +interface guest { + use types.{point}; + + describe: func() -> point; +} + +world plugin { + use host.{canvas}; + use types.{shape, pair}; + + import host; + + export guest; + export start: func(canvas: canvas) -> result<_, string>; + export measure: func(shape: shape, scale: pair) -> f32; + export stop: func(); +} diff --git a/wit b/wit new file mode 160000 index 0000000..2366bb9 --- /dev/null +++ b/wit @@ -0,0 +1 @@ +Subproject commit 2366bb9edb3d9a093e3f579c3dac541eba70e6d7