├── .gitattributes ├── .github └── workflows │ └── go.yml ├── .gitignore ├── LICENSE ├── README.md ├── config.toml ├── go.mod ├── go.sum ├── gophertunnel_telescope_coloured.png ├── main.go ├── minecraft ├── auth │ ├── doc.go │ ├── live.go │ ├── minecraft.go │ └── xbox.go ├── conn.go ├── dial.go ├── doc.go ├── err.go ├── example_dial_test.go ├── example_listener_test.go ├── game_data.go ├── internal │ ├── log.go │ └── pool.go ├── listener.go ├── nbt │ ├── decode.go │ ├── doc.go │ ├── dump.go │ ├── encode.go │ ├── encoding.go │ ├── encoding_big_endian.go │ ├── encoding_little_endian.go │ ├── err.go │ ├── reader.go │ ├── tag.go │ └── writer.go ├── network.go ├── packet.go ├── protocol.go ├── protocol │ ├── ability.go │ ├── attribute.go │ ├── biome.go │ ├── bitset.go │ ├── blob_cache.go │ ├── block.go │ ├── block_pos.go │ ├── camera.go │ ├── chunk_pos.go │ ├── command.go │ ├── container.go │ ├── creative.go │ ├── doc.go │ ├── education.go │ ├── enchant.go │ ├── entity_link.go │ ├── entity_metadata.go │ ├── entity_properties.go │ ├── events.go │ ├── experiments.go │ ├── game_rule.go │ ├── info.go │ ├── inventory.go │ ├── io.go │ ├── item.go │ ├── item_descriptor.go │ ├── item_stack.go │ ├── login │ │ ├── data.go │ │ ├── doc.go │ │ └── request.go │ ├── map.go │ ├── os.go │ ├── packet │ │ ├── actor_event.go │ │ ├── actor_pick_request.go │ │ ├── add_actor.go │ │ ├── add_behaviour_tree.go │ │ ├── add_item_actor.go │ │ ├── add_painting.go │ │ ├── add_player.go │ │ ├── add_volume_entity.go │ │ ├── adventure_settings.go │ │ ├── agent_action.go │ │ ├── agent_animation.go │ │ ├── animate.go │ │ ├── animate_entity.go │ │ ├── anvil_damage.go │ │ ├── automation_client_connect.go │ │ ├── available_actor_identifiers.go │ │ ├── available_commands.go │ │ ├── award_achievement.go │ │ ├── biome_definition_list.go │ │ ├── block_actor_data.go │ │ ├── block_event.go │ │ ├── block_pick_request.go │ │ ├── book_edit.go │ │ ├── boss_event.go │ │ ├── camera.go │ │ ├── camera_aim_assist.go │ │ ├── camera_aim_assist_presets.go │ │ ├── camera_instruction.go │ │ ├── camera_presets.go │ │ ├── camera_shake.go │ │ ├── change_dimension.go │ │ ├── change_mob_property.go │ │ ├── chunk_radius_updated.go │ │ ├── client_bound_close_form.go │ │ ├── client_bound_control_scheme_set.go │ │ ├── client_bound_debug_renderer.go │ │ ├── client_bound_map_item_data.go │ │ ├── client_cache_blob_status.go │ │ ├── client_cache_miss_response.go │ │ ├── client_cache_status.go │ │ ├── client_camera_aim_assist.go │ │ ├── client_cheat_ability.go │ │ ├── client_movement_prediction_sync.go │ │ ├── client_start_item_cooldown.go │ │ ├── client_to_server_handshake.go │ │ ├── code_builder.go │ │ ├── code_builder_source.go │ │ ├── command_block_update.go │ │ ├── command_output.go │ │ ├── command_request.go │ │ ├── completed_using_item.go │ │ ├── compression.go │ │ ├── container_close.go │ │ ├── container_open.go │ │ ├── container_registry_cleanup.go │ │ ├── container_set_data.go │ │ ├── correct_player_move_prediction.go │ │ ├── crafting_data.go │ │ ├── create_photo.go │ │ ├── creative_content.go │ │ ├── current_structure_feature.go │ │ ├── death_info.go │ │ ├── debug_info.go │ │ ├── decoder.go │ │ ├── dimension_data.go │ │ ├── disconnect.go │ │ ├── doc.go │ │ ├── editor_network.go │ │ ├── education_resource_uri.go │ │ ├── education_settings.go │ │ ├── emote.go │ │ ├── emote_list.go │ │ ├── encoder.go │ │ ├── encryption.go │ │ ├── event.go │ │ ├── feature_registry.go │ │ ├── filter_text.go │ │ ├── game_rules_changed.go │ │ ├── game_test_request.go │ │ ├── game_test_results.go │ │ ├── gui_data_pick_item.go │ │ ├── hurt_armour.go │ │ ├── id.go │ │ ├── interact.go │ │ ├── inventory_content.go │ │ ├── inventory_slot.go │ │ ├── inventory_transaction.go │ │ ├── item_registry.go │ │ ├── item_stack_request.go │ │ ├── item_stack_response.go │ │ ├── jigsaw_structure_data.go │ │ ├── lab_table.go │ │ ├── lectern_update.go │ │ ├── lesson_progress.go │ │ ├── level_chunk.go │ │ ├── level_event.go │ │ ├── level_event_generic.go │ │ ├── level_sound_event.go │ │ ├── login.go │ │ ├── map_create_locked_copy.go │ │ ├── map_info_request.go │ │ ├── mob_armour_equipment.go │ │ ├── mob_effect.go │ │ ├── mob_equipment.go │ │ ├── modal_form_request.go │ │ ├── modal_form_response.go │ │ ├── motion_prediction_hints.go │ │ ├── move_actor_absolute.go │ │ ├── move_actor_delta.go │ │ ├── move_player.go │ │ ├── movement_effect.go │ │ ├── multi_player_settings.go │ │ ├── network_chunk_publisher_update.go │ │ ├── network_settings.go │ │ ├── network_stack_latency.go │ │ ├── npc_dialogue.go │ │ ├── npc_request.go │ │ ├── on_screen_texture_animation.go │ │ ├── open_sign.go │ │ ├── packet.go │ │ ├── packet_violation_warning.go │ │ ├── photo_info_request.go │ │ ├── photo_transfer.go │ │ ├── play_sound.go │ │ ├── play_status.go │ │ ├── player_action.go │ │ ├── player_armour_damage.go │ │ ├── player_auth_input.go │ │ ├── player_enchant_options.go │ │ ├── player_fog.go │ │ ├── player_hot_bar.go │ │ ├── player_list.go │ │ ├── player_location.go │ │ ├── player_skin.go │ │ ├── player_toggle_crafter_slot_request.go │ │ ├── player_update_entity_overrides.go │ │ ├── player_video_capture.go │ │ ├── pool.go │ │ ├── position_tracking_db_client_request.go │ │ ├── position_tracking_db_server_broadcast.go │ │ ├── purchase_receipt.go │ │ ├── refresh_entitlements.go │ │ ├── remove_actor.go │ │ ├── remove_objective.go │ │ ├── remove_volume_entity.go │ │ ├── request_ability.go │ │ ├── request_chunk_radius.go │ │ ├── request_network_settings.go │ │ ├── request_permissions.go │ │ ├── resource_pack_chunk_data.go │ │ ├── resource_pack_chunk_request.go │ │ ├── resource_pack_client_response.go │ │ ├── resource_pack_data_info.go │ │ ├── resource_pack_stack.go │ │ ├── resource_packs_info.go │ │ ├── respawn.go │ │ ├── script_custom_event.go │ │ ├── script_message.go │ │ ├── server_bound_diagnostics.go │ │ ├── server_bound_loading_screen.go │ │ ├── server_settings_request.go │ │ ├── server_settings_response.go │ │ ├── server_stats.go │ │ ├── server_to_client_handshake.go │ │ ├── set_actor_data.go │ │ ├── set_actor_link.go │ │ ├── set_actor_motion.go │ │ ├── set_commands_enabled.go │ │ ├── set_default_game_type.go │ │ ├── set_difficulty.go │ │ ├── set_display_objective.go │ │ ├── set_health.go │ │ ├── set_hud.go │ │ ├── set_last_hurt_by.go │ │ ├── set_local_player_as_initialised.go │ │ ├── set_movement_authority.go │ │ ├── set_player_game_type.go │ │ ├── set_player_inventory_options.go │ │ ├── set_score.go │ │ ├── set_scoreboard_identity.go │ │ ├── set_spawn_position.go │ │ ├── set_time.go │ │ ├── set_title.go │ │ ├── settings_command.go │ │ ├── show_credits.go │ │ ├── show_profile.go │ │ ├── show_store_offer.go │ │ ├── simple_event.go │ │ ├── simulation_type.go │ │ ├── spawn_experience_orb.go │ │ ├── spawn_particle_effect.go │ │ ├── start_game.go │ │ ├── stop_sound.go │ │ ├── structure_block_update.go │ │ ├── structure_template_data_request.go │ │ ├── structure_template_data_response.go │ │ ├── sub_chunk.go │ │ ├── sub_chunk_request.go │ │ ├── sub_client_login.go │ │ ├── sync_actor_property.go │ │ ├── take_item_actor.go │ │ ├── text.go │ │ ├── ticking_areas_load_status.go │ │ ├── toast_request.go │ │ ├── transfer.go │ │ ├── trim_data.go │ │ ├── unknown.go │ │ ├── unlocked_recipes.go │ │ ├── update_abilities.go │ │ ├── update_adventure_settings.go │ │ ├── update_attributes.go │ │ ├── update_block.go │ │ ├── update_block_synced.go │ │ ├── update_client_input_locks.go │ │ ├── update_client_options.go │ │ ├── update_equip.go │ │ ├── update_player_game_type.go │ │ ├── update_soft_enum.go │ │ ├── update_sub_chunk_blocks.go │ │ └── update_trade.go │ ├── player.go │ ├── reader.go │ ├── reader_big_endian.go │ ├── reader_little_endian.go │ ├── recipe.go │ ├── resource_pack.go │ ├── scoreboard.go │ ├── skin.go │ ├── structure.go │ ├── sub_chunk.go │ ├── trim.go │ ├── varint.go │ ├── world.go │ ├── writer.go │ ├── writer_big_endian.go │ └── writer_little_endian.go ├── raknet.go ├── realms │ └── realms.go ├── resource │ ├── doc.go │ ├── manifest.go │ └── pack.go ├── resource_pack_queue.go ├── server_status_provider.go ├── skin_geometry.json ├── skin_resource_patch.json └── text │ ├── colour.go │ ├── doc.go │ └── map.go ├── query ├── doc.go ├── packet.go └── query.go └── staticcheck.conf /.gitattributes: -------------------------------------------------------------------------------- 1 | go.mod text eol=lf -------------------------------------------------------------------------------- /.github/workflows/go.yml: -------------------------------------------------------------------------------- 1 | name: Go 2 | on: [push, pull_request] 3 | jobs: 4 | 5 | build: 6 | name: Build 7 | runs-on: ubuntu-latest 8 | steps: 9 | 10 | - name: Set up Go 1.22 11 | uses: actions/setup-go@v1 12 | with: 13 | go-version: 1.22 14 | id: go 15 | 16 | - name: Check out code into the Go module directory 17 | uses: actions/checkout@v1 18 | 19 | - name: Get dependencies 20 | run: | 21 | mkdir -p $GOPATH/bin 22 | export PATH=$PATH:$GOPATH/bin 23 | 24 | - name: Vet 25 | run: go vet ./... 26 | 27 | - name: Staticcheck 28 | run: | 29 | go get honnef.co/go/tools/cmd/staticcheck 30 | GOBIN=$PWD/bin go install honnef.co/go/tools/cmd/staticcheck 31 | ./bin/staticcheck ./... 32 | 33 | - name: Build 34 | run: go build -o gophertunnel_exe -v . 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | config.toml 2 | # Created by .ignore support plugin (hsz.mobi) 3 | ### Go template 4 | # Binaries for programs and plugins 5 | *.exe 6 | *.exe~ 7 | *.dll 8 | *.so 9 | *.dylib 10 | 11 | # Test binary, build with `go test -c` 12 | *.test 13 | 14 | # Output of the go coverage tool, specifically when used with LiteIDE 15 | *.out 16 | ### JetBrains template 17 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 18 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 19 | 20 | .idea 21 | 22 | # User-specific stuff 23 | .idea/**/workspace.xml 24 | .idea/**/tasks.xml 25 | .idea/**/dictionaries 26 | .idea/**/shelf 27 | 28 | # Sensitive or high-churn files 29 | .idea/**/dataSources/ 30 | .idea/**/dataSources.ids 31 | .idea/**/dataSources.local.xml 32 | .idea/**/sqlDataSources.xml 33 | .idea/**/dynamic.xml 34 | .idea/**/uiDesigner.xml 35 | .idea/**/dbnavigator.xml 36 | 37 | # Gradle 38 | .idea/**/gradle.xml 39 | .idea/**/libraries 40 | 41 | # CMake 42 | cmake-build-debug/ 43 | cmake-build-release/ 44 | 45 | # Mongo Explorer plugin 46 | .idea/**/mongoSettings.xml 47 | 48 | # File-based project format 49 | *.iws 50 | 51 | # IntelliJ 52 | out/ 53 | 54 | # mpeltonen/sbt-idea plugin 55 | .idea_modules/ 56 | 57 | # JIRA plugin 58 | atlassian-ide-plugin.xml 59 | 60 | # Cursive Clojure plugin 61 | .idea/replstate.xml 62 | 63 | # Crashlytics plugin (for Android Studio and IntelliJ) 64 | com_crashlytics_export_strings.xml 65 | crashlytics.properties 66 | crashlytics-build.properties 67 | fabric.properties 68 | 69 | # Editor-based Rest Client 70 | .idea/httpRequests 71 | 72 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Sandertv 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gophertunnel 2 | > Swiss army knife for Minecraft (Bedrock Edition) software written in Go 3 | 4 | [![PkgGoDev](https://pkg.go.dev/badge/github.com/sandertv/gophertunnel)](https://pkg.go.dev/github.com/sandertv/gophertunnel) 5 | 6 | ![telescope gopher](https://raw.githubusercontent.com/Sandertv/gophertunnel/master/gophertunnel_telescope_coloured.png) 7 | 8 | ## Overview 9 | 10 | gophertunnel is composed of several packages that may be of use for creating Minecraft related tools. 11 | As of version v1.38.0, Gophertunnel requires at least Go 1.22. 12 | A brief overview of all packages may be found [here](https://pkg.go.dev/mod/github.com/sandertv/gophertunnel?tab=packages). 13 | 14 | ## Examples 15 | Examples on how to dial a connection or start a server can be found in the [minecraft package](https://github.com/Sandertv/gophertunnel/tree/master/minecraft). 16 | Additionally, a MITM proxy is implemented in the [main.go file](https://github.com/Sandertv/gophertunnel/blob/master/main.go). 17 | 18 | ## Versions 19 | Gophertunnel supports only one version at a time (generally the latest official Minecraft release), but multiple protocols can be supported with the API. Generally, a new 20 | minor version is tagged when gophertunnel supports a new Minecraft version that was not previously supported. 21 | 22 | ## Contact 23 | [![Chat on Discord](https://img.shields.io/badge/Chat-On%20Discord-738BD7.svg?style=for-the-badge)](https://discord.com/invite/U4kFWHhTNR) 24 | 25 | ### Note: We do not under any circumstance support or endorse the usage of gophertunnel with malicious intent. 26 | -------------------------------------------------------------------------------- /config.toml: -------------------------------------------------------------------------------- 1 | 2 | [Connection] 3 | LocalAddress = "0.0.0.0:19132" 4 | RemoteAddress = "" 5 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/sandertv/gophertunnel 2 | 3 | go 1.22 4 | 5 | toolchain go1.22.1 6 | 7 | require ( 8 | github.com/go-gl/mathgl v1.1.0 9 | github.com/go-jose/go-jose/v4 v4.0.4 10 | github.com/golang/snappy v0.0.4 11 | github.com/google/uuid v1.6.0 12 | github.com/klauspost/compress v1.17.11 13 | github.com/muhammadmuzzammil1998/jsonc v1.0.0 14 | github.com/pelletier/go-toml v1.9.5 15 | github.com/sandertv/go-raknet v1.14.3-0.20250305181847-6af3e95113d6 16 | golang.org/x/net v0.35.0 17 | golang.org/x/oauth2 v0.23.0 18 | golang.org/x/text v0.22.0 19 | ) 20 | 21 | require ( 22 | golang.org/x/crypto v0.33.0 // indirect 23 | golang.org/x/image v0.21.0 // indirect 24 | ) 25 | -------------------------------------------------------------------------------- /gophertunnel_telescope_coloured.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sandertv/gophertunnel/5a48e0410a47b521d8d7e583a365622a9890432f/gophertunnel_telescope_coloured.png -------------------------------------------------------------------------------- /minecraft/auth/doc.go: -------------------------------------------------------------------------------- 1 | // Package auth implements authentication to Microsoft Live Connect accounts, XBOX Live accounts and 2 | // ultimately Minecraft accounts associated with them. Microsoft Live Connect auth is performed using device 3 | // auth. 4 | // 5 | // The auth package provides token sources for Microsoft Live Connect auth with an oauth2-style interface, 6 | // with token sources that may be plugged into services directly. 7 | package auth 8 | -------------------------------------------------------------------------------- /minecraft/doc.go: -------------------------------------------------------------------------------- 1 | // Package minecraft implements Minecraft Bedrock Edition connections. It implements a Dial() function to dial 2 | // a connection to a Minecraft server and a Listen() function to create a listener in order to listen for 3 | // incoming Minecraft connections. Typically these connections are done over RakNet, which is implemented by 4 | // the github.com/sandertv/go-raknet package. 5 | // 6 | // The minecraft package provides a high level abstraction over Minecraft network related features. It handles 7 | // the authentication, encryption and spawning sequence by itself and users can send and read packets 8 | // implemented in the minecraft/protocol/packet package. 9 | package minecraft 10 | -------------------------------------------------------------------------------- /minecraft/err.go: -------------------------------------------------------------------------------- 1 | package minecraft 2 | 3 | import ( 4 | "errors" 5 | "net" 6 | ) 7 | 8 | var errBufferTooSmall = errors.New("a message sent was larger than the buffer used to receive the message into") 9 | 10 | // wrap wraps the error passed into a net.OpError with the op as operation and returns it, or nil if the error 11 | // passed is nil. 12 | func (conn *Conn) wrap(err error, op string) error { 13 | if err == nil { 14 | return nil 15 | } 16 | return &net.OpError{ 17 | Op: op, 18 | Net: "minecraft", 19 | Source: conn.LocalAddr(), 20 | Addr: conn.RemoteAddr(), 21 | Err: err, 22 | } 23 | } 24 | 25 | // DisconnectError is an error returned by operations from Conn when the connection is closed by the other 26 | // end through a packet.Disconnect. It is wrapped in a net.OpError and may be obtained using 27 | // errors.Unwrap(net.OpError). 28 | type DisconnectError string 29 | 30 | // Error returns the message held in the packet.Disconnect. 31 | func (d DisconnectError) Error() string { 32 | return string(d) 33 | } 34 | -------------------------------------------------------------------------------- /minecraft/internal/log.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "context" 5 | "log/slog" 6 | ) 7 | 8 | // DiscardHandler implements a slog.Handler that is always disabled. Each of its 9 | // methods return immediately without any code running. 10 | type DiscardHandler struct{} 11 | 12 | func (d DiscardHandler) Enabled(context.Context, slog.Level) bool { return false } 13 | func (d DiscardHandler) Handle(context.Context, slog.Record) error { return nil } 14 | func (d DiscardHandler) WithAttrs([]slog.Attr) slog.Handler { return d } 15 | func (d DiscardHandler) WithGroup(string) slog.Handler { return d } 16 | -------------------------------------------------------------------------------- /minecraft/internal/pool.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "bytes" 5 | "sync" 6 | ) 7 | 8 | // BufferPool is a sync.Pool for buffers used to write compressed data to. 9 | var BufferPool = sync.Pool{ 10 | New: func() any { 11 | return bytes.NewBuffer(make([]byte, 0, 256)) 12 | }, 13 | } 14 | -------------------------------------------------------------------------------- /minecraft/nbt/doc.go: -------------------------------------------------------------------------------- 1 | // Package nbt implements the NBT formats used by Minecraft Bedrock Edition and Minecraft Java Edition. These 2 | // formats are a little endian format, a big endian format and a little endian format using varints (typically 3 | // used over network in Bedrock Edition). 4 | // 5 | // The package exposes serialisation and deserialisation roughly the same way as the JSON standard library 6 | // does, using nbt.Marshal() and nbt.Unmarshal when working with byte slices, and nbt.NewEncoder() and 7 | // nbt.NewDecoder() when working with readers or writers. 8 | // 9 | // The package encodes and decodes the following Go types with the following NBT tags. 10 | // byte/uint8: TAG_Byte 11 | // bool: TAG_Byte 12 | // int16: TAG_Short 13 | // int32: TAG_Int 14 | // int64: TAG_Long 15 | // float32: TAG_Float 16 | // float64: TAG_Double 17 | // [...]byte: TAG_ByteArray 18 | // [...]int32: TAG_IntArray 19 | // [...]int64: TAG_LongArray 20 | // string: TAG_String 21 | // []: TAG_List 22 | // struct{...}: TAG_Compound 23 | // map[string]: TAG_Compound 24 | // 25 | // Structures decoded or encoded may have struct field tags in a comparable way to the JSON standard library. 26 | // The 'nbt' struct tag may be filled out the following ways: 27 | // '-': Ignores the field completely when encoding and decoding. 28 | // ',omitempty': Doesn't encode the field if its value is the same as the default value. 29 | // 'name(,omitempty)': Encodes/decodes the field with a different name than its usual name. 30 | // If no 'nbt' struct tag is present for a field, the name of the field will be used to encode/decode the 31 | // struct. Note that this package, unlike the JSON standard library package, is case sensitive when decoding. 32 | package nbt 33 | -------------------------------------------------------------------------------- /minecraft/nbt/writer.go: -------------------------------------------------------------------------------- 1 | package nbt 2 | 3 | import "io" 4 | 5 | // offsetWriter is a wrapper around an io.Writer which keeps track of the amount of bytes written, so that it 6 | // may be used in errors. 7 | type offsetWriter struct { 8 | io.Writer 9 | off int64 10 | 11 | // WriteByte is a function implemented by offsetWriter if the io.Writer does not implement it itself. 12 | WriteByte func(byte) error 13 | } 14 | 15 | // Write writes a byte slice to the underlying io.Writer. It increases the byte offset by exactly n. 16 | func (w *offsetWriter) Write(b []byte) (n int, err error) { 17 | n, err = w.Writer.Write(b) 18 | w.off += int64(n) 19 | return 20 | } 21 | -------------------------------------------------------------------------------- /minecraft/protocol/bitset.go: -------------------------------------------------------------------------------- 1 | package protocol 2 | 3 | import "math/big" 4 | 5 | // Bitset is a representation of std::bitset being sent over the network, allowing for more than 64 bits 6 | // to be stored in a single integer. A Bitset has a fixed size, which is set at creation time. 7 | type Bitset struct { 8 | size int 9 | int *big.Int 10 | } 11 | 12 | // NewBitset creates a new Bitset with a specific size. The size is the amount of bits that the Bitset can 13 | // store. Attempting to set a bit at an index higher than the size will panic. 14 | func NewBitset(size int) Bitset { 15 | return Bitset{size: size, int: new(big.Int)} 16 | } 17 | 18 | // Set sets a bit at a specific index in the Bitset. If the index is higher than the size of the Bitset, a 19 | // panic will occur. 20 | func (b Bitset) Set(i int) { 21 | if i >= b.size { 22 | panic("index out of bounds") 23 | } 24 | b.int.SetBit(b.int, i, 1) 25 | } 26 | 27 | // Unset unsets a bit at a specific index in the Bitset. If the index is higher than the size of the Bitset, 28 | // a panic will occur. 29 | func (b Bitset) Unset(i int) { 30 | if i >= b.size { 31 | panic("index out of bounds") 32 | } 33 | b.int.SetBit(b.int, i, 0) 34 | } 35 | 36 | // Load returns if a bit at a specific index in the Bitset is set. If the index is higher than the size of the 37 | // Bitset, a panic will occur. 38 | func (b Bitset) Load(i int) bool { 39 | if i >= b.size { 40 | panic("index out of bounds") 41 | } 42 | return b.int.Bit(i) == 1 43 | } 44 | 45 | // Len returns the size of the Bitset. 46 | func (b Bitset) Len() int { 47 | return b.size 48 | } -------------------------------------------------------------------------------- /minecraft/protocol/blob_cache.go: -------------------------------------------------------------------------------- 1 | package protocol 2 | 3 | // CacheBlob represents a blob as used in the client side blob cache protocol. It holds a hash of its data and 4 | // the full data of it. 5 | type CacheBlob struct { 6 | // Hash is the hash of the blob. The hash is computed using xxHash, and must be deterministic for the same 7 | // chunk data. 8 | Hash uint64 9 | // Payload is the data of the blob. When sent, the client will associate the Hash of the blob with the 10 | // Payload in it. 11 | Payload []byte 12 | } 13 | 14 | // Marshal encodes/decodes a CacheBlob. 15 | func (x *CacheBlob) Marshal(r IO) { 16 | r.Uint64(&x.Hash) 17 | r.ByteSlice(&x.Payload) 18 | } 19 | -------------------------------------------------------------------------------- /minecraft/protocol/block_pos.go: -------------------------------------------------------------------------------- 1 | package protocol 2 | 3 | // BlockPos is the position of a block. It is composed of three integers, and is typically written as either 4 | // 3 varint32s or a varint32, varuint32 and varint32. 5 | type BlockPos [3]int32 6 | 7 | // X returns the X coordinate of the block position. It is equivalent to BlockPos[0]. 8 | func (pos BlockPos) X() int32 { 9 | return pos[0] 10 | } 11 | 12 | // Y returns the Y coordinate of the block position. It is equivalent to BlockPos[1]. 13 | func (pos BlockPos) Y() int32 { 14 | return pos[1] 15 | } 16 | 17 | // Z returns the Z coordinate of the block position. It is equivalent to BlockPos[2]. 18 | func (pos BlockPos) Z() int32 { 19 | return pos[2] 20 | } 21 | -------------------------------------------------------------------------------- /minecraft/protocol/chunk_pos.go: -------------------------------------------------------------------------------- 1 | package protocol 2 | 3 | // ChunkPos is the position of a chunk. It is composed of two integers and is written as two varint32s. 4 | type ChunkPos [2]int32 5 | 6 | // X returns the X coordinate of the chunk position. It is equivalent to ChunkPos[0]. 7 | func (pos ChunkPos) X() int32 { 8 | return pos[0] 9 | } 10 | 11 | // Z returns the Z coordinate of the chunk position. It is equivalent to ChunkPos[1]. 12 | func (pos ChunkPos) Z() int32 { 13 | return pos[1] 14 | } 15 | 16 | // SubChunkPos is the position of a sub-chunk. The X and Z coordinates are the coordinates of the chunk, and the Y 17 | // coordinate is the absolute sub-chunk index. 18 | type SubChunkPos [3]int32 19 | 20 | // X returns the X coordinate of the sub-chunk position. It is equivalent to SubChunkPos[0]. 21 | func (pos SubChunkPos) X() int32 { 22 | return pos[0] 23 | } 24 | 25 | // Y returns the Y coordinate of the sub-chunk position. It is equivalent to SubChunkPos[1]. 26 | func (pos SubChunkPos) Y() int32 { 27 | return pos[1] 28 | } 29 | 30 | // Z returns the Z coordinate of the sub-chunk position. It is equivalent to SubChunkPos[2]. 31 | func (pos SubChunkPos) Z() int32 { 32 | return pos[2] 33 | } 34 | -------------------------------------------------------------------------------- /minecraft/protocol/doc.go: -------------------------------------------------------------------------------- 1 | // Package protocol implements structures and functions used to write or read data related to the Minecraft 2 | // Bedrock Edition protocol. The functions present in this package are generally used in the 3 | // minecraft/protocol/packet library, where the encoding and decoding of packets may be found. 4 | package protocol 5 | -------------------------------------------------------------------------------- /minecraft/protocol/education.go: -------------------------------------------------------------------------------- 1 | package protocol 2 | 3 | // EducationSharedResourceURI is an education edition feature that is used for transmitting 4 | // education resource settings to clients. It contains a button name and a link URL. 5 | type EducationSharedResourceURI struct { 6 | // ButtonName is the button name of the resource URI. 7 | ButtonName string 8 | // LinkURI is the link URI for the resource URI. 9 | LinkURI string 10 | } 11 | 12 | // Marshal reads/writes an EducationSharedResourceURI to an IO. 13 | func (x *EducationSharedResourceURI) Marshal(r IO) { 14 | r.String(&x.ButtonName) 15 | r.String(&x.LinkURI) 16 | } 17 | 18 | // EducationExternalLinkSettings ... 19 | type EducationExternalLinkSettings struct { 20 | // URL is the external link URL. 21 | URL string 22 | // DisplayName is the display name in game. 23 | DisplayName string 24 | } 25 | 26 | // Marshal encodes/decodes an EducationExternalLinkSettings. 27 | func (x *EducationExternalLinkSettings) Marshal(r IO) { 28 | r.String(&x.URL) 29 | r.String(&x.DisplayName) 30 | } 31 | -------------------------------------------------------------------------------- /minecraft/protocol/entity_properties.go: -------------------------------------------------------------------------------- 1 | package protocol 2 | 3 | // EntityProperties holds lists of entity properties that define specific attributes of an entity. As of v1.19.40, the 4 | // vanilla server does not use these properties, however they are still supported by the protocol. 5 | type EntityProperties struct { 6 | // IntegerProperties is a list of entity properties that contain integer values. 7 | IntegerProperties []IntegerEntityProperty 8 | // FloatProperties is a list of entity properties that contain float values. 9 | FloatProperties []FloatEntityProperty 10 | } 11 | 12 | // Marshal ... 13 | func (e *EntityProperties) Marshal(r IO) { 14 | Slice(r, &e.IntegerProperties) 15 | Slice(r, &e.FloatProperties) 16 | } 17 | 18 | // IntegerEntityProperty is an entity property that contains an integer value. 19 | type IntegerEntityProperty struct { 20 | // Index represents the index of the property. It is unclear what the exact purpose of this is. 21 | Index uint32 22 | // Value is the value of the property. 23 | Value int32 24 | } 25 | 26 | // Marshal ... 27 | func (i *IntegerEntityProperty) Marshal(r IO) { 28 | r.Varuint32(&i.Index) 29 | r.Varint32(&i.Value) 30 | } 31 | 32 | // FloatEntityProperty is an entity property that contains a float value. 33 | type FloatEntityProperty struct { 34 | // Index represents the index of the property. It is unclear what the exact purpose of this is. 35 | Index uint32 36 | // Value is the value of the property. 37 | Value float32 38 | } 39 | 40 | // Marshal ... 41 | func (f *FloatEntityProperty) Marshal(r IO) { 42 | r.Varuint32(&f.Index) 43 | r.Float32(&f.Value) 44 | } 45 | -------------------------------------------------------------------------------- /minecraft/protocol/experiments.go: -------------------------------------------------------------------------------- 1 | package protocol 2 | 3 | // ExperimentData holds data on an experiment that is either enabled or disabled. 4 | type ExperimentData struct { 5 | // Name is the name of the experiment. 6 | Name string 7 | // Enabled specifies if the experiment is enabled. Vanilla typically always sets this to true for any 8 | // experiments sent. 9 | Enabled bool 10 | } 11 | 12 | // Marshal encodes/decodes an ExperimentData. 13 | func (x *ExperimentData) Marshal(r IO) { 14 | r.String(&x.Name) 15 | r.Bool(&x.Enabled) 16 | } 17 | -------------------------------------------------------------------------------- /minecraft/protocol/game_rule.go: -------------------------------------------------------------------------------- 1 | package protocol 2 | 3 | // GameRule contains game rule data. 4 | type GameRule struct { 5 | // Name is the name of the game rule. 6 | Name string 7 | // CanBeModifiedByPlayer specifies if the game rule can be modified by the player through the in-game UI. 8 | CanBeModifiedByPlayer bool 9 | // Value is the new value of the game rule. This is either a bool, uint32 or float32. 10 | Value any 11 | } 12 | -------------------------------------------------------------------------------- /minecraft/protocol/info.go: -------------------------------------------------------------------------------- 1 | package protocol 2 | 3 | const ( 4 | // CurrentProtocol is the current protocol version for the version below. 5 | CurrentProtocol = 800 6 | // CurrentVersion is the current version of Minecraft as supported by the `packet` package. 7 | CurrentVersion = "1.21.80" 8 | ) 9 | -------------------------------------------------------------------------------- /minecraft/protocol/login/doc.go: -------------------------------------------------------------------------------- 1 | // Package login provides functions to decode and encode Minecraft login requests found in the Login packet 2 | // connection request. The JWT chain found in this connection request may also be verified using this 3 | // package. 4 | package login 5 | -------------------------------------------------------------------------------- /minecraft/protocol/os.go: -------------------------------------------------------------------------------- 1 | package protocol 2 | 3 | // DeviceOS is a device DeviceOS identifier. It holds a value of one of the constants below and may be found 4 | // in packets such as the Login packet. 5 | type DeviceOS int 6 | 7 | const ( 8 | DeviceAndroid DeviceOS = iota + 1 9 | DeviceIOS 10 | DeviceOSX 11 | DeviceFireOS 12 | // Deprecated: DeviceGearVR is deprecated as of 1.21.50. 13 | DeviceGearVR 14 | DeviceHololens 15 | DeviceWin10 16 | DeviceWin32 17 | DeviceDedicated 18 | // Deprecated: DeviceTVOS is deprecated as of 1.20.10. 19 | DeviceTVOS 20 | DeviceOrbis // PlayStation 21 | DeviceNX 22 | DeviceXBOX 23 | // Deprecated: DeviceWP is deprecated as of 1.20.10. 24 | DeviceWP // Windows Phone 25 | DeviceLinux 26 | ) 27 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/actor_pick_request.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // ActorPickRequest is sent by the client when it tries to pick an entity, so that it gets a spawn egg which 8 | // can spawn that entity. 9 | type ActorPickRequest struct { 10 | // EntityUniqueID is the unique ID of the entity that was attempted to be picked. The server must find the 11 | // type of that entity and provide the correct spawn egg to the player. 12 | EntityUniqueID int64 13 | // HotBarSlot is the held hot bar slot of the player at the time of trying to pick the entity. If empty, 14 | // the resulting spawn egg should be put into this slot. 15 | HotBarSlot byte 16 | // WithData is true if the pick request requests the entity metadata. 17 | WithData bool 18 | } 19 | 20 | // ID ... 21 | func (*ActorPickRequest) ID() uint32 { 22 | return IDActorPickRequest 23 | } 24 | 25 | func (pk *ActorPickRequest) Marshal(io protocol.IO) { 26 | io.Int64(&pk.EntityUniqueID) 27 | io.Uint8(&pk.HotBarSlot) 28 | io.Bool(&pk.WithData) 29 | } 30 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/add_behaviour_tree.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // AddBehaviourTree is sent by the server to the client. The packet is currently unused by both client and 8 | // server. 9 | type AddBehaviourTree struct { 10 | // BehaviourTree is an unused string. 11 | BehaviourTree string 12 | } 13 | 14 | // ID ... 15 | func (*AddBehaviourTree) ID() uint32 { 16 | return IDAddBehaviourTree 17 | } 18 | 19 | func (pk *AddBehaviourTree) Marshal(io protocol.IO) { 20 | io.String(&pk.BehaviourTree) 21 | } 22 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/add_painting.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/go-gl/mathgl/mgl32" 5 | "github.com/sandertv/gophertunnel/minecraft/protocol" 6 | ) 7 | 8 | // AddPainting is sent by the server to the client to make a painting entity show up. It is one of the few 9 | // entities that cannot be sent using the AddActor packet. 10 | type AddPainting struct { 11 | // EntityUniqueID is the unique ID of the entity. The unique ID is a value that remains consistent across 12 | // different sessions of the same world, but most servers simply fill the runtime ID of the entity out for 13 | // this field. 14 | EntityUniqueID int64 15 | // EntityRuntimeID is the runtime ID of the entity. The runtime ID is unique for each world session, and 16 | // entities are generally identified in packets using this runtime ID. 17 | EntityRuntimeID uint64 18 | // Position is the position to spawn the entity on. If the entity is on a distance that the player cannot 19 | // see it, the entity will still show up if the player moves closer. 20 | Position mgl32.Vec3 21 | // Direction is the facing direction of the painting. 22 | Direction int32 23 | // Title is the title of the painting. It specifies the motive of the painting. The title of the painting 24 | // must be valid. 25 | Title string 26 | } 27 | 28 | // ID ... 29 | func (*AddPainting) ID() uint32 { 30 | return IDAddPainting 31 | } 32 | 33 | func (pk *AddPainting) Marshal(io protocol.IO) { 34 | io.Varint64(&pk.EntityUniqueID) 35 | io.Varuint64(&pk.EntityRuntimeID) 36 | io.Vec3(&pk.Position) 37 | io.Varint32(&pk.Direction) 38 | io.String(&pk.Title) 39 | } 40 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/agent_action.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | AgentActionTypeAttack = iota + 1 9 | AgentActionTypeCollect 10 | AgentActionTypeDestroy 11 | AgentActionTypeDetectRedstone 12 | AgentActionTypeDetectObstacle 13 | AgentActionTypeDrop 14 | AgentActionTypeDropAll 15 | AgentActionTypeInspect 16 | AgentActionTypeInspectData 17 | AgentActionTypeInspectItemCount 18 | AgentActionTypeInspectItemDetail 19 | AgentActionTypeInspectItemSpace 20 | AgentActionTypeInteract 21 | AgentActionTypeMove 22 | AgentActionTypePlaceBlock 23 | AgentActionTypeTill 24 | AgentActionTypeTransferItemTo 25 | AgentActionTypeTurn 26 | ) 27 | 28 | // AgentAction is an Education Edition packet sent from the server to the client to return a response to a 29 | // previously requested action. 30 | type AgentAction struct { 31 | // Identifier is a JSON identifier referenced in the initial action. 32 | Identifier string 33 | // Action represents the action type that was requested. It is one of the constants defined above. 34 | Action int32 35 | // Response is a JSON string containing the response to the action. 36 | Response []byte 37 | } 38 | 39 | // ID ... 40 | func (*AgentAction) ID() uint32 { 41 | return IDAgentAction 42 | } 43 | 44 | func (pk *AgentAction) Marshal(io protocol.IO) { 45 | io.String(&pk.Identifier) 46 | io.Varint32(&pk.Action) 47 | io.ByteSlice(&pk.Response) 48 | } 49 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/agent_animation.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // AgentAnimation is an Education Edition packet sent from the server to the client to make an agent perform an animation. 8 | type AgentAnimation struct { 9 | // Animation is the ID of the animation that the agent should perform. As of its implementation, there are no IDs 10 | // that can be used in the regular client. 11 | Animation byte 12 | // EntityRuntimeID is the runtime ID of the entity. The runtime ID is unique for each world session, and 13 | // entities are generally identified in packets using this runtime ID. 14 | EntityRuntimeID uint64 15 | } 16 | 17 | // ID ... 18 | func (*AgentAnimation) ID() uint32 { 19 | return IDAgentAnimation 20 | } 21 | 22 | func (pk *AgentAnimation) Marshal(io protocol.IO) { 23 | io.Uint8(&pk.Animation) 24 | io.Varuint64(&pk.EntityRuntimeID) 25 | } 26 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/animate.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | AnimateActionSwingArm = iota + 1 9 | _ 10 | AnimateActionStopSleep 11 | AnimateActionCriticalHit 12 | AnimateActionMagicCriticalHit 13 | ) 14 | 15 | // Animate is sent by the server to send a player animation from one player to all viewers of that player. It 16 | // is used for a couple of actions, such as arm swimming and critical hits. 17 | type Animate struct { 18 | // ActionType is the ID of the animation action to execute. It is one of the action type constants that 19 | // may be found above. 20 | ActionType int32 21 | // EntityRuntimeID is the runtime ID of the player that the animation should be played upon. The runtime 22 | // ID is unique for each world session, and entities are generally identified in packets using this 23 | // runtime ID. 24 | EntityRuntimeID uint64 25 | // BoatRowingTime ... 26 | BoatRowingTime float32 27 | } 28 | 29 | // ID ... 30 | func (*Animate) ID() uint32 { 31 | return IDAnimate 32 | } 33 | 34 | func (pk *Animate) Marshal(io protocol.IO) { 35 | io.Varint32(&pk.ActionType) 36 | io.Varuint64(&pk.EntityRuntimeID) 37 | if pk.ActionType&0x80 != 0 { 38 | io.Float32(&pk.BoatRowingTime) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/anvil_damage.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // AnvilDamage is sent by the client to request the dealing damage to an anvil. This packet is completely 8 | // pointless and the server should never listen to it. 9 | type AnvilDamage struct { 10 | // Damage is the damage that the client requests to be dealt to the anvil. 11 | Damage uint8 12 | // AnvilPosition is the position in the world that the anvil can be found at. 13 | AnvilPosition protocol.BlockPos 14 | } 15 | 16 | // ID ... 17 | func (*AnvilDamage) ID() uint32 { 18 | return IDAnvilDamage 19 | } 20 | 21 | func (pk *AnvilDamage) Marshal(io protocol.IO) { 22 | io.Uint8(&pk.Damage) 23 | io.UBlockPos(&pk.AnvilPosition) 24 | } 25 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/automation_client_connect.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // AutomationClientConnect is used to make the client connect to a websocket server. This websocket server has 8 | // the ability to execute commands on the behalf of the client and it can listen for certain events fired by 9 | // the client. 10 | type AutomationClientConnect struct { 11 | // ServerURI is the URI to make the client connect to. It can be, for example, 'localhost:8000/ws' to 12 | // connect to a websocket server on the localhost at port 8000. 13 | ServerURI string 14 | } 15 | 16 | // ID ... 17 | func (*AutomationClientConnect) ID() uint32 { 18 | return IDAutomationClientConnect 19 | } 20 | 21 | func (pk *AutomationClientConnect) Marshal(io protocol.IO) { 22 | io.String(&pk.ServerURI) 23 | } 24 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/available_actor_identifiers.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // AvailableActorIdentifiers is sent by the server at the start of the game to let the client know all 8 | // entities that are available on the server. 9 | type AvailableActorIdentifiers struct { 10 | // SerialisedEntityIdentifiers is a network NBT serialised compound of all entity identifiers that are 11 | // available in the server. 12 | SerialisedEntityIdentifiers []byte 13 | } 14 | 15 | // ID ... 16 | func (*AvailableActorIdentifiers) ID() uint32 { 17 | return IDAvailableActorIdentifiers 18 | } 19 | 20 | func (pk *AvailableActorIdentifiers) Marshal(io protocol.IO) { 21 | io.Bytes(&pk.SerialisedEntityIdentifiers) 22 | } 23 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/award_achievement.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // AwardAchievement is sent by the server to award an achievement to a player. 8 | type AwardAchievement struct { 9 | // AchievementID is the ID of the achievement that should be awarded to the player. The values for these 10 | // IDs are currently unknown. 11 | AchievementID int32 12 | } 13 | 14 | // ID ... 15 | func (*AwardAchievement) ID() uint32 { 16 | return IDAwardAchievement 17 | } 18 | 19 | func (pk *AwardAchievement) Marshal(io protocol.IO) { 20 | io.Int32(&pk.AchievementID) 21 | } 22 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/biome_definition_list.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // BiomeDefinitionList is sent by the server to let the client know all biomes that are available and 8 | // implemented on the server side. When enabled, it also includes information for the client to 9 | // accurately recreate the server-side generation in vanilla worlds/servers for increased performance. 10 | type BiomeDefinitionList struct { 11 | // BiomeDefinitions is a list of biomes that are available on the server. 12 | BiomeDefinitions []protocol.BiomeDefinition 13 | // StringList is a makeshift dictionary implementation Mojang created to try and reduce the size of the 14 | // overall packet. It is a list of common strings that are used in the biome definitions, such as 15 | // biome names, float values or query expressions. 16 | StringList []string 17 | } 18 | 19 | // ID ... 20 | func (*BiomeDefinitionList) ID() uint32 { 21 | return IDBiomeDefinitionList 22 | } 23 | 24 | func (pk *BiomeDefinitionList) Marshal(io protocol.IO) { 25 | protocol.Slice(io, &pk.BiomeDefinitions) 26 | protocol.FuncSlice(io, &pk.StringList, io.String) 27 | } 28 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/block_actor_data.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/nbt" 5 | "github.com/sandertv/gophertunnel/minecraft/protocol" 6 | ) 7 | 8 | // BlockActorData is sent by the server to update data of a block entity client-side, for example the data of 9 | // a chest. 10 | type BlockActorData struct { 11 | // Position is the position of the block that holds the block entity. If no block entity is at this 12 | // position, the packet is ignored by the client. 13 | Position protocol.BlockPos 14 | // NBTData is the new data of the block that will be encoded to NBT and applied client-side, so that the 15 | // client can see the block update. The NBTData should contain all properties of the block, not just 16 | // properties that were changed. 17 | NBTData map[string]any 18 | } 19 | 20 | // ID ... 21 | func (*BlockActorData) ID() uint32 { 22 | return IDBlockActorData 23 | } 24 | 25 | func (pk *BlockActorData) Marshal(io protocol.IO) { 26 | io.UBlockPos(&pk.Position) 27 | io.NBT(&pk.NBTData, nbt.NetworkLittleEndian) 28 | } 29 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/block_event.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | BlockEventChangeChestState = 1 9 | ) 10 | 11 | // BlockEvent is sent by the server to initiate a certain event that has something to do with blocks in 12 | // specific, for example opening a chest. 13 | type BlockEvent struct { 14 | // Position is the position of the block that an event occurred at. 15 | Position protocol.BlockPos 16 | // EventType is the type of the block event. The event type decides the way the event data that follows 17 | // is used. It is one of the constants found above. 18 | EventType int32 19 | // EventData holds event type specific data. For chests for example, opening the chest means the data must 20 | // hold 1, whereas closing it should hold 0. 21 | EventData int32 22 | } 23 | 24 | // ID ... 25 | func (*BlockEvent) ID() uint32 { 26 | return IDBlockEvent 27 | } 28 | 29 | func (pk *BlockEvent) Marshal(io protocol.IO) { 30 | io.UBlockPos(&pk.Position) 31 | io.Varint32(&pk.EventType) 32 | io.Varint32(&pk.EventData) 33 | } 34 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/block_pick_request.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // BlockPickRequest is sent by the client when it requests to pick a block in the world and place its item in 8 | // their inventory. 9 | type BlockPickRequest struct { 10 | // Position is the position at which the client requested to pick the block. The block at that position 11 | // should have its item put in HotBarSlot if it is empty. 12 | Position protocol.BlockPos 13 | // AddBlockNBT specifies if the item should get all NBT tags from the block, meaning the item places a 14 | // block practically always equal to the one picked. 15 | AddBlockNBT bool 16 | // HotBarSlot is the slot that was held at the time of picking a block. 17 | HotBarSlot byte 18 | } 19 | 20 | // ID ... 21 | func (*BlockPickRequest) ID() uint32 { 22 | return IDBlockPickRequest 23 | } 24 | 25 | func (pk *BlockPickRequest) Marshal(io protocol.IO) { 26 | io.BlockPos(&pk.Position) 27 | io.Bool(&pk.AddBlockNBT) 28 | io.Uint8(&pk.HotBarSlot) 29 | } 30 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/camera.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // Camera is sent by the server to use an Education Edition camera on a player. It produces an image 8 | // client-side. 9 | type Camera struct { 10 | // CameraEntityUniqueID is the unique ID of the camera entity from which the picture was taken. 11 | CameraEntityUniqueID int64 12 | // TargetPlayerUniqueID is the unique ID of the target player. The unique ID is a value that remains 13 | // consistent across different sessions of the same world, but most servers simply fill the runtime ID of 14 | // the player out for this field. 15 | TargetPlayerUniqueID int64 16 | } 17 | 18 | // ID ... 19 | func (*Camera) ID() uint32 { 20 | return IDCamera 21 | } 22 | 23 | func (pk *Camera) Marshal(io protocol.IO) { 24 | io.Varint64(&pk.CameraEntityUniqueID) 25 | io.Varint64(&pk.TargetPlayerUniqueID) 26 | } 27 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/camera_aim_assist.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/go-gl/mathgl/mgl32" 5 | "github.com/sandertv/gophertunnel/minecraft/protocol" 6 | ) 7 | 8 | const ( 9 | CameraAimAssistActionSet = iota 10 | CameraAimAssistActionClear 11 | ) 12 | 13 | // CameraAimAssist is sent by the server to the client to set up aim assist for the client's camera. 14 | type CameraAimAssist struct { 15 | // Preset is the ID of the preset that has previously been defined in the CameraAimAssistPresets packet. 16 | Preset string 17 | // Angle is the maximum angle around the playes's cursor that the aim assist should check for a target, 18 | // if TargetMode is set to protocol.AimAssistTargetModeAngle. 19 | Angle mgl32.Vec2 20 | // Distance is the maximum distance from the player's cursor should check for a target, if TargetMode is 21 | // set to protocol.AimAssistTargetModeDistance. 22 | Distance float32 23 | // TargetMode is the mode that the camera should use for detecting targets. This is currently one of 24 | // protocol.AimAssistTargetModeAngle or protocol.AimAssistTargetModeDistance. 25 | TargetMode byte 26 | // Action is the action that should be performed with the aim assist. This is one of the constants above. 27 | Action byte 28 | } 29 | 30 | // ID ... 31 | func (*CameraAimAssist) ID() uint32 { 32 | return IDCameraAimAssist 33 | } 34 | 35 | func (pk *CameraAimAssist) Marshal(io protocol.IO) { 36 | io.String(&pk.Preset) 37 | io.Vec2(&pk.Angle) 38 | io.Float32(&pk.Distance) 39 | io.Uint8(&pk.TargetMode) 40 | io.Uint8(&pk.Action) 41 | } 42 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/camera_aim_assist_presets.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | CameraAunAssistPresetOperationSet = iota 9 | CameraAunAssistPresetOperationAddToExisting 10 | ) 11 | 12 | // CameraAimAssistPresets is sent by the server to the client to provide a list of categories and presets 13 | // that can be used when sending a CameraAimAssist packet or a CameraInstruction including aim assist. 14 | type CameraAimAssistPresets struct { 15 | // Categories is a list of categories which can be referenced by one of the Presets. 16 | Categories []protocol.CameraAimAssistCategory 17 | // Presets is a list of presets which define a base for how aim assist should behave 18 | Presets []protocol.CameraAimAssistPreset 19 | // Operation is the operation to perform with the presets. It is one of the constants above. 20 | Operation byte 21 | } 22 | 23 | // ID ... 24 | func (*CameraAimAssistPresets) ID() uint32 { 25 | return IDCameraAimAssistPresets 26 | } 27 | 28 | func (pk *CameraAimAssistPresets) Marshal(io protocol.IO) { 29 | protocol.Slice(io, &pk.Categories) 30 | protocol.Slice(io, &pk.Presets) 31 | io.Uint8(&pk.Operation) 32 | } 33 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/camera_instruction.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // CameraInstruction gives a custom camera specific instructions to operate. 8 | type CameraInstruction struct { 9 | // Set is a camera instruction that sets the camera to a specified preset. 10 | Set protocol.Optional[protocol.CameraInstructionSet] 11 | // Clear can be set to true to clear all the current camera instructions. 12 | Clear protocol.Optional[bool] 13 | // Fade is a camera instruction that fades the screen to a specified colour. 14 | Fade protocol.Optional[protocol.CameraInstructionFade] 15 | // Target is a camera instruction that targets a specific entity. 16 | Target protocol.Optional[protocol.CameraInstructionTarget] 17 | // RemoveTarget can be set to true to remove the current aim assist target. 18 | RemoveTarget protocol.Optional[bool] 19 | } 20 | 21 | // ID ... 22 | func (*CameraInstruction) ID() uint32 { 23 | return IDCameraInstruction 24 | } 25 | 26 | func (pk *CameraInstruction) Marshal(io protocol.IO) { 27 | protocol.OptionalMarshaler(io, &pk.Set) 28 | protocol.OptionalFunc(io, &pk.Clear, io.Bool) 29 | protocol.OptionalMarshaler(io, &pk.Fade) 30 | protocol.OptionalMarshaler(io, &pk.Target) 31 | protocol.OptionalFunc(io, &pk.RemoveTarget, io.Bool) 32 | } 33 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/camera_presets.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // CameraPresets gives the client a list of custom camera presets. 8 | type CameraPresets struct { 9 | // Presets is a list of camera presets that can be used by other cameras. The order of this list is important because 10 | // the index of presets is used as a pointer in the CameraInstruction packet. 11 | Presets []protocol.CameraPreset 12 | } 13 | 14 | // ID ... 15 | func (*CameraPresets) ID() uint32 { 16 | return IDCameraPresets 17 | } 18 | 19 | func (pk *CameraPresets) Marshal(io protocol.IO) { 20 | protocol.Slice(io, &pk.Presets) 21 | } 22 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/camera_shake.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import "github.com/sandertv/gophertunnel/minecraft/protocol" 4 | 5 | const ( 6 | CameraShakeTypePositional uint8 = iota 7 | CameraShakeTypeRotational 8 | ) 9 | 10 | const ( 11 | CameraShakeActionAdd = iota 12 | CameraShakeActionStop 13 | ) 14 | 15 | // CameraShake is sent by the server to make the camera shake client-side. This feature was added for map- 16 | // making partners. 17 | type CameraShake struct { 18 | // Intensity is the intensity of the shaking. The client limits this value to 4, so anything higher may 19 | // not work. 20 | Intensity float32 21 | // Duration is the number of seconds the camera will shake for. 22 | Duration float32 23 | // Type is the type of shake, and is one of the constants listed above. The different type affects how 24 | // the shake looks in game. 25 | Type uint8 26 | // Action is the action to be performed, and is one of the constants listed above. Currently the 27 | // different actions will either add or stop shaking the client. 28 | Action uint8 29 | } 30 | 31 | // ID ... 32 | func (*CameraShake) ID() uint32 { 33 | return IDCameraShake 34 | } 35 | 36 | func (pk *CameraShake) Marshal(io protocol.IO) { 37 | io.Float32(&pk.Intensity) 38 | io.Float32(&pk.Duration) 39 | io.Uint8(&pk.Type) 40 | io.Uint8(&pk.Action) 41 | } 42 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/change_mob_property.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // ChangeMobProperty is a packet sent from the server to the client to change one of the properties of a mob client-side. 8 | type ChangeMobProperty struct { 9 | // EntityUniqueID is the unique ID of the entity whose property is being changed. 10 | EntityUniqueID uint64 11 | // Property is the name of the property being updated. 12 | Property string 13 | // BoolValue is set if the property value is a bool type. If the type is not a bool, this field is ignored. 14 | BoolValue bool 15 | // StringValue is set if the property value is a string type. If the type is not a string, this field is ignored. 16 | StringValue string 17 | // IntValue is set if the property value is an int type. If the type is not an int, this field is ignored. 18 | IntValue int32 19 | // FloatValue is set if the property value is a float type. If the type is not a float, this field is ignored. 20 | FloatValue float32 21 | } 22 | 23 | // ID ... 24 | func (*ChangeMobProperty) ID() uint32 { 25 | return IDChangeMobProperty 26 | } 27 | 28 | func (pk *ChangeMobProperty) Marshal(io protocol.IO) { 29 | io.Uint64(&pk.EntityUniqueID) 30 | io.String(&pk.Property) 31 | io.Bool(&pk.BoolValue) 32 | io.String(&pk.StringValue) 33 | io.Varint32(&pk.IntValue) 34 | io.Float32(&pk.FloatValue) 35 | } 36 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/chunk_radius_updated.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // ChunkRadiusUpdated is sent by the server in response to a RequestChunkRadius packet. It defines the chunk 8 | // radius that the server allows the client to have. This may be lower than the chunk radius requested by the 9 | // client in the RequestChunkRadius packet. 10 | type ChunkRadiusUpdated struct { 11 | // ChunkRadius is the final chunk radius that the client will adapt when it receives the packet. It does 12 | // not have to be the same as the requested chunk radius. 13 | ChunkRadius int32 14 | } 15 | 16 | // ID ... 17 | func (*ChunkRadiusUpdated) ID() uint32 { 18 | return IDChunkRadiusUpdated 19 | } 20 | 21 | func (pk *ChunkRadiusUpdated) Marshal(io protocol.IO) { 22 | io.Varint32(&pk.ChunkRadius) 23 | } 24 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/client_bound_close_form.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // ClientBoundCloseForm is sent by the server to clear the entire form stack of the client. This means that all 8 | // forms that are currently open will be closed. This does not affect inventories and other containers. 9 | type ClientBoundCloseForm struct{} 10 | 11 | // ID ... 12 | func (*ClientBoundCloseForm) ID() uint32 { 13 | return IDClientBoundCloseForm 14 | } 15 | 16 | func (pk *ClientBoundCloseForm) Marshal(protocol.IO) {} 17 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/client_bound_debug_renderer.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/go-gl/mathgl/mgl32" 5 | "github.com/sandertv/gophertunnel/minecraft/protocol" 6 | ) 7 | 8 | const ( 9 | ClientBoundDebugRendererClear uint32 = iota + 1 10 | ClientBoundDebugRendererAddCube 11 | ) 12 | 13 | // ClientBoundDebugRenderer is sent by the server to spawn an outlined cube on client-side. 14 | type ClientBoundDebugRenderer struct { 15 | // Type is the type of action. It is one of the constants above. 16 | Type uint32 17 | // Text is the text that is displayed above the debug. 18 | Text string 19 | // Position is the position to spawn the debug on. 20 | Position mgl32.Vec3 21 | // Red is the red value from the RGBA colour rendered on the debug. This value is in the range 0-1. 22 | Red float32 23 | // Green is the green value from the RGBA colour rendered on the debug. This value is in the range 0-1. 24 | Green float32 25 | // Blue is the blue value from the RGBA colour rendered on the debug. This value is in the range 0-1. 26 | Blue float32 27 | // Alpha is the alpha value from the RGBA colour rendered on the debug. This value is in the range 0-1. 28 | Alpha float32 29 | // Duration is how long the debug will last in the world for. It is measured in milliseconds. 30 | Duration uint64 31 | } 32 | 33 | // ID ... 34 | func (*ClientBoundDebugRenderer) ID() uint32 { 35 | return IDClientBoundDebugRenderer 36 | } 37 | 38 | func (pk *ClientBoundDebugRenderer) Marshal(io protocol.IO) { 39 | io.Uint32(&pk.Type) 40 | if pk.Type == ClientBoundDebugRendererAddCube { 41 | io.String(&pk.Text) 42 | io.Vec3(&pk.Position) 43 | io.Float32(&pk.Red) 44 | io.Float32(&pk.Green) 45 | io.Float32(&pk.Blue) 46 | io.Float32(&pk.Alpha) 47 | io.Uint64(&pk.Duration) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/client_cache_blob_status.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // ClientCacheBlobStatus is part of the blob cache protocol. It is sent by the client to let the server know 8 | // what blobs it needs and which blobs it already has, in an ACK type system. 9 | type ClientCacheBlobStatus struct { 10 | // MissHashes is a list of blob hashes that the client does not have a blob available for. The server 11 | // should send the blobs matching these hashes as soon as possible. 12 | MissHashes []uint64 13 | // HitHashes is a list of blob hashes that the client has a blob available for. The blobs hashes here mean 14 | // that the client already has them: The server does not need to send the blobs anymore. 15 | HitHashes []uint64 16 | } 17 | 18 | // ID ... 19 | func (pk *ClientCacheBlobStatus) ID() uint32 { 20 | return IDClientCacheBlobStatus 21 | } 22 | 23 | func (pk *ClientCacheBlobStatus) Marshal(io protocol.IO) { 24 | missLen, hitLen := uint32(len(pk.MissHashes)), uint32(len(pk.HitHashes)) 25 | io.Varuint32(&missLen) 26 | io.Varuint32(&hitLen) 27 | protocol.FuncSliceOfLen(io, missLen, &pk.MissHashes, io.Uint64) 28 | protocol.FuncSliceOfLen(io, hitLen, &pk.HitHashes, io.Uint64) 29 | } 30 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/client_cache_miss_response.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // ClientCacheMissResponse is part of the blob cache protocol. It is sent by the server in response to a 8 | // ClientCacheBlobStatus packet and contains the blob data of all blobs that the client acknowledged not to 9 | // have yet. 10 | type ClientCacheMissResponse struct { 11 | // Blobs is a list of all blobs that the client sent misses for in the ClientCacheBlobStatus. These blobs 12 | // hold the data of the blobs with the hashes they are matched with. 13 | Blobs []protocol.CacheBlob 14 | } 15 | 16 | // ID ... 17 | func (pk *ClientCacheMissResponse) ID() uint32 { 18 | return IDClientCacheMissResponse 19 | } 20 | 21 | func (pk *ClientCacheMissResponse) Marshal(io protocol.IO) { 22 | protocol.Slice(io, &pk.Blobs) 23 | } 24 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/client_cache_status.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // ClientCacheStatus is sent by the client to the server at the start of the game. It is sent to let the 8 | // server know if it supports the client-side blob cache. Clients such as Nintendo Switch do not support the 9 | // cache, and attempting to use it anyway will fail. 10 | type ClientCacheStatus struct { 11 | // Enabled specifies if the blob cache is enabled. If false, the server should not attempt to use the 12 | // blob cache. If true, it may do so, but it may also choose not to use it. 13 | Enabled bool 14 | } 15 | 16 | // ID ... 17 | func (pk *ClientCacheStatus) ID() uint32 { 18 | return IDClientCacheStatus 19 | } 20 | 21 | func (pk *ClientCacheStatus) Marshal(io protocol.IO) { 22 | io.Bool(&pk.Enabled) 23 | } 24 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/client_camera_aim_assist.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | ClientCameraAimAssistActionSet = iota 9 | ClientCameraAimAssistActionClear 10 | ) 11 | 12 | // ClientCameraAimAssist is sent by the server to send a player animation from one player to all viewers of that player. It 13 | // is used for a couple of actions, such as arm swimming and critical hits. 14 | type ClientCameraAimAssist struct { 15 | // PresetID is the identifier of the preset to use which was previously defined in the CameraAimAssistPresets 16 | // packet. 17 | PresetID string 18 | // Action is the action to perform with the aim assist. It is one of the constants above. 19 | Action byte 20 | // AllowAimAssist specifies the client can use aim assist or not. 21 | AllowAimAssist bool 22 | } 23 | 24 | // ID ... 25 | func (*ClientCameraAimAssist) ID() uint32 { 26 | return IDClientCameraAimAssist 27 | } 28 | 29 | func (pk *ClientCameraAimAssist) Marshal(io protocol.IO) { 30 | io.String(&pk.PresetID) 31 | io.Uint8(&pk.Action) 32 | io.Bool(&pk.AllowAimAssist) 33 | } 34 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/client_cheat_ability.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // ClientCheatAbility functions the same as UpdateAbilities. It is unclear why these two were separated. 8 | // 9 | // Deprecated: ClientCheatAbility is deprecated as of 1.20.10. 10 | type ClientCheatAbility struct { 11 | // AbilityData represents various data about the abilities of a player, such as ability layers or permissions. 12 | AbilityData protocol.AbilityData 13 | } 14 | 15 | // ID ... 16 | func (*ClientCheatAbility) ID() uint32 { 17 | return IDClientCheatAbility 18 | } 19 | 20 | func (pk *ClientCheatAbility) Marshal(io protocol.IO) { 21 | protocol.Single(io, &pk.AbilityData) 22 | } 23 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/client_start_item_cooldown.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // ClientStartItemCooldown is sent by the server to the client to initiate a cooldown on an item. 8 | type ClientStartItemCooldown struct { 9 | // Category is the category of the item to start the cooldown on. 10 | Category string 11 | // Duration is the duration of ticks the cooldown should last. 12 | Duration int32 13 | } 14 | 15 | // ID ... 16 | func (*ClientStartItemCooldown) ID() uint32 { 17 | return IDClientStartItemCooldown 18 | } 19 | 20 | func (pk *ClientStartItemCooldown) Marshal(io protocol.IO) { 21 | io.String(&pk.Category) 22 | io.Varint32(&pk.Duration) 23 | } 24 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/client_to_server_handshake.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // ClientToServerHandshake is sent by the client in response to a ServerToClientHandshake packet sent by the 8 | // server. It is the first encrypted packet in the login handshake and serves as a confirmation that 9 | // encryption is correctly initialised client side. 10 | type ClientToServerHandshake struct { 11 | // ClientToServerHandshake has no fields. 12 | } 13 | 14 | // ID ... 15 | func (*ClientToServerHandshake) ID() uint32 { 16 | return IDClientToServerHandshake 17 | } 18 | 19 | func (*ClientToServerHandshake) Marshal(protocol.IO) {} 20 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/code_builder.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // CodeBuilder is an Education Edition packet sent by the server to the client to open the URL to a Code 8 | // Builder (websocket) server. 9 | type CodeBuilder struct { 10 | // URL is the url to the Code Builder (websocket) server. 11 | URL string 12 | // ShouldOpenCodeBuilder specifies if the client should automatically open the Code Builder app. If set to 13 | // true, the client will attempt to use the Code Builder app to connect to and interface with the server 14 | // running at the URL above. 15 | ShouldOpenCodeBuilder bool 16 | } 17 | 18 | // ID ... 19 | func (*CodeBuilder) ID() uint32 { 20 | return IDCodeBuilder 21 | } 22 | 23 | func (pk *CodeBuilder) Marshal(io protocol.IO) { 24 | io.String(&pk.URL) 25 | io.Bool(&pk.ShouldOpenCodeBuilder) 26 | } 27 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/code_builder_source.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | CodeBuilderOperationNone = iota 9 | CodeBuilderOperationGet 10 | CodeBuilderOperationSet 11 | CodeBuilderOperationReset 12 | ) 13 | 14 | const ( 15 | CodeBuilderCategoryNone = iota 16 | CodeBuilderCategoryStatus 17 | CodeBuilderCategoryInstantiation 18 | ) 19 | 20 | const ( 21 | CodeBuilderStatusNone = iota 22 | CodeBuilderStatusNotStarted 23 | CodeBuilderStatusInProgress 24 | CodeBuilderStatusPaused 25 | CodeBuilderStatusError 26 | CodeBuilderStatusSucceeded 27 | ) 28 | 29 | // CodeBuilderSource is an Education Edition packet sent by the client to the server to run an operation with a 30 | // code builder. 31 | type CodeBuilderSource struct { 32 | // Operation is used to distinguish the operation performed. It is always one of the constants listed above. 33 | Operation byte 34 | // Category is used to distinguish the category of the operation performed. It is always one of the constants 35 | // listed above. 36 | Category byte 37 | // CodeStatus is the status of the code builder. It is always one of the constants listed above. 38 | CodeStatus byte 39 | } 40 | 41 | // ID ... 42 | func (pk *CodeBuilderSource) ID() uint32 { 43 | return IDCodeBuilderSource 44 | } 45 | 46 | func (pk *CodeBuilderSource) Marshal(io protocol.IO) { 47 | io.Uint8(&pk.Operation) 48 | io.Uint8(&pk.Category) 49 | io.Uint8(&pk.CodeStatus) 50 | } 51 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/command_request.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // CommandRequest is sent by the client to request the execution of a server-side command. Although some 8 | // servers support sending commands using the Text packet, this packet is guaranteed to have the correct 9 | // result. 10 | type CommandRequest struct { 11 | // CommandLine is the raw entered command line. The client does no parsing of the command line by itself 12 | // (unlike it did in the early stages), but lets the server do that. 13 | CommandLine string 14 | // CommandOrigin is the data specifying the origin of the command. In other words, the source that the 15 | // command was from, such as the player itself or a websocket server. 16 | CommandOrigin protocol.CommandOrigin 17 | // Internal specifies if the command request internal. Setting it to false seems to work and the usage of 18 | // this field is not known. 19 | Internal bool 20 | // Version is the version of the command that is being executed. This field currently has no purpose or functionality. 21 | Version int32 22 | } 23 | 24 | // ID ... 25 | func (*CommandRequest) ID() uint32 { 26 | return IDCommandRequest 27 | } 28 | 29 | func (pk *CommandRequest) Marshal(io protocol.IO) { 30 | io.String(&pk.CommandLine) 31 | protocol.CommandOriginData(io, &pk.CommandOrigin) 32 | io.Bool(&pk.Internal) 33 | io.Varint32(&pk.Version) 34 | } 35 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/completed_using_item.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | UseItemEquipArmour = iota 9 | UseItemEat 10 | UseItemAttack 11 | UseItemConsume 12 | UseItemThrow 13 | UseItemShoot 14 | UseItemPlace 15 | UseItemFillBottle 16 | UseItemFillBucket 17 | UseItemPourBucket 18 | UseItemUseTool 19 | UseItemInteract 20 | UseItemRetrieved 21 | UseItemDyed 22 | UseItemTraded 23 | UseItemBrushingCompleted 24 | UseItemOpenedVault 25 | ) 26 | 27 | // CompletedUsingItem is sent by the server to tell the client that it should be done using the item it is 28 | // currently using. 29 | type CompletedUsingItem struct { 30 | // UsedItemID is the item ID of the item that the client completed using. This should typically be the 31 | // ID of the item held in the hand. 32 | UsedItemID int16 33 | // UseMethod is the method of the using of the item that was completed. It is one of the constants that 34 | // may be found above. 35 | UseMethod int32 36 | } 37 | 38 | // ID ... 39 | func (*CompletedUsingItem) ID() uint32 { 40 | return IDCompletedUsingItem 41 | } 42 | 43 | func (pk *CompletedUsingItem) Marshal(io protocol.IO) { 44 | io.Int16(&pk.UsedItemID) 45 | io.Int32(&pk.UseMethod) 46 | } 47 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/container_close.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // ContainerClose is sent by the server to close a container the player currently has opened, which was opened 8 | // using the ContainerOpen packet, or by the client to tell the server it closed a particular container, such 9 | // as the crafting grid. 10 | type ContainerClose struct { 11 | // WindowID is the ID representing the window of the container that should be closed. It must be equal to 12 | // the one sent in the ContainerOpen packet to close the designated window. 13 | WindowID byte 14 | // ContainerType is the type of container that the server is trying to close. This is used to validate on 15 | // the client side whether or not the server's close request is valid. 16 | ContainerType byte 17 | // ServerSide determines whether or not the container was force-closed by the server. If this value is 18 | // not set correctly, the client may ignore the packet and respond with a PacketViolationWarning. 19 | ServerSide bool 20 | } 21 | 22 | // ID ... 23 | func (*ContainerClose) ID() uint32 { 24 | return IDContainerClose 25 | } 26 | 27 | func (pk *ContainerClose) Marshal(io protocol.IO) { 28 | io.Uint8(&pk.WindowID) 29 | io.Uint8(&pk.ContainerType) 30 | io.Bool(&pk.ServerSide) 31 | } 32 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/container_registry_cleanup.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // ContainerRegistryCleanup is sent by the server to trigger a client-side cleanup of the dynamic container 8 | // registry. 9 | type ContainerRegistryCleanup struct { 10 | // RemovedContainers is a list of protocol.FullContainerName's that should be removed from the client-side 11 | // container registry. 12 | RemovedContainers []protocol.FullContainerName 13 | } 14 | 15 | // ID ... 16 | func (*ContainerRegistryCleanup) ID() uint32 { 17 | return IDContainerRegistryCleanup 18 | } 19 | 20 | func (pk *ContainerRegistryCleanup) Marshal(io protocol.IO) { 21 | protocol.Slice(io, &pk.RemovedContainers) 22 | } 23 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/container_set_data.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | ContainerDataFurnaceTickCount = iota 9 | ContainerDataFurnaceLitTime 10 | ContainerDataFurnaceLitDuration 11 | _ 12 | ContainerDataFurnaceFuelAux 13 | ) 14 | 15 | const ( 16 | ContainerDataBrewingStandBrewTime = iota 17 | ContainerDataBrewingStandFuelAmount 18 | ContainerDataBrewingStandFuelTotal 19 | ) 20 | 21 | // ContainerSetData is sent by the server to update specific data of a single container, meaning a block such 22 | // as a furnace or a brewing stand. This data is usually used by the client to display certain features 23 | // client-side. 24 | type ContainerSetData struct { 25 | // WindowID is the ID of the window that should have its data set. The player must have a window open with 26 | // the window ID passed, or nothing will happen. 27 | WindowID byte 28 | // Key is the key of the property. It is one of the constants that can be found above. Multiple properties 29 | // share the same key, but the functionality depends on the type of the container that the data is set to. 30 | Key int32 31 | // Value is the value of the property. Its use differs per property. 32 | Value int32 33 | } 34 | 35 | // ID ... 36 | func (*ContainerSetData) ID() uint32 { 37 | return IDContainerSetData 38 | } 39 | 40 | func (pk *ContainerSetData) Marshal(io protocol.IO) { 41 | io.Uint8(&pk.WindowID) 42 | io.Varint32(&pk.Key) 43 | io.Varint32(&pk.Value) 44 | } 45 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/create_photo.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import "github.com/sandertv/gophertunnel/minecraft/protocol" 4 | 5 | // CreatePhoto is a packet that allows players to export photos from their portfolios into items in their inventory. 6 | // This packet only works on the Education Edition version of Minecraft. 7 | type CreatePhoto struct { 8 | // EntityUniqueID is the unique ID of the entity. 9 | EntityUniqueID int64 10 | // PhotoName is the name of the photo. 11 | PhotoName string 12 | // ItemName is the name of the photo as an item. 13 | ItemName string 14 | } 15 | 16 | // ID ... 17 | func (*CreatePhoto) ID() uint32 { 18 | return IDCreatePhoto 19 | } 20 | 21 | func (pk *CreatePhoto) Marshal(io protocol.IO) { 22 | io.Int64(&pk.EntityUniqueID) 23 | io.String(&pk.PhotoName) 24 | io.String(&pk.ItemName) 25 | } 26 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/current_structure_feature.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // CurrentStructureFeature is sent by the server to let the client know the name of the structure feature 8 | // that the player is currently occupying. 9 | type CurrentStructureFeature struct { 10 | // CurrentFeature is the identifier of the structure feature that the player is currently occupying. 11 | // If the player is not occupying any structure feature, this field is empty. 12 | CurrentFeature string 13 | } 14 | 15 | // ID ... 16 | func (*CurrentStructureFeature) ID() uint32 { 17 | return IDCurrentStructureFeature 18 | } 19 | 20 | func (pk *CurrentStructureFeature) Marshal(io protocol.IO) { 21 | io.String(&pk.CurrentFeature) 22 | } 23 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/death_info.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // DeathInfo is a packet sent from the server to the client expected to be sent when a player dies. It contains messages 8 | // related to the player's death, which are shown on the death screen as of v1.19.10. 9 | type DeathInfo struct { 10 | // Cause is the cause of the player's death, such as "suffocation" or "suicide". 11 | Cause string 12 | // Messages is a list of death messages to be shown on the death screen. 13 | Messages []string 14 | } 15 | 16 | // ID ... 17 | func (*DeathInfo) ID() uint32 { 18 | return IDDeathInfo 19 | } 20 | 21 | func (pk *DeathInfo) Marshal(io protocol.IO) { 22 | io.String(&pk.Cause) 23 | protocol.FuncSlice(io, &pk.Messages, io.String) 24 | } 25 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/debug_info.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // DebugInfo is a packet sent by the server to the client. It does not seem to do anything when sent to the 8 | // normal client in 1.16. 9 | type DebugInfo struct { 10 | // PlayerUniqueID is the unique ID of the player that the packet is sent to. 11 | PlayerUniqueID int64 12 | // Data is the debug data. 13 | Data []byte 14 | } 15 | 16 | // ID ... 17 | func (*DebugInfo) ID() uint32 { 18 | return IDDebugInfo 19 | } 20 | 21 | func (pk *DebugInfo) Marshal(io protocol.IO) { 22 | io.Varint64(&pk.PlayerUniqueID) 23 | io.ByteSlice(&pk.Data) 24 | } 25 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/dimension_data.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // DimensionData is a packet sent from the server to the client containing information about data-driven dimensions 8 | // that the server may have registered. This packet does not seem to be sent by default, rather only being sent when 9 | // any data-driven dimensions are registered. 10 | type DimensionData struct { 11 | // Definitions contain a list of data-driven dimension definitions registered on the server. 12 | Definitions []protocol.DimensionDefinition 13 | } 14 | 15 | // ID ... 16 | func (*DimensionData) ID() uint32 { 17 | return IDDimensionData 18 | } 19 | 20 | func (pk *DimensionData) Marshal(io protocol.IO) { 21 | protocol.Slice(io, &pk.Definitions) 22 | } 23 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/disconnect.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // Disconnect may be sent by the server to disconnect the client using an optional message to send as the 8 | // disconnect screen. 9 | type Disconnect struct { 10 | // Reason is the reason for the disconnection. It seems as if this field has no use other than for 11 | // telemetry reasons as it does not affect the message that gets displayed on the disconnect screen. 12 | Reason int32 13 | // HideDisconnectionScreen specifies if the disconnection screen should be hidden when the client is 14 | // disconnected, meaning it will be sent directly to the main menu. 15 | HideDisconnectionScreen bool 16 | // Message is an optional message to show when disconnected. This message is only written if the 17 | // HideDisconnectionScreen field is set to true. 18 | Message string 19 | // FilteredMessage is a filtered version of Message with all the profanity removed. The client will use 20 | // this over Message if this field is not empty and they have the "Filter Profanity" setting enabled. 21 | FilteredMessage string 22 | } 23 | 24 | // ID ... 25 | func (*Disconnect) ID() uint32 { 26 | return IDDisconnect 27 | } 28 | 29 | func (pk *Disconnect) Marshal(io protocol.IO) { 30 | io.Varint32(&pk.Reason) 31 | io.Bool(&pk.HideDisconnectionScreen) 32 | if !pk.HideDisconnectionScreen { 33 | io.String(&pk.Message) 34 | io.String(&pk.FilteredMessage) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/doc.go: -------------------------------------------------------------------------------- 1 | // Package packet implements every packet in the Minecraft Bedrock Edition protocol using the functions found 2 | // in the minecraft/protocol package. Each of the packets hold their own encoding and decoding methods which 3 | // are used to read the packet from a bytes.Buffer or write the packet to one. 4 | // 5 | // Besides the implementations of packets themselves, the packet package also implements the decoding and 6 | // encoding of the lowest level Minecraft related packets, meaning the compressed packet batches. It handles 7 | // the compression and (optional) encryption of these packet batches. 8 | package packet 9 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/editor_network.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/nbt" 5 | "github.com/sandertv/gophertunnel/minecraft/protocol" 6 | ) 7 | 8 | // EditorNetwork is a packet sent from the server to the client and vise-versa to communicate editor-mode related 9 | // information. It carries a single compound tag containing the relevant information. 10 | type EditorNetwork struct { 11 | // RouteToManager ... 12 | RouteToManager bool 13 | // Payload is a network little endian compound tag holding data relevant to the editor. 14 | Payload map[string]any 15 | } 16 | 17 | // ID ... 18 | func (*EditorNetwork) ID() uint32 { 19 | return IDEditorNetwork 20 | } 21 | 22 | func (pk *EditorNetwork) Marshal(io protocol.IO) { 23 | io.Bool(&pk.RouteToManager) 24 | io.NBT(&pk.Payload, nbt.NetworkLittleEndian) 25 | } 26 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/education_resource_uri.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import "github.com/sandertv/gophertunnel/minecraft/protocol" 4 | 5 | // EducationResourceURI is a packet that transmits education resource settings to all clients. 6 | type EducationResourceURI struct { 7 | // Resource is the resource that is being referenced. 8 | Resource protocol.EducationSharedResourceURI 9 | } 10 | 11 | // ID ... 12 | func (*EducationResourceURI) ID() uint32 { 13 | return IDEducationResourceURI 14 | } 15 | 16 | func (pk *EducationResourceURI) Marshal(io protocol.IO) { 17 | protocol.Single(io, &pk.Resource) 18 | } 19 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/emote.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | EmoteFlagServerSide = 1 << iota 9 | EmoteFlagMuteChat 10 | ) 11 | 12 | // Emote is sent by both the server and the client. When the client sends an emote, it sends this packet to 13 | // the server, after which the server will broadcast the packet to other players online. 14 | type Emote struct { 15 | // EntityRuntimeID is the entity that sent the emote. When a player sends this packet, it has this field 16 | // set as its own entity runtime ID. 17 | EntityRuntimeID uint64 18 | // EmoteLength is the number of ticks that the emote lasts for. 19 | EmoteLength uint32 20 | // EmoteID is the ID of the emote to send. 21 | EmoteID string 22 | // XUID is the Xbox User ID of the player that sent the emote. It is only set when the emote is used by a player that 23 | // is authenticated with Xbox Live. 24 | XUID string 25 | // PlatformID is an identifier only set for particular platforms when using an emote (presumably only for Nintendo 26 | // Switch). It is otherwise an empty string, and is used to decide which players are able to emote with each other. 27 | PlatformID string 28 | // Flags is a combination of flags that change the way the Emote packet operates. When the server sends 29 | // this packet to other players, EmoteFlagServerSide must be present. 30 | Flags byte 31 | } 32 | 33 | // ID ... 34 | func (*Emote) ID() uint32 { 35 | return IDEmote 36 | } 37 | 38 | func (pk *Emote) Marshal(io protocol.IO) { 39 | io.Varuint64(&pk.EntityRuntimeID) 40 | io.String(&pk.EmoteID) 41 | io.Varuint32(&pk.EmoteLength) 42 | io.String(&pk.XUID) 43 | io.String(&pk.PlatformID) 44 | io.Uint8(&pk.Flags) 45 | } 46 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/emote_list.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/google/uuid" 5 | "github.com/sandertv/gophertunnel/minecraft/protocol" 6 | ) 7 | 8 | // EmoteList is sent by the client every time it joins the server and when it equips new emotes. It may be 9 | // used by the server to find out which emotes the client has available. If the player has no emotes equipped, 10 | // this packet is not sent. 11 | // Under certain circumstances, this packet is also sent from the server to the client, but I was unable to 12 | // find when this is done. 13 | type EmoteList struct { 14 | // PlayerRuntimeID is the runtime ID of the player that owns the emote pieces below. If sent by the 15 | // client, this player runtime ID is always that of the player itself. 16 | PlayerRuntimeID uint64 17 | // EmotePieces is a list of emote pieces that the player with the runtime ID above has. 18 | EmotePieces []uuid.UUID 19 | } 20 | 21 | // ID ... 22 | func (*EmoteList) ID() uint32 { 23 | return IDEmoteList 24 | } 25 | 26 | func (pk *EmoteList) Marshal(io protocol.IO) { 27 | io.Varuint64(&pk.PlayerRuntimeID) 28 | protocol.FuncSlice(io, &pk.EmotePieces, io.UUID) 29 | } 30 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/event.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // Event is sent by the server to send an event with additional data. It is typically sent to the client for 8 | // telemetry reasons, much like the SimpleEvent packet. 9 | type Event struct { 10 | // EntityRuntimeID is the runtime ID of the player. The runtime ID is unique for each world session, and 11 | // entities are generally identified in packets using this runtime ID. 12 | EntityRuntimeID int64 13 | // UsePlayerID ... 14 | // TODO: Figure out what UsePlayerID is for. 15 | UsePlayerID byte 16 | // Event is the event that is transmitted. 17 | Event protocol.Event 18 | } 19 | 20 | // ID ... 21 | func (*Event) ID() uint32 { 22 | return IDEvent 23 | } 24 | 25 | func (pk *Event) Marshal(io protocol.IO) { 26 | io.Varint64(&pk.EntityRuntimeID) 27 | io.EventType(&pk.Event) 28 | io.Uint8(&pk.UsePlayerID) 29 | pk.Event.Marshal(io) 30 | } 31 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/feature_registry.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // FeatureRegistry is a packet used to notify the client about the world generation features the server is currently 8 | // using. This is used in combination with the client-side world generation system introduced in v1.19.20, allowing the 9 | // client to completely generate the chunks of the world without having to rely on the server. 10 | type FeatureRegistry struct { 11 | // Features is a slice of all registered world generation features. 12 | Features []protocol.GenerationFeature 13 | } 14 | 15 | // ID ... 16 | func (pk *FeatureRegistry) ID() uint32 { 17 | return IDFeatureRegistry 18 | } 19 | 20 | func (pk *FeatureRegistry) Marshal(io protocol.IO) { 21 | protocol.Slice(io, &pk.Features) 22 | } 23 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/filter_text.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // FilterText is sent by the both the client and the server. The client sends the packet to the server to 8 | // allow the server to filter the text server-side. The server then responds with the same packet and the 9 | // safer version of the text. 10 | // 11 | // Deprecated: This packet was deprecated in unknown. 12 | type FilterText struct { 13 | // Text is either the text from the client or the safer version of the text sent by the server. 14 | Text string 15 | // FromServer indicates if the packet was sent by the server or not. 16 | FromServer bool 17 | } 18 | 19 | // ID ... 20 | func (*FilterText) ID() uint32 { 21 | return IDFilterText 22 | } 23 | 24 | func (pk *FilterText) Marshal(io protocol.IO) { 25 | io.String(&pk.Text) 26 | io.Bool(&pk.FromServer) 27 | } 28 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/game_rules_changed.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // GameRulesChanged is sent by the server to the client to update client-side game rules, such as game rules 8 | // like the 'showCoordinates' game rule. 9 | type GameRulesChanged struct { 10 | // GameRules defines game rules changed with their respective values. The value of these game rules may be 11 | // either 'bool', 'int32' or 'float32'. 12 | // Note that some game rules are server side only, and don't necessarily need to be sent to the client. 13 | // Only changed game rules need to be sent in this packet. Game rules that were not changed do not need to 14 | // be sent if the client is already updated on them. 15 | GameRules []protocol.GameRule 16 | } 17 | 18 | // ID ... 19 | func (*GameRulesChanged) ID() uint32 { 20 | return IDGameRulesChanged 21 | } 22 | 23 | func (pk *GameRulesChanged) Marshal(io protocol.IO) { 24 | protocol.FuncSlice(io, &pk.GameRules, io.GameRule) 25 | } 26 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/game_test_request.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import "github.com/sandertv/gophertunnel/minecraft/protocol" 4 | 5 | const ( 6 | GameTestRequestRotation0 = iota 7 | GameTestRequestRotation90 8 | GameTestRequestRotation180 9 | GameTestRequestRotation270 10 | GameTestRequestRotation360 11 | ) 12 | 13 | // GameTestRequest ... 14 | type GameTestRequest struct { 15 | // Name represents the name of the test. 16 | Name string 17 | // Rotation represents the rotation of the test. It is one of the constants above. 18 | Rotation uint8 19 | // Repetitions represents the amount of times the test will be run. 20 | Repetitions int32 21 | // Position is the position at which the test will be performed. 22 | Position protocol.BlockPos 23 | // StopOnError indicates whether the test should immediately stop when an error is encountered. 24 | StopOnError bool 25 | // TestsPerRow ... 26 | TestsPerRow int32 27 | // MaxTestsPerBatch ... 28 | MaxTestsPerBatch int32 29 | } 30 | 31 | // ID ... 32 | func (pk *GameTestRequest) ID() uint32 { 33 | return IDGameTestRequest 34 | } 35 | 36 | func (pk *GameTestRequest) Marshal(io protocol.IO) { 37 | io.Varint32(&pk.MaxTestsPerBatch) 38 | io.Varint32(&pk.Repetitions) 39 | io.Uint8(&pk.Rotation) 40 | io.Bool(&pk.StopOnError) 41 | io.BlockPos(&pk.Position) 42 | io.Varint32(&pk.TestsPerRow) 43 | io.String(&pk.Name) 44 | } 45 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/game_test_results.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // GameTestResults is a packet sent in response to the GameTestRequest packet, with a boolean indicating whether the 8 | // test was successful or not, and an error string if the test failed. 9 | type GameTestResults struct { 10 | // Name represents the name of the test. 11 | Name string 12 | // Succeeded indicates whether the test succeeded or not. 13 | Succeeded bool 14 | // Error is the error that occurred. If Succeeded is true, this field is empty. 15 | Error string 16 | } 17 | 18 | // ID ... 19 | func (pk *GameTestResults) ID() uint32 { 20 | return IDGameTestResults 21 | } 22 | 23 | func (pk *GameTestResults) Marshal(io protocol.IO) { 24 | io.Bool(&pk.Succeeded) 25 | io.String(&pk.Error) 26 | io.String(&pk.Name) 27 | } 28 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/gui_data_pick_item.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // GUIDataPickItem is sent by the server to make the client 'select' a hot bar slot. It currently appears to 8 | // be broken however, and does not actually set the selected slot to the hot bar slot set in the packet. 9 | type GUIDataPickItem struct { 10 | // ItemName is the name of the item that shows up in the top part of the popup that shows up when 11 | // selecting an item. It is shown as if an item was selected by the player itself. 12 | ItemName string 13 | // ItemEffects is the line under the ItemName, where the effects of the item are usually situated. 14 | ItemEffects string 15 | // HotBarSlot is the hot bar slot to be selected/picked. This does not currently work, so it does not 16 | // matter what number this is. 17 | HotBarSlot int32 18 | } 19 | 20 | // ID ... 21 | func (*GUIDataPickItem) ID() uint32 { 22 | return IDGUIDataPickItem 23 | } 24 | 25 | func (pk *GUIDataPickItem) Marshal(io protocol.IO) { 26 | io.String(&pk.ItemName) 27 | io.String(&pk.ItemEffects) 28 | io.Int32(&pk.HotBarSlot) 29 | } 30 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/hurt_armour.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // HurtArmour is sent by the server to damage the player's armour after being hit. The packet should never be 8 | // used by servers as it hands the responsibility over to the player completely, while the server can easily 9 | // reliably update the armour damage of players itself. 10 | type HurtArmour struct { 11 | // Cause is the cause of the damage dealt to the armour. 12 | Cause int32 13 | // Damage is the amount of damage points that was dealt to the player. The damage to the armour will be 14 | // calculated by the client based upon this damage, and will also be based upon any enchantments like 15 | // thorns that the armour may have. 16 | Damage int32 17 | // ArmourSlots is a bitset of all armour slots affected. 18 | ArmourSlots int64 19 | } 20 | 21 | // ID ... 22 | func (*HurtArmour) ID() uint32 { 23 | return IDHurtArmour 24 | } 25 | 26 | func (pk *HurtArmour) Marshal(io protocol.IO) { 27 | io.Varint32(&pk.Cause) 28 | io.Varint32(&pk.Damage) 29 | io.Varint64(&pk.ArmourSlots) 30 | } 31 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/interact.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/go-gl/mathgl/mgl32" 5 | "github.com/sandertv/gophertunnel/minecraft/protocol" 6 | ) 7 | 8 | const ( 9 | _ = iota + 1 10 | _ 11 | InteractActionLeaveVehicle 12 | InteractActionMouseOverEntity 13 | InteractActionNPCOpen 14 | InteractActionOpenInventory 15 | ) 16 | 17 | // Interact is sent by the client when it interacts with another entity in some way. It used to be used for 18 | // normal entity and block interaction, but this is no longer the case now. 19 | type Interact struct { 20 | // Action type is the ID of the action that was executed by the player. It is one of the constants that 21 | // may be found above. 22 | ActionType byte 23 | // TargetEntityRuntimeID is the runtime ID of the entity that the player interacted with. This is empty 24 | // for the InteractActionOpenInventory action type. 25 | TargetEntityRuntimeID uint64 26 | // Position associated with the ActionType above. For the InteractActionMouseOverEntity, this is the 27 | // position relative to the entity moused over over which the player hovered with its mouse/touch. For the 28 | // InteractActionLeaveVehicle, this is the position that the player spawns at after leaving the vehicle. 29 | Position mgl32.Vec3 30 | } 31 | 32 | // ID ... 33 | func (*Interact) ID() uint32 { 34 | return IDInteract 35 | } 36 | 37 | func (pk *Interact) Marshal(io protocol.IO) { 38 | io.Uint8(&pk.ActionType) 39 | io.Varuint64(&pk.TargetEntityRuntimeID) 40 | if pk.ActionType == InteractActionMouseOverEntity || pk.ActionType == InteractActionLeaveVehicle { 41 | io.Vec3(&pk.Position) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/inventory_content.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // InventoryContent is sent by the server to update the full content of a particular inventory. It is usually 8 | // sent for the main inventory of the player, but also works for other inventories that are currently opened 9 | // by the player. 10 | type InventoryContent struct { 11 | // WindowID is the ID that identifies one of the windows that the client currently has opened, or one of 12 | // the consistent windows such as the main inventory. 13 | WindowID uint32 14 | // Content is the new content of the inventory. The length of this slice must be equal to the full size of 15 | // the inventory window updated. 16 | Content []protocol.ItemInstance 17 | // Container is the protocol.FullContainerName that describes the container that the content is for. 18 | Container protocol.FullContainerName 19 | // StorageItem is the item that is acting as the storage container for the inventory. If the inventory is 20 | // not a dynamic container then this field should be left empty. When set, only the item type is used by 21 | // the client and none of the other stack info. 22 | StorageItem protocol.ItemInstance 23 | } 24 | 25 | // ID ... 26 | func (*InventoryContent) ID() uint32 { 27 | return IDInventoryContent 28 | } 29 | 30 | func (pk *InventoryContent) Marshal(io protocol.IO) { 31 | io.Varuint32(&pk.WindowID) 32 | protocol.FuncSlice(io, &pk.Content, io.ItemInstance) 33 | protocol.Single(io, &pk.Container) 34 | io.ItemInstance(&pk.StorageItem) 35 | } 36 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/inventory_slot.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // InventorySlot is sent by the server to update a single slot in one of the inventory windows that the client 8 | // currently has opened. Usually this is the main inventory, but it may also be the off hand or, for example, 9 | // a chest inventory. 10 | type InventorySlot struct { 11 | // WindowID is the ID of the window that the packet modifies. It must point to one of the windows that the 12 | // client currently has opened. 13 | WindowID uint32 14 | // Slot is the index of the slot that the packet modifies. The new item will be set to the slot at this 15 | // index. 16 | Slot uint32 17 | // Container is the protocol.FullContainerName that describes the container that the content is for. 18 | Container protocol.FullContainerName 19 | // StorageItem is the item that is acting as the storage container for the inventory. If the inventory is 20 | // not a dynamic container then this field should be left empty. When set, only the item type is used by 21 | // the client and none of the other stack info. 22 | StorageItem protocol.ItemInstance 23 | // NewItem is the item to be put in the slot at Slot. It will overwrite any item that may currently 24 | // be present in that slot. 25 | NewItem protocol.ItemInstance 26 | } 27 | 28 | // ID ... 29 | func (*InventorySlot) ID() uint32 { 30 | return IDInventorySlot 31 | } 32 | 33 | func (pk *InventorySlot) Marshal(io protocol.IO) { 34 | io.Varuint32(&pk.WindowID) 35 | io.Varuint32(&pk.Slot) 36 | protocol.Single(io, &pk.Container) 37 | io.ItemInstance(&pk.StorageItem) 38 | io.ItemInstance(&pk.NewItem) 39 | } 40 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/item_registry.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // ItemRegistry is sent by the server to send the client a list of available items and attach client-side 8 | // components to a custom item. This packet was formerly known as the ItemComponent packet before 1.21.60, 9 | // which did not include item definitions but only the components. 10 | type ItemRegistry struct { 11 | // Items is a list of all items with their legacy IDs which are available in the game. Failing to send any 12 | // of the items that are in the game will crash mobile clients. Any custom components are also attached to 13 | // the items in this list. 14 | Items []protocol.ItemEntry 15 | } 16 | 17 | // ID ... 18 | func (*ItemRegistry) ID() uint32 { 19 | return IDItemRegistry 20 | } 21 | 22 | func (pk *ItemRegistry) Marshal(io protocol.IO) { 23 | protocol.Slice(io, &pk.Items) 24 | } 25 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/item_stack_request.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // ItemStackRequest is sent by the client to change item stacks in an inventory. It is essentially a 8 | // replacement of the InventoryTransaction packet added in 1.16 for inventory specific actions, such as moving 9 | // items around or crafting. The InventoryTransaction packet is still used for actions such as placing blocks 10 | // and interacting with entities. 11 | type ItemStackRequest struct { 12 | // Requests holds a list of item stack requests. These requests are all separate, but the client buffers 13 | // the requests, so you might find multiple unrelated requests in this packet. 14 | Requests []protocol.ItemStackRequest 15 | } 16 | 17 | // ID ... 18 | func (*ItemStackRequest) ID() uint32 { 19 | return IDItemStackRequest 20 | } 21 | 22 | func (pk *ItemStackRequest) Marshal(io protocol.IO) { 23 | protocol.Slice(io, &pk.Requests) 24 | } 25 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/item_stack_response.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // ItemStackResponse is sent by the server in response to an ItemStackRequest packet from the client. This 8 | // packet is used to either approve or reject ItemStackRequests from the client. If a request is approved, the 9 | // client will simply continue as normal. If rejected, the client will undo the actions so that the inventory 10 | // should be in sync with the server again. 11 | type ItemStackResponse struct { 12 | // Responses is a list of responses to ItemStackRequests sent by the client before. Responses either 13 | // approve or reject a request from the client. 14 | // Vanilla limits the size of this slice to 4096. 15 | Responses []protocol.ItemStackResponse 16 | } 17 | 18 | // ID ... 19 | func (*ItemStackResponse) ID() uint32 { 20 | return IDItemStackResponse 21 | } 22 | 23 | func (pk *ItemStackResponse) Marshal(io protocol.IO) { 24 | protocol.Slice(io, &pk.Responses) 25 | } 26 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/jigsaw_structure_data.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // JigsawStructureData is sent by the server to let the client know all the rules for jigsaw structures. 8 | type JigsawStructureData struct { 9 | // StructureData is a network NBT serialised compound of all the jigsaw structure rules defined 10 | // on the server. 11 | StructureData []byte 12 | } 13 | 14 | // ID ... 15 | func (*JigsawStructureData) ID() uint32 { 16 | return IDJigsawStructureData 17 | } 18 | 19 | func (pk *JigsawStructureData) Marshal(io protocol.IO) { 20 | io.Bytes(&pk.StructureData) 21 | } 22 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/lab_table.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | LabTableActionCombine = iota 9 | LabTableActionReact 10 | LabTableActionReset 11 | ) 12 | 13 | // LabTable is sent by the client to let the server know it started a chemical reaction in Education Edition, 14 | // and is sent by the server to other clients to show the effects. 15 | // The packet is only functional if Education features are enabled. 16 | type LabTable struct { 17 | // ActionType is the type of the action that was executed. It is one of the constants above. Typically, 18 | // only LabTableActionCombine is sent by the client, whereas LabTableActionReact is sent by the server. 19 | ActionType byte 20 | // Position is the position at which the lab table used was located. 21 | Position protocol.BlockPos 22 | // ReactionType is the type of the reaction that took place as a result of the items put into the lab 23 | // table. The reaction type can be either that of an item or a particle, depending on whatever the result 24 | // was of the reaction. 25 | ReactionType byte 26 | } 27 | 28 | // ID ... 29 | func (*LabTable) ID() uint32 { 30 | return IDLabTable 31 | } 32 | 33 | func (pk *LabTable) Marshal(io protocol.IO) { 34 | io.Uint8(&pk.ActionType) 35 | io.BlockPos(&pk.Position) 36 | io.Uint8(&pk.ReactionType) 37 | } 38 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/lectern_update.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // LecternUpdate is sent by the client to update the server on which page was opened in a book on a lectern, 8 | // or if the book should be removed from it. 9 | type LecternUpdate struct { 10 | // Page is the page number in the book that was opened by the player on the lectern. 11 | Page byte 12 | // PageCount is the number of pages that the book opened in the lectern has. 13 | PageCount byte 14 | // Position is the position of the lectern that was updated. If no lectern is at the block position, 15 | // the packet should be ignored. 16 | Position protocol.BlockPos 17 | } 18 | 19 | // ID ... 20 | func (*LecternUpdate) ID() uint32 { 21 | return IDLecternUpdate 22 | } 23 | 24 | func (pk *LecternUpdate) Marshal(io protocol.IO) { 25 | io.Uint8(&pk.Page) 26 | io.Uint8(&pk.PageCount) 27 | io.UBlockPos(&pk.Position) 28 | } 29 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/lesson_progress.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | LessonActionStart = iota 9 | LessonActionComplete 10 | LessonActionRestart 11 | ) 12 | 13 | // LessonProgress is a packet sent by the server to the client to inform the client of updated progress on a lesson. 14 | // This packet only functions on the Minecraft: Education Edition version of the game. 15 | type LessonProgress struct { 16 | // Identifier is the identifier of the lesson that is being progressed. 17 | Identifier string 18 | // Action is the action the client should perform to show progress. This is one of the constants defined above. 19 | Action uint8 20 | // Score is the score the client should use when displaying the progress. 21 | Score int32 22 | } 23 | 24 | // ID ... 25 | func (*LessonProgress) ID() uint32 { 26 | return IDLessonProgress 27 | } 28 | 29 | func (pk *LessonProgress) Marshal(io protocol.IO) { 30 | io.Uint8(&pk.Action) 31 | io.Varint32(&pk.Score) 32 | io.String(&pk.Identifier) 33 | } 34 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/login.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // Login is sent when the client initially tries to join the server. It is the first packet sent and contains 8 | // information specific to the player. 9 | type Login struct { 10 | // ClientProtocol is the protocol version of the player. The player is disconnected if the protocol is incompatible 11 | // with the protocol of the server. It has been superseded by the protocol version sent in the 12 | // RequestNetworkSettings packet, so this should no longer be used by the server. 13 | ClientProtocol int32 14 | // ConnectionRequest is a string containing information about the player and JWTs that may be used to 15 | // verify if the player is connected to XBOX Live. The connection request also contains the necessary 16 | // client public key to initiate encryption. 17 | ConnectionRequest []byte 18 | } 19 | 20 | // ID ... 21 | func (*Login) ID() uint32 { 22 | return IDLogin 23 | } 24 | 25 | func (pk *Login) Marshal(io protocol.IO) { 26 | io.BEInt32(&pk.ClientProtocol) 27 | io.ByteSlice(&pk.ConnectionRequest) 28 | } 29 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/map_create_locked_copy.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // MapCreateLockedCopy is sent by the client to create a locked copy of one map into another map. In vanilla, 8 | // it is used in the cartography table to create a map that is locked and cannot be modified. 9 | type MapCreateLockedCopy struct { 10 | // OriginalMapID is the ID of the map that is being copied. The locked copy will obtain all content that 11 | // is visible on this map, except the content will not change. 12 | OriginalMapID int64 13 | // NewMapID is the ID of the map that holds the locked copy of the map that OriginalMapID points to. Its 14 | // contents will be impossible to change. 15 | NewMapID int64 16 | } 17 | 18 | // ID ... 19 | func (*MapCreateLockedCopy) ID() uint32 { 20 | return IDMapCreateLockedCopy 21 | } 22 | 23 | func (pk *MapCreateLockedCopy) Marshal(io protocol.IO) { 24 | io.Varint64(&pk.OriginalMapID) 25 | io.Varint64(&pk.NewMapID) 26 | } 27 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/map_info_request.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // MapInfoRequest is sent by the client to request the server to deliver information of a certain map in the 8 | // inventory of the player. The server should respond with a ClientBoundMapItemData packet. 9 | type MapInfoRequest struct { 10 | // MapID is the unique identifier that represents the map that is requested over network. It remains 11 | // consistent across sessions. 12 | MapID int64 13 | // ClientPixels is a slice of pixels sent from the client to notify the server about the pixels that it isn't aware 14 | // of. 15 | ClientPixels []protocol.PixelRequest 16 | } 17 | 18 | // ID ... 19 | func (*MapInfoRequest) ID() uint32 { 20 | return IDMapInfoRequest 21 | } 22 | 23 | func (pk *MapInfoRequest) Marshal(io protocol.IO) { 24 | io.Varint64(&pk.MapID) 25 | protocol.SliceUint32Length(io, &pk.ClientPixels) 26 | } 27 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/mob_armour_equipment.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // MobArmourEquipment is sent by the server to the client to update the armour an entity is wearing. It is 8 | // sent for both players and other entities, such as zombies. 9 | type MobArmourEquipment struct { 10 | // EntityRuntimeID is the runtime ID of the entity. The runtime ID is unique for each world session, and 11 | // entities are generally identified in packets using this runtime ID. 12 | EntityRuntimeID uint64 13 | // Helmet is the equipped helmet of the entity. Items that are not wearable on the head will not be 14 | // rendered by the client. Unlike in Java Edition, blocks cannot be worn. 15 | Helmet protocol.ItemInstance 16 | // Chestplate is the chestplate of the entity. Items that are not wearable as chestplate will not be 17 | // rendered. 18 | Chestplate protocol.ItemInstance 19 | // Leggings is the item worn as leggings by the entity. Items not wearable as leggings will not be 20 | // rendered client-side. 21 | Leggings protocol.ItemInstance 22 | // Boots is the item worn as boots by the entity. Items not wearable as boots will not be rendered. 23 | Boots protocol.ItemInstance 24 | // Body is the item worn on the body of the entity. Items not wearable on the body will not be rendered. 25 | Body protocol.ItemInstance 26 | } 27 | 28 | // ID ... 29 | func (*MobArmourEquipment) ID() uint32 { 30 | return IDMobArmourEquipment 31 | } 32 | 33 | func (pk *MobArmourEquipment) Marshal(io protocol.IO) { 34 | io.Varuint64(&pk.EntityRuntimeID) 35 | io.ItemInstance(&pk.Helmet) 36 | io.ItemInstance(&pk.Chestplate) 37 | io.ItemInstance(&pk.Leggings) 38 | io.ItemInstance(&pk.Boots) 39 | io.ItemInstance(&pk.Body) 40 | } 41 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/mob_equipment.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // MobEquipment is sent by the client to the server and the server to the client to make the other side 8 | // aware of the new item that an entity is holding. It is used to show the item in the hand of entities such 9 | // as zombies too. 10 | type MobEquipment struct { 11 | // EntityRuntimeID is the runtime ID of the entity. The runtime ID is unique for each world session, and 12 | // entities are generally identified in packets using this runtime ID. 13 | EntityRuntimeID uint64 14 | // NewItem is the new item held after sending the MobEquipment packet. The entity will be shown holding 15 | // that item to the player it was sent to. 16 | NewItem protocol.ItemInstance 17 | // InventorySlot is the slot in the inventory that was held. This is the same as HotBarSlot, and only 18 | // remains for backwards compatibility. 19 | InventorySlot byte 20 | // HotBarSlot is the slot in the hot bar that was held. It is the same as InventorySlot, which is only 21 | // there for backwards compatibility purposes. 22 | HotBarSlot byte 23 | // WindowID is the window ID of the window that had its equipped item changed. This is usually the window 24 | // ID of the normal inventory, but may also be something else, for example with the off hand. 25 | WindowID byte 26 | } 27 | 28 | // ID ... 29 | func (*MobEquipment) ID() uint32 { 30 | return IDMobEquipment 31 | } 32 | 33 | func (pk *MobEquipment) Marshal(io protocol.IO) { 34 | io.Varuint64(&pk.EntityRuntimeID) 35 | io.ItemInstance(&pk.NewItem) 36 | io.Uint8(&pk.InventorySlot) 37 | io.Uint8(&pk.HotBarSlot) 38 | io.Uint8(&pk.WindowID) 39 | } 40 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/modal_form_request.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // ModalFormRequest is sent by the server to make the client open a form. This form may be either a modal form 8 | // which has two options, a menu form for a selection of options and a custom form for properties. 9 | type ModalFormRequest struct { 10 | // FormID is an ID used to identify the form. The ID is saved by the client and sent back when the player 11 | // submits the form, so that the server can identify which form was submitted. 12 | FormID uint32 13 | // FormData is a JSON encoded object of form data. The content of the object differs, depending on the 14 | // type of the form sent, which is also set in the JSON. 15 | FormData []byte 16 | } 17 | 18 | // ID ... 19 | func (*ModalFormRequest) ID() uint32 { 20 | return IDModalFormRequest 21 | } 22 | 23 | func (pk *ModalFormRequest) Marshal(io protocol.IO) { 24 | io.Varuint32(&pk.FormID) 25 | io.ByteSlice(&pk.FormData) 26 | } 27 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/modal_form_response.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | ModalFormCancelReasonUserClosed = iota 9 | ModalFormCancelReasonUserBusy 10 | ) 11 | 12 | // ModalFormResponse is sent by the client in response to a ModalFormRequest, after the player has submitted 13 | // the form sent. It contains the options/properties selected by the player, or a JSON encoded 'null' if 14 | // the form was closed by clicking the X at the top right corner of the form. 15 | type ModalFormResponse struct { 16 | // FormID is the form ID of the form the client has responded to. It is the same as the ID sent in the 17 | // ModalFormRequest, and may be used to identify which form was submitted. 18 | FormID uint32 19 | // ResponseData is a JSON encoded value representing the response of the player. For a modal form, the response is 20 | // either true or false, for a menu form, the response is an integer specifying the index of the button clicked, and 21 | // for a custom form, the response is an array containing a value for each element. 22 | ResponseData protocol.Optional[[]byte] 23 | // CancelReason represents the reason why the form was cancelled. It is one of the constants above. 24 | CancelReason protocol.Optional[uint8] 25 | } 26 | 27 | // ID ... 28 | func (*ModalFormResponse) ID() uint32 { 29 | return IDModalFormResponse 30 | } 31 | 32 | func (pk *ModalFormResponse) Marshal(io protocol.IO) { 33 | io.Varuint32(&pk.FormID) 34 | protocol.OptionalFunc(io, &pk.ResponseData, io.ByteSlice) 35 | protocol.OptionalFunc(io, &pk.CancelReason, io.Uint8) 36 | } 37 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/motion_prediction_hints.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/go-gl/mathgl/mgl32" 5 | "github.com/sandertv/gophertunnel/minecraft/protocol" 6 | ) 7 | 8 | // MotionPredictionHints is sent by the server to the client. There is a predictive movement component for 9 | // entities. This packet fills the "history" of that component and entity movement is computed based on the 10 | // points. Vanilla sends this packet instead of the SetActorMotion packet when 'spatial optimisations' are 11 | // enabled. 12 | type MotionPredictionHints struct { 13 | // EntityRuntimeID is the runtime ID of the entity whose velocity is sent to the client. 14 | EntityRuntimeID uint64 15 | // Velocity is the server-calculated velocity of the entity at the point of sending the packet. 16 | Velocity mgl32.Vec3 17 | // OnGround specifies if the server currently thinks the entity is on the ground. 18 | OnGround bool 19 | } 20 | 21 | // ID ... 22 | func (*MotionPredictionHints) ID() uint32 { 23 | return IDMotionPredictionHints 24 | } 25 | 26 | func (pk *MotionPredictionHints) Marshal(io protocol.IO) { 27 | io.Varuint64(&pk.EntityRuntimeID) 28 | io.Vec3(&pk.Velocity) 29 | io.Bool(&pk.OnGround) 30 | } 31 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/move_actor_absolute.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/go-gl/mathgl/mgl32" 5 | "github.com/sandertv/gophertunnel/minecraft/protocol" 6 | ) 7 | 8 | const ( 9 | MoveFlagOnGround = 1 << iota 10 | MoveFlagTeleport 11 | ) 12 | 13 | // MoveActorAbsolute is sent by the server to move an entity to an absolute position. It is typically used 14 | // for movements where high accuracy isn't needed, such as for long range teleporting. 15 | type MoveActorAbsolute struct { 16 | // EntityRuntimeID is the runtime ID of the entity. The runtime ID is unique for each world session, and 17 | // entities are generally identified in packets using this runtime ID. 18 | EntityRuntimeID uint64 19 | // Flags is a combination of flags that specify details of the movement. It is a combination of the flags 20 | // above. 21 | Flags byte 22 | // Position is the position to spawn the entity on. If the entity is on a distance that the player cannot 23 | // see it, the entity will still show up if the player moves closer. 24 | Position mgl32.Vec3 25 | // Rotation is a Vec3 holding the X, Y and Z rotation of the entity after the movement. This is a Vec3 for 26 | // the reason that projectiles like arrows don't have yaw/pitch, but do have roll. 27 | Rotation mgl32.Vec3 28 | } 29 | 30 | // ID ... 31 | func (*MoveActorAbsolute) ID() uint32 { 32 | return IDMoveActorAbsolute 33 | } 34 | 35 | func (pk *MoveActorAbsolute) Marshal(io protocol.IO) { 36 | io.Varuint64(&pk.EntityRuntimeID) 37 | io.Uint8(&pk.Flags) 38 | io.Vec3(&pk.Position) 39 | io.ByteFloat(&pk.Rotation[0]) 40 | io.ByteFloat(&pk.Rotation[1]) 41 | io.ByteFloat(&pk.Rotation[2]) 42 | } 43 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/movement_effect.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | MovementEffectTypeGlideBoost = iota 9 | ) 10 | 11 | // MovementEffect is sent by the server to the client to update specific movement effects to allow the client 12 | // to predict its movement. For example, fireworks used during gliding will send this packet to tell the 13 | // client the exact duration of the boost. 14 | type MovementEffect struct { 15 | // EntityRuntimeID is the runtime ID of the entity. The runtime ID is unique for each world session, and 16 | // entities are generally identified in packets using this runtime ID. 17 | EntityRuntimeID uint64 18 | // Type is the type of movement effect being updated. It is one of the constants found above. 19 | Type int32 20 | // Duration is the duration of the effect, measured in ticks. 21 | Duration int32 22 | // Tick is the server tick at which the packet was sent. It is used in relation to CorrectPlayerMovePrediction. 23 | Tick uint64 24 | } 25 | 26 | // ID ... 27 | func (*MovementEffect) ID() uint32 { 28 | return IDMovementEffect 29 | } 30 | 31 | func (pk *MovementEffect) Marshal(io protocol.IO) { 32 | io.Varuint64(&pk.EntityRuntimeID) 33 | io.Varint32(&pk.Type) 34 | io.Varint32(&pk.Duration) 35 | io.Varuint64(&pk.Tick) 36 | } 37 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/multi_player_settings.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | EnableMultiPlayer = iota 9 | DisableMultiPlayer 10 | RefreshJoinCode 11 | ) 12 | 13 | // MultiPlayerSettings is sent by the client to update multi-player related settings server-side and sent back 14 | // to online players by the server. 15 | // The MultiPlayerSettings packet is a Minecraft: Education Edition packet. It has no functionality for the 16 | // base game. 17 | type MultiPlayerSettings struct { 18 | // ActionType is the action that should be done when this packet is sent. It is one of the constants that 19 | // may be found above. 20 | ActionType int32 21 | } 22 | 23 | // ID ... 24 | func (*MultiPlayerSettings) ID() uint32 { 25 | return IDMultiPlayerSettings 26 | } 27 | 28 | func (pk *MultiPlayerSettings) Marshal(io protocol.IO) { 29 | io.Varint32(&pk.ActionType) 30 | } 31 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/network_stack_latency.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // NetworkStackLatency is sent by the server (and the client, on development builds) to measure the latency 8 | // over the entire Minecraft stack, rather than the RakNet latency. It has other usages too, such as the 9 | // ability to be used as some kind of acknowledgement packet, to know when the client has received a certain 10 | // other packet. 11 | type NetworkStackLatency struct { 12 | // Timestamp is the timestamp of the network stack latency packet. The client will, if NeedsResponse is 13 | // set to true, send a NetworkStackLatency packet with this same timestamp packet in response. 14 | Timestamp int64 15 | // NeedsResponse specifies if the sending side of this packet wants a response to the packet, meaning that 16 | // the other side should send a NetworkStackLatency packet back. 17 | NeedsResponse bool 18 | } 19 | 20 | // ID ... 21 | func (*NetworkStackLatency) ID() uint32 { 22 | return IDNetworkStackLatency 23 | } 24 | 25 | func (pk *NetworkStackLatency) Marshal(io protocol.IO) { 26 | io.Int64(&pk.Timestamp) 27 | io.Bool(&pk.NeedsResponse) 28 | } 29 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/npc_dialogue.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import "github.com/sandertv/gophertunnel/minecraft/protocol" 4 | 5 | const ( 6 | NPCDialogueActionOpen int32 = iota 7 | NPCDialogueActionClose 8 | ) 9 | 10 | // NPCDialogue is a packet that allows the client to display dialog boxes for interacting with NPCs. 11 | type NPCDialogue struct { 12 | // EntityUniqueID is the unique ID of the NPC being requested. 13 | EntityUniqueID uint64 14 | // ActionType is the type of action for the packet. 15 | ActionType int32 16 | // Dialogue is the text that the client should see. 17 | Dialogue string 18 | // SceneName is the identifier of the scene. If this is left empty, the client will use the last scene sent to it. 19 | // https://docs.microsoft.com/en-us/minecraft/creator/documents/npcdialogue. 20 | SceneName string 21 | // NPCName is the name of the NPC to be displayed to the client. 22 | NPCName string 23 | // ActionJSON is the JSON string of the buttons/actions the server can perform. 24 | ActionJSON string 25 | } 26 | 27 | // ID ... 28 | func (*NPCDialogue) ID() uint32 { 29 | return IDNPCDialogue 30 | } 31 | 32 | func (pk *NPCDialogue) Marshal(io protocol.IO) { 33 | io.Uint64(&pk.EntityUniqueID) 34 | io.Varint32(&pk.ActionType) 35 | io.String(&pk.Dialogue) 36 | io.String(&pk.SceneName) 37 | io.String(&pk.NPCName) 38 | io.String(&pk.ActionJSON) 39 | } 40 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/npc_request.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import "github.com/sandertv/gophertunnel/minecraft/protocol" 4 | 5 | const ( 6 | NPCRequestActionSetActions = iota 7 | NPCRequestActionExecuteAction 8 | NPCRequestActionExecuteClosingCommands 9 | NPCRequestActionSetName 10 | NPCRequestActionSetSkin 11 | NPCRequestActionSetInteractText 12 | NPCRequestActionExecuteOpeningCommands 13 | ) 14 | 15 | // NPCRequest is sent by the client when it interacts with an NPC. 16 | // The packet is specifically made for Education Edition, where NPCs are available to use. 17 | type NPCRequest struct { 18 | // EntityRuntimeID is the runtime ID of the NPC entity that the player interacted with. It is the same 19 | // as sent by the server when spawning the entity. 20 | EntityRuntimeID uint64 21 | // RequestType is the type of the request, which depends on the permission that the player has. It will 22 | // be either a type that indicates that the NPC should show its dialog, or that it should open the 23 | // editing window. 24 | RequestType byte 25 | // CommandString is the command string set in the NPC. It may consist of multiple commands, depending on 26 | // what the player set in it. 27 | CommandString string 28 | // ActionType is the type of the action to execute. 29 | ActionType byte 30 | // SceneName is the name of the scene. This can be left empty to specify the last scene that the player 31 | // was sent. 32 | SceneName string 33 | } 34 | 35 | // ID ... 36 | func (*NPCRequest) ID() uint32 { 37 | return IDNPCRequest 38 | } 39 | 40 | func (pk *NPCRequest) Marshal(io protocol.IO) { 41 | io.Varuint64(&pk.EntityRuntimeID) 42 | io.Uint8(&pk.RequestType) 43 | io.String(&pk.CommandString) 44 | io.Uint8(&pk.ActionType) 45 | io.String(&pk.SceneName) 46 | } 47 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/on_screen_texture_animation.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // OnScreenTextureAnimation is sent by the server to show a certain animation on the screen of the player. 8 | // The packet is used, as an example, for when a raid is triggered and when a raid is defeated. 9 | type OnScreenTextureAnimation struct { 10 | // AnimationType is the type of the animation to show. The packet provides no further extra data to allow 11 | // modifying the duration or other properties of the animation. 12 | AnimationType int32 13 | } 14 | 15 | // ID ... 16 | func (*OnScreenTextureAnimation) ID() uint32 { 17 | return IDOnScreenTextureAnimation 18 | } 19 | 20 | func (pk *OnScreenTextureAnimation) Marshal(io protocol.IO) { 21 | io.Int32(&pk.AnimationType) 22 | } 23 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/open_sign.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // OpenSign is sent by the server to open a sign for editing. As of 1.19.80, the player can interact with a sign to edit 8 | // the text on both sides instead of just the front. 9 | type OpenSign struct { 10 | // Position is the position of the sign to edit. The client uses this position to get the data of the sign, including 11 | // the existing text and formatting etc. 12 | Position protocol.BlockPos 13 | // FrontSide dictates whether the front side of the sign should be opened for editing. If false, the back side is 14 | // assumed to be edited. 15 | FrontSide bool 16 | } 17 | 18 | // ID ... 19 | func (*OpenSign) ID() uint32 { 20 | return IDOpenSign 21 | } 22 | 23 | func (pk *OpenSign) Marshal(io protocol.IO) { 24 | io.UBlockPos(&pk.Position) 25 | io.Bool(&pk.FrontSide) 26 | } 27 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/packet_violation_warning.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | ViolationTypeMalformed = iota 9 | ) 10 | 11 | const ( 12 | ViolationSeverityWarning = iota 13 | ViolationSeverityFinalWarning 14 | ViolationSeverityTerminatingConnection 15 | ) 16 | 17 | // PacketViolationWarning is sent by the client when it receives an invalid packet from the server. It holds 18 | // some information on the error that occurred. 19 | // noinspection GoNameStartsWithPackageName 20 | type PacketViolationWarning struct { 21 | // Type is the type of violation. It is one of the constants above. 22 | Type int32 23 | // Severity specifies the severity of the packet violation. The action the client takes after this 24 | // violation depends on the severity sent. 25 | Severity int32 26 | // PacketID is the ID of the invalid packet that was received. 27 | PacketID int32 28 | // ViolationContext holds a description on the violation of the packet. 29 | ViolationContext string 30 | } 31 | 32 | // ID ... 33 | func (*PacketViolationWarning) ID() uint32 { 34 | return IDPacketViolationWarning 35 | } 36 | 37 | func (pk *PacketViolationWarning) Marshal(io protocol.IO) { 38 | io.Varint32(&pk.Type) 39 | io.Varint32(&pk.Severity) 40 | io.Varint32(&pk.PacketID) 41 | io.String(&pk.ViolationContext) 42 | } 43 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/photo_info_request.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // PhotoInfoRequest is sent by the client to request photo information from the server. 8 | // 9 | // Deprecated: This packet was deprecated in 1.19.80. 10 | type PhotoInfoRequest struct { 11 | // PhotoID is the ID of the photo. 12 | PhotoID int64 13 | } 14 | 15 | // ID ... 16 | func (*PhotoInfoRequest) ID() uint32 { 17 | return IDPhotoInfoRequest 18 | } 19 | 20 | func (pk *PhotoInfoRequest) Marshal(io protocol.IO) { 21 | io.Varint64(&pk.PhotoID) 22 | } 23 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/play_sound.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/go-gl/mathgl/mgl32" 5 | "github.com/sandertv/gophertunnel/minecraft/protocol" 6 | ) 7 | 8 | // PlaySound is sent by the server to play a sound to the client. Some of the sounds may only be started using 9 | // this packet and must be stopped using the StopSound packet. 10 | type PlaySound struct { 11 | // SoundName is the name of the sound to play. 12 | SoundName string 13 | // Position is the position at which the sound was played. Some sounds do not depend on a position, 14 | // which will then ignore it, but most of them will play with the direction based on the position compared 15 | // to the player's position. 16 | Position mgl32.Vec3 17 | // Volume is the relative volume of the sound to play. It will be less loud for the player if it is 18 | // farther away from the position of the sound. 19 | Volume float32 20 | // Pitch is the pitch of the sound to play. Some sounds completely ignore this field, whereas others use 21 | // it to specify the pitch as the field is intended. 22 | Pitch float32 23 | } 24 | 25 | // ID ... 26 | func (*PlaySound) ID() uint32 { 27 | return IDPlaySound 28 | } 29 | 30 | func (pk *PlaySound) Marshal(io protocol.IO) { 31 | io.String(&pk.SoundName) 32 | io.SoundPos(&pk.Position) 33 | io.Float32(&pk.Volume) 34 | io.Float32(&pk.Pitch) 35 | } 36 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/play_status.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | PlayStatusLoginSuccess int32 = iota 9 | PlayStatusLoginFailedClient 10 | PlayStatusLoginFailedServer 11 | PlayStatusPlayerSpawn 12 | PlayStatusLoginFailedInvalidTenant 13 | PlayStatusLoginFailedVanillaEdu 14 | PlayStatusLoginFailedEduVanilla 15 | PlayStatusLoginFailedServerFull 16 | PlayStatusLoginFailedEditorVanilla 17 | PlayStatusLoginFailedVanillaEditor 18 | ) 19 | 20 | // PlayStatus is sent by the server to update a player on the play status. This includes failed statuses due 21 | // to a mismatched version, but also success statuses. 22 | type PlayStatus struct { 23 | // Status is the status of the packet. It is one of the constants found above. 24 | Status int32 25 | } 26 | 27 | // ID ... 28 | func (*PlayStatus) ID() uint32 { 29 | return IDPlayStatus 30 | } 31 | 32 | func (pk *PlayStatus) Marshal(io protocol.IO) { 33 | io.BEInt32(&pk.Status) 34 | } 35 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/player_action.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // PlayerAction is sent by the client when it executes any action, for example starting to sprint, swim, 8 | // starting the breaking of a block, dropping an item, etc. 9 | type PlayerAction struct { 10 | // EntityRuntimeID is the runtime ID of the player. The runtime ID is unique for each world session, and 11 | // entities are generally identified in packets using this runtime ID. 12 | EntityRuntimeID uint64 13 | // ActionType is the ID of the action that was executed by the player. It is one of the constants that may 14 | // be found in protocol/player.go. 15 | ActionType int32 16 | // BlockPosition is the position of the target block, if the action with the ActionType set concerned a 17 | // block. If that is not the case, the block position will be zero. 18 | BlockPosition protocol.BlockPos 19 | // ResultPosition is the position of the action's result. When a UseItemOn action is sent, this is the position of 20 | // the block clicked, but when a block is placed, this is the position at which the block will be placed. 21 | ResultPosition protocol.BlockPos 22 | // BlockFace is the face of the target block that was touched. If the action with the ActionType set 23 | // concerned a block. If not, the face is always 0. 24 | BlockFace int32 25 | } 26 | 27 | // ID ... 28 | func (*PlayerAction) ID() uint32 { 29 | return IDPlayerAction 30 | } 31 | 32 | func (pk *PlayerAction) Marshal(io protocol.IO) { 33 | io.Varuint64(&pk.EntityRuntimeID) 34 | io.Varint32(&pk.ActionType) 35 | io.UBlockPos(&pk.BlockPosition) 36 | io.UBlockPos(&pk.ResultPosition) 37 | io.Varint32(&pk.BlockFace) 38 | } 39 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/player_enchant_options.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // PlayerEnchantOptions is sent by the server to update the enchantment options displayed when the user opens 8 | // the enchantment table and puts an item in. This packet was added in 1.16 and allows the server to decide on 9 | // the enchantments that can be selected by the player. 10 | // The PlayerEnchantOptions packet should be sent once for every slot update of the enchantment table. The 11 | // vanilla server sends an empty PlayerEnchantOptions packet when the player opens the enchantment table 12 | // (air is present in the enchantment table slot) and sends the packet with actual enchantments in it when 13 | // items are put in that can have enchantments. 14 | type PlayerEnchantOptions struct { 15 | // Options is a list of possible enchantment options for the item that was put into the enchantment table. 16 | Options []protocol.EnchantmentOption 17 | } 18 | 19 | // ID ... 20 | func (*PlayerEnchantOptions) ID() uint32 { 21 | return IDPlayerEnchantOptions 22 | } 23 | 24 | func (pk *PlayerEnchantOptions) Marshal(io protocol.IO) { 25 | protocol.Slice(io, &pk.Options) 26 | } 27 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/player_fog.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // PlayerFog is sent by the server to render the different fogs in the Stack. The types of fog are controlled 8 | // by resource packs to change how they are rendered, and the ability to create custom fog. 9 | type PlayerFog struct { 10 | // Stack is a list of fog identifiers to be sent to the client. Examples of fog identifiers are 11 | // "minecraft:fog_ocean" and "minecraft:fog_hell". 12 | Stack []string 13 | } 14 | 15 | // ID ... 16 | func (*PlayerFog) ID() uint32 { 17 | return IDPlayerFog 18 | } 19 | 20 | func (pk *PlayerFog) Marshal(io protocol.IO) { 21 | protocol.FuncSlice(io, &pk.Stack, io.String) 22 | } 23 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/player_hot_bar.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // PlayerHotBar is sent by the server to the client. It used to be used to link hot bar slots of the player to 8 | // actual slots in the inventory, but as of 1.2, this was changed and hot bar slots are no longer a free 9 | // floating part of the inventory. 10 | // Since 1.2, the packet has been re-purposed, but its new functionality is not clear. 11 | type PlayerHotBar struct { 12 | // SelectedHotBarSlot ... 13 | SelectedHotBarSlot uint32 14 | // WindowID ... 15 | WindowID byte 16 | // SelectHotBarSlot ... 17 | SelectHotBarSlot bool 18 | } 19 | 20 | // ID ... 21 | func (*PlayerHotBar) ID() uint32 { 22 | return IDPlayerHotBar 23 | } 24 | 25 | func (pk *PlayerHotBar) Marshal(io protocol.IO) { 26 | io.Varuint32(&pk.SelectedHotBarSlot) 27 | io.Uint8(&pk.WindowID) 28 | io.Bool(&pk.SelectHotBarSlot) 29 | } 30 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/player_list.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | PlayerListActionAdd = iota 9 | PlayerListActionRemove 10 | ) 11 | 12 | // PlayerList is sent by the server to update the client-side player list in the in-game menu screen. It shows 13 | // the icon of each player if the correct XUID is written in the packet. 14 | // Sending the PlayerList packet is obligatory when sending an AddPlayer packet. The added player will not 15 | // show up to a client if it has not been added to the player list, because several properties of the player 16 | // are obtained from the player list, such as the skin. 17 | type PlayerList struct { 18 | // ActionType is the action to execute upon the player list. The entries that follow specify which entries 19 | // are added or removed from the player list. 20 | ActionType byte 21 | // Entries is a list of all player list entries that should be added/removed from the player list, 22 | // depending on the ActionType set. 23 | Entries []protocol.PlayerListEntry 24 | } 25 | 26 | // ID ... 27 | func (*PlayerList) ID() uint32 { 28 | return IDPlayerList 29 | } 30 | 31 | func (pk *PlayerList) Marshal(io protocol.IO) { 32 | io.Uint8(&pk.ActionType) 33 | switch pk.ActionType { 34 | case PlayerListActionAdd: 35 | protocol.Slice(io, &pk.Entries) 36 | case PlayerListActionRemove: 37 | protocol.FuncIOSlice(io, &pk.Entries, protocol.PlayerListRemoveEntry) 38 | default: 39 | io.UnknownEnumOption(pk.ActionType, "player list action type") 40 | } 41 | if pk.ActionType == PlayerListActionAdd { 42 | for i := 0; i < len(pk.Entries); i++ { 43 | io.Bool(&pk.Entries[i].Skin.Trusted) 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/player_location.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/go-gl/mathgl/mgl32" 5 | "github.com/sandertv/gophertunnel/minecraft/protocol" 6 | ) 7 | 8 | const ( 9 | PlayerLocationTypeCoordinates = iota 10 | PlayerLocationTypeHide 11 | ) 12 | 13 | // PlayerLocation is sent by the client to the server when it updates its own skin using the in-game skin picker. 14 | // It is relayed by the server, or sent if the server changes the skin of a player on its own accord. Note 15 | // that the packet can only be sent for players that are in the player list at the time of sending. 16 | type PlayerLocation struct { 17 | // Type is the action that is being performed. It is one of the constants above. 18 | Type int32 19 | // EntityUniqueID is the unique ID of the entity. The unique ID is a value that remains consistent across 20 | // different sessions of the same world. 21 | EntityUniqueID int64 22 | // Position is the position of the player to be used on the locator bar. This is only set when the Type is 23 | // PlayerLocationTypeCoordinates. 24 | Position mgl32.Vec3 25 | } 26 | 27 | // ID ... 28 | func (*PlayerLocation) ID() uint32 { 29 | return IDPlayerLocation 30 | } 31 | 32 | func (pk *PlayerLocation) Marshal(io protocol.IO) { 33 | io.Int32(&pk.Type) 34 | io.Varint64(&pk.EntityUniqueID) 35 | if pk.Type == PlayerLocationTypeCoordinates { 36 | io.Vec3(&pk.Position) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/player_skin.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/google/uuid" 5 | "github.com/sandertv/gophertunnel/minecraft/protocol" 6 | ) 7 | 8 | // PlayerSkin is sent by the client to the server when it updates its own skin using the in-game skin picker. 9 | // It is relayed by the server, or sent if the server changes the skin of a player on its own accord. Note 10 | // that the packet can only be sent for players that are in the player list at the time of sending. 11 | type PlayerSkin struct { 12 | // UUID is the UUID of the player as sent in the Login packet when the client joined the server. It must 13 | // match this UUID exactly for the skin to show up on the player. 14 | UUID uuid.UUID 15 | // Skin is the new skin to be applied on the player with the UUID in the field above. The skin, including 16 | // its animations, will be shown after sending it. 17 | Skin protocol.Skin 18 | // NewSkinName no longer has a function: The field can be left empty at all times. 19 | NewSkinName string 20 | // OldSkinName no longer has a function: The field can be left empty at all times. 21 | OldSkinName string 22 | } 23 | 24 | // ID ... 25 | func (*PlayerSkin) ID() uint32 { 26 | return IDPlayerSkin 27 | } 28 | 29 | func (pk *PlayerSkin) Marshal(io protocol.IO) { 30 | io.UUID(&pk.UUID) 31 | protocol.Single(io, &pk.Skin) 32 | io.String(&pk.NewSkinName) 33 | io.String(&pk.OldSkinName) 34 | io.Bool(&pk.Skin.Trusted) 35 | } 36 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/player_toggle_crafter_slot_request.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // PlayerToggleCrafterSlotRequest is sent by the client when it tries to toggle the state of a slot within a Crafter. 8 | type PlayerToggleCrafterSlotRequest struct { 9 | // PosX is the X position of the Crafter that is being modified. 10 | PosX int32 11 | // PosY is the Y position of the Crafter that is being modified. 12 | PosY int32 13 | // PosZ is the Z position of the Crafter that is being modified. 14 | PosZ int32 15 | // Slot is the index of the slot that was toggled. This should be a value between 0 and 8. 16 | Slot byte 17 | // Disabled is the new state of the slot. If true, the slot is disabled, if false, the slot is enabled. 18 | Disabled bool 19 | } 20 | 21 | // ID ... 22 | func (*PlayerToggleCrafterSlotRequest) ID() uint32 { 23 | return IDPlayerToggleCrafterSlotRequest 24 | } 25 | 26 | func (pk *PlayerToggleCrafterSlotRequest) Marshal(io protocol.IO) { 27 | io.Int32(&pk.PosX) 28 | io.Int32(&pk.PosY) 29 | io.Int32(&pk.PosZ) 30 | io.Uint8(&pk.Slot) 31 | io.Bool(&pk.Disabled) 32 | } 33 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/player_video_capture.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | PlayerVideoCaptureActionStop = iota 9 | PlayerVideoCaptureActionStart 10 | ) 11 | 12 | // PlayerVideoCapture packet is sent by the server to start or stop video recording for a player. This packet 13 | // only works on development builds and has no effect on retail builds. When recording, the client will save 14 | // individual frames to '/LocalCache/minecraftpe' in the format specified below. 15 | type PlayerVideoCapture struct { 16 | // Action is the action to perform with the video capture. It is one of the constants above. 17 | Action byte 18 | // FrameRate is the frame rate at which the video should be recorded. It is only used when Action is 19 | // PlayerVideoCaptureActionStart. A higher frame rate will cause more frames to be recorded, but also 20 | // a noticeable increase in lag. 21 | FrameRate int32 22 | // FilePrefix is the prefix of the file name that will be used to save the frames. The frames will be saved 23 | // in the format 'FilePrefix%d.png' where %d is the frame index. 24 | FilePrefix string 25 | } 26 | 27 | // ID ... 28 | func (*PlayerVideoCapture) ID() uint32 { 29 | return IDPlayerVideoCapture 30 | } 31 | 32 | func (pk *PlayerVideoCapture) Marshal(io protocol.IO) { 33 | io.Uint8(&pk.Action) 34 | if pk.Action == PlayerVideoCaptureActionStart { 35 | io.Int32(&pk.FrameRate) 36 | io.String(&pk.FilePrefix) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/position_tracking_db_client_request.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | PositionTrackingDBRequestActionQuery = iota 9 | ) 10 | 11 | // PositionTrackingDBClientRequest is a packet sent by the client to request the position and dimension of a 12 | // 'tracking ID'. These IDs are tracked in a database by the server. In 1.16, this is used for lodestones. 13 | // The client will send this request to find the position a lodestone compass needs to point to. If found, it 14 | // will point to the lodestone. If not, it will start spinning around. 15 | // A PositionTrackingDBServerBroadcast packet should be sent in response to this packet. 16 | type PositionTrackingDBClientRequest struct { 17 | // RequestAction is the action that should be performed upon the receiving of the packet. It is one of the 18 | // constants found above. 19 | RequestAction byte 20 | // TrackingID is a unique ID used to identify the request. The server responds with a 21 | // PositionTrackingDBServerBroadcast packet holding the same ID, so that the client can find out what that 22 | // packet was in response to. 23 | TrackingID int32 24 | } 25 | 26 | // ID ... 27 | func (*PositionTrackingDBClientRequest) ID() uint32 { 28 | return IDPositionTrackingDBClientRequest 29 | } 30 | 31 | func (pk *PositionTrackingDBClientRequest) Marshal(io protocol.IO) { 32 | io.Uint8(&pk.RequestAction) 33 | io.Varint32(&pk.TrackingID) 34 | } 35 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/purchase_receipt.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // PurchaseReceipt is sent by the client to the server to notify the server it purchased an item from the 8 | // Marketplace store that was offered by the server. The packet is only used for partnered servers. 9 | type PurchaseReceipt struct { 10 | // Receipts is a list of receipts, or proofs of purchases, for the offers that have been purchased by the 11 | // player. 12 | Receipts []string 13 | } 14 | 15 | // ID ... 16 | func (*PurchaseReceipt) ID() uint32 { 17 | return IDPurchaseReceipt 18 | } 19 | 20 | func (pk *PurchaseReceipt) Marshal(io protocol.IO) { 21 | protocol.FuncSlice(io, &pk.Receipts, io.String) 22 | } 23 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/refresh_entitlements.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // RefreshEntitlements is sent by the client to the server to refresh the entitlements of the player. 8 | type RefreshEntitlements struct{} 9 | 10 | // ID ... 11 | func (*RefreshEntitlements) ID() uint32 { 12 | return IDRefreshEntitlements 13 | } 14 | 15 | func (*RefreshEntitlements) Marshal(protocol.IO) {} 16 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/remove_actor.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // RemoveActor is sent by the server to remove an entity that currently exists in the world from the client- 8 | // side. Sending this packet if the client cannot already see this entity will have no effect. 9 | type RemoveActor struct { 10 | // EntityUniqueID is the unique ID of the entity to be removed. The unique ID is a value that remains 11 | // consistent across different sessions of the same world, but most servers simply fill the runtime ID 12 | // of the entity out for this field. 13 | EntityUniqueID int64 14 | } 15 | 16 | // ID ... 17 | func (*RemoveActor) ID() uint32 { 18 | return IDRemoveActor 19 | } 20 | 21 | func (pk *RemoveActor) Marshal(io protocol.IO) { 22 | io.Varint64(&pk.EntityUniqueID) 23 | } 24 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/remove_objective.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // RemoveObjective is sent by the server to remove a scoreboard objective. It is used to stop showing a 8 | // scoreboard to a player. 9 | type RemoveObjective struct { 10 | // ObjectiveName is the name of the objective that the scoreboard currently active has. This name must 11 | // be identical to the one sent in the SetDisplayObjective packet. 12 | ObjectiveName string 13 | } 14 | 15 | // ID ... 16 | func (*RemoveObjective) ID() uint32 { 17 | return IDRemoveObjective 18 | } 19 | 20 | func (pk *RemoveObjective) Marshal(io protocol.IO) { 21 | io.String(&pk.ObjectiveName) 22 | } 23 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/remove_volume_entity.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // RemoveVolumeEntity indicates a volume entity to be removed from server to client. 8 | type RemoveVolumeEntity struct { 9 | // EntityRuntimeID ... 10 | EntityRuntimeID uint64 11 | // Dimension ... 12 | Dimension int32 13 | } 14 | 15 | // ID ... 16 | func (*RemoveVolumeEntity) ID() uint32 { 17 | return IDRemoveVolumeEntity 18 | } 19 | 20 | func (pk *RemoveVolumeEntity) Marshal(io protocol.IO) { 21 | io.Uint64(&pk.EntityRuntimeID) 22 | io.Varint32(&pk.Dimension) 23 | } 24 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/request_ability.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | AbilityBuild = iota 9 | AbilityMine 10 | AbilityDoorsAndSwitches 11 | AbilityOpenContainers 12 | AbilityAttackPlayers 13 | AbilityAttackMobs 14 | AbilityOperatorCommands 15 | AbilityTeleport 16 | AbilityInvulnerable 17 | AbilityFlying 18 | AbilityMayFly 19 | AbilityInstantBuild 20 | AbilityLightning 21 | AbilityFlySpeed 22 | AbilityWalkSpeed 23 | AbilityMuted 24 | AbilityWorldBuilder 25 | AbilityNoClip 26 | AbilityCount 27 | ) 28 | 29 | // RequestAbility is a packet sent by the client to the server to request permission for a specific ability from the 30 | // server. These abilities are defined above. 31 | type RequestAbility struct { 32 | // Ability is the ability that the client is requesting. This is one of the constants defined in the 33 | // protocol/ability.go file. 34 | Ability int32 35 | // Value represents the value of the ability. This can either be a boolean or a float32, otherwise the writer/reader 36 | // will panic. 37 | Value any 38 | } 39 | 40 | // ID ... 41 | func (*RequestAbility) ID() uint32 { 42 | return IDRequestAbility 43 | } 44 | 45 | func (pk *RequestAbility) Marshal(io protocol.IO) { 46 | io.Varint32(&pk.Ability) 47 | io.AbilityValue(&pk.Value) 48 | } 49 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/request_chunk_radius.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // RequestChunkRadius is sent by the client to the server to update the server on the chunk view radius that 8 | // it has set in the settings. The server may respond with a ChunkRadiusUpdated packet with either the chunk 9 | // radius requested, or a different chunk radius if the server chooses so. 10 | type RequestChunkRadius struct { 11 | // ChunkRadius is the requested chunk radius. This value is always the value set in the settings of the 12 | // player. 13 | ChunkRadius int32 14 | // MaxChunkRadius is the maximum chunk radius that the player wants to receive. The reason for the client sending this 15 | // is currently unknown. 16 | MaxChunkRadius int32 17 | } 18 | 19 | // ID ... 20 | func (*RequestChunkRadius) ID() uint32 { 21 | return IDRequestChunkRadius 22 | } 23 | 24 | func (pk *RequestChunkRadius) Marshal(io protocol.IO) { 25 | io.Varint32(&pk.ChunkRadius) 26 | io.Varint32(&pk.MaxChunkRadius) 27 | } 28 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/request_network_settings.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // RequestNetworkSettings is sent by the client to request network settings, such as compression, from the server. 8 | type RequestNetworkSettings struct { 9 | // ClientProtocol is the protocol version of the player. The player is disconnected if the protocol is 10 | // incompatible with the protocol of the server. 11 | ClientProtocol int32 12 | } 13 | 14 | // ID ... 15 | func (pk *RequestNetworkSettings) ID() uint32 { 16 | return IDRequestNetworkSettings 17 | } 18 | 19 | func (pk *RequestNetworkSettings) Marshal(io protocol.IO) { 20 | io.BEInt32(&pk.ClientProtocol) 21 | } 22 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/request_permissions.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // RequestPermissions is a packet sent from the client to the server to request permissions that the client does not 8 | // currently have. It can only be sent by operators and host in vanilla Minecraft. 9 | type RequestPermissions struct { 10 | // EntityUniqueID is the unique ID of the player. The unique ID is unique for the entire world and is 11 | // often used in packets. Most servers send an EntityUniqueID equal to the EntityRuntimeID. 12 | EntityUniqueID int64 13 | // PermissionLevel is the current permission level of the player. This is one of the constants that may be found 14 | // in the AdventureSettings packet. 15 | PermissionLevel uint8 16 | // RequestedPermissions contains the requested permission flags. 17 | RequestedPermissions uint16 18 | } 19 | 20 | // ID ... 21 | func (*RequestPermissions) ID() uint32 { 22 | return IDRequestPermissions 23 | } 24 | 25 | func (pk *RequestPermissions) Marshal(io protocol.IO) { 26 | io.Int64(&pk.EntityUniqueID) 27 | io.Uint8(&pk.PermissionLevel) 28 | io.Uint16(&pk.RequestedPermissions) 29 | } 30 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/resource_pack_chunk_data.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // ResourcePackChunkData is sent to the client so that the client can download the resource pack. Each packet 8 | // holds a chunk of the compressed resource pack, of which the size is defined in the ResourcePackDataInfo 9 | // packet sent before. 10 | type ResourcePackChunkData struct { 11 | // UUID is the unique ID of the resource pack that the chunk of data is taken out of. 12 | UUID string 13 | // ChunkIndex is the current chunk index of the chunk. It is a number that starts at 0 and is incremented 14 | // for each resource pack data chunk sent to the client. 15 | ChunkIndex uint32 16 | // DataOffset is the current progress in bytes or offset in the data that the resource pack data chunk is 17 | // taken from. 18 | DataOffset uint64 19 | // RawPayload is a byte slice containing a chunk of data from the resource pack. It must be of the same size or 20 | // less than the DataChunkSize set in the ResourcePackDataInfo packet. 21 | Data []byte 22 | } 23 | 24 | // ID ... 25 | func (*ResourcePackChunkData) ID() uint32 { 26 | return IDResourcePackChunkData 27 | } 28 | 29 | func (pk *ResourcePackChunkData) Marshal(io protocol.IO) { 30 | io.String(&pk.UUID) 31 | io.Uint32(&pk.ChunkIndex) 32 | io.Uint64(&pk.DataOffset) 33 | io.ByteSlice(&pk.Data) 34 | } 35 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/resource_pack_chunk_request.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // ResourcePackChunkRequest is sent by the client to request a chunk of data from a particular resource pack, 8 | // that it has obtained information about in a ResourcePackDataInfo packet. 9 | type ResourcePackChunkRequest struct { 10 | // UUID is the unique ID of the resource pack that the chunk of data is requested from. 11 | UUID string 12 | // ChunkIndex is the requested chunk index of the chunk. It is a number that starts at 0 and is 13 | // incremented for each resource pack data chunk requested. 14 | ChunkIndex uint32 15 | } 16 | 17 | // ID ... 18 | func (*ResourcePackChunkRequest) ID() uint32 { 19 | return IDResourcePackChunkRequest 20 | } 21 | 22 | func (pk *ResourcePackChunkRequest) Marshal(io protocol.IO) { 23 | io.String(&pk.UUID) 24 | io.Uint32(&pk.ChunkIndex) 25 | } 26 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/resource_pack_client_response.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | PackResponseRefused = iota + 1 9 | PackResponseSendPacks 10 | PackResponseAllPacksDownloaded 11 | PackResponseCompleted 12 | ) 13 | 14 | // ResourcePackClientResponse is sent by the client in response to resource packets sent by the server. It is 15 | // used to let the server know what action needs to be taken for the client to have all resource packs ready 16 | // and set. 17 | type ResourcePackClientResponse struct { 18 | // Response is the response type of the response. It is one of the constants found above. 19 | Response byte 20 | // PacksToDownload is a list of resource pack UUIDs combined with their version that need to be downloaded 21 | // (for example SomePack_1.0.0), if the Response field is PackResponseSendPacks. 22 | PacksToDownload []string 23 | } 24 | 25 | // ID ... 26 | func (*ResourcePackClientResponse) ID() uint32 { 27 | return IDResourcePackClientResponse 28 | } 29 | 30 | func (pk *ResourcePackClientResponse) Marshal(io protocol.IO) { 31 | io.Uint8(&pk.Response) 32 | protocol.FuncSliceUint16Length(io, &pk.PacksToDownload, io.String) 33 | } 34 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/respawn.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/go-gl/mathgl/mgl32" 5 | "github.com/sandertv/gophertunnel/minecraft/protocol" 6 | ) 7 | 8 | const ( 9 | RespawnStateSearchingForSpawn = iota 10 | RespawnStateReadyToSpawn 11 | RespawnStateClientReadyToSpawn 12 | ) 13 | 14 | // Respawn is sent by the server to make a player respawn client-side. It is sent in response to a 15 | // PlayerAction packet with ActionType PlayerActionRespawn. 16 | // As of 1.13, the server sends two of these packets with different states, and the client sends one of these 17 | // back in order to complete the respawn. 18 | type Respawn struct { 19 | // Position is the position on which the player should be respawned. The position might be in a different 20 | // dimension, in which case the client should first be sent a ChangeDimension packet. 21 | Position mgl32.Vec3 22 | // State is the 'state' of the respawn. It is one of the constants that may be found above, and the value 23 | // the packet contains depends on whether the server or client sends it. 24 | State byte 25 | // EntityRuntimeID is the entity runtime ID of the player that the respawn packet concerns. This is 26 | // apparently for the server to recognise which player sends this packet. 27 | EntityRuntimeID uint64 28 | } 29 | 30 | // ID ... 31 | func (*Respawn) ID() uint32 { 32 | return IDRespawn 33 | } 34 | 35 | func (pk *Respawn) Marshal(io protocol.IO) { 36 | io.Vec3(&pk.Position) 37 | io.Uint8(&pk.State) 38 | io.Varuint64(&pk.EntityRuntimeID) 39 | } 40 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/script_custom_event.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // ScriptCustomEvent is sent by both the client and the server. It is a way to let scripts communicate with 8 | // the server, so that the client can let the server know it triggered an event, or the other way around. 9 | // ScriptCustomEvent is deprecated as of 1.20.10. 10 | type ScriptCustomEvent struct { 11 | // EventName is the name of the event. The script and the server will use this event name to identify the 12 | // data that is sent. 13 | EventName string 14 | // EventData is the data of the event. This data is typically a JSON encoded string, that the script is 15 | // able to encode and decode too. 16 | EventData []byte 17 | } 18 | 19 | // ID ... 20 | func (*ScriptCustomEvent) ID() uint32 { 21 | return IDScriptCustomEvent 22 | } 23 | 24 | func (pk *ScriptCustomEvent) Marshal(io protocol.IO) { 25 | io.String(&pk.EventName) 26 | io.ByteSlice(&pk.EventData) 27 | } 28 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/script_message.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // ScriptMessage is used to communicate custom messages from the client to the server, or from the server to the client. 8 | // While the name may suggest this packet is used for the discontinued scripting API, it is likely instead for the 9 | // GameTest framework. 10 | type ScriptMessage struct { 11 | // Identifier is the identifier of the message, used by either party to identify the message data sent. 12 | Identifier string 13 | // Data contains the data of the message. 14 | Data []byte 15 | } 16 | 17 | // ID ... 18 | func (pk *ScriptMessage) ID() uint32 { 19 | return IDScriptMessage 20 | } 21 | 22 | func (pk *ScriptMessage) Marshal(io protocol.IO) { 23 | io.String(&pk.Identifier) 24 | io.ByteSlice(&pk.Data) 25 | } 26 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/server_bound_loading_screen.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | LoadingScreenTypeUnknown = iota 9 | LoadingScreenTypeStart 10 | LoadingScreenTypeEnd 11 | ) 12 | 13 | // ServerBoundLoadingScreen is sent by the client to tell the server about the state of the loading 14 | // screen that the client is currently displaying. 15 | type ServerBoundLoadingScreen struct { 16 | // Type is the type of the loading screen event. It is one of the constants that may be found above. 17 | Type int32 18 | // LoadingScreenID is the ID of the screen that was previously sent by the server in the ChangeDimension 19 | // packet. The server should validate that the ID matches the last one it sent. 20 | LoadingScreenID protocol.Optional[uint32] 21 | } 22 | 23 | // ID ... 24 | func (*ServerBoundLoadingScreen) ID() uint32 { 25 | return IDServerBoundLoadingScreen 26 | } 27 | 28 | func (pk *ServerBoundLoadingScreen) Marshal(io protocol.IO) { 29 | io.Varint32(&pk.Type) 30 | protocol.OptionalFunc(io, &pk.LoadingScreenID, io.Uint32) 31 | } 32 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/server_settings_request.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // ServerSettingsRequest is sent by the client to request the settings specific to the server. These settings 8 | // are shown in a separate tab client-side, and have the same structure as a custom form. 9 | type ServerSettingsRequest struct { 10 | // ServerSettingsRequest has no fields. 11 | } 12 | 13 | // ID ... 14 | func (*ServerSettingsRequest) ID() uint32 { 15 | return IDServerSettingsRequest 16 | } 17 | 18 | func (*ServerSettingsRequest) Marshal(protocol.IO) {} 19 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/server_settings_response.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // ServerSettingsResponse is optionally sent by the server in response to a ServerSettingsRequest from the 8 | // client. It is structured the same as a ModalFormRequest packet, and if filled out correctly, will show 9 | // a specific tab for the server in the settings of the client. A ModalFormResponse packet is sent by the 10 | // client in response to a ServerSettingsResponse, when the client fills out the settings and closes the 11 | // settings again. 12 | type ServerSettingsResponse struct { 13 | // FormID is an ID used to identify the form. The ID is saved by the client and sent back when the player 14 | // submits the form, so that the server can identify which form was submitted. 15 | FormID uint32 16 | // FormData is a JSON encoded object of form data. The content of the object differs, depending on the 17 | // type of the form sent, which is also set in the JSON. 18 | FormData []byte 19 | } 20 | 21 | // ID ... 22 | func (*ServerSettingsResponse) ID() uint32 { 23 | return IDServerSettingsResponse 24 | } 25 | 26 | func (pk *ServerSettingsResponse) Marshal(io protocol.IO) { 27 | io.Varuint32(&pk.FormID) 28 | io.ByteSlice(&pk.FormData) 29 | } 30 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/server_stats.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import "github.com/sandertv/gophertunnel/minecraft/protocol" 4 | 5 | // ServerStats is a packet sent from the server to the client to update the client on server statistics. It is purely 6 | // used for telemetry. 7 | type ServerStats struct { 8 | // ServerTime ... 9 | ServerTime float32 10 | // NetworkTime ... 11 | NetworkTime float32 12 | } 13 | 14 | // ID ... 15 | func (pk *ServerStats) ID() uint32 { 16 | return IDServerStats 17 | } 18 | 19 | func (pk *ServerStats) Marshal(io protocol.IO) { 20 | io.Float32(&pk.ServerTime) 21 | io.Float32(&pk.NetworkTime) 22 | } 23 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/server_to_client_handshake.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // ServerToClientHandshake is sent by the server to the client to complete the key exchange in order to 8 | // initialise encryption on client and server side. It is followed up by a ClientToServerHandshake packet 9 | // from the client. 10 | type ServerToClientHandshake struct { 11 | // JWT is a raw JWT token containing data such as the public key from the server, the algorithm used and 12 | // the server's token. It is used for the client to produce a shared secret. 13 | JWT []byte 14 | } 15 | 16 | // ID ... 17 | func (*ServerToClientHandshake) ID() uint32 { 18 | return IDServerToClientHandshake 19 | } 20 | 21 | func (pk *ServerToClientHandshake) Marshal(io protocol.IO) { 22 | io.ByteSlice(&pk.JWT) 23 | } 24 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/set_actor_data.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // SetActorData is sent by the server to update the entity metadata of an entity. It includes flags such as 8 | // if the entity is on fire, but also properties such as the air it has left until it starts drowning. 9 | type SetActorData struct { 10 | // EntityRuntimeID is the runtime ID of the entity. The runtime ID is unique for each world session, and 11 | // entities are generally identified in packets using this runtime ID. 12 | EntityRuntimeID uint64 13 | // EntityMetadata is a map of entity metadata, which includes flags and data properties that alter in 14 | // particular the way the entity looks. Flags include ones such as 'on fire' and 'sprinting'. 15 | // The metadata values are indexed by their property key. 16 | EntityMetadata map[uint32]any 17 | // EntityProperties is a list of properties that the entity inhibits. These properties define and alter specific 18 | // attributes of the entity. 19 | EntityProperties protocol.EntityProperties 20 | // Tick is the server tick at which the packet was sent. It is used in relation to CorrectPlayerMovePrediction. 21 | Tick uint64 22 | } 23 | 24 | // ID ... 25 | func (*SetActorData) ID() uint32 { 26 | return IDSetActorData 27 | } 28 | 29 | func (pk *SetActorData) Marshal(io protocol.IO) { 30 | io.Varuint64(&pk.EntityRuntimeID) 31 | io.EntityMetadata(&pk.EntityMetadata) 32 | protocol.Single(io, &pk.EntityProperties) 33 | io.Varuint64(&pk.Tick) 34 | } 35 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/set_actor_link.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // SetActorLink is sent by the server to initiate an entity link client-side, meaning one entity will start 8 | // riding another. 9 | type SetActorLink struct { 10 | // EntityLink is the link to be set client-side. It links two entities together, so that one entity rides 11 | // another. Note that players that see those entities later will not see the link, unless it is also sent 12 | // in the AddActor and AddPlayer packets. 13 | EntityLink protocol.EntityLink 14 | } 15 | 16 | // ID ... 17 | func (*SetActorLink) ID() uint32 { 18 | return IDSetActorLink 19 | } 20 | 21 | func (pk *SetActorLink) Marshal(io protocol.IO) { 22 | protocol.Single(io, &pk.EntityLink) 23 | } 24 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/set_actor_motion.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/go-gl/mathgl/mgl32" 5 | "github.com/sandertv/gophertunnel/minecraft/protocol" 6 | ) 7 | 8 | // SetActorMotion is sent by the server to change the client-side velocity of an entity. It is usually used 9 | // in combination with server-side movement calculation. 10 | type SetActorMotion struct { 11 | // EntityRuntimeID is the runtime ID of the entity. The runtime ID is unique for each world session, and 12 | // entities are generally identified in packets using this runtime ID. 13 | EntityRuntimeID uint64 14 | // Velocity is the new velocity the entity gets. This velocity will initiate the client-side movement of 15 | // the entity. 16 | Velocity mgl32.Vec3 17 | // Tick is the server tick at which the packet was sent. It is used in relation to CorrectPlayerMovePrediction. 18 | Tick uint64 19 | } 20 | 21 | // ID ... 22 | func (*SetActorMotion) ID() uint32 { 23 | return IDSetActorMotion 24 | } 25 | 26 | func (pk *SetActorMotion) Marshal(io protocol.IO) { 27 | io.Varuint64(&pk.EntityRuntimeID) 28 | io.Vec3(&pk.Velocity) 29 | io.Varuint64(&pk.Tick) 30 | } 31 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/set_commands_enabled.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // SetCommandsEnabled is sent by the server to enable or disable the ability to execute commands for the 8 | // client. If disabled, the client itself will stop the execution of commands. 9 | type SetCommandsEnabled struct { 10 | // Enabled defines if the commands should be enabled, or if false, disabled. 11 | Enabled bool 12 | } 13 | 14 | // ID ... 15 | func (*SetCommandsEnabled) ID() uint32 { 16 | return IDSetCommandsEnabled 17 | } 18 | 19 | func (pk *SetCommandsEnabled) Marshal(io protocol.IO) { 20 | io.Bool(&pk.Enabled) 21 | } 22 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/set_default_game_type.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // SetDefaultGameType is sent by the client when it toggles the default game type in the settings UI, and is 8 | // sent by the server when it actually changes the default game type, resulting in the toggle being changed 9 | // in the settings UI. 10 | type SetDefaultGameType struct { 11 | // GameType is the new game type that is set. When sent by the client, this is the requested new default 12 | // game type. 13 | GameType int32 14 | } 15 | 16 | // ID ... 17 | func (*SetDefaultGameType) ID() uint32 { 18 | return IDSetDefaultGameType 19 | } 20 | 21 | func (pk *SetDefaultGameType) Marshal(io protocol.IO) { 22 | io.Varint32(&pk.GameType) 23 | } 24 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/set_difficulty.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // SetDifficulty is sent by the server to update the client-side difficulty of the client. The actual effect 8 | // of this packet on the client isn't very significant, as the difficulty is handled server-side. 9 | type SetDifficulty struct { 10 | // Difficulty is the new difficulty that the world has. 11 | Difficulty uint32 12 | } 13 | 14 | // ID ... 15 | func (*SetDifficulty) ID() uint32 { 16 | return IDSetDifficulty 17 | } 18 | 19 | func (pk *SetDifficulty) Marshal(io protocol.IO) { 20 | io.Varuint32(&pk.Difficulty) 21 | } 22 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/set_health.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // SetHealth is sent by the server. It sets the health of the player it is sent to. The SetHealth packet 8 | // should no longer be used. Instead, the health attribute should be used so that the health and maximum 9 | // health may be changed directly. 10 | type SetHealth struct { 11 | // Health is the new health of the player. 12 | Health int32 13 | } 14 | 15 | // ID ... 16 | func (*SetHealth) ID() uint32 { 17 | return IDSetHealth 18 | } 19 | 20 | func (pk *SetHealth) Marshal(io protocol.IO) { 21 | io.Varint32(&pk.Health) 22 | } 23 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/set_hud.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | HudElementPaperDoll = iota 9 | HudElementArmour 10 | HudElementToolTips 11 | HudElementTouchControls 12 | HudElementCrosshair 13 | HudElementHotBar 14 | HudElementHealth 15 | HudElementProgressBar 16 | HudElementHunger 17 | HudElementAirBubbles 18 | HudElementHorseHealth 19 | HudElementStatusEffects 20 | HudElementItemText 21 | ) 22 | 23 | const ( 24 | HudVisibilityHide = iota 25 | HudVisibilityReset 26 | ) 27 | 28 | // SetHud is sent by the server to set the visibility of individual HUD elements on the client. It is 29 | // important to note that the client does not reset the state of the HUD elements after it leaves a server, 30 | // meaning they can leak into sessions on different servers. To be safe, you should reset the visibility of 31 | // all HUD elements when a player connects. 32 | type SetHud struct { 33 | // Elements is a list of HUD elements that are being modified. The values can be any of the HudElement 34 | // constants above. 35 | Elements []int32 36 | // Visibility represents the new visibility of the specified Elements. It can be any of the HudVisibility 37 | // constants above. 38 | Visibility int32 39 | } 40 | 41 | // ID ... 42 | func (*SetHud) ID() uint32 { 43 | return IDSetHud 44 | } 45 | 46 | func (pk *SetHud) Marshal(io protocol.IO) { 47 | protocol.FuncSlice(io, &pk.Elements, io.Varint32) 48 | io.Varint32(&pk.Visibility) 49 | } 50 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/set_last_hurt_by.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // SetLastHurtBy is sent by the server to let the client know what entity type it was last hurt by. At this 8 | // moment, the packet is useless and should not be used. There is no behaviour that depends on if this 9 | // packet is sent or not. 10 | type SetLastHurtBy struct { 11 | // EntityType is the numerical type of the entity that the player was last hurt by. 12 | EntityType int32 13 | } 14 | 15 | // ID ... 16 | func (*SetLastHurtBy) ID() uint32 { 17 | return IDSetLastHurtBy 18 | } 19 | 20 | func (pk *SetLastHurtBy) Marshal(io protocol.IO) { 21 | io.Varint32(&pk.EntityType) 22 | } 23 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/set_local_player_as_initialised.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // SetLocalPlayerAsInitialised is sent by the client in response to a PlayStatus packet with the status set 8 | // to 3. The packet marks the moment at which the client is fully initialised and can receive any packet 9 | // without discarding it. 10 | type SetLocalPlayerAsInitialised struct { 11 | // EntityRuntimeID is the entity runtime ID the player was assigned earlier in the login sequence in the 12 | // StartGame packet. 13 | EntityRuntimeID uint64 14 | } 15 | 16 | // ID ... 17 | func (*SetLocalPlayerAsInitialised) ID() uint32 { 18 | return IDSetLocalPlayerAsInitialised 19 | } 20 | 21 | func (pk *SetLocalPlayerAsInitialised) Marshal(io protocol.IO) { 22 | io.Varuint64(&pk.EntityRuntimeID) 23 | } 24 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/set_movement_authority.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // SetMovementAuthority is sent by the server to the client to change its movement mode. 8 | type SetMovementAuthority struct { 9 | // MovementType specifies the way the server handles player movement. Available options are 10 | // protocol.PlayerMovementModeClient, protocol.PlayerMovementModeServer and 11 | // protocol.PlayerMovementModeServerWithRewind, where the server authoritative types result 12 | // in the client sending PlayerAuthInput packets instead of MovePlayer packets and the rewind mode 13 | // requires sending the tick of movement and several actions. 14 | MovementType byte 15 | } 16 | 17 | // ID ... 18 | func (*SetMovementAuthority) ID() uint32 { 19 | return IDSetMovementAuthority 20 | } 21 | 22 | func (pk *SetMovementAuthority) Marshal(io protocol.IO) { 23 | io.Uint8(&pk.MovementType) 24 | } 25 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/set_player_game_type.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | GameTypeSurvival = iota 9 | GameTypeCreative 10 | GameTypeAdventure 11 | GameTypeSurvivalSpectator 12 | GameTypeCreativeSpectator 13 | GameTypeDefault 14 | GameTypeSpectator 15 | ) 16 | 17 | // SetPlayerGameType is sent by the server to update the game type, which is otherwise known as the game mode, 18 | // of a player. 19 | type SetPlayerGameType struct { 20 | // GameType is the new game type of the player. It is one of the constants that can be found above. Some 21 | // of these game types require additional flags to be set in an AdventureSettings packet for the game mode 22 | // to obtain its full functionality. 23 | GameType int32 24 | } 25 | 26 | // ID ... 27 | func (*SetPlayerGameType) ID() uint32 { 28 | return IDSetPlayerGameType 29 | } 30 | 31 | func (pk *SetPlayerGameType) Marshal(io protocol.IO) { 32 | io.Varint32(&pk.GameType) 33 | } 34 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/set_score.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | ScoreboardActionModify = iota 9 | ScoreboardActionRemove 10 | ) 11 | 12 | // SetScore is sent by the server to send the contents of a scoreboard to the player. It may be used to either 13 | // add, remove or edit entries on the scoreboard. 14 | type SetScore struct { 15 | // ActionType is the type of the action to execute upon the scoreboard with the entries that the packet 16 | // has. If ActionType is ScoreboardActionModify, all entries will be added to the scoreboard if not yet 17 | // present, or modified if already present. If set to ScoreboardActionRemove, all scoreboard entries set 18 | // will be removed from the scoreboard. 19 | ActionType byte 20 | // Entries is a list of all entries that the client should operate on. When modifying, it will add or 21 | // modify all entries, whereas when removing, it will remove all entries. 22 | Entries []protocol.ScoreboardEntry 23 | } 24 | 25 | // ID ... 26 | func (*SetScore) ID() uint32 { 27 | return IDSetScore 28 | } 29 | 30 | func (pk *SetScore) Marshal(io protocol.IO) { 31 | io.Uint8(&pk.ActionType) 32 | switch pk.ActionType { 33 | case ScoreboardActionRemove: 34 | protocol.FuncIOSlice(io, &pk.Entries, protocol.ScoreRemoveEntry) 35 | case ScoreboardActionModify: 36 | protocol.Slice(io, &pk.Entries) 37 | default: 38 | io.UnknownEnumOption(pk.ActionType, "set score action type") 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/set_scoreboard_identity.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | ScoreboardIdentityActionRegister = iota 9 | ScoreboardIdentityActionClear 10 | ) 11 | 12 | // SetScoreboardIdentity is sent by the server to change the identity type of one of the entries on a 13 | // scoreboard. This is used to change, for example, an entry pointing to a player, to a fake player when it 14 | // leaves the server, and to change it back to a real player when it joins again. 15 | // In non-vanilla situations, the packet is quite useless. 16 | type SetScoreboardIdentity struct { 17 | // ActionType is the type of the action to execute. The action is either ScoreboardIdentityActionRegister 18 | // to associate an identity with the entry, or ScoreboardIdentityActionClear to remove associations with 19 | // an entity. 20 | ActionType byte 21 | // Entries is a list of all entries in the packet. Each of these entries points to one of the entries on 22 | // a scoreboard. Depending on ActionType, their identity will either be registered or cleared. 23 | Entries []protocol.ScoreboardIdentityEntry 24 | } 25 | 26 | // ID ... 27 | func (*SetScoreboardIdentity) ID() uint32 { 28 | return IDSetScoreboardIdentity 29 | } 30 | 31 | func (pk *SetScoreboardIdentity) Marshal(io protocol.IO) { 32 | io.Uint8(&pk.ActionType) 33 | switch pk.ActionType { 34 | case ScoreboardIdentityActionRegister: 35 | protocol.Slice(io, &pk.Entries) 36 | case ScoreboardIdentityActionClear: 37 | protocol.FuncIOSlice(io, &pk.Entries, protocol.ScoreboardIdentityClearEntry) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/set_spawn_position.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | SpawnTypePlayer = iota 9 | SpawnTypeWorld 10 | ) 11 | 12 | // SetSpawnPosition is sent by the server to update the spawn position of a player, for example when sleeping 13 | // in a bed. 14 | type SetSpawnPosition struct { 15 | // SpawnType is the type of spawn to set. It is either SpawnTypePlayer or SpawnTypeWorld, and specifies 16 | // the behaviour of the spawn set. If SpawnTypeWorld is set, the position to which compasses will point is 17 | // also changed. 18 | SpawnType int32 19 | // Position is the new position of the spawn that was set. If SpawnType is SpawnTypeWorld, compasses will 20 | // point to this position. As of 1.16, Position is always the position of the player. 21 | Position protocol.BlockPos 22 | // Dimension is the ID of the dimension that had its spawn updated. This is specifically relevant for 23 | // behaviour added in 1.16 such as the respawn anchor, which allows setting the spawn in a specific 24 | // dimension. 25 | Dimension int32 26 | // SpawnPosition is a new field added in 1.16. It holds the spawn position of the world. This spawn 27 | // position is {-2147483648, -2147483648, -2147483648} for a default spawn position. 28 | SpawnPosition protocol.BlockPos 29 | } 30 | 31 | // ID ... 32 | func (*SetSpawnPosition) ID() uint32 { 33 | return IDSetSpawnPosition 34 | } 35 | 36 | func (pk *SetSpawnPosition) Marshal(io protocol.IO) { 37 | io.Varint32(&pk.SpawnType) 38 | io.UBlockPos(&pk.Position) 39 | io.Varint32(&pk.Dimension) 40 | io.UBlockPos(&pk.SpawnPosition) 41 | } 42 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/set_time.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // SetTime is sent by the server to update the current time client-side. The client actually advances time 8 | // client-side by itself, so this packet does not need to be sent each tick. It is merely a means of 9 | // synchronising time between server and client. 10 | type SetTime struct { 11 | // Time is the current time. The time is not limited to 24000 (time of day), but continues progressing 12 | // after that. 13 | Time int32 14 | } 15 | 16 | // ID ... 17 | func (*SetTime) ID() uint32 { 18 | return IDSetTime 19 | } 20 | 21 | func (pk *SetTime) Marshal(io protocol.IO) { 22 | io.Varint32(&pk.Time) 23 | } 24 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/settings_command.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // SettingsCommand is sent by the client when it changes a setting in the settings that results in the issuing 8 | // of a command to the server, such as when Show Coordinates is enabled. 9 | type SettingsCommand struct { 10 | // CommandLine is the full command line that was sent to the server as a result of the setting that the 11 | // client changed. 12 | CommandLine string 13 | // SuppressOutput specifies if the client requests the suppressing of the output of the command that was 14 | // executed. Generally this is set to true, as the client won't need a message to confirm the output of 15 | // the change. 16 | SuppressOutput bool 17 | } 18 | 19 | // ID ... 20 | func (*SettingsCommand) ID() uint32 { 21 | return IDSettingsCommand 22 | } 23 | 24 | func (pk *SettingsCommand) Marshal(io protocol.IO) { 25 | io.String(&pk.CommandLine) 26 | io.Bool(&pk.SuppressOutput) 27 | } 28 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/show_credits.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | ShowCreditsStatusStart = iota 9 | ShowCreditsStatusEnd 10 | ) 11 | 12 | // ShowCredits is sent by the server to show the Minecraft credits screen to the client. It is typically sent 13 | // when the player beats the ender dragon and leaves the End. 14 | type ShowCredits struct { 15 | // PlayerRuntimeID is the entity runtime ID of the player to show the credits to. It's not clear why this 16 | // field is actually here in the first place. 17 | PlayerRuntimeID uint64 18 | // StatusType is the status type of the credits. It is one of the constants above, and either starts or 19 | // stops the credits. 20 | StatusType int32 21 | } 22 | 23 | // ID ... 24 | func (*ShowCredits) ID() uint32 { 25 | return IDShowCredits 26 | } 27 | 28 | func (pk *ShowCredits) Marshal(io protocol.IO) { 29 | io.Varuint64(&pk.PlayerRuntimeID) 30 | io.Varint32(&pk.StatusType) 31 | } 32 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/show_profile.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // ShowProfile is sent by the server to show the XBOX Live profile of one player to another. 8 | type ShowProfile struct { 9 | // XUID is the XBOX Live User ID of the player whose profile should be shown to the player. If it is not 10 | // a valid XUID, the client ignores the packet. 11 | XUID string 12 | } 13 | 14 | // ID ... 15 | func (*ShowProfile) ID() uint32 { 16 | return IDShowProfile 17 | } 18 | 19 | func (pk *ShowProfile) Marshal(io protocol.IO) { 20 | io.String(&pk.XUID) 21 | } 22 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/show_store_offer.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | StoreOfferTypeMarketplace = iota 9 | StoreOfferTypeDressingRoom 10 | StoreOfferTypeServerPage 11 | ) 12 | 13 | // ShowStoreOffer is sent by the server to show a Marketplace store offer to a player. It opens a window 14 | // client-side that displays the item. 15 | // The ShowStoreOffer packet only works on the partnered servers: Servers that are not partnered will not have 16 | // a store buttons show up in the in-game pause menu and will, as a result, not be able to open store offers 17 | // on the client side. Sending the packet does therefore not work when using a proxy that is not connected to 18 | // with the domain of one of the partnered servers. 19 | type ShowStoreOffer struct { 20 | // OfferID is a string that identifies the offer for which a window should be opened. ID should be in the format of 21 | // a UUID, however it can be left empty if StoreOfferTypeServerPage is used. 22 | OfferID string 23 | // Type is the type of the store offer that is being shown to the player. It is one of the constants that may be 24 | // found above. 25 | Type byte 26 | } 27 | 28 | // ID ... 29 | func (*ShowStoreOffer) ID() uint32 { 30 | return IDShowStoreOffer 31 | } 32 | 33 | func (pk *ShowStoreOffer) Marshal(io protocol.IO) { 34 | io.String(&pk.OfferID) 35 | io.Uint8(&pk.Type) 36 | } 37 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/simple_event.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | SimpleEventCommandsEnabled = iota + 1 9 | SimpleEventCommandsDisabled 10 | SimpleEventUnlockWorldTemplateSettings 11 | ) 12 | 13 | // SimpleEvent is sent by the server to send a 'simple event' to the client, meaning an event without any 14 | // additional event data. The event is typically used by the client for telemetry. 15 | type SimpleEvent struct { 16 | // EventType is the type of the event to be called. It is one of the constants that may be found above. 17 | EventType int16 18 | } 19 | 20 | // ID ... 21 | func (*SimpleEvent) ID() uint32 { 22 | return IDSimpleEvent 23 | } 24 | 25 | func (pk *SimpleEvent) Marshal(io protocol.IO) { 26 | io.Int16(&pk.EventType) 27 | } 28 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/simulation_type.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import "github.com/sandertv/gophertunnel/minecraft/protocol" 4 | 5 | const ( 6 | SimulationTypeGame byte = iota 7 | SimulationTypeEditor 8 | SimulationTypeTest 9 | SimulationTypeInvalid 10 | ) 11 | 12 | // SimulationType is an in-progress packet. We currently do not know the use case. 13 | type SimulationType struct { 14 | // SimulationType is the simulation type selected. 15 | SimulationType byte 16 | } 17 | 18 | // ID ... 19 | func (*SimulationType) ID() uint32 { 20 | return IDSimulationType 21 | } 22 | 23 | func (pk *SimulationType) Marshal(io protocol.IO) { 24 | io.Uint8(&pk.SimulationType) 25 | } 26 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/spawn_experience_orb.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/go-gl/mathgl/mgl32" 5 | "github.com/sandertv/gophertunnel/minecraft/protocol" 6 | ) 7 | 8 | // SpawnExperienceOrb is sent by the server to spawn an experience orb entity client-side. Much like the 9 | // AddPainting packet, it is one of the few packets that spawn an entity without using the AddActor packet. 10 | type SpawnExperienceOrb struct { 11 | // Position is the position to spawn the experience orb on. If the entity is on a distance that the player 12 | // cannot see it, the entity will still show up if the player moves closer. 13 | Position mgl32.Vec3 14 | // ExperienceAmount is the amount of experience in experience points that the orb carries. The client-side 15 | // size of the orb depends on the amount of experience in the orb: There are 11 possible sizes for the 16 | // orb, for 1–2, 3–6, 7–16, 17–36, 37–72, 73–148, 149–306, 307–616, 617–1236, 1237–2476, and 2477 and up. 17 | ExperienceAmount int32 18 | } 19 | 20 | // ID ... 21 | func (*SpawnExperienceOrb) ID() uint32 { 22 | return IDSpawnExperienceOrb 23 | } 24 | 25 | func (pk *SpawnExperienceOrb) Marshal(io protocol.IO) { 26 | io.Vec3(&pk.Position) 27 | io.Varint32(&pk.ExperienceAmount) 28 | } 29 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/stop_sound.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // StopSound is sent by the server to stop a sound playing to the player, such as a playing music disk track 8 | // or other long-lasting sounds. 9 | type StopSound struct { 10 | // SoundName is the name of the sound that should be stopped from playing. If no sound with this name is 11 | // currently active, the packet is ignored. 12 | SoundName string 13 | // StopAll specifies if all sounds currently playing to the player should be stopped. If set to true, the 14 | // SoundName field may be left empty. 15 | StopAll bool 16 | // StopMusicLegacy is currently unknown. 17 | StopMusicLegacy bool 18 | } 19 | 20 | // ID ... 21 | func (*StopSound) ID() uint32 { 22 | return IDStopSound 23 | } 24 | 25 | func (pk *StopSound) Marshal(io protocol.IO) { 26 | io.String(&pk.SoundName) 27 | io.Bool(&pk.StopAll) 28 | io.Bool(&pk.StopMusicLegacy) 29 | } 30 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/structure_template_data_request.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | StructureTemplateRequestExportFromSave = iota + 1 9 | StructureTemplateRequestExportFromLoad 10 | StructureTemplateRequestQuerySavedStructure 11 | ) 12 | 13 | // StructureTemplateDataRequest is sent by the client to request data of a structure. 14 | type StructureTemplateDataRequest struct { 15 | // StructureName is the name of the structure that was set in the structure block's UI. This is the name 16 | // used to export the structure to a file. 17 | StructureName string 18 | // Position is the position of the structure block that has its template data requested. 19 | Position protocol.BlockPos 20 | // Settings is a struct of settings that should be used for exporting the structure. These settings are 21 | // identical to the last sent in the StructureBlockUpdate packet by the client. 22 | Settings protocol.StructureSettings 23 | // RequestType specifies the type of template data request that the player sent. It is one of the 24 | // constants found above. 25 | RequestType byte 26 | } 27 | 28 | // ID ... 29 | func (pk *StructureTemplateDataRequest) ID() uint32 { 30 | return IDStructureTemplateDataRequest 31 | } 32 | 33 | func (pk *StructureTemplateDataRequest) Marshal(io protocol.IO) { 34 | io.String(&pk.StructureName) 35 | io.UBlockPos(&pk.Position) 36 | protocol.Single(io, &pk.Settings) 37 | io.Uint8(&pk.RequestType) 38 | } 39 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/structure_template_data_response.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/nbt" 5 | "github.com/sandertv/gophertunnel/minecraft/protocol" 6 | ) 7 | 8 | const ( 9 | StructureTemplateResponseExport = iota + 1 10 | StructureTemplateResponseQuery 11 | ) 12 | 13 | // StructureTemplateDataResponse is sent by the server to send data of a structure to the client in response 14 | // to a StructureTemplateDataRequest packet. 15 | type StructureTemplateDataResponse struct { 16 | // StructureName is the name of the structure that was requested. This is the name used to export the 17 | // structure to a file. 18 | StructureName string 19 | // Success specifies if a structure template was found by the StructureName that was sent in a 20 | // StructureTemplateDataRequest packet. 21 | Success bool 22 | // ResponseType specifies the response type of the packet. This depends on the RequestType field sent in 23 | // the StructureTemplateDataRequest packet and is one of the constants above. 24 | ResponseType byte 25 | // StructureTemplate holds the data of the structure template. 26 | StructureTemplate map[string]any 27 | } 28 | 29 | // ID ... 30 | func (pk *StructureTemplateDataResponse) ID() uint32 { 31 | return IDStructureTemplateDataResponse 32 | } 33 | 34 | func (pk *StructureTemplateDataResponse) Marshal(io protocol.IO) { 35 | io.String(&pk.StructureName) 36 | io.Bool(&pk.Success) 37 | if pk.Success { 38 | io.NBT(&pk.StructureTemplate, nbt.NetworkLittleEndian) 39 | } 40 | io.Uint8(&pk.ResponseType) 41 | } 42 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/sub_chunk.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // SubChunk sends data about multiple sub-chunks around a center point. 8 | type SubChunk struct { 9 | // CacheEnabled is whether the sub-chunk caching is enabled or not. 10 | CacheEnabled bool 11 | // Dimension is the dimension the sub-chunks are in. 12 | Dimension int32 13 | // Position is an absolute sub-chunk center point that every SubChunkRequest uses as a reference. 14 | Position protocol.SubChunkPos 15 | // SubChunkEntries contains sub-chunk entries relative to the center point. 16 | SubChunkEntries []protocol.SubChunkEntry 17 | } 18 | 19 | // ID ... 20 | func (*SubChunk) ID() uint32 { 21 | return IDSubChunk 22 | } 23 | 24 | func (pk *SubChunk) Marshal(io protocol.IO) { 25 | io.Bool(&pk.CacheEnabled) 26 | io.Varint32(&pk.Dimension) 27 | io.SubChunkPos(&pk.Position) 28 | if pk.CacheEnabled { 29 | protocol.SliceUint32Length(io, &pk.SubChunkEntries) 30 | } else { 31 | protocol.FuncIOSliceUint32Length(io, &pk.SubChunkEntries, protocol.SubChunkEntryNoCache) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/sub_chunk_request.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // SubChunkRequest requests specific sub-chunks from the server using a center point. 8 | type SubChunkRequest struct { 9 | // Dimension is the dimension of the sub-chunk. 10 | Dimension int32 11 | // Position is an absolute sub-chunk center point used as a base point for all sub-chunks requested. The X and Z 12 | // coordinates represent the chunk coordinates, while the Y coordinate is the absolute sub-chunk index. 13 | Position protocol.SubChunkPos 14 | // Offsets contains all requested offsets around the center point. 15 | Offsets []protocol.SubChunkOffset 16 | } 17 | 18 | // ID ... 19 | func (*SubChunkRequest) ID() uint32 { 20 | return IDSubChunkRequest 21 | } 22 | 23 | func (pk *SubChunkRequest) Marshal(io protocol.IO) { 24 | io.Varint32(&pk.Dimension) 25 | io.SubChunkPos(&pk.Position) 26 | protocol.SliceUint32Length(io, &pk.Offsets) 27 | } 28 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/sub_client_login.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // SubClientLogin is sent when a sub-client joins the server while another client is already connected to it. 8 | // The packet is sent as a result of split-screen game play, and allows up to four players to play using the 9 | // same network connection. After an initial Login packet from the 'main' client, each sub-client that 10 | // connects sends a SubClientLogin to request their own login. 11 | type SubClientLogin struct { 12 | // ConnectionRequest is a string containing information about the player and JWTs that may be used to 13 | // verify if the player is connected to XBOX Live. The connection request also contains the necessary 14 | // client public key to initiate encryption. 15 | // The ConnectionRequest in this packet is identical to the one found in the Login packet. 16 | ConnectionRequest []byte 17 | } 18 | 19 | // ID ... 20 | func (*SubClientLogin) ID() uint32 { 21 | return IDSubClientLogin 22 | } 23 | 24 | func (pk *SubClientLogin) Marshal(io protocol.IO) { 25 | io.ByteSlice(&pk.ConnectionRequest) 26 | } 27 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/sync_actor_property.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/nbt" 5 | "github.com/sandertv/gophertunnel/minecraft/protocol" 6 | ) 7 | 8 | // SyncActorProperty is an alternative to synced actor data. 9 | type SyncActorProperty struct { 10 | // PropertyData ... 11 | PropertyData map[string]any 12 | } 13 | 14 | // ID ... 15 | func (*SyncActorProperty) ID() uint32 { 16 | return IDSyncActorProperty 17 | } 18 | 19 | func (pk *SyncActorProperty) Marshal(io protocol.IO) { 20 | io.NBT(&pk.PropertyData, nbt.NetworkLittleEndian) 21 | } 22 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/take_item_actor.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // TakeItemActor is sent by the server when a player picks up an item entity. It makes the item entity 8 | // disappear to viewers and shows the pick-up animation. 9 | type TakeItemActor struct { 10 | // ItemEntityRuntimeID is the entity runtime ID of the item that is being taken by another entity. It will 11 | // disappear to viewers after showing the pick-up animation. 12 | ItemEntityRuntimeID uint64 13 | // TakerEntityRuntimeID is the runtime ID of the entity that took the item, which is usually a player, but 14 | // could be another entity like a zombie too. 15 | TakerEntityRuntimeID uint64 16 | } 17 | 18 | // ID ... 19 | func (*TakeItemActor) ID() uint32 { 20 | return IDTakeItemActor 21 | } 22 | 23 | func (pk *TakeItemActor) Marshal(io protocol.IO) { 24 | io.Varuint64(&pk.ItemEntityRuntimeID) 25 | io.Varuint64(&pk.TakerEntityRuntimeID) 26 | } 27 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/ticking_areas_load_status.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import "github.com/sandertv/gophertunnel/minecraft/protocol" 4 | 5 | // TickingAreasLoadStatus is sent by the server to the client to notify the client of a ticking area's loading status. 6 | type TickingAreasLoadStatus struct { 7 | // Preload is true if the server is waiting for the area's preload. 8 | Preload bool 9 | } 10 | 11 | // ID ... 12 | func (*TickingAreasLoadStatus) ID() uint32 { 13 | return IDTickingAreasLoadStatus 14 | } 15 | 16 | func (pk *TickingAreasLoadStatus) Marshal(io protocol.IO) { 17 | io.Bool(&pk.Preload) 18 | } 19 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/toast_request.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import "github.com/sandertv/gophertunnel/minecraft/protocol" 4 | 5 | // ToastRequest is a packet sent from the server to the client to display a toast to the top of the screen. These toasts 6 | // are the same as the ones seen when, for example, loading a new resource pack or obtaining an achievement. 7 | type ToastRequest struct { 8 | // Title is the title of the toast. 9 | Title string 10 | // Message is the message that the toast may contain alongside the title. 11 | Message string 12 | } 13 | 14 | // ID ... 15 | func (*ToastRequest) ID() uint32 { 16 | return IDToastRequest 17 | } 18 | 19 | func (pk *ToastRequest) Marshal(io protocol.IO) { 20 | io.String(&pk.Title) 21 | io.String(&pk.Message) 22 | } 23 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/transfer.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // Transfer is sent by the server to transfer a player from the current server to another. Doing so will 8 | // fully disconnect the client, bring it back to the main menu and make it connect to the next server. 9 | type Transfer struct { 10 | // Address is the address of the new server, which might be either a hostname or an actual IP address. 11 | Address string 12 | // Port is the UDP port of the new server. 13 | Port uint16 14 | // ReloadWorld currently has an unknown usage. 15 | ReloadWorld bool 16 | } 17 | 18 | // ID ... 19 | func (*Transfer) ID() uint32 { 20 | return IDTransfer 21 | } 22 | 23 | func (pk *Transfer) Marshal(io protocol.IO) { 24 | io.String(&pk.Address) 25 | io.Uint16(&pk.Port) 26 | io.Bool(&pk.ReloadWorld) 27 | } 28 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/trim_data.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // TrimData is sent by the server to the client when they first join the server. It contains a list of all the patterns 8 | // and materials that can be applied via armour trims. 9 | type TrimData struct { 10 | // Patterns is a list of patterns that can be applied to armour. Each pattern has its own style and texture that is 11 | // defined through resource packs. 12 | Patterns []protocol.TrimPattern 13 | // Materials is a list of materials that can be applied to armour. These are mostly different ores that have different 14 | // colours for more customization. 15 | Materials []protocol.TrimMaterial 16 | } 17 | 18 | // ID ... 19 | func (*TrimData) ID() uint32 { 20 | return IDTrimData 21 | } 22 | 23 | func (pk *TrimData) Marshal(io protocol.IO) { 24 | protocol.Slice(io, &pk.Patterns) 25 | protocol.Slice(io, &pk.Materials) 26 | } 27 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/unknown.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "fmt" 5 | "github.com/sandertv/gophertunnel/minecraft/protocol" 6 | ) 7 | 8 | // Unknown is an implementation of the Packet interface for unknown/unimplemented packets. It holds the packet 9 | // ID and the raw payload. It serves as a way to read raw unknown packets and forward them to another 10 | // connection, without necessarily implementing them. 11 | type Unknown struct { 12 | // PacketID is the packet ID of the packet. 13 | PacketID uint32 14 | // Payload is the raw payload of the packet. 15 | Payload []byte 16 | } 17 | 18 | // ID ... 19 | func (pk *Unknown) ID() uint32 { 20 | return pk.PacketID 21 | } 22 | 23 | func (pk *Unknown) Marshal(io protocol.IO) { 24 | io.Bytes(&pk.Payload) 25 | } 26 | 27 | // String implements a hex representation of an unknown packet, so that it is easier to read and identify 28 | // unknown incoming packets. 29 | func (pk *Unknown) String() string { 30 | return fmt.Sprintf("{ID:0x%x Payload:0x%x}", pk.PacketID, pk.Payload) 31 | } 32 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/unlocked_recipes.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | UnlockedRecipesTypeEmpty = iota 9 | UnlockedRecipesTypeInitiallyUnlocked 10 | UnlockedRecipesTypeNewlyUnlocked 11 | UnlockedRecipesTypeRemoveUnlocked 12 | UnlockedRecipesTypeRemoveAllUnlocked 13 | ) 14 | 15 | // UnlockedRecipes gives the client a list of recipes that have been unlocked, restricting the recipes that appear in 16 | // the recipe book. 17 | type UnlockedRecipes struct { 18 | // UnlockType is the type of unlock that the packet represents, and can either be adding or removing a list of recipes. 19 | // It is one of the constants listed above. 20 | UnlockType uint32 21 | // Recipes is a list of recipe names that have been unlocked. 22 | Recipes []string 23 | } 24 | 25 | // ID ... 26 | func (*UnlockedRecipes) ID() uint32 { 27 | return IDUnlockedRecipes 28 | } 29 | 30 | func (pk *UnlockedRecipes) Marshal(io protocol.IO) { 31 | io.Uint32(&pk.UnlockType) 32 | protocol.FuncSlice(io, &pk.Recipes, io.String) 33 | } 34 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/update_abilities.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // UpdateAbilities is a packet sent from the server to the client to update the abilities of the player. It, along with 8 | // the UpdateAdventureSettings packet, are replacements of the AdventureSettings packet since v1.19.10. 9 | type UpdateAbilities struct { 10 | // AbilityData represents various data about the abilities of a player, such as ability layers or permissions. 11 | AbilityData protocol.AbilityData 12 | } 13 | 14 | // ID ... 15 | func (*UpdateAbilities) ID() uint32 { 16 | return IDUpdateAbilities 17 | } 18 | 19 | func (pk *UpdateAbilities) Marshal(io protocol.IO) { 20 | protocol.Single(io, &pk.AbilityData) 21 | } 22 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/update_adventure_settings.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // UpdateAdventureSettings is a packet sent from the server to the client to update the adventure settings of the player. 8 | // It, along with the UpdateAbilities packet, are replacements of the AdventureSettings packet since v1.19.10. 9 | type UpdateAdventureSettings struct { 10 | // NoPvM is a boolean indicating whether the player is allowed to fight mobs or not. 11 | NoPvM bool 12 | // NoMvP is a boolean indicating whether mobs are allowed to fight the player or not. It is unclear why this is sent 13 | // to the client. 14 | NoMvP bool 15 | // ImmutableWorld is a boolean indicating whether the player is allowed to modify the world or not. 16 | ImmutableWorld bool 17 | // ShowNameTags is a boolean indicating whether player name tags are shown or not. 18 | ShowNameTags bool 19 | // AutoJump is a boolean indicating whether the player is allowed to jump automatically or not. 20 | AutoJump bool 21 | } 22 | 23 | // ID ... 24 | func (*UpdateAdventureSettings) ID() uint32 { 25 | return IDUpdateAdventureSettings 26 | } 27 | 28 | func (pk *UpdateAdventureSettings) Marshal(io protocol.IO) { 29 | io.Bool(&pk.NoPvM) 30 | io.Bool(&pk.NoMvP) 31 | io.Bool(&pk.ImmutableWorld) 32 | io.Bool(&pk.ShowNameTags) 33 | io.Bool(&pk.AutoJump) 34 | } 35 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/update_attributes.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // UpdateAttributes is sent by the server to update an amount of attributes of any entity in the world. These 8 | // attributes include ones such as the health or the movement speed of the entity. 9 | type UpdateAttributes struct { 10 | // EntityRuntimeID is the runtime ID of the entity. The runtime ID is unique for each world session, and 11 | // entities are generally identified in packets using this runtime ID. 12 | EntityRuntimeID uint64 13 | // Attributes is a slice of new attributes that the entity gets. It includes attributes such as its 14 | // health, movement speed, etc. Note that only changed attributes have to be sent in this packet. It is 15 | // not required to send attributes that did not have their values changed. 16 | Attributes []protocol.Attribute 17 | // Tick is the server tick at which the packet was sent. It is used in relation to CorrectPlayerMovePrediction. 18 | Tick uint64 19 | } 20 | 21 | // ID ... 22 | func (*UpdateAttributes) ID() uint32 { 23 | return IDUpdateAttributes 24 | } 25 | 26 | func (pk *UpdateAttributes) Marshal(io protocol.IO) { 27 | io.Varuint64(&pk.EntityRuntimeID) 28 | protocol.Slice(io, &pk.Attributes) 29 | io.Varuint64(&pk.Tick) 30 | } 31 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/update_block.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | BlockUpdateNeighbours = 1 << iota 9 | BlockUpdateNetwork 10 | BlockUpdateNoGraphics 11 | BlockUpdatePriority 12 | ) 13 | 14 | // UpdateBlock is sent by the server to update a block client-side, without resending the entire chunk that 15 | // the block is located in. It is particularly useful for small modifications like block breaking/placing. 16 | type UpdateBlock struct { 17 | // Position is the block position at which a block is updated. 18 | Position protocol.BlockPos 19 | // NewBlockRuntimeID is the runtime ID of the block that is placed at Position after sending the packet 20 | // to the client. 21 | NewBlockRuntimeID uint32 22 | // Flags is a combination of flags that specify the way the block is updated client-side. It is a 23 | // combination of the flags above, but typically sending only the BlockUpdateNetwork flag is sufficient. 24 | Flags uint32 25 | // Layer is the world layer on which the block is updated. For most blocks, this is the first layer, as 26 | // that layer is the default layer to place blocks on, but for blocks inside of each other, this differs. 27 | Layer uint32 28 | } 29 | 30 | // ID ... 31 | func (*UpdateBlock) ID() uint32 { 32 | return IDUpdateBlock 33 | } 34 | 35 | func (pk *UpdateBlock) Marshal(io protocol.IO) { 36 | io.UBlockPos(&pk.Position) 37 | io.Varuint32(&pk.NewBlockRuntimeID) 38 | io.Varuint32(&pk.Flags) 39 | io.Varuint32(&pk.Layer) 40 | } 41 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/update_client_input_locks.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/go-gl/mathgl/mgl32" 5 | "github.com/sandertv/gophertunnel/minecraft/protocol" 6 | ) 7 | 8 | const ( 9 | ClientInputLockCamera = 1 << (iota + 1) 10 | ClientInputLockMovement 11 | ) 12 | 13 | // UpdateClientInputLocks is sent by the server to the client to lock either the camera or physical movement of the client. 14 | type UpdateClientInputLocks struct { 15 | // Locks is a bitset that controls which locks are active. It is a combination of the constants above. If the camera 16 | // is locked, then the player cannot change their pitch or yaw. If movement is locked, the player cannot move in any 17 | // direction, they cannot jump, sneak or mount/dismount from any entities. 18 | Locks uint32 19 | // Position is the server's position of the client at the time the packet was sent. It is unclear what the exact 20 | // purpose of this field is. 21 | Position mgl32.Vec3 22 | } 23 | 24 | // ID ... 25 | func (pk *UpdateClientInputLocks) ID() uint32 { 26 | return IDUpdateClientInputLocks 27 | } 28 | 29 | func (pk *UpdateClientInputLocks) Marshal(io protocol.IO) { 30 | io.Varuint32(&pk.Locks) 31 | io.Vec3(&pk.Position) 32 | } 33 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/update_client_options.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | GraphicsModeSimple = iota 9 | GraphicsModeFancy 10 | GraphicsModeAdvanced 11 | GraphicsModeRayTraced 12 | ) 13 | 14 | // UpdateClientOptions is sent by the client when some of the client's options are updated, such as the 15 | // graphics mode. 16 | type UpdateClientOptions struct { 17 | // GraphicsMode is the graphics mode that the client is using. It is one of the constants above. 18 | GraphicsMode protocol.Optional[byte] 19 | } 20 | 21 | // ID ... 22 | func (*UpdateClientOptions) ID() uint32 { 23 | return IDUpdateClientOptions 24 | } 25 | 26 | func (pk *UpdateClientOptions) Marshal(io protocol.IO) { 27 | protocol.OptionalFunc(io, &pk.GraphicsMode, io.Uint8) 28 | } 29 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/update_player_game_type.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | // UpdatePlayerGameType is sent by the server to change the game mode of a player. It is functionally 8 | // identical to the SetPlayerGameType packet. 9 | type UpdatePlayerGameType struct { 10 | // GameType is the new game type of the player. It is one of the constants that can be found in 11 | // set_player_game_type.go. Some of these game types require additional flags to be set in an 12 | // UpdateAbilities packet for the game mode to obtain its full functionality. 13 | GameType int32 14 | // PlayerUniqueID is the entity unique ID of the player that should have its game mode updated. If this 15 | // packet is sent to other clients with the player unique ID of another player, nothing happens. 16 | PlayerUniqueID int64 17 | // Tick is the server tick at which the packet was sent. It is used in relation to CorrectPlayerMovePrediction. 18 | Tick uint64 19 | } 20 | 21 | // ID ... 22 | func (*UpdatePlayerGameType) ID() uint32 { 23 | return IDUpdatePlayerGameType 24 | } 25 | 26 | func (pk *UpdatePlayerGameType) Marshal(io protocol.IO) { 27 | io.Varint32(&pk.GameType) 28 | io.Varint64(&pk.PlayerUniqueID) 29 | io.Varuint64(&pk.Tick) 30 | } 31 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/update_soft_enum.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import ( 4 | "github.com/sandertv/gophertunnel/minecraft/protocol" 5 | ) 6 | 7 | const ( 8 | SoftEnumActionAdd = iota 9 | SoftEnumActionRemove 10 | SoftEnumActionSet 11 | ) 12 | 13 | // UpdateSoftEnum is sent by the server to update a soft enum, also known as a dynamic enum, previously sent 14 | // in the AvailableCommands packet. It is sent whenever the enum should get new options or when some of its 15 | // options should be removed. 16 | // The UpdateSoftEnum packet will apply for enums that have been set in the AvailableCommands packet with the 17 | // 'Dynamic' field of the CommandEnum set to true. 18 | type UpdateSoftEnum struct { 19 | // EnumType is the type of the enum. This type must be identical to the one set in the AvailableCommands 20 | // packet, because the client uses this to recognise which enum to update. 21 | EnumType string 22 | // Options is a list of options that should be updated. Depending on the ActionType field, either these 23 | // options will be added to the enum, the enum options will be set to these options or all of these 24 | // options will be removed from the enum. 25 | Options []string 26 | // ActionType is the type of the action to execute on the enum. The Options field has a different result, 27 | // depending on what ActionType is used. 28 | ActionType byte 29 | } 30 | 31 | // ID ... 32 | func (*UpdateSoftEnum) ID() uint32 { 33 | return IDUpdateSoftEnum 34 | } 35 | 36 | func (pk *UpdateSoftEnum) Marshal(io protocol.IO) { 37 | io.String(&pk.EnumType) 38 | protocol.FuncSlice(io, &pk.Options, io.String) 39 | io.Uint8(&pk.ActionType) 40 | } 41 | -------------------------------------------------------------------------------- /minecraft/protocol/packet/update_sub_chunk_blocks.go: -------------------------------------------------------------------------------- 1 | package packet 2 | 3 | import "github.com/sandertv/gophertunnel/minecraft/protocol" 4 | 5 | // UpdateSubChunkBlocks is essentially just UpdateBlock packet, however for a set of blocks in a sub-chunk. 6 | type UpdateSubChunkBlocks struct { 7 | // Position is the position of the sub-chunk being referred to. 8 | Position protocol.SubChunkPos 9 | // Blocks contains each updated block change entry. 10 | Blocks []protocol.BlockChangeEntry 11 | // Extra contains each updated block change entry for the second layer, usually for waterlogged blocks. 12 | Extra []protocol.BlockChangeEntry 13 | } 14 | 15 | // ID ... 16 | func (*UpdateSubChunkBlocks) ID() uint32 { 17 | return IDUpdateSubChunkBlocks 18 | } 19 | 20 | func (pk *UpdateSubChunkBlocks) Marshal(io protocol.IO) { 21 | io.SubChunkPos(&pk.Position) 22 | protocol.Slice(io, &pk.Blocks) 23 | protocol.Slice(io, &pk.Extra) 24 | } 25 | -------------------------------------------------------------------------------- /minecraft/protocol/trim.go: -------------------------------------------------------------------------------- 1 | package protocol 2 | 3 | // TrimPattern represents a pattern that can be applied to an armour piece in combination with a TrimMaterial. 4 | type TrimPattern struct { 5 | // ItemName is the identifier of the item that represents the pattern, for example 6 | // 'minecraft:wayfinder_armor_trim_smithing_template'. 7 | ItemName string 8 | // PatternID is the identifier of the pattern, for example, 'wayfinder'. 9 | PatternID string 10 | } 11 | 12 | // Marshal ... 13 | func (x *TrimPattern) Marshal(r IO) { 14 | r.String(&x.ItemName) 15 | r.String(&x.PatternID) 16 | } 17 | 18 | // TrimMaterial represents a material that can be used when applying an armour trim. 19 | type TrimMaterial struct { 20 | // MaterialID is the identifier of the material, for example 'netherite'. 21 | MaterialID string 22 | // Colour is the colour code used for text formatting, for example '§j'. 23 | Colour string 24 | // ItemName is the identifier of the item that represents the material, for example, 'minecraft:netherite_ingot'. 25 | ItemName string 26 | } 27 | 28 | // Marshal ... 29 | func (x *TrimMaterial) Marshal(r IO) { 30 | r.String(&x.MaterialID) 31 | r.String(&x.Colour) 32 | r.String(&x.ItemName) 33 | } 34 | -------------------------------------------------------------------------------- /minecraft/protocol/world.go: -------------------------------------------------------------------------------- 1 | package protocol 2 | 3 | const ( 4 | GeneratorLegacy = 0 5 | GeneratorOverworld = 1 6 | GeneratorFlat = 2 7 | GeneratorNether = 3 8 | GeneratorEnd = 4 9 | GeneratorVoid = 5 10 | ) 11 | 12 | // DimensionDefinition contains information specifying dimension-specific properties, used for data-driven dimensions. 13 | // These include the range (the height min/max), generator variant, and more. 14 | type DimensionDefinition struct { 15 | // Name specifies the name of the dimension. 16 | Name string 17 | // Range is the height range of the dimension, where the first value is the minimum and the second is the maximum. 18 | Range [2]int32 19 | // Generator is the variant of generator that exists in the provided dimension. These can be one of the constants 20 | // defined above. If this is set to GeneratorLegacy, the legacy horizontal world limits will be enforced. 21 | Generator int32 22 | } 23 | 24 | // Marshal encodes/decodes a DimensionDefinition. 25 | func (x *DimensionDefinition) Marshal(r IO) { 26 | r.String(&x.Name) 27 | r.Varint32(&x.Range[0]) 28 | r.Varint32(&x.Range[1]) 29 | r.Varint32(&x.Generator) 30 | } 31 | 32 | // GenerationFeature represents a world generation feature, used when encoding the FeatureRegistry to the client. 33 | type GenerationFeature struct { 34 | // Name is the name of the feature. 35 | Name string 36 | // JSON is the encoded JSON data instructing the client on how to generate the feature. 37 | JSON []byte 38 | } 39 | 40 | // Marshal encodes/decodes a GenerationFeature. 41 | func (x *GenerationFeature) Marshal(r IO) { 42 | r.String(&x.Name) 43 | r.ByteSlice(&x.JSON) 44 | } 45 | -------------------------------------------------------------------------------- /minecraft/raknet.go: -------------------------------------------------------------------------------- 1 | package minecraft 2 | 3 | import ( 4 | "context" 5 | "github.com/sandertv/go-raknet" 6 | "log/slog" 7 | "net" 8 | ) 9 | 10 | // RakNet is an implementation of a RakNet v10 Network. 11 | type RakNet struct { 12 | l *slog.Logger 13 | } 14 | 15 | // DialContext ... 16 | func (r RakNet) DialContext(ctx context.Context, address string) (net.Conn, error) { 17 | return raknet.Dialer{ErrorLog: r.l.With("net origin", "raknet")}.DialContext(ctx, address) 18 | } 19 | 20 | // PingContext ... 21 | func (r RakNet) PingContext(ctx context.Context, address string) (response []byte, err error) { 22 | return raknet.Dialer{ErrorLog: r.l.With("net origin", "raknet")}.PingContext(ctx, address) 23 | } 24 | 25 | // Listen ... 26 | func (r RakNet) Listen(address string) (NetworkListener, error) { 27 | return raknet.ListenConfig{ErrorLog: r.l.With("net origin", "raknet")}.Listen(address) 28 | } 29 | 30 | // init registers the RakNet network. 31 | func init() { 32 | RegisterNetwork("raknet", func(l *slog.Logger) Network { return RakNet{l: l} }) 33 | } 34 | -------------------------------------------------------------------------------- /minecraft/resource/doc.go: -------------------------------------------------------------------------------- 1 | // Package resource implements the compiling of resource packs found in files, directories or raw byte data. 2 | // It ensures the data in the resource pack is valid (for example, it checks if the manifest is present and 3 | // holds correct data) and extracts information which may be obtained by calling the exported methods of a 4 | // *resource.Pack. 5 | package resource 6 | -------------------------------------------------------------------------------- /minecraft/skin_resource_patch.json: -------------------------------------------------------------------------------- 1 | { 2 | "geometry" : { 3 | "default" : "geometry.humanoid.custom" 4 | } 5 | } -------------------------------------------------------------------------------- /minecraft/text/doc.go: -------------------------------------------------------------------------------- 1 | // Package text has utility methods used for formatting text to display in Minecraft, and to convert these 2 | // colour codes into codes suitable for the command line. It also contains constants for each of the 3 | // Minecraft colours and formatting codes. 4 | package text 5 | -------------------------------------------------------------------------------- /query/doc.go: -------------------------------------------------------------------------------- 1 | // Package query implements the UT3 query protocol as described on 2 | // http://wiki.unrealadmin.org/UT3_query_protocol. It is composed of a handshake, followed by data sent 3 | // by the server that responds to a query sent by the client. 4 | // 5 | // Where some server softwares (most common public ones, such as PocketMine) support this query protocol, 6 | // others do not. A different kind of 'query', which is supported by all servers, may be performed using the 7 | // go-raknet library. (raknet.Ping()) Server softwares which do not implement the query protocol include the 8 | // Bedrock Dedicated Server. 9 | package query 10 | -------------------------------------------------------------------------------- /staticcheck.conf: -------------------------------------------------------------------------------- 1 | checks = ["all", "-ST1000", "-ST1003", "-ST1016"] 2 | initialisms = ["ACL", "API", "ASCII", "CPU", "CSS", "DNS", 3 | "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", 4 | "IP", "JSON", "QPS", "RAM", "RPC", "SLA", 5 | "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", 6 | "UDP", "UI", "GID", "UID", "UUID", "URI", 7 | "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", 8 | "XSS", "XUID"] 9 | dot_import_whitelist = [] 10 | http_status_code_whitelist = ["200", "400", "404", "500"] --------------------------------------------------------------------------------