├── CMakeLists.txt ├── LICENSE ├── README.md ├── doc └── Doxyfile └── include ├── client ├── AppPlatform.h ├── ClientInstance.h ├── EventCoordinator.h ├── LevelRenderer.h ├── Minecraft.h ├── MinecraftCommands.h ├── MinecraftGame.h ├── ServiceLocator.h ├── Timer.h ├── events │ └── ClientInstanceEventCoordinator.h ├── gui │ ├── CaretMeasureData.h │ ├── GuiData.h │ ├── RectangleArea.h │ ├── TextMeasureData.h │ ├── controls │ │ ├── TextComponent.h │ │ ├── UIControl.h │ │ └── UIControlFactory.h │ └── screens │ │ ├── BaseScreen.h │ │ ├── ScreenComponent.h │ │ └── models │ │ ├── ClientInstanceScreenModel.h │ │ ├── MinecraftScreenModel.h │ │ └── PlayScreenModel.h ├── input │ ├── ClientInputHandler.h │ ├── Keyboard.h │ ├── Mouse.h │ └── MoveInputHandler.h ├── options │ └── Options.h └── render │ ├── ActorRenderDispatcher.h │ ├── BaseActorRenderContext.h │ ├── CaretMeasureData.h │ ├── Font.h │ ├── ItemRenderer.h │ ├── RectangleArea.h │ └── ScreenContext.h ├── command ├── Command.h ├── CommandMessage.h ├── CommandOutput.h ├── CommandParameterData.h ├── CommandRegistry.h ├── CommandUtils.h └── CommandVersion.h ├── entity ├── Actor.h ├── Agent.h ├── BlockActor.h ├── GameMode.h ├── LocalPlayer.h ├── Mob.h ├── Player.h ├── RemotePlayer.h ├── Sensing.h ├── ability │ ├── Abilities.h │ └── Ability.h ├── animal │ ├── EnderMan.h │ └── Wolf.h ├── effect │ ├── MobEffect.h │ └── MobEffectInstance.h └── events │ ├── ClientPlayerEventCoordinator.h │ └── PlayerEventCoordinator.h ├── gsl-lite.hpp ├── item ├── Container.h ├── Enchant.h ├── EnchantUtils.h ├── EnchantmentInstance.h ├── Item.h ├── ItemEnchants.h ├── ItemUseCallback.h └── VanillaItems.h ├── math ├── AABB.h ├── BlockPos.h ├── Facing.h ├── SubChunkPos.h ├── Vec2.h └── Vec3.h ├── mce ├── Image.h ├── Shader.h └── UUID.h ├── network ├── BinaryStream.h ├── ConnectionRequest.h ├── ExternalServer.h ├── NetworkHandler.h ├── NetworkIdentifier.h ├── NetworkPeer.h ├── NetworkStats.h ├── PacketSender.h ├── ServerNetworkHandler.h ├── ServerPlayer.h └── protocol │ ├── ActorEventPacket.h │ ├── ActorFallPacket.h │ ├── AddActorPacket.h │ ├── AddItemActorPacket.h │ ├── AddPlayerPacket.h │ ├── AnimatePacket.h │ ├── ClientboundMapItemDataPacket.h │ ├── DisconnectPacket.h │ ├── InteractPacket.h │ ├── InventoryTransactionPacket.h │ ├── LevelEventPacket.h │ ├── LevelSoundEventPacket.h │ ├── LoginPacket.h │ ├── MobEffectPacket.h │ ├── ModalFormRequestPacket.h │ ├── ModalFormResponsePacket.h │ ├── MoveActorAbsolutePacket.h │ ├── MovePlayerPacket.h │ ├── Packet.h │ ├── PlaySoundPacket.h │ ├── PlayerActionPacket.h │ ├── RemoveActorPacket.h │ ├── ServerSettingsRequestPacket.h │ ├── ServerSettingsResponsePacket.h │ ├── SetActorDataPacket.h │ ├── SetActorMotionPacket.h │ ├── SetTitlePacket.h │ ├── TextPacket.h │ ├── UpdateBlockPacket.h │ └── VirtualTemplate.h ├── realms └── Realms.h ├── util ├── ActorRuntimeID.h ├── ActorType.h ├── Brightness.h ├── Certificate.h ├── Color.h ├── ColorFormat.h ├── CompoundTag.h ├── DataItem.h ├── DeviceOS.h ├── GameType.h ├── Json.h ├── MapDecoration.h ├── MinecraftHandle.h ├── SmallSet.h ├── serialize.h └── typeid.h └── world ├── BedrockBlocks.h ├── Block.h ├── BlockGraphics.h ├── BlockSource.h ├── BlockTessellator.h ├── HitResult.h ├── VanillaBlocks.h ├── World.h └── level ├── Level.h ├── LevelData.h └── storage └── GameRules.h /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #include_directories(${CMAKE_CURRENT_LIST_DIR}/GSL/include) 2 | include_directories(${CMAKE_CURRENT_LIST_DIR}/include) 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Minecraft: Bedrock Edition modding headers 2 | 3 | #### This is currently (being) adapted to the Android 1.16.200.02 x86_64 binary. This project was abandoned for a while when symbols were stripped from the official binaries but they're back in this version. Field offsets are similar to Windows 10 Edition and some info is ripped from a W10E project. 4 | 5 | You can view symbols from your lib with `nm -anDC libminecraftpe.so` which is a handy utility provided by `binutils`. If you only see MSA (Xbox Live stuff), AppPlatform, FMod, and other related symbols then they might be stripped: this seems to be the case in latest betas. 6 | 7 | Rest assured if you're determined you can pattern search for instances of these classes and the field offsets provided in this project should be relatively the same. However, function offsets are currently not a priority in this project so you will sadly have to implement those on your own for now. 8 | 9 | This repository aims to be the most complete, organized, and up to date headers available for the game. 10 | 11 | Obviously it's far from this at the moment but yes, you too can help contribute! 12 | 13 | ## Using 14 | 15 | For CMake users you can simply `include(bedrock-headers/CMakeLists.txt)` in your project! 16 | 17 | For everything else such as traditional Makefile you will need to add the search paths manually. -------------------------------------------------------------------------------- /include/client/AppPlatform.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct AppPlatform { 4 | struct HardwareInformation { 5 | std::string deviceModel; 6 | }; 7 | 8 | int getScreenWidth(); 9 | 10 | int getScreenHeight(); 11 | 12 | AppPlatform::HardwareInformation &getHardwareInformation() const; 13 | 14 | AppPlatform::HardwareInformation &getHardwareInformationToModify(); 15 | 16 | const char *getPlatformRuntimeInformation() const; 17 | }; 18 | 19 | struct AppPlatform_android : AppPlatform { 20 | void queueForMainThread(std::function function); 21 | }; -------------------------------------------------------------------------------- /include/client/ClientInstance.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "network/NetworkHandler.h" 4 | #include "client/options/Options.h" 5 | #include "world/BlockTessellator.h" 6 | #include "network/PacketSender.h" 7 | #include "world/level/Level.h" 8 | #include "gui/GuiData.h" 9 | #include "render/Font.h" 10 | #include "input/ClientInputHandler.h" 11 | #include "events/ClientInstanceEventCoordinator.h" 12 | #include "render/ActorRenderDispatcher.h" 13 | #include "LevelRenderer.h" 14 | 15 | struct MinecraftGame; 16 | 17 | struct LevelRenderer; 18 | 19 | struct LocalPlayer; 20 | 21 | struct SceneStack { 22 | int getSize() const; 23 | }; 24 | 25 | struct ClientInstance { 26 | /** 27 | * Checks that player is playing and not busy in any UI 28 | * @return bool 29 | */ 30 | bool isInGame() const; 31 | 32 | BlockTessellator& getBlockTessellator(); 33 | 34 | /** 35 | * Gets PacketSender 36 | * @return LoopbackPacketSender 37 | */ 38 | PacketSender *getPacketSender(); 39 | 40 | /** 41 | * Get SceneStack 42 | * @return SceneStack* 43 | */ 44 | SceneStack *getClientSceneStack(); 45 | 46 | /** 47 | * Gets InputHandler for LocalPlayer 48 | * @return ClientInputHandler 49 | */ 50 | ClientInputHandler &getInput() const; 51 | 52 | /* 53 | * 54 | */ 55 | Options *getOptionsPtr(); 56 | 57 | /** 58 | * Gets EventCoordinator for LocalPlayer 59 | * @return ClientInstanceEventCoordinator 60 | */ 61 | ClientInstanceEventCoordinator *getEventCoordinator(); 62 | 63 | /** 64 | * Gets primary game font 65 | * @return Font 66 | */ 67 | Font &getFont() const; 68 | 69 | /** 70 | * Gets current Controller ID 71 | * @return int 72 | */ 73 | int getControllerId() const; 74 | 75 | /** 76 | * Get ClientNetworkHandler 77 | * @return NetworkHandler 78 | */ 79 | NetworkHandler *getClientNetworkSystem(); 80 | 81 | MinecraftGame *getMinecraftGame() const; 82 | 83 | bool isLeavingGame() const; 84 | 85 | /** 86 | * Is in a level 87 | * @return bool 88 | */ 89 | bool isPlaying() const; 90 | 91 | bool isExitingLevel() const; 92 | 93 | bool isDestroyingGame() const; 94 | 95 | bool isReadyToRender() const; 96 | 97 | bool isPreGame() const; 98 | 99 | LevelRenderer *getLevelRenderer() const; 100 | 101 | MoveInputHandler *getMoveTurnInput(); 102 | 103 | ActorRenderDispatcher &getEntityRenderDispatcher(); 104 | 105 | void onClientInputInitComplete(); 106 | 107 | void onClientCreatedLevel(std::unique_ptr, std::unique_ptr); 108 | }; 109 | -------------------------------------------------------------------------------- /include/client/EventCoordinator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct EventCoordinator {}; -------------------------------------------------------------------------------- /include/client/LevelRenderer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "math/SubChunkPos.h" 4 | 5 | struct LevelRendererCamera { 6 | void renderChunkImmediateChanged(const SubChunkPos &); 7 | }; 8 | 9 | struct LevelRendererPlayer { 10 | //char pad_0000[0x5c]; 11 | //LevelRendererCamera *levelRendererCamera; 12 | 13 | //void computeCameraPos(float mode); 14 | 15 | void tickLevelRendererCamera(); 16 | }; 17 | 18 | -------------------------------------------------------------------------------- /include/client/Minecraft.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "network/NetworkHandler.h" 4 | #include "Timer.h" 5 | 6 | struct Minecraft { 7 | char pad_0000[0xA0]; 8 | Level *level; 9 | Timer *gameTimer, *renderTimer; 10 | NetworkHandler *networkHandler; 11 | 12 | /** 13 | * Checks if game is fully initialized 14 | * @return bool 15 | */ 16 | bool isInitialized() const; 17 | 18 | /** 19 | * Get NetworkHandler 20 | * @return NetworkHandler 21 | */ 22 | NetworkHandler *getNetworkHandler() const; 23 | 24 | /** 25 | * Send quitting packet to connected server 26 | * @param showDisconnect Whether or not to display the disconnection screen 27 | */ 28 | void startLeaveGame(bool showDisconnect); 29 | 30 | /** 31 | * Get game timer 32 | */ 33 | Timer *getTimer(); 34 | 35 | /** 36 | * Called near the mid-end of the title screen 37 | */ 38 | void init(); 39 | }; 40 | 41 | static_assert(offsetof(Minecraft, level) == 0xA0); 42 | static_assert(offsetof(Minecraft, gameTimer) == 0xA8); 43 | static_assert(offsetof(Minecraft, networkHandler) == 0xB8); -------------------------------------------------------------------------------- /include/client/MinecraftCommands.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct MinecraftCommands {}; 4 | -------------------------------------------------------------------------------- /include/client/MinecraftGame.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ClientInstance.h" 4 | #include "../network/NetworkHandler.h" 5 | #include "../entity/LocalPlayer.h" 6 | #include "../network/ExternalServer.h" 7 | #include "../client/render/Font.h" 8 | #include "../client/options/Options.h" 9 | #include "Minecraft.h" 10 | #include 11 | 12 | struct GuiData; 13 | 14 | struct MinecraftEventing; 15 | 16 | struct Realms; 17 | 18 | struct Player; 19 | 20 | // Does this inherit the Minecraft class? Or just similar field layout 21 | struct MinecraftGame { 22 | MinecraftGame(int, char **); 23 | 24 | ~MinecraftGame(); 25 | 26 | void _initMinecraftGame(); 27 | 28 | void setEduMode(bool); 29 | 30 | void setIsInGame(bool); 31 | 32 | void onTick(); 33 | 34 | void onDimensionChanged(); 35 | 36 | void onOptionsLoadBegin(); 37 | 38 | void onPlayerLoaded(ClientInstance &, Player &); 39 | 40 | void onUserSignin(); 41 | 42 | void handleBack(bool); 43 | 44 | GuiData *getPrimaryGuiData(); 45 | 46 | Realms *getRealms(); 47 | 48 | bool isInGame() const; 49 | 50 | bool isInRealm(); 51 | 52 | bool isEduMode() const; 53 | 54 | ClientInstance *getPrimaryClientInstance(); 55 | 56 | LocalPlayer *getPrimaryLocalPlayer(); 57 | 58 | Font &getFont() const; 59 | 60 | //ExternalServer &getExternalServer() const; 61 | 62 | void startLeaveGame(); 63 | 64 | bool isLeaveGameDone() const; 65 | }; 66 | -------------------------------------------------------------------------------- /include/client/ServiceLocator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | template 4 | struct ServiceLocator { 5 | static T &mService; 6 | }; -------------------------------------------------------------------------------- /include/client/Timer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | struct Timer { 6 | float tps; 7 | char pad_0004[0x4]; 8 | float partialTicks; 9 | 10 | Timer(float, std::function); 11 | void advanceTime(float); 12 | void advanceTimeQuickly(); 13 | float getAlpha() const; 14 | float getLastTimestep(); 15 | unsigned getTicks() const; 16 | float getTime() const; 17 | float getTimeScale() const; 18 | int resetTimePassed(); 19 | void setTimeScale(float); 20 | void skipTime(); 21 | int stepTick(int); 22 | bool stepping() const; 23 | }; 24 | -------------------------------------------------------------------------------- /include/client/events/ClientInstanceEventCoordinator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct ClientInstance; 4 | 5 | struct Minecraft; 6 | 7 | struct ClientInstanceEventCoordinator { 8 | void sendClientSuspend(ClientInstance &); 9 | 10 | void sendStartLeaveGame(ClientInstance &); 11 | 12 | void sendClientUpdateEnd(ClientInstance &); 13 | 14 | void sendClientUpdateStart(ClientInstance &); 15 | 16 | void sendClientCreatedLevel(ClientInstance &, Level &); 17 | 18 | void sendClientEnteredWorld(ClientInstance &); 19 | 20 | void sendClientInitializeEnd(ClientInstance &); 21 | 22 | void sendClientInitializeStart(ClientInstance &); 23 | 24 | void sendClientMinecraftInitialized(ClientInstance &, Minecraft &); 25 | }; -------------------------------------------------------------------------------- /include/client/gui/CaretMeasureData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct CaretMeasureData { 4 | CaretMeasureData(int, bool); 5 | }; 6 | -------------------------------------------------------------------------------- /include/client/gui/GuiData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | struct ClientInstance; 6 | 7 | struct GuiData { 8 | // TODO: find types 9 | static GuiData *BUTTONS_TRANSPARENCY; 10 | static GuiData *GUI_SCALE_VALUES; 11 | 12 | GuiData(ClientInstance &); 13 | 14 | void addTTSMessage(std::string const &); 15 | 16 | void clearAllTTSMessages(); 17 | 18 | void clearTitleMessages(); 19 | 20 | void clearMessages(); 21 | 22 | void forceMuteChat(); 23 | 24 | void toggleMuteChat(); 25 | 26 | void clearTitle(); 27 | 28 | void resetTitle(); 29 | 30 | void setTitle(std::string const &); 31 | 32 | void setSubtitle(std::string const &); 33 | 34 | void setTitleAnimationTimes(int, int, int); 35 | 36 | void setActionBarMessage(std::string const &); 37 | 38 | void setDevConsoleMaxMessages(int); 39 | 40 | void setTextToSpeechEnabled(bool); 41 | 42 | void setIsChatting(bool); 43 | 44 | void setGuiScale(float); 45 | 46 | void setNowPlaying(std::string const &); 47 | 48 | void addDevConsoleMessage(std::string const &); 49 | 50 | void displayClientMessage(std::string const &); 51 | 52 | void displaySystemMessage(std::string const &); 53 | 54 | void displayWhisperMessage(std::string const &, std::string const &, std::string const &, std::string const &); 55 | 56 | void displayAnnouncementMessage(std::string const &, std::string, std::string const &, std::string const &); 57 | 58 | void displayLocalizedMessage(std::string const &, bool); 59 | 60 | void displayDevConsoleMessage(std::string const &); 61 | 62 | void showJukeboxPopupNotice(std::string const &, std::string const &); 63 | 64 | void showTipMessage(std::string const &); 65 | 66 | bool isMuteChat(); 67 | 68 | bool isTouchEnabledOrHolographic(); 69 | 70 | bool isOddGuiScale(); 71 | 72 | int getDevConsoleMaxMessages() const; 73 | 74 | std::string getTitleMessage() const; 75 | 76 | std::string getLastPopupText() const; 77 | 78 | std::string getLastDevConsoleMessage() const; 79 | 80 | std::string getLastChatMessage() const; 81 | }; 82 | -------------------------------------------------------------------------------- /include/client/gui/RectangleArea.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct RectangleArea { 4 | int x1, y1, x2, y2; 5 | 6 | RectangleArea(float x1, float y1, float x2, float y2, bool something); 7 | }; -------------------------------------------------------------------------------- /include/client/gui/TextMeasureData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct TextMeasureData { 4 | TextMeasureData(float, float, bool, bool, bool); 5 | }; 6 | -------------------------------------------------------------------------------- /include/client/gui/controls/TextComponent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "util/Color.h" 5 | #include "util/Font.h" 6 | 7 | struct UIControl; 8 | 9 | struct TextComponent { 10 | // TODO: find types 11 | static TextComponent *CARET_BLINK_TIME; 12 | 13 | TextComponent(UIControl &); 14 | 15 | ~TextComponent(); 16 | 17 | void setLocalize(bool); 18 | 19 | void setPrimaryFont(Font &); 20 | 21 | void setBackupFont(Font *); 22 | 23 | void setHideHyphen(bool); 24 | 25 | void setLinePadding(float); 26 | 27 | void setLockedAlpha(float); 28 | 29 | void setLockedColor(Color const &); 30 | 31 | void setText(std::string const &); 32 | 33 | void setColor(Color const &); 34 | 35 | void setShadow(bool); 36 | 37 | std::string getText() const; 38 | 39 | bool getShadow() const; 40 | 41 | bool getLocalize() const; 42 | 43 | bool getHideHyphen() const; 44 | }; 45 | -------------------------------------------------------------------------------- /include/client/gui/controls/UIControl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct UIControl {}; -------------------------------------------------------------------------------- /include/client/gui/controls/UIControlFactory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct UIControlFactory {}; -------------------------------------------------------------------------------- /include/client/gui/screens/BaseScreen.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../render/ScreenContext.h" 4 | #include 5 | 6 | struct FocusImpact; 7 | 8 | struct BaseScreen { 9 | BaseScreen(); 10 | 11 | ~BaseScreen(); 12 | 13 | void applyInput(float); 14 | 15 | void leaveScreen(); 16 | 17 | void tick(int, int); 18 | 19 | void reload(); 20 | 21 | void terminate(); 22 | 23 | void onCreation(); 24 | 25 | void onScreenExit(bool, bool); 26 | 27 | void onScreenEntrance(bool, bool); 28 | 29 | void onFocusGained(); 30 | 31 | void onLeave(); 32 | 33 | void onInternetUpdate(); 34 | 35 | void onKeyboardDismissed(); 36 | 37 | void handleBackEvent(bool); 38 | 39 | void handleButtonPress(unsigned int, FocusImpact); 40 | 41 | void handleButtonRelease(unsigned int, FocusImpact); 42 | 43 | void handleIdActorLost(); 44 | 45 | void setupForRendering(ScreenContext &); 46 | 47 | void setupAndRender(ScreenContext &); 48 | 49 | void setTextboxText(std::string const &); 50 | 51 | void setWantsTextOnly(bool); 52 | 53 | bool getWantsTextOnly(); 54 | 55 | bool getShouldSendEvents(); 56 | 57 | bool canBePopped() const; 58 | 59 | bool canBePushed() const; 60 | 61 | bool ignoreAsTop() const; 62 | 63 | bool isPlayScreen() const; 64 | 65 | bool isShowingMenu() const; 66 | 67 | bool renderGameBehind() const; 68 | 69 | bool shouldStealMouse() const; 70 | 71 | bool canBeTransitioned() const; 72 | 73 | bool closeOnPlayerHurt() const; 74 | 75 | bool alwaysAcceptsInput() const; 76 | 77 | bool loadScreenImmediately() const; 78 | 79 | bool renderOnlyWhenTopMost() const; 80 | 81 | bool isGamepadCursorEnabled() const; 82 | 83 | bool isTerminating() const; 84 | 85 | bool isModal() const; 86 | 87 | bool isEntering() const; 88 | 89 | bool isExiting() const; 90 | 91 | std::string getScreenName() const; 92 | 93 | std::string getScreenNameW() const; 94 | }; 95 | -------------------------------------------------------------------------------- /include/client/gui/screens/ScreenComponent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct UIControl; 4 | 5 | struct ScreenComponent { 6 | public: 7 | ScreenComponent(UIControl &); 8 | 9 | void reset(); 10 | 11 | void clone(UIControl &); 12 | 13 | void setIsModal(bool); 14 | 15 | void setIsVRMode(bool); 16 | 17 | void setCacheScreen(bool); 18 | 19 | void setAbsorbsInput(bool); 20 | 21 | void setGamepadCursor(bool); 22 | 23 | void setIsShowingMenu(bool); 24 | 25 | void setScreenDrawsLast(bool); 26 | 27 | void setForceRenderBelow(bool); 28 | 29 | void setLowFreqRendering(bool); 30 | 31 | void setRenderGameBehind(bool); 32 | 33 | void setShouldSendEvents(bool); 34 | 35 | void setShouldStealMouse(bool); 36 | 37 | void setCloseOnPlayerHurt(bool); 38 | 39 | void setAlwaysAcceptsInput(bool); 40 | 41 | void setVerticalScrollDelta(float); 42 | 43 | void setScreenIsNotFlushable(bool); 44 | 45 | void setLoadScreenImmediately(bool); 46 | 47 | bool getIsModal() const; 48 | 49 | bool getIsVRMode() const; 50 | 51 | bool getCacheScreen() const; 52 | 53 | bool getAbsorbsInput() const; 54 | 55 | bool getGamepadCursor() const; 56 | 57 | bool getIsShowingMenu() const; 58 | 59 | bool getScreenDrawsLast() const; 60 | 61 | bool getForceRenderBelow() const; 62 | 63 | bool getLowFreqRendering() const; 64 | 65 | bool getRenderGameBehind() const; 66 | 67 | bool getShouldSendEvents() const; 68 | 69 | bool getShouldStealMouse() const; 70 | 71 | bool getCloseOnPlayerHurt() const; 72 | 73 | bool getAlwaysAcceptsInput() const; 74 | 75 | bool loadScreenImmediately() 76 | 77 | float getVerticalScrollDelta() const; 78 | 79 | bool getScreenIsNotFlushable() const; 80 | }; 81 | -------------------------------------------------------------------------------- /include/client/gui/screens/models/ClientInstanceScreenModel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct GuiMessage { 4 | char pad_0000[0xC]; 5 | std::string text; 6 | //const std::string &getString() const; 7 | 8 | GuiMessage(const GuiMessage &); 9 | }; 10 | 11 | struct ClientInstanceScreenModel { 12 | bool isPlayerOnGround() const; 13 | 14 | void sendChatMessage(std::string const&); 15 | 16 | std::vector &getGuiMessageList(); 17 | 18 | void sendBlockEntityUpdatePacket(BlockPos const&); 19 | }; -------------------------------------------------------------------------------- /include/client/gui/screens/models/MinecraftScreenModel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct MinecraftScreenModel { 4 | /** 5 | * Check if game is in trial mode 6 | * @return bool 7 | */ 8 | bool isTrial() const; 9 | 10 | /** 11 | * Check if realms are enabled 12 | * @return bool 13 | */ 14 | bool isRealmsEnabled() const; 15 | }; 16 | -------------------------------------------------------------------------------- /include/client/gui/screens/models/PlayScreenModel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | struct ClientInstance; 6 | 7 | struct MinecraftGame; 8 | 9 | struct MinecraftEventing; 10 | 11 | struct LocalWorldInfo; 12 | 13 | struct SceneStack; 14 | 15 | struct SceneFactory; 16 | 17 | struct Social { 18 | struct MultiplayerGameInfo; 19 | 20 | struct MultiplayerServiceIdentifier; 21 | } 22 | 23 | struct PlayScreenModel { 24 | static int mRetryTimeout; 25 | 26 | PlayScreenModel(MinecraftGame &, ClientInstance &, SceneStack &, SceneFactory &); 27 | 28 | ~PlayScreenModel(); 29 | 30 | void startLocalWorld(LocalWorldInfo); 31 | 32 | void _startLocalWorld(LocalWorldInfo &); 33 | 34 | void _updateOwnerInfo(); 35 | 36 | void _fetchInviteCount(); 37 | 38 | void _passLicenseCheck(LocalWorldInfo &); 39 | 40 | void _populateLocalWorlds(); 41 | 42 | void _fetchTrialAvailability(); 43 | 44 | void uploadArchivedFile(std::string const &); 45 | 46 | void resetUpdateIntervals(); 47 | 48 | void repopulateLocalWorlds(); 49 | 50 | void initializeRealmsWorlds(); 51 | 52 | void initLegacyWorldImporter(); 53 | 54 | MinecraftEventing *getMinecraftEventing(); 55 | 56 | bool _isCrossPlatformGame(Social::MultiplayerGameInfo const &) const; 57 | 58 | bool isServiceMultiplayerAvailable(Social::MultiplayerServiceIdentifier) const; 59 | 60 | bool isServiceMultiplayerConnected(Social::MultiplayerServiceIdentifier) const; 61 | 62 | bool _hasEditionMismatch(LocalWorldInfo &); 63 | 64 | bool supportsLegacyWorlds() const; 65 | 66 | bool supportsLegacyWorldUpload() const; 67 | 68 | bool supportsManualAddedServers() const; 69 | 70 | int getPendingInviteCount() const; 71 | }; 72 | -------------------------------------------------------------------------------- /include/client/input/ClientInputHandler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "MoveInputHandler.h" 4 | 5 | struct ClientInputHandler : MoveInputHandler { 6 | /** 7 | * Checks if player is sneaking 8 | * @return bool 9 | */ 10 | bool isSneaking() const; 11 | 12 | /** 13 | * Checks if player is moving forward (or strafing forward) 14 | * @return bool 15 | */ 16 | bool isMovingForward() const; 17 | 18 | // string? 19 | void *getCurrentInputMapping() const; 20 | 21 | /** 22 | * Check if in water 23 | * @return bool 24 | */ 25 | bool isInWater() const; 26 | 27 | void render(ScreenContext &); 28 | }; -------------------------------------------------------------------------------- /include/client/input/Keyboard.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct Keyboard { 4 | static int* _states; // TODO: link symbol 5 | }; 6 | -------------------------------------------------------------------------------- /include/client/input/Mouse.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct Mouse { 4 | static Mouse* _instance; 5 | 6 | static bool isButtonDown(int); 7 | 8 | static int getButtonState(int); 9 | 10 | static int getX(); 11 | 12 | static int getY(); 13 | }; -------------------------------------------------------------------------------- /include/client/input/MoveInputHandler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct MoveInputHandler { 4 | // unknown bools are afaik duplicates 5 | char pad_0000[8]; //0x0000 6 | float strafe; //0x0008 7 | float forward; //0x000C 8 | char pad_0010[56]; //0x0010 9 | bool N000008EF; //0x0048 10 | bool N000008FE; //0x0049 11 | char pad_004A[1]; //0x004A 12 | bool jump; //0x004B 13 | bool sneak; //0x004C 14 | char pad_004D[2]; //0x004D 15 | bool N000008FF; //0x004F 16 | // there's a couple bools that change in this padding 17 | char pad_0050[11]; //0x0050 18 | // these can show two opposite directions being pressed at once while strafe and forward cancel out and become 0 19 | bool up; //0x005B 20 | bool down; //0x005C 21 | bool left; //0x005D 22 | bool right; //0x005E 23 | 24 | /** 25 | * Checks if player is moving forward (or strafing forward) 26 | * @return bool 27 | */ 28 | bool isMovingForward() const; 29 | 30 | /** 31 | * I recall this not working, see for yourself 32 | * @return bool 33 | */ 34 | bool isPlayerMoving() const; 35 | }; -------------------------------------------------------------------------------- /include/client/options/Options.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct Options { 4 | bool getFullscreen() const; 5 | 6 | void setHdrBrightness(float); 7 | 8 | int getPlayerViewPerspective(); 9 | 10 | void setPlayerViewPerspective(int); 11 | }; 12 | -------------------------------------------------------------------------------- /include/client/render/ActorRenderDispatcher.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "entity/Actor.h" 4 | #include "BaseActorRenderContext.h" 5 | 6 | struct ActorRenderDispatcher { 7 | BaseActorRenderContext &getRenderer(Actor const&) const; 8 | 9 | void render(BaseActorRenderContext&, Actor&, bool); 10 | }; 11 | -------------------------------------------------------------------------------- /include/client/render/BaseActorRenderContext.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Font.h" 4 | #include "ItemRenderer.h" 5 | 6 | struct BaseActorRenderContext { 7 | ItemRenderer &getItemRenderer(); 8 | 9 | ScreenContext &getScreenContext(); 10 | 11 | Font &getFont(); 12 | }; -------------------------------------------------------------------------------- /include/client/render/CaretMeasureData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct CaretMeasureData { 4 | CaretMeasureData(int, bool); 5 | }; 6 | -------------------------------------------------------------------------------- /include/client/render/Font.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "util/Color.h" 4 | #include "ScreenContext.h" 5 | #include 6 | 7 | // Not sure what this is atm 8 | namespace mce { 9 | struct MaterialPtr; 10 | } 11 | 12 | struct Font { 13 | void drawShadow(ScreenContext&, std::string const &, float, float, mce::Color const &, bool, mce::MaterialPtr*, float); 14 | }; -------------------------------------------------------------------------------- /include/client/render/ItemRenderer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "item/Item.h" 4 | 5 | struct BaseActorRenderContext; 6 | 7 | struct ItemRenderer { 8 | void renderGuiItemNew(BaseActorRenderContext &, const ItemStack &, int, float, float, float, float, float, bool); 9 | }; -------------------------------------------------------------------------------- /include/client/render/RectangleArea.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct RectangleArea { 4 | int x1, y1, x2, y2; 5 | 6 | RectangleArea(float x1, float y1, float x2, float y2, bool something); 7 | }; -------------------------------------------------------------------------------- /include/client/render/ScreenContext.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CaretMeasureData.h" 4 | 5 | struct ScreenContext {}; -------------------------------------------------------------------------------- /include/command/Command.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "util/typeid.h" 4 | #include "CommandRegistry.h" 5 | 6 | struct CommandOutput; 7 | 8 | struct Command { 9 | private: 10 | char filler[0x10]; 11 | 12 | public: 13 | Command(); 14 | 15 | virtual ~Command() = 0; 16 | 17 | virtual void execute(CommandOrigin const &, CommandOutput &) = 0; 18 | }; 19 | -------------------------------------------------------------------------------- /include/command/CommandMessage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "util/typeid.h" 4 | 5 | struct CommandRegistry; 6 | 7 | struct CommandOrigin; 8 | 9 | struct CommandMessage { 10 | private: 11 | char filler[0xC]; 12 | 13 | public: 14 | // NOTE: Even though this function is not part of this struct in MCPE, I am adding it there because it's much nicer 15 | // than using the symbol directly. 16 | static typeid_t type_id() { 17 | static typeid_t ret = type_id_minecraft_symbol( 18 | "_ZZ7type_idI15CommandRegistry14CommandMessageE8typeid_tIT_EvE2id"); 19 | return ret; 20 | }; 21 | 22 | CommandMessage(); 23 | 24 | ~CommandMessage(); 25 | 26 | std::string getMessage(CommandOrigin const &origin) const; 27 | }; -------------------------------------------------------------------------------- /include/command/CommandOutput.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | struct CommandOutputParameter; 7 | 8 | enum struct CommandOutputMessageType { 9 | DEFAULT 10 | }; 11 | 12 | struct CommandOutput { 13 | void success(); 14 | 15 | void addMessage(std::string const &, std::vector const & = {}, 16 | CommandOutputMessageType = CommandOutputMessageType::DEFAULT); 17 | }; 18 | 19 | struct CommandOutputParameter { 20 | private: 21 | std::string str; 22 | int type; 23 | 24 | public: 25 | CommandOutputParameter(std::string const &); 26 | 27 | CommandOutputParameter(int); 28 | }; -------------------------------------------------------------------------------- /include/command/CommandParameterData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "CommandRegistry.h" 6 | #include "util/typeid.h" 7 | 8 | enum struct CommandParameterDataType; 9 | 10 | struct CommandParameterData { 11 | private: 12 | char filler[0x28]; 13 | 14 | public: 15 | CommandParameterData(typeid_t, 16 | bool (CommandRegistry::*)(void *, CommandRegistry::ParseToken const &, CommandOrigin const &, 17 | int, std::string &, std::vector &) const, char const *, 18 | CommandParameterDataType, char const *, int, bool, int); 19 | 20 | CommandParameterData(CommandParameterData const &); 21 | }; -------------------------------------------------------------------------------- /include/command/CommandRegistry.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "CommandVersion.h" 6 | 7 | struct Command; 8 | 9 | struct CommandParameterData { 10 | }; 11 | 12 | struct CommandOrigin; 13 | 14 | enum struct CommandPermissionLevel; 15 | enum struct CommandFlag; 16 | 17 | struct CommandRegistry { 18 | struct ParseToken; 19 | 20 | struct Overload { 21 | CommandVersion version; 22 | 23 | std::unique_ptr (*allocator)(); 24 | 25 | std::vector params; 26 | 27 | private: 28 | int filler; // I don't think this is an actual member, looks like padding to me 29 | 30 | public: 31 | Overload(CommandVersion version, std::unique_ptr (*allocator)()) : version(version), 32 | allocator(allocator) {} 33 | }; 34 | 35 | struct Signature { 36 | private: 37 | char filler[0x8]; 38 | 39 | public: 40 | std::vector overloads; 41 | }; 42 | 43 | Signature *findCommand(std::string const &); 44 | 45 | void buildOverload(Overload &); 46 | 47 | void registerOverloadInternal(Signature &, Overload &); 48 | 49 | void registerCommand(std::string const &, char const *, CommandPermissionLevel, CommandFlag, CommandFlag); 50 | 51 | template 52 | bool 53 | parse(void *, ParseToken const &, CommandOrigin const &, int, std::string &, std::vector &) const; 54 | 55 | template 56 | static std::unique_ptr allocateCommand() { 57 | return std::unique_ptr(new T()); 58 | } 59 | 60 | template 61 | void registerOverload(const char *name, CommandVersion version, Args &&... args) { 62 | Signature *signature = findCommand(name); 63 | signature->overloads.emplace_back(version, allocateCommand); 64 | Overload &overload = *signature->overloads.rbegin(); 65 | buildOverload(overload); 66 | overload.params = {args...}; 67 | registerOverloadInternal(*signature, overload); 68 | } 69 | }; -------------------------------------------------------------------------------- /include/command/CommandUtils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "item/Item.h" 4 | #include "util/Json.h" 5 | #include 6 | 7 | struct CommandUtils { 8 | static ItemStack createItemStack(const std::string &name, int, int); 9 | 10 | static ItemInstance createItemInstance(const Item *, int, int); 11 | 12 | static ItemInstance createItemInstance(const std::string &name, int, int); 13 | 14 | static bool addItemInstanceComponents(ItemInstance &targetItem, const Json::Value &json, std::string &outputMessge); 15 | 16 | //static std::string toJsonResult(const std::string &input, const Jsonca) 17 | }; -------------------------------------------------------------------------------- /include/command/CommandVersion.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct CommandVersion { 4 | private: 5 | int i, i2; 6 | 7 | public: 8 | CommandVersion(int, int); 9 | }; -------------------------------------------------------------------------------- /include/entity/Actor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "world/level/Level.h" 4 | #include "world/BlockSource.h" 5 | #include "math/Vec3.h" 6 | #include "math/BlockPos.h" 7 | #include "math/Vec2.h" 8 | #include "util/ActorRuntimeID.h" 9 | #include 10 | #include 11 | #include "effect/MobEffect.h" 12 | #include "effect/MobEffectInstance.h" 13 | #include "GameMode.h" 14 | #include "util/ActorType.h" 15 | 16 | struct ActorDamageSource; 17 | struct BlockSource; 18 | struct ActorDefinitionGroup; 19 | struct ActorDefinitionIdentifier; 20 | struct Mob; 21 | enum struct ArmorSlot; 22 | 23 | struct Actor { 24 | // ReClass.NET is used for helping find these and generating what you see 25 | // Some of the higher values do NOT apply to all Actors, inheritance is a bitch 26 | // I defined virtual functions but the way it links broke stuff so this is just an accessor 27 | uintptr_t** vtable; //0x0000 28 | char pad_0000[220]; //0x0008 29 | int32_t dimensionId; //0x00E4 30 | char pad_00E8[48]; //0x00E8 31 | Vec2 rotation; //0x0118 32 | Vec2 prevRotation; //0x0120 33 | float diveProgress; //0x0128 34 | float prevDiveProgress; //0x012C 35 | char pad_0130[8]; //0x0130 36 | float x; //0x0138 37 | float y; //0x013C 38 | float z; //0x0140 39 | char pad_0144[112]; //0x0144 40 | float fallDistance; //0x01B4 41 | bool onGround; //0x01B8 42 | bool prevOnGround; //0x01B9 43 | bool collidedHorizontally; //0x01BA 44 | bool collidedVertically; //0x01BB 45 | bool collided; //0x01BC 46 | char pad_01BD[91]; //0x01BD 47 | float stepHeight; //0x0218 48 | char pad_021C[112]; //0x021C 49 | uint32_t ticksExisted; //0x028C 50 | uint32_t hurtTime; //0x0290 51 | char pad_0294[24]; //0x0294 52 | bool isOnMagma; //0x02AC 53 | bool isOnFire; //0x02AD 54 | char pad_02AE[426]; //0x02AE 55 | AABB aabb; //0x0458 56 | char pad_0470[4]; //0x0470 57 | float width; //0x0474 58 | float height; //0x0478 59 | Vec3 pos; //0x047C 60 | Vec3 prevPos; //0x0488 61 | Vec3 motion; //0x0494 62 | char pad_04A0[3192]; //0x04A0 63 | class GameMode *gameMode; //0x1118 64 | 65 | Actor(ActorDefinitionGroup *, ActorDefinitionIdentifier const &); 66 | Actor(BlockSource &, std::string const &); 67 | Actor(Level &); 68 | 69 | void doFireHurt(int); 70 | void normalTick(); 71 | void burn(int, bool); 72 | void feed(int); 73 | void hurt(ActorDamageSource const &, int, bool, bool); 74 | void die(ActorDamageSource const&); 75 | void setCharged(bool); 76 | void setDancing(bool); 77 | void setNameTag(std::string const &); 78 | void setPowered(bool); 79 | void setResting(bool); 80 | void setSitting(bool); 81 | void setSwimmer(bool); 82 | void setTempted(bool); 83 | void setVariant(int); 84 | void setRiding(bool, bool); 85 | void setCanClimb(bool); 86 | void setClimbing(bool); 87 | void setHurtTime(int); 88 | void setStanding(bool); 89 | void setStrength(int); 90 | void startRiding(Actor &); 91 | void serializationSetHealth(int); 92 | bool isRiding() const; 93 | void setEnchanted(bool); 94 | void setCanPowerJump(bool); 95 | void setExperimental(bool); 96 | void setCanFly(bool); 97 | void setOnFire(int); 98 | void setMoving(bool); 99 | void setInLove(Actor *); 100 | void setSaddle(bool); 101 | void setTarget(Actor *); 102 | void stopSwimming(); 103 | void startSwimming(); 104 | void teleportTo(Vec3 const &, bool, int, int); 105 | void animateHurt(); 106 | void moveRelative(float, float, float, float); 107 | void move(Vec3 const&); 108 | void onTame(); 109 | void onMate(Mob &); 110 | void despawn(); 111 | bool isInsidePortal(); 112 | bool canShowNameTag(); 113 | bool isSwimming() const; 114 | bool isSneaking() const; 115 | bool isFishable() const; 116 | bool isClimbing() const; 117 | bool isInClouds() const; 118 | bool isInWater() const; 119 | bool isImmersedInWater() const; 120 | ItemStack &getArmor(ArmorSlot) const; 121 | std::vector getSlotItems(); 122 | ActorRuntimeID getRuntimeID() const; 123 | ActorUniqueID const &getUniqueID() const; 124 | void setSize(float width, float height); 125 | void attack(Actor &); 126 | int getHealth() const; 127 | void swing(); 128 | const Vec3 &getPosExtrapolated(float) const; 129 | const Vec3 &getPos() const; 130 | const Vec3 &getInterpolatedPosition(float) const; 131 | const Vec3 &getPosOld() const; 132 | const Vec3 &getViewVector(float) const; 133 | Level &getLevel() const; 134 | const std::string &getNameTag() const; 135 | std::vector fetchNearbyActorsSorted(const Vec3 &pos, ActorType); 136 | std::string getUnformattedNameTag() const { 137 | static const std::regex colorCodes{"\u00A7[0-9A-Ga-gK-Ok-oRr]"}; 138 | return std::regex_replace(getNameTag(), colorCodes, ""); 139 | } 140 | bool hasTags() const; 141 | float distanceTo(Actor const &) const; 142 | float distanceTo(Vec3 const &) const; 143 | void addEffect(MobEffectInstance const &); 144 | void onEffectAdded(MobEffectInstance &); 145 | void removeAllEffects(); 146 | void removeEffect(int); 147 | BlockPos getBlockTarget() const; 148 | void setRot(Vec2 const &); 149 | Vec2 getRotation() const; 150 | BlockSource &getRegion() const; 151 | void buildForward() const; 152 | void setPos(Vec3 const &); 153 | bool isInvisible() const; 154 | bool isRemoved() const; 155 | bool isAlive() const; 156 | void setInvisible(bool); 157 | bool hasEffect(MobEffect const&) const; 158 | const MobEffectInstance *getEffect(MobEffect const&) const; 159 | signed int checkInsideBlocks(float offset); 160 | bool isInWall() const; 161 | bool canSee(Actor const&) const; 162 | bool canSee(Vec3 const&) const; 163 | bool isJumping() const; 164 | bool isTickingEntity() const; 165 | bool isPickable(); 166 | bool isWalker() const; 167 | bool isGlobal() const; 168 | bool isInWorld() const; 169 | bool isWASDControlled(); 170 | bool isImmobile() const; 171 | bool isSilent(); 172 | bool isBlocking() const; 173 | bool isStanding() const; 174 | bool getAlwaysShowNameTag() const; 175 | void setNameTagVisible(bool); 176 | bool isRegionValid() const; 177 | bool isLayingDown() const; 178 | int getSkinID() const; 179 | ActorType getEntityTypeId() const; 180 | ActorRuntimeID getRideRuntimeID() const; 181 | Actor &getRide() const; 182 | bool hasType(ActorType) const; 183 | bool isOverWater() const; 184 | void lerpMotion(const Vec3 &); 185 | bool isMoving() const; 186 | bool isSleeping() const; 187 | void baseTick(); 188 | bool isLocalPlayer() const; 189 | uint32_t getHurtTime() const; 190 | }; 191 | 192 | static_assert(offsetof(Actor, dimensionId) == 0xE4); 193 | static_assert(offsetof(Actor, motion) == 0x494); 194 | static_assert(offsetof(Actor, gameMode) == 0x1118); -------------------------------------------------------------------------------- /include/entity/Agent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct Agent { 4 | bool canShowNameTag() const; 5 | bool getAlwaysShowNameTag() const; 6 | bool isPushable() const; 7 | bool isPushableByPiston() const; 8 | void swingArm(); 9 | bool isInvisible() const; 10 | bool isPickable(); 11 | void setSelectedSlot(int); 12 | int getSelectedSlot() const; 13 | }; -------------------------------------------------------------------------------- /include/entity/BlockActor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "util/CompoundTag.h" 4 | 5 | struct BlockSource; 6 | 7 | // TODO: Correct inheritance 8 | struct BlockActor { 9 | void saveItemInstanceData(CompoundTag &); 10 | void save(CompoundTag &) const; 11 | void saveBlockData(CompoundTag &, BlockSource &) const; 12 | }; 13 | -------------------------------------------------------------------------------- /include/entity/GameMode.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Actor.h" 4 | #include "item/Item.h" 5 | 6 | struct GameMode { 7 | bool buildBlock(BlockPos const&, unsigned char face); 8 | void baseUseItem(ItemStack&); 9 | void stopBuildBlock(); 10 | void releaseUsingItem(); 11 | void attack(Actor&); 12 | void useItem(ItemStack&); 13 | void interact(Actor&, Vec3 const&); 14 | void useItemOn(ItemStack&, BlockPos const&, unsigned char, Vec3 const&, Block const*); 15 | void startDestroyBlock(const BlockPos&, unsigned char face, bool &unk); 16 | void continueDestroyBlock(const BlockPos &, unsigned char face, bool &unk); 17 | void destroyBlock(const BlockPos &, unsigned char face); 18 | void stopDestroyBlock(BlockPos const&); 19 | }; 20 | 21 | struct SurvivalMode : GameMode { 22 | void buildBlock(BlockPos const&, unsigned char); 23 | void baseUseItem(ItemStack&); 24 | void attack(Actor&); 25 | }; -------------------------------------------------------------------------------- /include/entity/LocalPlayer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Player.h" 4 | #include "events/PlayerEventCoordinator.h" 5 | #include "client/ClientInstance.h" 6 | #include "item/Container.h" 7 | #include "util/GameType.h" 8 | 9 | struct InventoryMenu { 10 | ContainerItemStack *getSlot(int slot) { 11 | // TODO: Figure out why the real method doesn't work as expected... 12 | return const_cast(_getContainer()->getSlots()[slot]); 13 | }; 14 | 15 | Container *_getContainer() const; 16 | 17 | void setSlot(int slot, const ContainerItemStack &); 18 | }; 19 | 20 | struct LocalPlayer : Player { 21 | PlayerEventCoordinator *getPlayerEventCoordinator(); 22 | ClientPlayerEventCoordinator *getClientPlayerEventCoordinator(); 23 | InventoryMenu &getInventoryMenu(); 24 | void setPlayerGameTypeWithoutServerNotification(GameType); 25 | void setSelectedItemSlot(short slot) { 26 | // TODO: Fuck 27 | getSupplies().selectSlot(slot, getSupplies().getSelectedContainerId()); 28 | getSupplies().setSelectedItem(*getInventoryMenu().getSlot(slot)); 29 | } 30 | void _applyTurnDelta(const Vec2 &); 31 | void displayClientMessage(std::string const&); 32 | void chat(std::string const&); 33 | void swing(); 34 | void setSprinting(bool); 35 | void startRiding(Actor &); 36 | bool isLocalPlayer() const; 37 | void move(Vec3 const &); 38 | ClientInstance &getClientInstance() const; 39 | MoveInputHandler &getMoveInputHandler(); 40 | float getFieldOfViewModifier(); 41 | }; 42 | 43 | -------------------------------------------------------------------------------- /include/entity/Mob.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Actor.h" 4 | 5 | struct ActorDamageSource; 6 | 7 | struct Sensing; 8 | 9 | struct Mob : Actor { 10 | bool isSprinting() const; 11 | void die(ActorDamageSource const &); 12 | void jumpFromGround(); 13 | void setSpeedModifier(float); 14 | void setSpeed(float); 15 | void setSprinting(bool); // doesn't like to work virtually togglesprint pls 16 | void animateHurt(); 17 | void setSneaking(bool); 18 | bool isGliding() const; 19 | void updateGliding(); 20 | bool isAlive() const; 21 | bool frostWalk(); 22 | int getGlidingTicks() const; 23 | int getTimeAlongSwing(); 24 | bool isSleeping() const; 25 | void swing(); 26 | void attack(Actor &); 27 | void baseTick(); 28 | bool isJumping() const; 29 | void doFireHurt(int); 30 | void normalTick(); 31 | }; 32 | -------------------------------------------------------------------------------- /include/entity/Player.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "item/Container.h" 4 | #include "Mob.h" 5 | #include "Agent.h" 6 | #include "item/Item.h" 7 | #include "util/Certificate.h" 8 | #include "mce/Image.h" 9 | #include "network/protocol/Packet.h" 10 | 11 | struct SkinInfoData { 12 | char pad_0000[0x38]; 13 | std::string &first, &second; 14 | mce::Image *getCapeImage() const; 15 | mce::Image *getSkinImage() const; 16 | //std::vector> &getSkinImage() const; 17 | std::vector> &getGeometryData() const; 18 | std::string &getSkinId() const; 19 | void setForceAlpha(std::vector >&, int, int, int, int, int); 20 | }; 21 | 22 | struct Player : Mob { 23 | PlayerInventory &getSupplies() const; 24 | bool canUseAbility(std::string const &); 25 | ItemInstance const &getSelectedItem() const; 26 | void setSelectedItem(ItemStack const &); 27 | void setSpeed(float); 28 | void sendNetworkPacket(Packet&) const; 29 | bool isUsingItem() const; 30 | short getSelectedItemSlot() const; 31 | void startSwimming(); 32 | void stopSwimming(); 33 | NetworkIdentifier const &getClientId() const; 34 | LookDirection getDirection() const; 35 | void setEnchantmentSeed(int); 36 | int getEnchantmentSeed() const; 37 | void stopGliding(); 38 | void startGliding(); 39 | void updateGliding(); 40 | Agent *getAgent() const; 41 | bool isSleeping() const; 42 | bool isJumping(); 43 | void displayClientMessage(std::string const&); 44 | const std::string &getPlatformOnlineId() const; 45 | Certificate *getCertificate() const; 46 | void startUsingItem(ItemStack const &, int); 47 | int getTicksUsingItem(); 48 | SkinInfoData *getSkin() const; 49 | bool isLocalPlayer() const; 50 | void attack(Actor &); 51 | void feed(int); 52 | void normalTick(); 53 | void move(Vec3 const &); 54 | }; -------------------------------------------------------------------------------- /include/entity/RemotePlayer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Player.h" 4 | #include "events/PlayerEventCoordinator.h" 5 | 6 | struct RemotePlayer : public Player { 7 | PlayerEventCoordinator *getPlayerEventCoordinator(); 8 | }; -------------------------------------------------------------------------------- /include/entity/Sensing.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Actor.h" 4 | #include "Mob.h" 5 | #include "math/Vec3.h" 6 | 7 | struct Sensing { 8 | bool canSee(Actor const&); 9 | 10 | bool withinFOV(Mob&, Vec3 const&, float); 11 | }; -------------------------------------------------------------------------------- /include/entity/ability/Abilities.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "Ability.h" 7 | 8 | struct CompoundTag; 9 | 10 | enum struct PlayerPermissions : unsigned char; 11 | 12 | enum struct CommandPermissionLevel : unsigned char {}; 13 | 14 | struct PermissionsHandler { 15 | CommandPermissionLevel permissionsLevel; // 0 16 | PlayerPermissions playerPermissionsLevel; // 1 17 | PermissionsHandler(); 18 | PermissionsHandler(PermissionsHandler const &); 19 | 20 | void addSaveData(CompoundTag &) const; 21 | bool loadSaveData(CompoundTag const &); 22 | 23 | CommandPermissionLevel getCommandPermissions() const; 24 | void setCommandPermissions(CommandPermissionLevel); 25 | PlayerPermissions getPlayerPermissions() const; 26 | void setPlayerPermissions(PlayerPermissions); 27 | }; 28 | 29 | 30 | struct Abilities { 31 | std::unordered_map abilityMap; 32 | 33 | std::vector permissionNames; 34 | 35 | std::unordered_map customAbilities; 36 | 37 | Abilities(Abilities const &); 38 | 39 | Abilities(); 40 | 41 | Abilities &operator=(Abilities const &); 42 | 43 | void _addTempCustomAbility(std::string const &); 44 | 45 | void _registerAbilities(); 46 | 47 | void _registerAbility(std::string const &, Ability const &); 48 | 49 | Ability &getAbility(std::string const &); 50 | 51 | Ability &getAbility(std::string const &) const; 52 | 53 | bool getBool(std::string const &) const; 54 | 55 | bool getFloat(std::string const &) const; 56 | 57 | void setAbility(std::string const &, bool); 58 | 59 | void setAbility(std::string const &, float); 60 | 61 | void setAbilityDiff(std::string const &, bool, bool &); 62 | 63 | std::unordered_map const &getAbilities() const; 64 | 65 | std::vector const &getPermissionsAbilitiesNames() const; 66 | 67 | std::unordered_map const &getStoredCustomAbilities() const; 68 | 69 | CommandPermissionLevel getCommandPermissions() const; 70 | 71 | void setCommandPermissions(CommandPermissionLevel); 72 | 73 | PlayerPermissions getPlayerPermissions() const; 74 | 75 | void setPlayerPermissions(PlayerPermissions); 76 | 77 | void addSaveData(CompoundTag &) const; 78 | 79 | void loadSaveData(CompoundTag const &); 80 | 81 | bool isFlying() const; 82 | 83 | //~Abilities(); 84 | 85 | static std::string INVULNERABLE; 86 | static std::string FLYING; 87 | static std::string MAYFLY; 88 | static std::string INSTABUILD; 89 | static std::string LIGHTNING; 90 | static std::string FLYSPEED; 91 | static std::string WALKSPEED; 92 | static std::string MUTED; 93 | static std::string WORLDBUILDER; 94 | static std::string NOCLIP; 95 | static std::string BUILD_AND_MINE; 96 | static std::string DOORS_AND_SWITCHES; 97 | static std::string OPEN_CONTAINERS; 98 | static std::string ATTACK_PLAYERS; 99 | static std::string ATTACK_MOBS; 100 | static std::string OPERATOR; 101 | static std::string TELEPORT; 102 | }; -------------------------------------------------------------------------------- /include/entity/ability/Ability.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct Ability { 4 | /*enum struct Type : char { Invalid = 0, Boolean = 1, Float = 2 }; 5 | enum struct Options : char { Unset = 0, Saved = 1, Command = 2, Permission = 4 }; 6 | union Value { 7 | bool val_bool; 8 | float val_float; 9 | Value(bool); 10 | Value(float); 11 | Value(); 12 | }; 13 | Type type; 14 | Value value; 15 | Options opts; 16 | 17 | Ability(); 18 | Ability(float, Options); 19 | Ability(int, Options); 20 | */ 21 | 22 | char getType() const; 23 | 24 | bool getBool() const; 25 | 26 | float getFloat() const; 27 | 28 | void setBool(bool); 29 | 30 | void setFloat(float) const; 31 | 32 | //bool hasOption(Options) const; 33 | }; -------------------------------------------------------------------------------- /include/entity/animal/EnderMan.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "world/Block.h" 4 | #include "../Mob.h" 5 | 6 | struct EnderMan : Mob { 7 | // TODO: find types 8 | static EnderMan *SPEED_MODIFIER_ATTACKING; 9 | static EnderMan *SPEED_MODIFIER_ATTACKING_UUID; 10 | static EnderMan *mMayTake; 11 | static EnderMan *mMayTakeIsSetup; 12 | 13 | void _teleport(); 14 | 15 | void setCarryingBlock(Block const &); 16 | 17 | Block *getCarryingBlock(); 18 | 19 | bool canBeAffectedByArrow(MobEffectInstance const &); 20 | }; 21 | -------------------------------------------------------------------------------- /include/entity/animal/Wolf.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../Mob.h" 4 | 5 | struct Actor; 6 | 7 | struct Wolf : Mob { 8 | void onBorn(Mob &, Mob &); 9 | 10 | void setInterested(bool); 11 | 12 | void setSitting(bool); 13 | 14 | void setWet(bool); 15 | 16 | void addRider(Actor &); 17 | 18 | bool isAlliedTo(Mob *); 19 | 20 | bool isInterested() const; 21 | 22 | bool isWet() const; 23 | }; 24 | -------------------------------------------------------------------------------- /include/entity/effect/MobEffect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "MobEffectInstance.h" 4 | #include 5 | 6 | // TODO: NYI but size should not need to be known for pointers 7 | struct Amplifier; 8 | struct Attribute; 9 | struct AttributeModifier; 10 | struct AttributeBuff; 11 | 12 | struct Actor; 13 | 14 | struct MobEffect { 15 | MobEffect(int, const std::string &, const std::string &, bool, int, int, const std::string &, bool); 16 | void removeEffects(Actor *); 17 | void applyEffects(Actor *, int, int) const; 18 | int getId() const; 19 | static void initEffects(void *resourcePackManager); 20 | void addAttributeModifier(Attribute const &, std::shared_ptr); 21 | void addAttributeBuff(Attribute const &, std::shared_ptr); 22 | void setValueAmplifier(std::shared_ptr); 23 | void setDurationAmplifier(std::shared_ptr); 24 | static MobEffect *getByName(const std::string &); 25 | static MobEffect *getById(int); 26 | const std::string &getComponentName() const; 27 | const std::string &getResourceName() const; 28 | const std::string &getIconName() const; 29 | // some useless internals 30 | void applyInstantaneousEffect(Actor*, Actor*, Actor*, int, float) const; 31 | bool isHarmful() const; 32 | bool isInstantaneous() const; 33 | const mce::Color &getColor() const; 34 | bool isDisabled() const; 35 | bool isVisible() const; 36 | const std::string &formatDuration(MobEffectInstance const *); 37 | // return types for these? 38 | void clearAttributeBuffs(); 39 | void clearAttributeModifiers(); 40 | void getAttributeModifierValue(int, AttributeModifier const &) const; 41 | void viewAttributeModifiers() const; 42 | 43 | // bc62d48 44 | static const MobEffect *WEAKNESS; 45 | static const mce::Color DEFAULT_COLOR; // ??? 46 | static const MobEffect *EMPTY_EFFECT; 47 | static const MobEffect *MOVEMENT_SPEED; 48 | static const MobEffect *MOVEMENT_SLOWDOWN; 49 | static const MobEffect *DIG_SPEED; 50 | static const MobEffect *DIG_SLOWDOWN; 51 | static const MobEffect *DAMAGE_BOOST; 52 | static const MobEffect *HEAL; 53 | static const MobEffect *HARM; 54 | static const MobEffect *JUMP; 55 | static const MobEffect *CONFUSION; 56 | static const MobEffect *REGENERATION; 57 | static const MobEffect *DAMAGE_RESISTANCE; 58 | static const MobEffect *FIRE_RESISTANCE; 59 | static const MobEffect *WATER_BREATHING; 60 | static const MobEffect *INVISIBILITY; 61 | static const MobEffect *BLINDNESS; 62 | static const MobEffect *NIGHT_VISION; 63 | static const MobEffect *HUNGER; 64 | static const MobEffect *POISON; 65 | static const MobEffect *WITHER; 66 | static const MobEffect *HEALTH_BOOST; 67 | static const MobEffect *ABSORPTION; 68 | static const MobEffect *SATURATION; 69 | static const MobEffect *LEVITATION; 70 | static const MobEffect *FATAL_POISON; 71 | static const MobEffect *CONDUIT_POWER; 72 | static const MobEffect *SLOW_FALLING; 73 | static const MobEffect *BAD_OMEN; 74 | static const MobEffect *HERO_OF_THE_VILLAGE; 75 | // bc62e50 76 | static const MobEffect **mMobEffects; 77 | }; -------------------------------------------------------------------------------- /include/entity/effect/MobEffectInstance.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | struct MobEffectInstance { 6 | MobEffectInstance(); 7 | 8 | MobEffectInstance(unsigned int id); 9 | 10 | MobEffectInstance(unsigned int id, int ticks); 11 | 12 | MobEffectInstance(unsigned int id, int ticks, int amplifier); 13 | 14 | MobEffectInstance(unsigned int id, int ticks, int amplifier, bool, bool particles, bool); 15 | 16 | MobEffectInstance(unsigned int id, int ticks, int amplifier, int, int, int, bool, bool, bool); 17 | 18 | int getId() const; 19 | 20 | int getAmplifier() const; 21 | 22 | std::string getDisplayName() const; 23 | 24 | int getDuration() const; 25 | 26 | int getLingerDuration() const; 27 | 28 | int getSplashDuration() const; 29 | 30 | int getDescriptionId() const; 31 | }; -------------------------------------------------------------------------------- /include/entity/events/ClientPlayerEventCoordinator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "PlayerEventCoordinator.h" 4 | #include "../entity/LocalPlayer.h" 5 | 6 | class IClientInstance {}; 7 | 8 | class PlayerEventListener {}; 9 | 10 | class BlockLegacy {}; 11 | 12 | struct ClientPlayerEventCoordinator : PlayerEventCoordinator { 13 | void registerClientPlayerEventCoordinatorListener(PlayerEventListener &); 14 | 15 | void unregisterClientPlayerEventCoordinatorListener(PlayerEventListener &); 16 | 17 | void sendPlayerCreated(LocalPlayer &); 18 | 19 | void sendLocalPlayerDeath(IClientInstance &, LocalPlayer &); 20 | 21 | void sendPlayerStopRiding(Player &, bool, bool, bool); 22 | 23 | void sendPlayerStartRiding(Player &, BlockPos const &, BlockLegacy const &); 24 | 25 | void sendStartDestroyBlock(Player &player, BlockPos const &block, unsigned char &face); 26 | 27 | void sendPlayerDestroyedBlock(Player &, BlockLegacy const &); 28 | }; -------------------------------------------------------------------------------- /include/entity/events/PlayerEventCoordinator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "client/EventCoordinator.h" 4 | 5 | struct PlayerEventCoordinator : EventCoordinator { 6 | void sendPlayerAttackedActor(Player &, Actor &); 7 | 8 | void sendPlayerItemPlaceInteraction(Player &, ItemInstance const &); 9 | 10 | void sendPlayerDestroyedBlock(Player &, int x, int y, int z); 11 | }; -------------------------------------------------------------------------------- /include/item/Container.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Item.h" 4 | 5 | enum struct ContainerID : int; 6 | 7 | struct PlayerInventory { 8 | ContainerID getSelectedContainerId(); 9 | 10 | void selectSlot(int, ContainerID); 11 | 12 | void setSelectedItem(const ItemStack&); 13 | 14 | void setContainerChanged(int); 15 | 16 | void setItem(int slot, const ItemStack &, ContainerID); 17 | 18 | void swapSlots(int, int); 19 | }; 20 | 21 | struct Container { 22 | bool addItem(ItemStack &); 23 | bool addItemToFirstEmptySlot(ItemStack &); 24 | std::vector getSlots() const; 25 | }; 26 | 27 | struct BaseContainerMenu : Container {}; 28 | 29 | struct SimpleContainer : Container { 30 | ItemStack const &getItem(int) const; 31 | int getContainerSize() const; 32 | int getMaxStackSize() const; 33 | }; -------------------------------------------------------------------------------- /include/item/Enchant.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct Enchant { 4 | enum struct Type { 5 | protection = 0, 6 | fire_protection = 1, 7 | feather_falling = 2, 8 | blast_protection = 3, 9 | projectile_protection = 4, 10 | thorns = 5, 11 | respiration = 6, 12 | depth_strider = 7, 13 | aqua_affinity = 8, 14 | sharpness = 9, 15 | smite = 10, 16 | bane_of_arthropods = 11, 17 | knockback = 12, 18 | fire_aspect = 13, 19 | looting = 14, 20 | efficiency = 15, 21 | silk_touch = 16, 22 | unbreaking = 17, 23 | fortune = 18, 24 | power = 19, 25 | punch = 20, 26 | flame = 21, 27 | infinity = 22, 28 | luck_of_the_sea = 23, 29 | lure = 24, 30 | frost_walker = 25, 31 | mending = 26, 32 | binding = 27, 33 | vanishing = 28, 34 | impaling = 29, 35 | riptide = 30, 36 | loyalty = 31, 37 | channeling = 32, 38 | // TODO 39 | }; 40 | }; -------------------------------------------------------------------------------- /include/item/EnchantUtils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Enchant.h" 4 | #include "Item.h" 5 | #include "EnchantmentInstance.h" 6 | 7 | struct EnchantUtils { 8 | static void applyEnchant(ItemStackBase &item, Enchant::Type type, int level, bool b_unk); 9 | 10 | static void applyEnchant(ItemStackBase &item, EnchantmentInstance const &enchant, int level, bool b_unk); 11 | 12 | static void applyEnchant(ItemStackBase &item, ItemEnchants const &enchants, bool b_unk); 13 | 14 | static bool canEnchant(ItemStackBase const &item, EnchantmentInstance const &enchant, bool b_unk); 15 | 16 | static bool canEnchant(ItemStackBase const &item, Enchant::Type enchant, int level, bool b_unk); 17 | }; -------------------------------------------------------------------------------- /include/item/EnchantmentInstance.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct EnchantmentInstance { 4 | // TODO 5 | }; -------------------------------------------------------------------------------- /include/item/Item.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "util/CompoundTag.h" 4 | #include "world/Block.h" 5 | #include "util/Color.h" 6 | #include "ItemEnchants.h" 7 | 8 | struct Item { 9 | // TODO 10 | }; 11 | 12 | struct ItemStackBase { 13 | uintptr_t **vtable; 14 | Item **item; 15 | void *tag; 16 | Block *block; 17 | uint8_t damage; 18 | char pad_0x0021[0x1]; 19 | uint8_t count; 20 | char pad_0x0023[0x65]; 21 | 22 | bool isNull() const; 23 | 24 | bool isDamageableItem() const; 25 | void setDamageValue(short); 26 | short getDamageValue() const; 27 | 28 | void _setItem(int id, bool b_unk = false); 29 | short getId() const; 30 | 31 | void set(int count); 32 | 33 | void setAuxValue(short meta); 34 | short getAuxValue() const; 35 | 36 | std::string getName() const; 37 | 38 | int getMaxDamage() const; 39 | 40 | int getAttackDamage() const; 41 | 42 | bool isBlock() const; 43 | 44 | void setCustomName(std::string const &); 45 | void setCustomLore(std::string const &); 46 | }; 47 | 48 | struct ItemInstance : ItemStackBase { 49 | static const ItemInstance EMPTY_ITEM; 50 | 51 | ItemInstance(Item const &, int, int); 52 | 53 | bool operator ==(const ItemInstance &) const; 54 | 55 | bool operator !=(const ItemInstance &) const; 56 | 57 | ItemEnchants &getEnchantmentsFromUserData() const; 58 | 59 | bool hasCompoundTextUserData() const; 60 | 61 | bool hasCustomHoverName() const; 62 | 63 | unsigned char getMaxStackSize() const; 64 | 65 | bool hasUserData() const; 66 | 67 | ItemEnchants &getEnchantsFromUserData() const; 68 | 69 | void fromTag(const CompoundTag &); 70 | 71 | void load(const CompoundTag &); 72 | }; 73 | 74 | struct ItemRegistry { 75 | static ItemRegistry *mItemRegistry; 76 | 77 | Item &getItem(std::string const &); 78 | 79 | Item &getItem(short); 80 | }; 81 | 82 | struct ItemStack : ItemInstance { 83 | ItemStack(ItemStack const &); 84 | 85 | ItemStack(ItemInstance const &); 86 | 87 | ItemStack(const Item &); 88 | 89 | ItemStack(const Item &, int, int); 90 | 91 | void setNull(); 92 | 93 | void setBlock(const Block *); 94 | 95 | bool operator==(const ItemStack &) const; 96 | 97 | std::string getFullItemName() const; 98 | }; 99 | 100 | struct ContainerItemStack : ItemStack { 101 | ContainerItemStack(ItemInstance const &); 102 | 103 | ContainerItemStack(ItemStack const &); 104 | 105 | void increaseCount(int); 106 | 107 | void decreaseCount(int); 108 | 109 | void setStackSize(unsigned char); 110 | 111 | void forceSetCount(int); 112 | 113 | unsigned char getStackSize() const; 114 | 115 | // Unknowns 116 | /*ItemStack getItemStack(); 117 | 118 | ItemInstance getItemInstance(); 119 | 120 | ItemStack getItemStack() const; 121 | 122 | ItemInstance getItemInstance() const;*/ 123 | 124 | bool operator==(const ContainerItemStack &) const; 125 | }; 126 | -------------------------------------------------------------------------------- /include/item/ItemEnchants.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct ItemEnchants { 4 | //void addEnchant(EnchantmentInstance); 5 | }; -------------------------------------------------------------------------------- /include/item/ItemUseCallback.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct ItemUseCallback {}; -------------------------------------------------------------------------------- /include/item/VanillaItems.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Item.h" 4 | 5 | struct VanillaItems { 6 | static const Item *mBirchSign; 7 | static const Item *mDoor_iron; 8 | static const Item *mDoor_wood; 9 | static const Item *mFilledMap; 10 | static const Item *mFlowerPot; 11 | static const Item *mGlowStick; 12 | static const Item *mGoldIngot; 13 | static const Item *mHoe_stone; 14 | static const Item *mIronIngot; 15 | static const Item *mItemFrame; 16 | static const Item *mMobPlacer; 17 | static const Item *mRabbitRaw; 18 | static const Item *mRecordCat; 19 | static const Item *mRecordFar; 20 | static const Item *mSlimeBall; 21 | static const Item *mAcaciaSign; 22 | static const Item *mApple_gold; 23 | static const Item *mArmorStand; 24 | static const Item *mBoots_gold; 25 | static const Item *mBoots_iron; 26 | static const Item *mChalkboard; 27 | static const Item *mComparator; 28 | static const Item *mDoor_birch; 29 | static const Item *mDye_powder; 30 | static const Item *mEndCrystal; 31 | static const Item *mEnderpearl; 32 | static const Item *mFireCharge; 33 | static const Item *mFishingRod; 34 | static const Item *mGhast_tear; 35 | static const Item *mJungleSign; 36 | static const Item *mKelp_dried; 37 | static const Item *mMelonSlice; 38 | static const Item *mMutton_raw; 39 | static const Item *mNetherStar; 40 | static const Item *mPumpkinPie; 41 | static const Item *mRabbitFoot; 42 | static const Item *mRabbitHide; 43 | static const Item *mRabbitStew; 44 | static const Item *mRecordMall; 45 | static const Item *mRecordStal; 46 | static const Item *mRecordWait; 47 | static const Item *mRecordWard; 48 | static const Item *mSpider_eye; 49 | static const Item *mSpruceSign; 50 | static const Item *mSword_gold; 51 | static const Item *mSword_iron; 52 | static const Item *mSword_wood; 53 | static const Item *mYellowDust; 54 | static const Item *mBeef_cooked; 55 | static const Item *mBlazePowder; 56 | static const Item *mBoots_chain; 57 | static const Item *mChicken_raw; 58 | static const Item *mChorusFruit; 59 | static const Item *mDarkOakSign; 60 | static const Item *mDoor_acacia; 61 | static const Item *mDoor_jungle; 62 | static const Item *mDoor_spruce; 63 | static const Item *mGold_nugget; 64 | static const Item *mHelmet_gold; 65 | static const Item *mHelmet_iron; 66 | static const Item *mHoe_diamond; 67 | static const Item *mIron_nugget; 68 | static const Item *mMagma_cream; 69 | static const Item *mNether_wart; 70 | static const Item *mNetherbrick; 71 | static const Item *mPotatoBaked; 72 | static const Item *mRecordChirp; 73 | static const Item *mRecordStrad; 74 | static const Item *mSeeds_melon; 75 | static const Item *mSeeds_wheat; 76 | static const Item *mShovel_gold; 77 | static const Item *mShovel_iron; 78 | static const Item *mShovel_wood; 79 | static const Item *mSword_stone; 80 | static const Item *mTNTMinecart; 81 | static const Item *mBeetrootSoup; 82 | static const Item *mDoor_darkoak; 83 | static const Item *mFish_raw_cod; 84 | static const Item *mGlass_bottle; 85 | static const Item *mGoldenCarrot; 86 | static const Item *mHatchet_gold; 87 | static const Item *mHatchet_iron; 88 | static const Item *mHatchet_wood; 89 | static const Item *mHelmet_chain; 90 | static const Item *mMushroomStew; 91 | static const Item *mNetherQuartz; 92 | static const Item *mPickAxe_gold; 93 | static const Item *mPickAxe_iron; 94 | static const Item *mPickAxe_wood; 95 | static const Item *mPorkChop_raw; 96 | static const Item *mRabbitCooked; 97 | static const Item *mRecordBlocks; 98 | static const Item *mRotten_flesh; 99 | static const Item *mShovel_stone; 100 | static const Item *mShulkerShell; 101 | static const Item *mSweetBerries; 102 | static const Item *mTurtleHelmet; 103 | static const Item *mWritten_book; 104 | 105 | //static const Item *registerItems(bool); 106 | 107 | //static const Item *initClientData(); 108 | 109 | static const Item *mBannerPattern; 110 | static const Item *mBoots_diamond; 111 | static const Item *mBoots_leather; 112 | static const Item *mBrewing_stand; 113 | static const Item *mChestMinecart; 114 | static const Item *mDragon_breath; 115 | static const Item *mFireworksItem; 116 | static const Item *mFlintAndSteel; 117 | static const Item *mHatchet_stone; 118 | static const Item *mHeartOfTheSea; 119 | static const Item *mLeggings_gold; 120 | static const Item *mLeggings_iron; 121 | static const Item *mMutton_cooked; 122 | static const Item *mNautilusShell; 123 | static const Item *mPickAxe_stone; 124 | static const Item *mPortfolioBook; 125 | static const Item *mRecordMellohi; 126 | static const Item *mSeeds_pumpkin; 127 | static const Item *mSplash_potion; 128 | static const Item *mSword_diamond; 129 | static const Item *mWritable_book; 130 | static const Item *mCarrotOnAStick; 131 | static const Item *mChicken_cooked; 132 | static const Item *mEnchanted_book; 133 | static const Item *mFireworkCharge; 134 | static const Item *mGoldHorseArmor; 135 | static const Item *mHelmet_diamond; 136 | static const Item *mHelmet_leather; 137 | static const Item *mHopperMinecart; 138 | static const Item *mIronHorseArmor; 139 | static const Item *mLeggings_chain; 140 | static const Item *mSeeds_beetroot; 141 | static const Item *mShovel_diamond; 142 | static const Item *mSpeckled_melon; 143 | 144 | //static const Item *unregisterItems(); 145 | 146 | static const Item *mApple_enchanted; 147 | static const Item *mChestplate_gold; 148 | static const Item *mChestplate_iron; 149 | static const Item *mFish_cooked_cod; 150 | static const Item *mFish_raw_salmon; 151 | static const Item *mHatchet_diamond; 152 | static const Item *mPhantomMembrane; 153 | static const Item *mPickAxe_diamond; 154 | static const Item *mPorkChop_cooked; 155 | static const Item *mPrismarineShard; 156 | static const Item *mRapidFertilizer; 157 | static const Item *mChestplate_chain; 158 | static const Item *mLeggings_diamond; 159 | static const Item *mLeggings_leather; 160 | static const Item *mLingering_potion; 161 | static const Item *mPoisonous_potato; 162 | static const Item *mChorusFruitPopped; 163 | static const Item *mDiamondHorseArmor; 164 | static const Item *mLeatherHorseArmor; 165 | static const Item *mChestplate_diamond; 166 | static const Item *mChestplate_leather; 167 | static const Item *mFish_cooked_salmon; 168 | static const Item *mFish_raw_clownfish; 169 | static const Item *mPrismarineCrystals; 170 | static const Item *mFish_raw_pufferfish; 171 | static const Item *mCommandBlockMinecart; 172 | static const Item *mExperiencePotionItem; 173 | static const Item *mFermented_spider_eye; 174 | 175 | //static const Item *initCreativeCategories(); 176 | 177 | //static const Item *initCreativeItemsCallback(ActorInfoRegistry *, BlockDefinitionGroup *, bool); 178 | 179 | static const Item *mBed; 180 | static const Item *mBow; 181 | static const Item *mEgg; 182 | static const Item *mBell; 183 | static const Item *mBoat; 184 | static const Item *mBone; 185 | static const Item *mBook; 186 | static const Item *mBowl; 187 | static const Item *mCake; 188 | static const Item *mClay; 189 | static const Item *mCoal; 190 | static const Item *mKelp; 191 | static const Item *mLead; 192 | static const Item *mSign; 193 | static const Item *mApple; 194 | static const Item *mArrow; 195 | static const Item *mBread; 196 | static const Item *mBrick; 197 | static const Item *mClock; 198 | static const Item *mFlint; 199 | static const Item *mPaper; 200 | static const Item *mReeds; 201 | static const Item *mScute; 202 | static const Item *mSkull; 203 | static const Item *mStick; 204 | static const Item *mSugar; 205 | static const Item *mTotem; 206 | static const Item *mWheat; 207 | static const Item *mBanner; 208 | static const Item *mBleach; 209 | static const Item *mBucket; 210 | static const Item *mCamera; 211 | static const Item *mCarrot; 212 | static const Item *mCookie; 213 | static const Item *mElytra; 214 | static const Item *mHopper; 215 | static const Item *mPotato; 216 | static const Item *mPotion; 217 | static const Item *mSaddle; 218 | static const Item *mShears; 219 | static const Item *mShield; 220 | static const Item *mString; 221 | static const Item *mBalloon; 222 | static const Item *mCompass; 223 | static const Item *mDiamond; 224 | static const Item *mEmerald; 225 | static const Item *mFeather; 226 | static const Item *mIceBomb; 227 | static const Item *mLeather; 228 | static const Item *mNameTag; 229 | static const Item *mSulphur; 230 | static const Item *mTrident; 231 | static const Item *mBeef_raw; 232 | static const Item *mBeetroot; 233 | static const Item *mBlazeRod; 234 | static const Item *mCampfire; 235 | static const Item *mCauldron; 236 | static const Item *mCompound; 237 | static const Item *mCrossbow; 238 | static const Item *mEmptyMap; 239 | static const Item *mEnderEye; 240 | static const Item *mHoe_gold; 241 | static const Item *mHoe_iron; 242 | static const Item *mHoe_wood; 243 | static const Item *mMedicine; 244 | static const Item *mMinecart; 245 | static const Item *mPainting; 246 | static const Item *mRecord11; 247 | static const Item *mRecord13; 248 | static const Item *mRedStone; 249 | static const Item *mRepeater; 250 | static const Item *mSnowBall; 251 | static const Item *mSparkler; 252 | }; -------------------------------------------------------------------------------- /include/math/AABB.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Vec3.h" 4 | 5 | struct AABB { 6 | Vec3 min, max; 7 | 8 | AABB(); 9 | 10 | AABB(float, float, float, float, float, float); 11 | 12 | AABB(Vec3 const&, Vec3 const&); 13 | 14 | // Check if these two return vals are right, guessed off BDS 15 | AABB set(AABB const&); 16 | 17 | AABB &set(Vec3 const&, Vec3 const&); 18 | 19 | void set(float, float, float, float, float, float); 20 | 21 | void expand(Vec3 const&); 22 | 23 | float getSize() const; 24 | 25 | float getVolume() const; 26 | 27 | Vec3 getBounds() const; 28 | 29 | Vec3 getCenter() const; 30 | 31 | AABB grow(Vec3 const&) const; 32 | 33 | AABB resize(Vec3 const&) const; 34 | 35 | AABB shrink(Vec3 const&) const; 36 | 37 | //HitResult clip(Vec3 const&, Vec3 const&) const; 38 | 39 | AABB translated(Vec3 const&) const; 40 | 41 | // TODO: Cause grow and expand doesn't do what I want them to or I just didn't write their signatures correctly >.< 42 | 43 | void offset(const Vec3 &o) { 44 | min.x += o.x; 45 | min.y += o.y; 46 | min.z += o.z; 47 | 48 | max.x += o.x; 49 | max.y += o.y; 50 | max.z += o.z; 51 | } 52 | 53 | void offset(float x, float y, float z) { 54 | min.x += x; 55 | min.y += y; 56 | min.z += z; 57 | 58 | max.x += x; 59 | max.y += y; 60 | max.z += z; 61 | } 62 | 63 | static const AABB ZERO; 64 | }; -------------------------------------------------------------------------------- /include/math/BlockPos.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Vec3.h" 4 | #include "Facing.h" 5 | 6 | struct ChunkPos {}; 7 | 8 | struct BlockPos { 9 | int32_t x; 10 | uint32_t y; 11 | int32_t z; 12 | 13 | //BlockPos(float, float, float); 14 | 15 | BlockPos(int32_t x, uint32_t y, int32_t z) : x(x), y(y), z(z) {}; 16 | 17 | /** 18 | * Create BlockPos from Vec3 19 | */ 20 | BlockPos(Vec3 const &); 21 | 22 | /** 23 | * Create BlockPos from ChunkPos 24 | */ 25 | BlockPos(ChunkPos const &, int); 26 | 27 | /** 28 | * Copy BlockPos 29 | * @param pos 30 | */ 31 | BlockPos(BlockPos const &pos) : BlockPos(pos.x, pos.y, pos.z) {}; 32 | 33 | static BlockPos MAX; 34 | static BlockPos MIN; 35 | static BlockPos ONE; 36 | static BlockPos ZERO; 37 | 38 | /** 39 | * Get Vec3 with center of BlockPos instead of the corner 40 | * @return Vec3 41 | */ 42 | Vec3 center() const; 43 | 44 | BlockPos neighbor(unsigned char) const; 45 | 46 | BlockPos relative(unsigned char, int) const; 47 | 48 | inline friend std::ostream& operator<<(std::ostream &ss, const BlockPos &blockPos) { 49 | return ss << "BlockPos{" << blockPos.x << ", " << blockPos.y << ", " << blockPos.z << "}"; 50 | } 51 | }; -------------------------------------------------------------------------------- /include/math/Facing.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | // Yes, Player->getDirection() is weird so this was required 6 | enum struct LookDirection : unsigned char { 7 | SOUTH, WEST, NORTH, EAST 8 | }; 9 | 10 | struct Direction { 11 | enum : unsigned char { 12 | DOWN, UP, NORTH, SOUTH, WEST, EAST, INVALID = 255 13 | }; 14 | 15 | static unsigned char getDirection(float, float); 16 | static unsigned char getDirection(int, int, int, int); 17 | 18 | // If it's INVALID you're on your own, I don't see the point in allocating 255 pointers 19 | static constexpr const char *names[] = {"Below", "Above", "North", "South", "West", "East"}; 20 | 21 | static unsigned char convertFacingDirectionToDirection(unsigned char); 22 | // Did I reimpl convertFacingDirectionToDirection? 23 | /*static constexpr unsigned char fromLook(LookDirection look) { 24 | switch (look) { 25 | case LookDirection::SOUTH: 26 | return SOUTH; 27 | case LookDirection::WEST: 28 | return WEST; 29 | case LookDirection::NORTH: 30 | return NORTH; 31 | case LookDirection::EAST: 32 | return EAST; 33 | } 34 | return INVALID; 35 | }*/ 36 | }; 37 | 38 | // TODO: Real Facing struct, though it's very rarely used (eg. BlockGeometry and BlockTessellator) -------------------------------------------------------------------------------- /include/math/SubChunkPos.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "BlockPos.h" 4 | 5 | struct SubChunkPos { 6 | SubChunkPos(const BlockPos &); 7 | 8 | SubChunkPos(const ChunkPos &, int); 9 | 10 | SubChunkPos(float, float, float); 11 | }; -------------------------------------------------------------------------------- /include/math/Vec2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Facing.h" 4 | 5 | #include 6 | #include 7 | 8 | struct Vec2 { 9 | union { 10 | struct { 11 | float pitch, yaw; 12 | }; 13 | struct { 14 | float x, y; 15 | }; 16 | }; 17 | 18 | Vec2(float x, float y) : x(x), y(y) {} 19 | 20 | static Vec2 NEG_UNIT_X, 21 | NEG_UNIT_Y, 22 | MAX, 23 | MIN, 24 | ONE, 25 | ZERO, 26 | UNIT_X, 27 | UNIT_Y; 28 | 29 | // What 30 | operator LookDirection() { 31 | return static_cast(Direction::getDirection(sin(yaw) * 0.0174532, cos(yaw) * 0.0174532)); 32 | } 33 | 34 | /*Vec2 &operator =(const Vec2 &o) { 35 | x = o.x; 36 | y = o.y; 37 | return *this; 38 | }*/ 39 | 40 | Vec2 distance(const Vec2 &o) { 41 | return {std::abs(x - o.x), std::abs(y - o.y)}; 42 | } 43 | 44 | Vec2 add(const Vec2 &o) { 45 | return {x + o.x, y + o.y}; 46 | } 47 | 48 | Vec2 subtract(const Vec2 &o) const { 49 | return {x - o.x, y - o.y}; 50 | } 51 | 52 | Vec2 multiply(const Vec2 &o) const { 53 | return {x * o.x, y * o.y}; 54 | } 55 | 56 | Vec2 limit(const Vec2 &o) const { 57 | return { 58 | x > o.x ? o.x : x < o.x ? -o.x : x, 59 | y > o.y ? o.y : y < o.y ? -o.y : y 60 | }; 61 | } 62 | 63 | friend std::ostream& operator<<(std::ostream &ss, const Vec2 &vec2) { 64 | return ss << "Vec2{" << vec2.pitch << ", " << vec2.yaw << "}"; 65 | } 66 | 67 | inline Vec2 &operator=(const Vec2 &other) { 68 | this->x = other.x; 69 | this->y = other.y; 70 | return *this; 71 | } 72 | }; -------------------------------------------------------------------------------- /include/math/Vec3.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "Vec2.h" 5 | 6 | struct BlockPos; 7 | 8 | // TODO: Cleanup self defined utility functions (constexpr stuff?) 9 | struct Vec3 { 10 | union { 11 | struct { 12 | float x, y, z; 13 | }; 14 | struct { 15 | float pitch, yaw, headYaw; 16 | }; 17 | }; 18 | 19 | Vec3(BlockPos const &); 20 | 21 | // Pos is unknown 22 | //Vec3(Post const &); 23 | 24 | Vec3(float x, float y, float z) : x(x), y(y), z(z) {}; 25 | 26 | Vec3(float x) : x(x), y(x), z(x) {}; 27 | 28 | Vec3() : x(0.f), y(0.f), z(0.f) {}; 29 | 30 | // Conversion from Vec2 we just combine yaw (not like most server softwares impl it anyway) 31 | explicit Vec3(const Vec2 &rotations) : x(rotations.x), y(rotations.y), z(rotations.y) {}; 32 | // Conversion for the lossy bytes some packets use for rotations 33 | explicit Vec3(uint8_t xRot, uint8_t yRot, uint8_t zRot) : pitch(xRot * (360.f / 256.f)), yaw(yRot * (360.f / 256.f)), headYaw(zRot * (360.f / 256.f)) {}; 34 | 35 | static Vec3 NEG_UNIT_X, 36 | NEG_UNIT_Y, 37 | NEG_UNIT_Z, 38 | MAX, 39 | MIN, 40 | ONE, 41 | TWO, 42 | HALF, 43 | ZERO, 44 | UNIT_X, 45 | UNIT_Y, 46 | UNIT_Z; 47 | 48 | inline bool operator==(Vec3 &vec3) { 49 | return x == vec3.x && y == vec3.y && z == vec3.z; 50 | } 51 | 52 | inline bool operator!=(Vec3 &vec3) { 53 | return x != vec3.x || y != vec3.y || z != vec3.z; 54 | } 55 | 56 | inline Vec3 &operator=(const Vec3 &vec3) { 57 | x = vec3.x; 58 | y = vec3.y; 59 | z = vec3.z; 60 | return *this; 61 | } 62 | 63 | inline Vec3 add(const Vec3 &o) const { 64 | return {x + o.x, y + o.y, z + o.z}; 65 | } 66 | 67 | inline Vec3 add(float ox, float oy, float oz) const { 68 | return {x + ox, y + oy, z + oz}; 69 | } 70 | 71 | inline Vec3 subtract(const Vec3 &o) const { 72 | return {x - o.x, y - o.y, z - o.z}; 73 | } 74 | 75 | inline Vec3 subtract(float ox, float oy, float oz) const { 76 | return {x - ox, y - oy, z - oz}; 77 | } 78 | 79 | inline Vec3 multiply(const Vec3 &o) const { 80 | return {x * o.x, y * o.y, z * o.z}; 81 | } 82 | 83 | inline Vec3 multiply(float ox, float oy, float oz) const { 84 | return {x * ox, y * oy, z * oz}; 85 | } 86 | 87 | inline Vec3 multiply(float h, float v) const { 88 | return {x * h, y * v, z * h}; 89 | } 90 | 91 | inline friend std::ostream& operator<<(std::ostream &ss, const Vec3 &vec3) { 92 | return ss << "Vec3{" << vec3.x << ", " << vec3.y << ", " << vec3.z << "}"; 93 | } 94 | 95 | inline float delta() { 96 | return std::sqrt(x * x + z * z); 97 | } 98 | 99 | inline float distance(const Vec3 &o) const { 100 | return std::abs(x - o.x) + std::abs(y - o.y) + std::abs(z - o.z); 101 | } 102 | }; -------------------------------------------------------------------------------- /include/mce/Image.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace cg { 4 | struct ImageBuffer; 5 | } 6 | 7 | struct ImageUtilsExt { 8 | static void savePNG(cg::ImageBuffer const&, std::ostream&); 9 | }; 10 | 11 | namespace mce { 12 | struct Image { 13 | Image(std::vector >&&); 14 | 15 | void setRawImage(std::vector >&&); 16 | 17 | void copyRawImage(std::vector > const&); 18 | 19 | void resizeImageBytesToFitImageDescription(); 20 | 21 | bool isEmpty() const; 22 | }; 23 | 24 | struct ImageUtils { 25 | // Returns size, I think? 26 | static short uncompress(Image &); 27 | }; 28 | } 29 | 30 | namespace cg { 31 | struct ImageDescription { 32 | unsigned int getArraySize() const; 33 | 34 | unsigned int getStorageSize() const; 35 | 36 | unsigned int getSubimageSize(); 37 | }; 38 | 39 | struct ImageBuffer { 40 | ImageBuffer(mce::Image &&); 41 | 42 | ImageBuffer(mce::Image const&); 43 | 44 | void allocateStorage(cg::ImageDescription const&); 45 | 46 | ImageDescription getImageDescription() const; 47 | 48 | bool isEmpty() const; 49 | 50 | bool isValid() const; 51 | 52 | unsigned int getStorageSize() const; 53 | 54 | unsigned char get(unsigned int); 55 | 56 | /*std::vector> &*/unsigned char *data() const; 57 | }; 58 | 59 | 60 | } 61 | -------------------------------------------------------------------------------- /include/mce/Shader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace mce { 4 | struct Shader { 5 | 6 | }; 7 | } -------------------------------------------------------------------------------- /include/mce/UUID.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace mce { 7 | struct UUID { 8 | uint64_t most, least; 9 | 10 | UUID() {} 11 | 12 | UUID(const UUID &oth) { 13 | most = oth.most; 14 | least = oth.least; 15 | } 16 | 17 | const std::string asString() const; 18 | 19 | static UUID fromString(std::string const &); 20 | 21 | bool operator==(UUID const &another) const; 22 | 23 | bool operator<(UUID const &another) const; 24 | 25 | bool operator!=(UUID const &another) const; 26 | }; 27 | } 28 | 29 | namespace std { 30 | template<> 31 | struct hash { 32 | size_t operator()(mce::UUID const &uuid) const { 33 | auto seed = std::hash{}(uuid.most); 34 | seed ^= std::hash{}(uuid.least) + 0x9e3779b9 + (seed << 6) + (seed >> 2); 35 | return seed; 36 | } 37 | }; 38 | } -------------------------------------------------------------------------------- /include/network/BinaryStream.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "item/Item.h" 4 | #include "math/BlockPos.h" 5 | #include "gsl-lite.hpp" 6 | 7 | struct ReadOnlyBinaryStream { 8 | long long getVarInt64(); 9 | int getSignedInt(); 10 | float getFixedFloat(double); 11 | long long getSignedInt64(); 12 | short getSignedShort(); 13 | unsigned int getUnsignedInt(); 14 | unsigned char getUnsignedChar(); 15 | unsigned long long getUnsignedInt64(); 16 | unsigned short getUnsignedShort(); 17 | unsigned int getUnsignedVarInt(); 18 | float getNormalizedFloat(); 19 | unsigned long long getUnsignedVarInt64(); 20 | int getSignedBigEndianInt(); 21 | bool getBool(); 22 | unsigned char getByte(); 23 | float getFloat(); 24 | double getDouble(); 25 | int getVarInt(); 26 | gsl::basic_string_span getString(); 27 | float getByteRotation() { 28 | return static_cast(getByte() * (360.f / 256.f)); 29 | } 30 | }; 31 | 32 | struct BinaryStream : ReadOnlyBinaryStream { 33 | BinaryStream(); 34 | void reset(); 35 | void writeFloat(float); 36 | void writeDouble(double); 37 | void writeStream(BinaryStream&); 38 | void writeString(gsl::basic_string_span); 39 | void writeVarInt(int); 40 | void writeVarInt64(long); 41 | void writeSignedInt(int); 42 | void writeFixedFloat(float, double); 43 | void writeSignedInt64(long long); 44 | void writeSignedShort(short); 45 | void writeUnsignedInt(unsigned int); 46 | void writeUnsignedChar(unsigned char); 47 | void writeUnsignedInt64(unsigned long long); 48 | void writeUnsignedShort(unsigned short); 49 | void writeUnsignedVarInt(unsigned int); 50 | void writeNormalizedFloat(float); 51 | void writeUnsignedVarInt64(unsigned long); 52 | void writeSignedBigEndianInt(int); 53 | void write(void const*, unsigned int); 54 | void writeBool(bool); 55 | void writeByte(unsigned char); 56 | // TODO These aren't in the game obviously, they're just useful adaptations from PMMP 57 | void writeByteRotation(unsigned char rotation) { 58 | writeByte(static_cast(rotation / (360.f / 256.f))); 59 | } 60 | void writeBlockPos(const BlockPos &pos) { 61 | writeVarInt(pos.x); 62 | writeUnsignedVarInt(pos.y); 63 | writeVarInt(pos.z); 64 | } 65 | void writeVec3(const Vec3 &vec3) { 66 | writeFloat(vec3.x); 67 | writeFloat(vec3.y); 68 | writeFloat(vec3.z); 69 | } 70 | }; 71 | -------------------------------------------------------------------------------- /include/network/ConnectionRequest.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | struct ConnectionRequest { 4 | std::string getDeviceId() const; 5 | 6 | std::string getTenantId() const; 7 | 8 | std::string getDeviceModel() const; 9 | 10 | std::string getSelfSignedId() const; 11 | 12 | std::string getSkinGeometry() const; 13 | 14 | std::string getServerAddress() const; 15 | 16 | std::string getClientPlatformId() const; 17 | 18 | std::string getSkinGeometryName() const; 19 | 20 | std::string getGameVersionString() const; 21 | 22 | std::string getClientThirdPartyName() const; 23 | 24 | std::string getClientPlatformOnlineId() const; 25 | 26 | std::string getClientPlatformOfflineId() const; 27 | 28 | std::string getSkinId() const; 29 | 30 | int getDeviceOS() const; 31 | 32 | int getGuiScale() const; 33 | 34 | int getUIProfile() const; 35 | 36 | int getCurrentInputMode() const; 37 | 38 | int getDefaultInputMode() const; 39 | 40 | int getADRole() const; 41 | 42 | std::string toString(); 43 | }; -------------------------------------------------------------------------------- /include/network/ExternalServer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct ExternalServer { 4 | // TODO: Fix 5 | 6 | /** 7 | * Get absolute IP address of server. Useful when trying to play on load-balancing servers with friends. 8 | * @return std::string 9 | */ 10 | std::string getIP() const; 11 | 12 | /** 13 | * Get server port 14 | * @return int 15 | */ 16 | int getPort() const; 17 | 18 | /** 19 | * Get advertised max plsyers 20 | * @return int 21 | */ 22 | int getMaxPlayers() const; 23 | 24 | /** 25 | * Get server version 26 | * @return std::string 27 | */ 28 | std::string getVersion() const; 29 | 30 | /** 31 | * Get server protocol 32 | * @return std::string 33 | */ 34 | std::string getProtocol() const; 35 | }; 36 | -------------------------------------------------------------------------------- /include/network/NetworkHandler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "NetworkPeer.h" 4 | #include "NetworkIdentifier.h" 5 | 6 | struct NetworkHandler { 7 | NetworkPeer &getPeerForUser(NetworkIdentifier const &); 8 | 9 | struct Connection {}; 10 | }; -------------------------------------------------------------------------------- /include/network/NetworkIdentifier.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | struct NetworkIdentifier { 9 | private: 10 | char filler[0x10]; 11 | 12 | public: 13 | sockaddr_storage sa; // 90 14 | int family; 15 | 16 | bool equalsTypeData(NetworkIdentifier const &) const; 17 | 18 | int getHash() const; 19 | 20 | std::string toString() const; 21 | 22 | bool operator==(NetworkIdentifier const &addr) const { return equalsTypeData(addr); } 23 | }; 24 | 25 | namespace std { 26 | template<> 27 | struct hash { 28 | std::size_t operator()(NetworkIdentifier const &s) const noexcept { 29 | return s.getHash(); 30 | } 31 | }; 32 | } -------------------------------------------------------------------------------- /include/network/NetworkPeer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "NetworkStats.h" 4 | 5 | struct NetworkPeer { 6 | virtual ~NetworkPeer(); 7 | 8 | virtual void sendPacket(); 9 | 10 | virtual void receivePacket(); 11 | 12 | virtual NetworkStats getNetworkStatus(void); 13 | }; -------------------------------------------------------------------------------- /include/network/NetworkStats.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | struct NetworkStats { 6 | private: 7 | int32_t filler; 8 | 9 | public: 10 | int32_t ping, avgPing, maxBps; 11 | float packetLoss, avgPacketLoss; 12 | }; -------------------------------------------------------------------------------- /include/network/PacketSender.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "protocol/Packet.h" 7 | 8 | struct PacketSender { 9 | unsigned char flag; 10 | 11 | PacketSender(unsigned char flag); 12 | 13 | virtual ~PacketSender(); 14 | 15 | virtual void send(Packet &) = 0; 16 | 17 | virtual void sendToServer(Packet &) = 0; 18 | 19 | virtual void sendToClient(NetworkIdentifier const &, Packet const &, unsigned char) = 0; 20 | 21 | virtual void sendBroadcast(Packet const &) = 0; 22 | 23 | virtual void sendBroadcast(NetworkIdentifier const &, unsigned char, Packet const &) = 0; 24 | 25 | virtual void flush(NetworkIdentifier const &, std::function) = 0; 26 | }; -------------------------------------------------------------------------------- /include/network/ServerNetworkHandler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "NetworkHandler.h" 4 | #include "ServerPlayer.h" 5 | 6 | struct ServerNetworkHandler : NetworkHandler { 7 | void disconnectClient(NetworkIdentifier const &, std::string const &, bool); 8 | 9 | ServerPlayer *_getServerPlayer(NetworkIdentifier const &, unsigned char); 10 | }; -------------------------------------------------------------------------------- /include/network/ServerPlayer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "entity/Player.h" 4 | #include "util/GameType.h" 5 | #include "item/ItemInstance.h" 6 | #include "item/ItemUseCallback.h" 7 | #include "math/Vec3.h" 8 | #include "protocol/Packet.h" 9 | #include "protocol/TextPacket.h" 10 | #include "protocol/SetTitlePacket.h" 11 | #include "protocol/ModalFormRequestPacket.h" 12 | #include "protocol/ModalFormResponsePacket.h" 13 | #include "protocol/ServerSettingsRequestPacket.h" 14 | #include "protocol/ServerSettingsResponsePacket.h" 15 | #include "protocol/DisconnectPacket.h" 16 | 17 | struct ServerPlayer : Player { 18 | void sendNetworkPacket(Packet &packet) const; 19 | 20 | void setPlayerGameType(GameType) override; 21 | 22 | void disconnect(); 23 | 24 | void disconnect(const std::string &message) { 25 | DisconnectPacket pk{message, false}; 26 | pk.playerSubIndex = getClientSubId(); 27 | sendNetworkPacket(pk); 28 | } 29 | 30 | //Sends chat message to player 31 | void sendMessage(const std::string &message, TextPacket::TextPacketType type = TextPacket::TextPacketType::RAW) { 32 | auto pk = TextPacket::createSystemMessage(message); 33 | pk.type = type; 34 | sendNetworkPacket(pk); 35 | } 36 | 37 | void sendTip(const std::string &message) { 38 | sendMessage(message, TextPacket::TextPacketType::TIP); 39 | } 40 | 41 | //Adds a title text to the user's screen, with an optional subtitle. 42 | void addTitle(const std::string &title, const std::string &subtitle = "", int fadeIn = -1, int stay = -1, 43 | int fadeOut = -1) { 44 | setTitleDuration(fadeIn, stay, fadeOut); 45 | if (!subtitle.empty()) { 46 | addSubTitle(subtitle); 47 | } 48 | sendTitleText(title, SetTitlePacket::TitleType::SET_TITLE); 49 | } 50 | 51 | //Sets the subtitle message, without sending a title. 52 | void addSubTitle(const std::string &message) { 53 | sendTitleText(message, SetTitlePacket::TitleType::SET_SUBTITLE); 54 | } 55 | 56 | //Adds small text to the user's screen. 57 | void addActionBarMessage(const std::string &message) { 58 | sendTitleText(message, SetTitlePacket::TitleType::SET_ACTIONBAR_MESSAGE); 59 | } 60 | 61 | //Removes the title from the client's screen. 62 | void removeTitles() { 63 | SetTitlePacket pk{this->getClientSubId(), SetTitlePacket::TitleType::CLEAR_TITLE}; 64 | sendNetworkPacket(pk); 65 | } 66 | 67 | //Resets the title duration settings. 68 | void resetTitles() { 69 | SetTitlePacket pk{this->getClientSubId(), SetTitlePacket::TitleType::RESET_TITLE}; 70 | sendNetworkPacket(pk); 71 | } 72 | 73 | //Sets the title duration. 74 | void setTitleDuration(int fadeIn, int stay, int fadeOut) { 75 | SetTitlePacket pk{this->getClientSubId(), fadeIn, stay, fadeOut}; 76 | pk.type = SetTitlePacket::TitleType::SET_ANIMATION_TIMES; 77 | sendNetworkPacket(pk); 78 | } 79 | 80 | //Function used for sending titles. 81 | void sendTitleText(const std::string &message, SetTitlePacket::TitleType type) { 82 | SetTitlePacket pk{this->getClientSubId(), type}; 83 | pk.message = message; 84 | sendNetworkPacket(pk); 85 | } 86 | }; -------------------------------------------------------------------------------- /include/network/protocol/ActorEventPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Packet.h" 4 | #include "util/ActorRuntimeID.h" 5 | 6 | struct ActorEventPacket : Packet { 7 | ActorRuntimeID eid; 8 | unsigned char event; 9 | char pad_001C[3]; 10 | int data; 11 | 12 | ActorEventPacket(ActorRuntimeID eid, unsigned char event, int data) : eid(eid), event(event), data(data), pad_001C{0} {} 13 | 14 | #include "VirtualTemplate.h" 15 | }; 16 | 17 | static_assert(offsetof(ActorEventPacket, eid) == 0x28); 18 | static_assert(offsetof(ActorEventPacket, event) == 0x30); 19 | static_assert(offsetof(ActorEventPacket, data) == 0x34); -------------------------------------------------------------------------------- /include/network/protocol/ActorFallPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Packet.h" 4 | 5 | struct ActorFallPacket : Packet { 6 | /** 7 | * Actor Runtime ID 8 | */ 9 | ActorRuntimeID rid; 10 | 11 | /** 12 | * Fall Distance 13 | */ 14 | float fallDistance; 15 | 16 | /** 17 | * Actor below bedrock 18 | */ 19 | bool inVoid; 20 | 21 | #include "VirtualTemplate.h" 22 | }; -------------------------------------------------------------------------------- /include/network/protocol/AddActorPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Packet.h" 4 | #include "gsl-lite.hpp" 5 | 6 | struct AddActorPacket : Packet { 7 | char pad_0024[0x1C]; 8 | Vec3 pos, motion, rot; 9 | char pad_0038[0x4]; // TODO: Attributes 10 | ActorUniqueID uid; 11 | ActorRuntimeID rid; 12 | char pad_0078[0x20]; // TODO: Synced actor data 13 | gsl::cstring_span entityType; 14 | // TODO: Entity meta data/links/attributes 15 | 16 | #include "VirtualTemplate.h" 17 | }; 18 | 19 | static_assert(offsetof(AddActorPacket, pos) == 0x40); 20 | static_assert(offsetof(AddActorPacket, motion) == 0x4C); 21 | static_assert(offsetof(AddActorPacket, rot) == 0x58); 22 | static_assert(offsetof(AddActorPacket, uid) == 0x68); 23 | static_assert(offsetof(AddActorPacket, rid) == 0x70); 24 | static_assert(offsetof(AddActorPacket, entityType) == 0x98); 25 | -------------------------------------------------------------------------------- /include/network/protocol/AddItemActorPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "util/DataItem.h" 4 | #include "util/ActorRuntimeID.h" 5 | #include "item/Item.h" 6 | #include "Packet.h" 7 | #include 8 | 9 | struct AddItemActorPacket : Packet { 10 | char pad_0024[0x20]; // TODO: Synched actor data(?) 11 | ActorUniqueID uid; // 0x48 12 | ActorRuntimeID eid; // 0x50 13 | ItemStack stack; // 0x58 14 | char stackpad[0x8]; // cause I probably am missing fields in ItemStackBase or this is some other random ptr 15 | //char pad_0060[0x8]; // Item meta? 16 | /*std::vector meta; 17 | char pad[0x70];*/ 18 | Vec3 pos; // 0x84 19 | Vec3 motion; // 0x90 20 | bool fromFishing; // 0x100 21 | 22 | #include "VirtualTemplate.h" 23 | }; 24 | 25 | static_assert(offsetof(AddItemActorPacket, uid) == 0x48); 26 | static_assert(offsetof(AddItemActorPacket, eid) == 0x50); 27 | static_assert(offsetof(AddItemActorPacket, stack) == 0x58); 28 | static_assert(offsetof(AddItemActorPacket, pos) == 0xE8); 29 | static_assert(offsetof(AddItemActorPacket, motion) == 0xF4); 30 | static_assert(offsetof(AddItemActorPacket, fromFishing) == 0x100); 31 | -------------------------------------------------------------------------------- /include/network/protocol/AddPlayerPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "util/DataItem.h" 4 | #include "Packet.h" 5 | #include "mce/UUID.h" 6 | #include "util/ActorRuntimeID.h" 7 | #include "util/DeviceOS.h" 8 | #include "gsl-lite.hpp" 9 | #include "item/Item.h" 10 | #include 11 | 12 | // TODO: Update 13 | 14 | struct AddPlayerPacket : Packet { 15 | char pad[0x24]; 16 | gsl::cstring_span username; 17 | mce::UUID uuid; 18 | ActorUniqueID uid; 19 | ActorRuntimeID eid; 20 | char pad2[0x8]; 21 | gsl::cstring_span platformChatId; 22 | Vec3 pos; 23 | Vec3 motion; 24 | Vec3 rot; 25 | ItemStack stack; 26 | // Can't read the hell hole that's going on past loc_4A14427 27 | //std::vector meta; 28 | char idk[0x168]; 29 | gsl::cstring_span deviceId; 30 | DeviceOS platform; // Off the top of my head: 0 = Android, 7 = Windows 10 31 | 32 | #include "VirtualTemplate.h" 33 | }; 34 | 35 | static_assert(offsetof(AddPlayerPacket, username) == 0x48); 36 | static_assert(offsetof(AddPlayerPacket, uuid) == 0x58); 37 | static_assert(offsetof(AddPlayerPacket, uid) == 0x68); 38 | static_assert(offsetof(AddPlayerPacket, eid) == 0x70); 39 | static_assert(offsetof(AddPlayerPacket, platformChatId) == 0x80); 40 | static_assert(offsetof(AddPlayerPacket, pos) == 0x90); 41 | static_assert(offsetof(AddPlayerPacket, motion) == 0x9C); 42 | static_assert(offsetof(AddPlayerPacket, rot) == 0xA8); 43 | static_assert(offsetof(AddPlayerPacket, stack) == 0xB8); 44 | //static_assert(offsetof(AddPlayerPacket, meta) == 0xF8); ? 45 | static_assert(offsetof(AddPlayerPacket, deviceId) == 0x2A8); 46 | static_assert(offsetof(AddPlayerPacket, platform) == 0x2B8); 47 | -------------------------------------------------------------------------------- /include/network/protocol/AnimatePacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Packet.h" 4 | #include "util/ActorRuntimeID.h" 5 | 6 | /** 7 | * Packet for hand swings 8 | */ 9 | struct AnimatePacket : Packet { 10 | enum struct Action : uint32_t { 11 | None = 0, 12 | SwingArm = 1, 13 | StopSleep = 3, 14 | Criticial = 4, 15 | EnchantCritical = 5, // aka magic 16 | 17 | // ???? 18 | RowRight = 128, 19 | RowLeft = 129 20 | }; 21 | 22 | /** 23 | * Runtime ID 24 | */ 25 | ActorRuntimeID rid; 26 | /** 27 | * Action 28 | * @see AnimatePacket::Action 29 | */ 30 | Action action; 31 | /** 32 | * Rowing time 33 | */ 34 | float rowingTime; 35 | 36 | AnimatePacket(ActorRuntimeID rid, Action action, float rowingTime = 0) : rid(rid), action(action) { 37 | if (action == Action::RowLeft || action == Action::RowRight) 38 | rowingTime = rowingTime; 39 | } 40 | 41 | #include "VirtualTemplate.h" 42 | }; 43 | 44 | static_assert(offsetof(AnimatePacket, rid) == 0x28); 45 | static_assert(offsetof(AnimatePacket, rowingTime) == 0x34); 46 | -------------------------------------------------------------------------------- /include/network/protocol/ClientboundMapItemDataPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct ClientboundMapItemDataPacket { 4 | 5 | }; -------------------------------------------------------------------------------- /include/network/protocol/DisconnectPacket.h: -------------------------------------------------------------------------------- 1 | #include "Packet.h" 2 | 3 | /** 4 | * Packet for gracefully disconnecting 5 | */ 6 | struct DisconnectPacket : Packet { 7 | bool hideDisconnectionScreen; 8 | char pad[0x3]; // don't need to add this cause byte alignment? 9 | gsl::cstring_span message; 10 | 11 | DisconnectPacket(gsl::cstring_span message = "client disconnect", bool value = false) : hideDisconnectionScreen(value), message(message) {} 12 | 13 | #include "VirtualTemplate.h" 14 | }; 15 | 16 | static_assert(offsetof(DisconnectPacket, hideDisconnectionScreen) == 0x24); 17 | static_assert(offsetof(DisconnectPacket, message) == 0x28); 18 | -------------------------------------------------------------------------------- /include/network/protocol/InteractPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Packet.h" 4 | #include "math/Vec3.h" 5 | #include "util/ActorRuntimeID.h" 6 | 7 | struct InteractPacket : Packet { 8 | enum struct Action : uint8_t { 9 | LegacyAttack = 2, 10 | LeaveVehicle = 3, 11 | MouseOver = 4, 12 | ActionOpenInventory = 6 13 | }; 14 | /** 15 | * Action 16 | * @see InteractPacket::Action 17 | */ 18 | Action action; 19 | char pad[0x3]; 20 | /** 21 | * Target Runtime ID 22 | */ 23 | ActorRuntimeID entityID; 24 | /** 25 | * Hit vector for MouseOver 26 | */ 27 | union { 28 | Vec3 pos; 29 | struct { 30 | float x, y, z; 31 | }; 32 | }; 33 | 34 | InteractPacket(Action action, ActorRuntimeID runtimeId, float x, float y, float z) : action(action), 35 | entityID(runtimeId), x(x), y(y), z(z) {} 36 | 37 | #include "VirtualTemplate.h" 38 | }; 39 | -------------------------------------------------------------------------------- /include/network/protocol/InventoryTransactionPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Packet.h" 4 | 5 | // TODO: Despite my pessimism in the note I might do it some day :) 6 | struct [[deprecated("This packet is extremely complicated. I'm not going to reverse engineer every other struct that it uses." 7 | "Best bet if you want to read/write packets for now is implementing the virtual functions in your own class derived from packet" 8 | "and reading/writing the BinaryStream based on some server's code." 9 | "")]] InventoryTransactionPacket : Packet {}; 10 | -------------------------------------------------------------------------------- /include/network/protocol/LevelEventPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Packet.h" 4 | 5 | struct LevelEventPacket : Packet { 6 | int event; 7 | Vec3 pos; 8 | int data; 9 | 10 | #include "VirtualTemplate.h" 11 | }; 12 | 13 | static_assert(offsetof(LevelEventPacket, event) == 0x24); -------------------------------------------------------------------------------- /include/network/protocol/LevelSoundEventPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Packet.h" 4 | 5 | struct LevelSoundEventPacket : Packet { 6 | uint32_t sound; 7 | Vec3 pos; 8 | int32_t extra; // -1 by default 9 | char pad[0x4]; 10 | gsl::cstring_span entityType; // semicolon by default, not used if extra is positive 11 | bool babyEntity, global; 12 | 13 | LevelSoundEventPacket(uint32_t sound, Vec3 pos, std::string entityType, bool global = false, int32_t extra = -1, bool babyEntity = false) : sound(sound), pos(pos), entityType(entityType), global(global), extra(extra), babyEntity(babyEntity) {}; 14 | 15 | #include "VirtualTemplate.h" 16 | }; 17 | 18 | static_assert(offsetof(LevelSoundEventPacket, sound) == 0x24); 19 | static_assert(offsetof(LevelSoundEventPacket, pos) == 0x28); 20 | static_assert(offsetof(LevelSoundEventPacket, extra) == 0x34); 21 | static_assert(offsetof(LevelSoundEventPacket, entityType) == 0x40); 22 | static_assert(offsetof(LevelSoundEventPacket, babyEntity) == 0x50); 23 | static_assert(offsetof(LevelSoundEventPacket, global) == 0x51); 24 | -------------------------------------------------------------------------------- /include/network/protocol/LoginPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Packet.h" 4 | #include 5 | 6 | struct LoginData; 7 | struct WebToken; 8 | struct LoginPacket : Packet { 9 | int32_t protocol; 10 | char pad[0x4]; 11 | LoginData *data; 12 | }; 13 | static_assert(offsetof(LoginPacket, protocol) == 0x24); 14 | struct LoginData { 15 | WebToken *cData1; 16 | WebToken *cData2; 17 | WebToken *skinData; 18 | }; 19 | struct WebToken { 20 | 21 | }; -------------------------------------------------------------------------------- /include/network/protocol/MobEffectPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Packet.h" 4 | 5 | /** 6 | * Informs clients of effects added, typically only sent by the server for your own effects. Only particle colors are sent for other entities (wink wink) 7 | * 8 | * Seems to still be relatively working without changes between 1.12-1.16 9 | */ 10 | struct MobEffectPacket : Packet { 11 | enum struct Event : uint8_t { 12 | Add = 1, Modify = 2, Remove = 3 13 | }; 14 | /** 15 | * Runtime ID 16 | */ 17 | ActorRuntimeID rid; 18 | /** 19 | * Duration in ticks 20 | */ 21 | uint32_t duration; 22 | /** 23 | * Event 24 | * @see MobEffectPacket::Event 25 | */ 26 | Event eventID; 27 | char pad[3]; 28 | /** 29 | * Effect ID 30 | */ 31 | uint32_t effectID; 32 | /** 33 | * Effect amplifier 34 | */ 35 | uint32_t amplifier; 36 | /** 37 | * Particles showing 38 | */ 39 | bool particles; 40 | 41 | #include "VirtualTemplate.h" 42 | }; 43 | -------------------------------------------------------------------------------- /include/network/protocol/ModalFormRequestPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Packet.h" 4 | #include 5 | 6 | /* 7 | * Server -> Client 8 | */ 9 | struct ModalFormRequestPacket : Packet { 10 | int formId; 11 | std::string formData; 12 | 13 | ModalFormRequestPacket(unsigned char playerSubIndex) : Packet(playerSubIndex) {} 14 | 15 | #include "VirtualTemplate.h" 16 | }; -------------------------------------------------------------------------------- /include/network/protocol/ModalFormResponsePacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Packet.h" 4 | #include 5 | 6 | /* 7 | * Client -> Server 8 | */ 9 | struct ModalFormResponsePacket : Packet { 10 | int formId; 11 | std::string formData; 12 | 13 | ModalFormResponsePacket(unsigned char playerSubIndex) : Packet(playerSubIndex) {} 14 | 15 | #include "VirtualTemplate.h" 16 | }; -------------------------------------------------------------------------------- /include/network/protocol/MoveActorAbsolutePacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Packet.h" 4 | #include "util/ActorRuntimeID.h" 5 | 6 | struct MoveActorAbsolutePacket : Packet { 7 | ActorRuntimeID rid; 8 | uint8_t flags; 9 | private: 10 | char filler[3]; 11 | public: 12 | union { 13 | struct { 14 | float x, y, z; 15 | }; 16 | Vec3 pos; 17 | }; 18 | union { 19 | struct { 20 | uint8_t xRot, yRot, zRot; // * (360 / 256) 21 | }; 22 | struct { 23 | uint8_t pitch, headYaw, yaw; 24 | }; 25 | }; 26 | }; 27 | 28 | static_assert(offsetof(MoveActorAbsolutePacket, rid) == 0x28); 29 | static_assert(offsetof(MoveActorAbsolutePacket, flags) == 0x30); 30 | static_assert(offsetof(MoveActorAbsolutePacket, pos) == 0x34); 31 | static_assert(offsetof(MoveActorAbsolutePacket, xRot) == 0x40); 32 | static_assert(offsetof(MoveActorAbsolutePacket, yRot) == 0x41); 33 | static_assert(offsetof(MoveActorAbsolutePacket, zRot) == 0x42); -------------------------------------------------------------------------------- /include/network/protocol/MovePlayerPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "math/Vec2.h" 4 | #include "math/Vec3.h" 5 | #include "util/ActorRuntimeID.h" 6 | #include "Packet.h" 7 | 8 | struct MovePlayerPacket : Packet { 9 | enum struct Mode : uint8_t { 10 | Normal, 11 | Reset, 12 | Teleport, 13 | Pitch // *shrug* 14 | }; 15 | /** 16 | * Player Runtime ID 17 | */ 18 | ActorRuntimeID runtimeID; 19 | /** 20 | * Position 21 | */ 22 | union { 23 | struct { 24 | float x, y, z; 25 | }; 26 | Vec3 pos; 27 | }; 28 | /** 29 | * Rotations 30 | */ 31 | union { 32 | struct { 33 | float pitch, yaw, headYaw; 34 | }; 35 | Vec3 rot; 36 | }; 37 | /** 38 | * Mode 39 | */ 40 | Mode mode; 41 | /** 42 | * On Ground 43 | */ 44 | bool onGround; 45 | 46 | /** 47 | * Ridden Entity Runtime ID 48 | */ 49 | ActorRuntimeID rideId; 50 | 51 | /** 52 | * Self explanatory, only written to BinaryStream if mode is teleport 53 | */ 54 | int32_t teleportCause, teleportItem; 55 | 56 | /** 57 | * Current tick, probably used for lag check/syncing 58 | */ 59 | uint64_t tick; 60 | 61 | MovePlayerPacket(const ActorRuntimeID runtimeID, bool onGround, const Vec3 &position, const Vec3 &rotations, Mode mode = Mode::Normal, ActorRuntimeID rideId = ActorRuntimeID{0}, 62 | int32_t teleportCause = 0, int32_t teleportItem = 0, uint64_t tick = 0) : 63 | runtimeID(runtimeID), onGround(onGround), pos(position), rot(rotations), 64 | mode(mode), rideId(rideId), teleportCause(teleportCause), teleportItem(teleportItem), tick(tick) {} 65 | 66 | explicit MovePlayerPacket(const MovePlayerPacket &base) : runtimeID(base.runtimeID), onGround(base.onGround), x(base.x), y(base.y), z(base.z), yaw(base.yaw), pitch(base.pitch), 67 | headYaw(base.headYaw), rideId(base.rideId), tick(base.tick) { 68 | if (base.mode == Mode::Teleport) { 69 | teleportCause = base.teleportCause; 70 | teleportItem = base.teleportItem; 71 | } else 72 | teleportCause = teleportItem = 0; // Necessary? 73 | } 74 | 75 | #include "VirtualTemplate.h" 76 | }; 77 | 78 | static_assert(offsetof(MovePlayerPacket, runtimeID) == 0x28); 79 | static_assert(offsetof(MovePlayerPacket, mode) == 0x48); 80 | static_assert(offsetof(MovePlayerPacket, onGround) == 0x49); 81 | static_assert(offsetof(MovePlayerPacket, rideId) == 0x50); 82 | static_assert(offsetof(MovePlayerPacket, teleportCause) == 0x58); 83 | static_assert(offsetof(MovePlayerPacket, teleportItem) == 0x5C); 84 | static_assert(offsetof(MovePlayerPacket, tick) == 0x60); -------------------------------------------------------------------------------- /include/network/protocol/Packet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../BinaryStream.h" 4 | #include 5 | #include 6 | 7 | struct NetworkIdentifier; 8 | struct NetEventCallback; 9 | 10 | /* 11 | * Important: When creating a subclass include VirtualTemplate.h inside the class 12 | */ 13 | #pragma pack(push, 4) 14 | struct Packet { 15 | // vtable should already be added by compiler because of the (broken) virtual decls below 16 | int unk_4 = 2, unk_8 = 1; // check if these are still correct 17 | char pad[0x8]; 18 | uintptr_t **handlerThunk; // dispatcher instance that handles this type of packet (array, first item should be for this packet type) 19 | char pad2[0x4]; 20 | 21 | //Packet() = default; 22 | 23 | //Packet(unsigned char playerSubIndex) : playerSubIndex(playerSubIndex) {} 24 | 25 | //Packet(Packet const &packet) : unk_4(packet.unk_4), unk_8(packet.unk_8) {} 26 | 27 | // Change these in VirtualTemplate.h as well 28 | virtual ~Packet() = 0; 29 | 30 | virtual int getId() const = 0; 31 | 32 | virtual std::string getName() const = 0; 33 | 34 | virtual void write(BinaryStream &) const = 0; 35 | 36 | virtual void read(ReadOnlyBinaryStream &) = 0; 37 | 38 | // You can substitute std::shared_ptr& with Packet** in case you don't want shared_ptrs logic 39 | virtual void handle(NetworkIdentifier const&, NetEventCallback &, std::shared_ptr &); 40 | 41 | //virtual bool disallowBatching() const = 0; 42 | }; 43 | #pragma pack(pop) 44 | 45 | static_assert(sizeof(Packet) == 0x24); -------------------------------------------------------------------------------- /include/network/protocol/PlaySoundPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Packet.h" 4 | #include "math/BlockPos.h" 5 | 6 | struct PlaySoundPacket : Packet { 7 | char pad[0x8]; 8 | gsl::cstring_span soundName; 9 | BlockPos pos; 10 | float volume, pitch; 11 | }; 12 | 13 | static_assert(offsetof(PlaySoundPacket, soundName) == 0x30); 14 | static_assert(offsetof(PlaySoundPacket, pos) == 0x40); 15 | static_assert(offsetof(PlaySoundPacket, volume) == 0x4C); 16 | static_assert(offsetof(PlaySoundPacket, pitch) == 0x50); 17 | -------------------------------------------------------------------------------- /include/network/protocol/PlayerActionPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "math/BlockPos.h" 4 | #include "util/ActorRuntimeID.h" 5 | #include "Packet.h" 6 | 7 | struct PlayerActionPacket : Packet { 8 | enum struct Action : uint32_t { 9 | StartBreak = 0, 10 | AbortBreak = 1, 11 | StopBreak = 2, 12 | GetUpdatedBlock = 3, 13 | DropItem = 4, 14 | StartSleeping = 5, 15 | StopSleeping = 6, 16 | Respawn = 7, 17 | Jump = 8, 18 | StartSprinting = 9, 19 | StopSprinting = 10, 20 | StartSneaking = 11, 21 | StopSneaking = 12, 22 | RequestDimensionChange = 13, 23 | DimensionChangeAck = 14, 24 | StartGlide = 15, 25 | StopGlide = 16, 26 | BuildDenied = 17, 27 | ContinueBreak = 18, 28 | ChangeSkin = 19, 29 | SetEnchantmentSeed = 20, 30 | StartSwimming = 21, 31 | StopSwimming = 22, 32 | StartSpinAttack = 23, 33 | StopSpinAttack = 24, 34 | InteractBlock = 25 35 | }; 36 | 37 | /** 38 | * Block position for some actions 39 | */ 40 | union { 41 | struct { 42 | int32_t x = 0; 43 | uint32_t y = 0; 44 | int32_t z = 0; 45 | }; 46 | BlockPos blockPos; 47 | }; 48 | 49 | uint32_t face; 50 | 51 | /** 52 | * Action 53 | * @see PlayerActionPacket::Action 54 | */ 55 | Action action; 56 | /** 57 | * Player Runtime ID 58 | */ 59 | ActorRuntimeID rid; 60 | 61 | PlayerActionPacket(ActorRuntimeID rid, Action action) : rid(rid), action(action) {} 62 | 63 | PlayerActionPacket(const PlayerActionPacket &other) : rid(other.rid), blockPos(other.blockPos), face(other.face), action(other.action) {} 64 | 65 | #include "VirtualTemplate.h" 66 | }; 67 | 68 | static_assert(offsetof(PlayerActionPacket, x) == 0x24); 69 | static_assert(offsetof(PlayerActionPacket, face) == 0x30); 70 | static_assert(offsetof(PlayerActionPacket, action) == 0x34); 71 | static_assert(offsetof(PlayerActionPacket, rid) == 0x38); -------------------------------------------------------------------------------- /include/network/protocol/RemoveActorPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Packet.h" 4 | #include "util/ActorRuntimeID.h" 5 | 6 | /** 7 | * Packet for noting the client should destroy an entity with this UID 8 | */ 9 | struct RemoveActorPacket : Packet { 10 | ActorUniqueID uid; 11 | 12 | #include "VirtualTemplate.h" 13 | }; 14 | 15 | static_assert(offsetof(RemoveActorPacket, uid) == 0x28); -------------------------------------------------------------------------------- /include/network/protocol/ServerSettingsRequestPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Packet.h" 4 | 5 | /* 6 | * Client -> Server 7 | */ 8 | struct ServerSettingsRequestPacket : Packet { 9 | ServerSettingsRequestPacket(unsigned char playerSubIndex) : Packet(playerSubIndex) {} 10 | 11 | #include "VirtualTemplate.h" 12 | }; -------------------------------------------------------------------------------- /include/network/protocol/ServerSettingsResponsePacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ModalFormRequestPacket.h" 4 | 5 | /* 6 | * Server -> Client 7 | */ 8 | struct ServerSettingsResponsePacket : Packet { 9 | int formId; 10 | std::string formData; 11 | 12 | ServerSettingsResponsePacket(unsigned char playerSubIndex) : Packet(playerSubIndex) {} 13 | 14 | #include "VirtualTemplate.h" 15 | }; -------------------------------------------------------------------------------- /include/network/protocol/SetActorDataPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "util/DataItem.h" 4 | #include "Packet.h" 5 | #include 6 | 7 | struct SetActorDataPacket : Packet { 8 | ActorRuntimeID rid; 9 | char pad[0x8]; 10 | std::vector entries; 11 | 12 | #include "VirtualTemplate.h" 13 | }; 14 | 15 | static_assert(offsetof(SetActorDataPacket, rid) == 0x28); 16 | static_assert(offsetof(SetActorDataPacket, entries) == 0x38); -------------------------------------------------------------------------------- /include/network/protocol/SetActorMotionPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Packet.h" 4 | #include "util/ActorRuntimeID.h" 5 | #include "math/Vec3.h" 6 | 7 | struct SetActorMotionPacket : Packet { 8 | /** 9 | * Runtime ID of Actor 10 | */ 11 | ActorRuntimeID rid; 12 | 13 | /** 14 | * Motion (Full motion, not modifier. Calculate that.) 15 | */ 16 | union { 17 | struct { 18 | float x, y, z; 19 | }; 20 | Vec3 motion; 21 | }; 22 | 23 | #include "VirtualTemplate.h" 24 | }; -------------------------------------------------------------------------------- /include/network/protocol/SetTitlePacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Packet.h" 4 | #include 5 | 6 | /** 7 | * Packet for setting main UI title bar (originally for bosses, etc.) 8 | */ 9 | struct SetTitlePacket : Packet { 10 | enum struct TitleType { 11 | CLEAR_TITLE = 0, 12 | RESET_TITLE, 13 | SET_TITLE, 14 | SET_SUBTITLE, 15 | SET_ACTIONBAR_MESSAGE, 16 | SET_ANIMATION_TIMES 17 | }; 18 | 19 | TitleType type; 20 | std::string message; 21 | int fadeIn = 0; 22 | int stay = 0; 23 | int fadeOut = 0; 24 | 25 | SetTitlePacket(unsigned char playerSubIndex, int fadeIn, int stay, int fadeOut) : Packet(playerSubIndex), 26 | fadeIn(fadeIn), stay(stay), 27 | fadeOut(fadeOut) {} 28 | 29 | SetTitlePacket(unsigned char playerSubIndex, TitleType type) : Packet(playerSubIndex), type(type) {} 30 | 31 | #include "VirtualTemplate.h" 32 | }; -------------------------------------------------------------------------------- /include/network/protocol/TextPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Packet.h" 4 | #include 5 | #include 6 | #include 7 | 8 | // Actual name 9 | enum struct TextPacketType : char { 10 | RAW = 0, 11 | CHAT = 1, 12 | TRANSLATION = 2, 13 | POPUP = 3, 14 | JUKEBOX_POPUP = 4, 15 | TIP = 5, 16 | SYSTEM = 6, 17 | WHISPER = 7, 18 | ANNOUNCEMENT = 8, 19 | JSON = 9, 20 | WHISPER_JSON = 10 21 | }; 22 | 23 | /** 24 | * Packet for most main UI text elements 25 | * 26 | * According to the offset jumps it must be storing them as normal std::strings ? probably uwp strings on win10/other editions 27 | */ 28 | struct TextPacket : Packet { 29 | TextPacketType type; 30 | char pad[0x17]; 31 | 32 | /*std::string str1; 33 | std::string str2;*/ 34 | 35 | // TODO: Nevermind the rest of the write function is too complicated for me atm lol 36 | 37 | public: 38 | TextPacket(TextPacketType type, const std::string &, const std::string &, const std::vector &, bool, const std::string &, const std::string &); 39 | 40 | #include "VirtualTemplate.h" 41 | }; 42 | 43 | static_assert(sizeof(std::string) == 0x18); 44 | static_assert(offsetof(TextPacket, type) == 0x24); 45 | /*static_assert(offsetof(TextPacket, str1) == 0x40); 46 | static_assert(offsetof(TextPacket, str2) == 0x58);*/ -------------------------------------------------------------------------------- /include/network/protocol/UpdateBlockPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Packet.h" 4 | 5 | struct UpdateBlockPacket : Packet { 6 | BlockPos pos; 7 | ActorRuntimeID bid; 8 | 9 | #include "VirtualTemplate.h" 10 | }; -------------------------------------------------------------------------------- /include/network/protocol/VirtualTemplate.h: -------------------------------------------------------------------------------- 1 | // The pure virtual function "implementations" to make the compiler happy. Include this inside a subpackets class. 2 | 3 | virtual void read(ReadOnlyBinaryStream &); 4 | 5 | virtual int getId() const; 6 | 7 | virtual void write(BinaryStream &) const; 8 | 9 | virtual std::string getName() const; -------------------------------------------------------------------------------- /include/realms/Realms.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | struct Realms { 6 | // TODO: find types 7 | static Realms *EMPTY_VERSION; 8 | 9 | std::string getUserAgent(); 10 | }; 11 | -------------------------------------------------------------------------------- /include/util/ActorRuntimeID.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "mce/UUID.h" 4 | 5 | struct ActorUniqueID { 6 | int64_t data; 7 | 8 | explicit ActorUniqueID(int64_t data) : data(data) {}; 9 | 10 | ActorUniqueID() : ActorUniqueID(0) {}; 11 | 12 | operator int64_t() const { 13 | return data; 14 | }; 15 | }; 16 | 17 | struct ActorRuntimeID { 18 | uint64_t data; 19 | 20 | explicit ActorRuntimeID(uint64_t data) : data(data) {}; 21 | 22 | ActorRuntimeID() : ActorRuntimeID(0) {}; 23 | 24 | operator uint64_t() const { 25 | return data; 26 | } 27 | }; 28 | -------------------------------------------------------------------------------- /include/util/ActorType.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum ActorType {}; -------------------------------------------------------------------------------- /include/util/Brightness.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum Brightness : unsigned char { 4 | MAX, 5 | MIN, 6 | INVALID 7 | }; -------------------------------------------------------------------------------- /include/util/Certificate.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct Certificate { 4 | 5 | }; 6 | 7 | struct ExtendedCertificate : Certificate { 8 | static std::string getXuid(Certificate const &); 9 | }; -------------------------------------------------------------------------------- /include/util/Color.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace mce { 4 | struct Color { 5 | static Color WHITE; 6 | static Color GREEN; 7 | static Color ORANGE; 8 | static Color NIL; 9 | static Color RED; 10 | static Color BLUE; 11 | static Color CYAN; 12 | static Color GREY; 13 | static Color BLACK; 14 | static Color PURPLE; 15 | static Color YELLOW; 16 | static Color SHADE_DOWN; 17 | static Color SHADE_WEST_EAST; 18 | static Color SHADE_NORTH_SOUTH; 19 | static Color SHADE_UP; 20 | 21 | int toABGR() const; 22 | 23 | int toARGB() const; 24 | 25 | /** 26 | * Create Color object from HSB 27 | * @param hue 28 | * @param saturation 29 | * @param brightness 30 | * @return Color 31 | */ 32 | static Color fromHSB(float hue, float saturation, float brightness); 33 | 34 | /** 35 | * Get Color in hexadecimal 36 | * @return std::string 37 | * TODO: Verify 38 | */ 39 | std::string toHexString() const; 40 | 41 | bool operator==(const Color &) const; 42 | }; 43 | } -------------------------------------------------------------------------------- /include/util/ColorFormat.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "Color.h" 5 | 6 | struct ColorFormat { 7 | static const char DARK_GREEN, 8 | OBFUSCATED, 9 | DARK_PURPLE, 10 | LIGHT_PURPLE, 11 | RED, 12 | AQUA, 13 | BLUE, 14 | BOLD, 15 | GOLD, 16 | GRAY, 17 | BLACK, 18 | GREEN, 19 | RESET, 20 | WHITE, 21 | ESCAPE, 22 | ITALIC, 23 | YELLOW, 24 | DARK_RED, 25 | DARK_AQUA, 26 | DARK_BLUE, 27 | DARK_GRAY; 28 | 29 | static short FromString(const std::string &); 30 | 31 | static bool IsColorCode(const std::string &); 32 | 33 | static bool IsColorCode(char); 34 | 35 | static mce::Color *ColorFromChar(char); 36 | 37 | static char ColorCodeFromColor(const mce::Color &); 38 | 39 | static mce::Color *ColorFromColorCode(const std::string &); 40 | 41 | static std::string NameFromFormatCode(std::string const &); 42 | }; -------------------------------------------------------------------------------- /include/util/CompoundTag.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | struct PrintStream; 8 | 9 | struct Tag { 10 | virtual ~Tag(); 11 | virtual int getId() const = 0; 12 | virtual bool equals(Tag const &) const; 13 | virtual void print(PrintStream &) const; 14 | }; 15 | 16 | struct CompoundTag : Tag { 17 | std::map> value; 18 | 19 | CompoundTag(); 20 | 21 | CompoundTag(CompoundTag&&); 22 | 23 | bool isEmpty() const; 24 | 25 | int getId() const; 26 | }; -------------------------------------------------------------------------------- /include/util/DataItem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "math/BlockPos.h" 5 | 6 | // TODO: See if these x64 offsets are right 7 | 8 | enum struct DataItemType : unsigned char { 9 | Byte, 10 | Short, 11 | Int, 12 | Float, 13 | String, 14 | CompoundTag, 15 | Pos, 16 | Long, 17 | Vec3 18 | }; 19 | 20 | struct DataItem { 21 | uintptr_t **vtable; 22 | DataItemType type; 23 | char pad_0005[1]; 24 | char id; // 0x6 25 | char pad_0006[5]; 26 | union { 27 | uint8_t byteVal; 28 | uint16_t shortVal; 29 | uint32_t intVal; 30 | float floatVal; 31 | uint64_t longVal; 32 | BlockPos posVal; 33 | Vec3 vectorVal; 34 | }; 35 | }; -------------------------------------------------------------------------------- /include/util/DeviceOS.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | enum struct DeviceOS : int32_t { 6 | Unknown = -1, 7 | Android = 1, 8 | iOS = 2, 9 | OSX = 3, 10 | Fire = 4, 11 | GearVR = 5, 12 | HoloLens = 6, 13 | Windows10 = 7, 14 | Win32 = 8, 15 | Dedicated = 9, 16 | TVOS = 10, 17 | Playstation = 11, 18 | NX = 12, 19 | Xbox = 13, 20 | WindowsPhone = 14 // lol 21 | }; -------------------------------------------------------------------------------- /include/util/GameType.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum struct GameType { 4 | SURVIVAL, 5 | CREATIVE, 6 | ADVENTURE, 7 | SURVIVAL_SPECTATOR, 8 | CREATIVE_SPECTATOR 9 | }; -------------------------------------------------------------------------------- /include/util/Json.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Json { 4 | struct Value { 5 | Value(const char *); 6 | 7 | std::string toStyledString() const; 8 | }; 9 | } -------------------------------------------------------------------------------- /include/util/MapDecoration.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Color.h" 4 | 5 | struct MapDecoration { 6 | char getX() const; 7 | char getY() const; 8 | mce::Color &getColor() const; 9 | bool isRenderedOnFrame() const; 10 | std::string &getLabel() const; 11 | }; -------------------------------------------------------------------------------- /include/util/MinecraftHandle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace { 6 | void *MinecraftHandle() { 7 | static void *handle = dlopen("libminecraftpe.so", RTLD_LAZY); 8 | return handle; 9 | } 10 | } -------------------------------------------------------------------------------- /include/util/SmallSet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | template 6 | struct SmallSet { 7 | std::vector data; 8 | /*SmallSet(int); 9 | typename std::vector::iterator &begin(); 10 | typename std::vector::iterator &begin() const; 11 | typename std::vector::iterator &end(); 12 | typename std::vector::iterator &end() const; 13 | void clear(); 14 | template void emplace(U); 15 | void erase(T const &); 16 | void erase(typename std::vector::iterator const &); 17 | typename std::vector::iterator &find(T const &); 18 | bool contains(T const &); 19 | bool empty(); 20 | SmallSet &operator=(SmallSet &&); 21 | T &operator[](int); 22 | std::size_t size() const;*/ 23 | }; -------------------------------------------------------------------------------- /include/util/serialize.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct ReadOnlyBinaryStream; 4 | 5 | struct BinaryStream; 6 | 7 | template 8 | struct serialize { 9 | static void write(const T &, BinaryStream &); 10 | static T read(ReadOnlyBinaryStream &); 11 | }; 12 | -------------------------------------------------------------------------------- /include/util/typeid.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "MinecraftHandle.h" 4 | #include 5 | 6 | template 7 | struct typeid_t { 8 | static short count; 9 | 10 | short id; 11 | 12 | typeid_t() { 13 | id = count++; 14 | } 15 | 16 | typeid_t(typeid_t const &t) { 17 | id = t.id; 18 | } 19 | }; 20 | 21 | template 22 | typeid_t type_id() { 23 | static typeid_t id; 24 | return id; 25 | }; 26 | 27 | template 28 | typeid_t type_id_minecraft_symbol(const char *sym) { 29 | typeid_t *id = (typeid_t *) dlsym(MinecraftHandle(), sym); 30 | void *guard = (typeid_t *) dlsym(MinecraftHandle(), std::string(sym).replace(0, 2, "_ZGV").c_str()); 31 | static int (*guardAcquire)(void *) = (int (*)(void *)) dlsym(MinecraftHandle(), "__cxa_guard_acquire"); 32 | static void (*guardRelease)(void *) = (void (*)(void *)) dlsym(MinecraftHandle(), "__cxa_guard_release"); 33 | if (*((char *) guard) == 0 && guardAcquire(guard)) { 34 | new(id)typeid_t(); 35 | guardRelease(guard); 36 | } 37 | return *id; 38 | }; -------------------------------------------------------------------------------- /include/world/BedrockBlocks.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Block.h" 4 | 5 | struct BedrockBlocks { 6 | static const Block *mAir; 7 | }; -------------------------------------------------------------------------------- /include/world/Block.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "util/Brightness.h" 4 | #include "math/AABB.h" 5 | #include "util/ActorRuntimeID.h" 6 | 7 | struct BlockSource; 8 | 9 | enum struct MaterialType; 10 | 11 | struct Material { 12 | bool isReplaceable() const; 13 | 14 | bool isType(MaterialType) const; 15 | }; 16 | 17 | enum struct BlockProperty : unsigned char; 18 | 19 | struct Block { 20 | ActorRuntimeID getRuntimeId() const; 21 | 22 | AABB &getAABB(BlockSource &, BlockPos const &, AABB &, bool) const; 23 | 24 | float getTranslucency() const; 25 | 26 | int getRenderLayer() const; 27 | 28 | unsigned int getColor() const; 29 | 30 | bool operator !=(const Block *other) const { 31 | return getRuntimeId().data != other->getRuntimeId().data; 32 | } 33 | 34 | bool operator !=(const Block &other) const { 35 | return getRuntimeId().data != other.getRuntimeId().data; 36 | } 37 | 38 | bool operator ==(const Block *other) const { 39 | return getRuntimeId().data == other->getRuntimeId().data; 40 | } 41 | 42 | bool operator ==(const Block &other) const { 43 | return getRuntimeId().data == other.getRuntimeId().data; 44 | } 45 | 46 | const Material &getMaterial() const; 47 | 48 | int getSerializationId() const; 49 | 50 | bool hasProperty(BlockProperty) const; 51 | }; 52 | 53 | struct BlockLegacy { 54 | //virtual void forEachBlockPermutation(std::function) const; 55 | 56 | virtual std::string getFullName() const; 57 | 58 | virtual unsigned int getColor(BlockSource&, BlockPos const&, Block const&) const; 59 | 60 | virtual Brightness getLightEmission(Block const&) const; 61 | }; 62 | 63 | struct BlockTypeRegistry { 64 | static void forEachBlock(std::function); 65 | }; 66 | 67 | enum struct BlockRenderLayer; -------------------------------------------------------------------------------- /include/world/BlockGraphics.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct BlockGraphics { 4 | static BlockGraphics *mBlocks[256]; 5 | 6 | Block &getBlock() const; 7 | 8 | bool isFullAndOpaque(Block const &); 9 | }; -------------------------------------------------------------------------------- /include/world/BlockSource.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "entity/BlockActor.h" 4 | #include "math/BlockPos.h" 5 | #include "math/Vec3.h" 6 | #include "Block.h" 7 | 8 | struct ActorBlockSyncMessage; 9 | 10 | struct BlockSource { 11 | Block &getBlock(BlockPos const &) const; 12 | 13 | Block &getBlock(int x, int y, int z) const; 14 | 15 | Material &getMaterial(BlockPos const&) const; 16 | 17 | Material &getMaterial(int x, int y, int z) const; 18 | 19 | bool isInWall(const Vec3 &); 20 | 21 | void setBlockNoUpdate(const BlockPos &, const Block &); 22 | 23 | void setBlock(const BlockPos &, const Block &, int = 0, const ActorBlockSyncMessage * = 0); 24 | 25 | BlockActor *getBlockEntity(const BlockPos &); 26 | 27 | //BlockEntity &getBlockEntity(BlockPos const &); 28 | 29 | //BlockEntity &getBlockEntity(int x, int y, int z) const; 30 | }; -------------------------------------------------------------------------------- /include/world/BlockTessellator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct BlockTessellator { 4 | void clearBlockCache(); 5 | }; -------------------------------------------------------------------------------- /include/world/HitResult.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "math/BlockPos.h" 4 | 5 | struct HitResult { 6 | enum struct Type { Tile, Entity, Miss }; 7 | Vec3 x, y; 8 | Type type; 9 | Direction face; 10 | BlockPos blockPos; 11 | Vec3 pos; 12 | Actor *actor; 13 | bool hitLiquid; 14 | Direction liquidFace; 15 | BlockPos liquid; 16 | Vec3 liquidPos; 17 | bool unk; 18 | }; 19 | -------------------------------------------------------------------------------- /include/world/VanillaBlocks.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Block.h" 4 | 5 | struct VanillaBlocks { 6 | static const Block *mStone; 7 | static const Block *mGrass; 8 | static const Block *mDirt; 9 | static const Block *mCobblestone; 10 | static const Block *mWoodPlanks; 11 | static const Block *mSapling; 12 | static const Block *mBedrock; 13 | static const Block *mFlowingWater; 14 | static const Block *mStillWater; 15 | static const Block *mFlowingLava; 16 | static const Block *mStillLava; 17 | static const Block *mSand; 18 | static const Block *mGravel; 19 | static const Block *mGoldOre; 20 | static const Block *mIronOre; 21 | static const Block *mCoalOre; 22 | static const Block *mLog; 23 | static const Block *mLeaves; 24 | static const Block *mBorder; 25 | static const Block *mAllow; 26 | static const Block *mDeny; 27 | static const Block *mSponge; 28 | static const Block *mGlass; 29 | static const Block *mLapisOre; 30 | static const Block *mLapisBlock; 31 | static const Block *mDispenser; 32 | static const Block *mSandStone; 33 | static const Block *mNote; 34 | static const Block *mBed; 35 | static const Block *mGoldenRail; 36 | static const Block *mDetectorRail; 37 | static const Block *mWeb; 38 | static const Block *mTallgrass; 39 | static const Block *mDeadBush; 40 | static const Block *mPiston; 41 | static const Block *mStickyPiston; 42 | static const Block *mPistonArm; 43 | static const Block *mMovingBlock; 44 | static const Block *mObserver; 45 | static const Block *mWool; 46 | static const Block *mYellowFlower; 47 | static const Block *mRedFlower; 48 | static const Block *mBrownMushroom; 49 | static const Block *mRedMushroom; 50 | static const Block *mGoldBlock; 51 | static const Block *mIronBlock; 52 | static const Block *mDoubleStoneSlab; 53 | static const Block *mStoneSlab; 54 | static const Block *mBrick; 55 | static const Block *mTNT; 56 | static const Block *mBookshelf; 57 | static const Block *mMossyCobblestone; 58 | static const Block *mObsidian; 59 | static const Block *mTorch; 60 | static const Block *mMobSpawner; 61 | static const Block *mOakStairs; 62 | static const Block *mChest; 63 | static const Block *mRedStoneDust; 64 | static const Block *mDiamondOre; 65 | static const Block *mDiamondBlock; 66 | static const Block *mWorkBench; 67 | static const Block *mWheatCrop; 68 | static const Block *mFarmland; 69 | static const Block *mFurnace; 70 | static const Block *mLitFurnace; 71 | static const Block *mSign; 72 | static const Block *mWoodenDoor; 73 | static const Block *mLadder; 74 | static const Block *mRail; 75 | static const Block *mStoneStairs; 76 | static const Block *mWallSign; 77 | static const Block *mLever; 78 | static const Block *mStonePressurePlate; 79 | static const Block *mIronDoor; 80 | static const Block *mWoodPressurePlate; 81 | static const Block *mRedStoneOre; 82 | static const Block *mLitRedStoneOre; 83 | static const Block *mUnlitRedStoneTorch; 84 | static const Block *mLitRedStoneTorch; 85 | static const Block *mStoneButton; 86 | static const Block *mTopSnow; 87 | static const Block *mIce; 88 | static const Block *mSnow; 89 | static const Block *mBlueIce; 90 | static const Block *mCactus; 91 | static const Block *mClay; 92 | static const Block *mReeds; 93 | static const Block *mJukebox; 94 | static const Block *mFence; 95 | static const Block *mNetherFence; 96 | static const Block *mPumpkin; 97 | static const Block *mCarvedPumpkin; 98 | static const Block *mNetherrack; 99 | static const Block *mSoulSand; 100 | static const Block *mGlowStone; 101 | static const Block *mPortal; 102 | static const Block *mLitPumpkin; 103 | static const Block *mCake; 104 | static const Block *mUnpoweredRepeater; 105 | static const Block *mPoweredRepeater; 106 | static const Block *mInvisibleBedrock; 107 | static const Block *mTrapdoor; 108 | static const Block *mMonsterStoneEgg; 109 | static const Block *mStoneBrick; 110 | static const Block *mBrownMushroomBlock; 111 | static const Block *mRedMushroomBlock; 112 | static const Block *mIronFence; 113 | static const Block *mGlassPane; 114 | static const Block *mMelon; 115 | static const Block *mPumpkinStem; 116 | static const Block *mMelonStem; 117 | static const Block *mVine; 118 | static const Block *mFenceGateOak; 119 | static const Block *mBrickStairs; 120 | static const Block *mMycelium; 121 | static const Block *mWaterlily; 122 | static const Block *mBrewingStand; 123 | static const Block *mCauldron; 124 | static const Block *mEndPortal; 125 | static const Block *mEndPortalFrame; 126 | static const Block *mEndBrick; 127 | static const Block *mEndStone; 128 | static const Block *mEndRod; 129 | static const Block *mUnlitRedStoneLamp; 130 | static const Block *mLitRedStoneLamp; 131 | static const Block *mCocoa; 132 | static const Block *mEmeraldOre; 133 | static const Block *mEmeraldBlock; 134 | static const Block *mSpruceStairs; 135 | static const Block *mBirchStairs; 136 | static const Block *mJungleStairs; 137 | static const Block *mBeacon; 138 | static const Block *mConduitBlock; 139 | static const Block *mWoodButton; 140 | static const Block *mAcaciaStairs; 141 | static const Block *mDarkOakStairs; 142 | static const Block *mStoneBrickStairs; 143 | static const Block *mNetherBrick; 144 | static const Block *mNetherBrickStairs; 145 | static const Block *mNetherWart; 146 | static const Block *mEnchantingTable; 147 | static const Block *mDropper; 148 | static const Block *mActivatorRail; 149 | static const Block *mSandstoneStairs; 150 | static const Block *mTripwireHook; 151 | static const Block *mTripwire; 152 | static const Block *mWallBlock; 153 | static const Block *mFlowerPot; 154 | static const Block *mCarrotCrop; 155 | static const Block *mPotatoCrop; 156 | static const Block *mSkull; 157 | static const Block *mAnvil; 158 | static const Block *mTrappedChest; 159 | static const Block *mLightWeightedPressurePlate; 160 | static const Block *mHeavyWeightedPressurePlate; 161 | static const Block *mUnpoweredComparator; 162 | static const Block *mPoweredComparator; 163 | static const Block *mCommandBlock; 164 | static const Block *mRepeatingCommandBlock; 165 | static const Block *mChainCommandBlock; 166 | static const Block *mStandingBanner; 167 | static const Block *mWallBanner; 168 | static const Block *mDaylightDetector; 169 | static const Block *mRedstoneBlock; 170 | static const Block *mQuartzOre; 171 | static const Block *mHopper; 172 | static const Block *mBoneBlock; 173 | static const Block *mQuartzBlock; 174 | static const Block *mQuartzStairs; 175 | static const Block *mPurpurBlock; 176 | static const Block *mPurpurStairs; 177 | static const Block *mChorusPlantBlock; 178 | static const Block *mChorusFlowerBlock; 179 | static const Block *mDoubleWoodenSlab; 180 | static const Block *mWoodenSlab; 181 | static const Block *mStainedClay; 182 | static const Block *mLeaves2; 183 | static const Block *mLog2; 184 | static const Block *mSlimeBlock; 185 | static const Block *mMagmaBlock; 186 | static const Block *mIronTrapdoor; 187 | static const Block *mHayBlock; 188 | static const Block *mWoolCarpet; 189 | static const Block *mCoalBlock; 190 | static const Block *mHardenedClay; 191 | static const Block *mPackedIce; 192 | static const Block *mDoublePlant; 193 | static const Block *mDaylightDetectorInverted; 194 | static const Block *mRedSandstone; 195 | static const Block *mRedSandstoneStairs; 196 | static const Block *mDoubleStoneSlab2; 197 | static const Block *mStoneSlab2; 198 | static const Block *mDoubleStoneSlab3; 199 | static const Block *mStoneSlab3; 200 | static const Block *mDoubleStoneSlab4; 201 | static const Block *mStoneSlab4; 202 | static const Block *mSpruceFenceGate; 203 | static const Block *mBirchFenceGate; 204 | static const Block *mJungleFenceGate; 205 | static const Block *mDarkOakFenceGate; 206 | static const Block *mAcaciaFenceGate; 207 | static const Block *mWoodenDoorSpruce; 208 | static const Block *mWoodenDoorBirch; 209 | static const Block *mWoodenDoorJungle; 210 | static const Block *mWoodenDoorAcacia; 211 | static const Block *mWoodenDoorDarkOak; 212 | static const Block *mGrassPathBlock; 213 | static const Block *mDragonEgg; 214 | static const Block *mItemFrame; 215 | static const Block *mStructureBlock; 216 | static const Block *mStructureVoid; 217 | static const Block *mJigsawBlock; 218 | static const Block *mPodzol; 219 | static const Block *mBeetrootCrop; 220 | static const Block *mStonecutterBench; 221 | static const Block *mLegacyStonecutterBench; 222 | static const Block *mGlowingObsidian; 223 | static const Block *mNetherReactor; 224 | static const Block *mInfoUpdateGame1; 225 | static const Block *mInfoUpdateGame2; 226 | static const Block *mInfoReserved6; 227 | static const Block *mFire; 228 | static const Block *mEnderChest; 229 | static const Block *mEndGateway; 230 | static const Block *mStainedGlass; 231 | static const Block *mStainedGlassPane; 232 | static const Block *mPrismarine; 233 | static const Block *mSeaLantern; 234 | static const Block *mCameraBlock; 235 | static const Block *mChalkboard; 236 | static const Block *mUndyedShulkerBox; 237 | static const Block *mShulkerBox; 238 | static const Block *mFrostedIce; 239 | static const Block *mNetherWartBlock; 240 | static const Block *mRedNetherBrick; 241 | static const Block *mGlazedTerracottaWhite; 242 | static const Block *mGlazedTerracottaOrange; 243 | static const Block *mGlazedTerracottaMagenta; 244 | static const Block *mGlazedTerracottaLightBlue; 245 | static const Block *mGlazedTerracottaYellow; 246 | static const Block *mGlazedTerracottaLime; 247 | static const Block *mGlazedTerracottaPink; 248 | static const Block *mGlazedTerracottaGray; 249 | static const Block *mGlazedTerracottaSilver; 250 | static const Block *mGlazedTerracottaCyan; 251 | static const Block *mGlazedTerracottaPurple; 252 | static const Block *mGlazedTerracottaBlue; 253 | static const Block *mGlazedTerracottaBrown; 254 | static const Block *mGlazedTerracottaGreen; 255 | static const Block *mGlazedTerracottaRed; 256 | static const Block *mGlazedTerracottaBlack; 257 | static const Block *mConcrete; 258 | static const Block *mConcretePowder; 259 | static const Block *mStrippedSpruceLog; 260 | static const Block *mStrippedBirchLog; 261 | static const Block *mStrippedJungleLog; 262 | static const Block *mStrippedAcaciaLog; 263 | static const Block *mStrippedDarkOakLog; 264 | static const Block *mStrippedOakLog; 265 | static const Block *mSeaGrass; 266 | static const Block *mPrismarineStairs; 267 | static const Block *mDarkPrismarineStairs; 268 | static const Block *mPrismarineBricksStairs; 269 | static const Block *mCoral; 270 | static const Block *mCoralBlock; 271 | static const Block *mCoralFan; 272 | static const Block *mCoralFanDead; 273 | static const Block *mCoralFanHang; 274 | static const Block *mCoralFanHang2; 275 | static const Block *mCoralFanHang3; 276 | static const Block *mChemistryTable; 277 | static const Block *mUnderwaterTorch; 278 | static const Block *mHardGlass; 279 | static const Block *mHardStainedGlass; 280 | static const Block *mHardGlassPane; 281 | static const Block *mHardStainedGlassPane; 282 | static const Block *mChemicalHeat; 283 | static const Block *mColoredTorchRG; 284 | static const Block *mColoredTorchBP; 285 | static const Block *mElement0; 286 | static const Block *mElement1; 287 | static const Block *mElement2; 288 | static const Block *mElement3; 289 | static const Block *mElement4; 290 | static const Block *mElement5; 291 | static const Block *mElement6; 292 | static const Block *mElement7; 293 | static const Block *mElement8; 294 | static const Block *mElement9; 295 | static const Block *mElement10; 296 | static const Block *mElement11; 297 | static const Block *mElement12; 298 | static const Block *mElement13; 299 | static const Block *mElement14; 300 | static const Block *mElement15; 301 | static const Block *mElement16; 302 | static const Block *mElement17; 303 | static const Block *mElement18; 304 | static const Block *mElement19; 305 | static const Block *mElement20; 306 | static const Block *mElement21; 307 | static const Block *mElement22; 308 | static const Block *mElement23; 309 | static const Block *mElement24; 310 | static const Block *mElement25; 311 | static const Block *mElement26; 312 | static const Block *mElement27; 313 | static const Block *mElement28; 314 | static const Block *mElement29; 315 | static const Block *mElement30; 316 | static const Block *mElement31; 317 | static const Block *mElement32; 318 | static const Block *mElement33; 319 | static const Block *mElement34; 320 | static const Block *mElement35; 321 | static const Block *mElement36; 322 | static const Block *mElement37; 323 | static const Block *mElement38; 324 | static const Block *mElement39; 325 | static const Block *mElement40; 326 | static const Block *mElement41; 327 | static const Block *mElement42; 328 | static const Block *mElement43; 329 | static const Block *mElement44; 330 | static const Block *mElement45; 331 | static const Block *mElement46; 332 | static const Block *mElement47; 333 | static const Block *mElement48; 334 | static const Block *mElement49; 335 | static const Block *mElement50; 336 | static const Block *mElement51; 337 | static const Block *mElement52; 338 | static const Block *mElement53; 339 | static const Block *mElement54; 340 | static const Block *mElement55; 341 | static const Block *mElement56; 342 | static const Block *mElement57; 343 | static const Block *mElement58; 344 | static const Block *mElement59; 345 | static const Block *mElement60; 346 | static const Block *mElement61; 347 | static const Block *mElement62; 348 | static const Block *mElement63; 349 | static const Block *mElement64; 350 | static const Block *mElement65; 351 | static const Block *mElement66; 352 | static const Block *mElement67; 353 | static const Block *mElement68; 354 | static const Block *mElement69; 355 | static const Block *mElement70; 356 | static const Block *mElement71; 357 | static const Block *mElement72; 358 | static const Block *mElement73; 359 | static const Block *mElement74; 360 | static const Block *mElement75; 361 | static const Block *mElement76; 362 | static const Block *mElement77; 363 | static const Block *mElement78; 364 | static const Block *mElement79; 365 | static const Block *mElement80; 366 | static const Block *mElement81; 367 | static const Block *mElement82; 368 | static const Block *mElement83; 369 | static const Block *mElement84; 370 | static const Block *mElement85; 371 | static const Block *mElement86; 372 | static const Block *mElement87; 373 | static const Block *mElement88; 374 | static const Block *mElement89; 375 | static const Block *mElement90; 376 | static const Block *mElement91; 377 | static const Block *mElement92; 378 | static const Block *mElement93; 379 | static const Block *mElement94; 380 | static const Block *mElement95; 381 | static const Block *mElement96; 382 | static const Block *mElement97; 383 | static const Block *mElement98; 384 | static const Block *mElement99; 385 | static const Block *mElement100; 386 | static const Block *mElement101; 387 | static const Block *mElement102; 388 | static const Block *mElement103; 389 | static const Block *mElement104; 390 | static const Block *mElement105; 391 | static const Block *mElement106; 392 | static const Block *mElement107; 393 | static const Block *mElement108; 394 | static const Block *mElement109; 395 | static const Block *mElement110; 396 | static const Block *mElement111; 397 | static const Block *mElement112; 398 | static const Block *mElement113; 399 | static const Block *mElement114; 400 | static const Block *mElement115; 401 | static const Block *mElement116; 402 | static const Block *mElement117; 403 | static const Block *mElement118; 404 | static const Block *mKelp; 405 | static const Block *mDriedKelpBlock; 406 | static const Block *mButtonAcacia; 407 | static const Block *mButtonBirch; 408 | static const Block *mButtonDarkOak; 409 | static const Block *mButtonJungle; 410 | static const Block *mButtonSpruce; 411 | static const Block *mTrapdoorAcacia; 412 | static const Block *mTrapdoorBirch; 413 | static const Block *mTrapdoorDarkOak; 414 | static const Block *mTrapdoorJungle; 415 | static const Block *mTrapdoorSpruce; 416 | static const Block *mPressurePlateAcacia; 417 | static const Block *mPressurePlateBirch; 418 | static const Block *mPressurePlateDarkOak; 419 | static const Block *mPressurePlateJungle; 420 | static const Block *mPressurePlateSpruce; 421 | static const Block *mSeaPickle; 422 | static const Block *mBubbleColumn; 423 | static const Block *mTurtleEgg; 424 | static const Block *mBarrierBlock; 425 | static const Block *mBambooBlock; 426 | static const Block *mBambooSapling; 427 | static const Block *mScaffoldingBlock; 428 | static const Block *mGraniteStairs; 429 | static const Block *mDioriteStairs; 430 | static const Block *mAndesiteStairs; 431 | static const Block *mPolishedGraniteStairs; 432 | static const Block *mPolishedDioriteStairs; 433 | static const Block *mPolishedAndesiteStairs; 434 | static const Block *mMossyStoneBrickStairs; 435 | static const Block *mSmoothRedSandstoneStairs; 436 | static const Block *mSmoothSandstoneStairs; 437 | static const Block *mEndBrickStairs; 438 | static const Block *mMossyCobblestoneStairs; 439 | static const Block *mCobblestoneStairs; 440 | static const Block *mSmoothStone; 441 | static const Block *mRedNetherBrickStairs; 442 | static const Block *mSmoothQuartzStairs; 443 | static const Block *mSpruceSign; 444 | static const Block *mSpruceWallSign; 445 | static const Block *mBirchSign; 446 | static const Block *mBirchWallSign; 447 | static const Block *mJungleSign; 448 | static const Block *mJungleWallSign; 449 | static const Block *mAcaciaSign; 450 | static const Block *mAcaciaWallSign; 451 | static const Block *mDarkOakSign; 452 | static const Block *mDarkOakWallSign; 453 | static const Block *mSmithingTable; 454 | static const Block *mSmokerBlock; 455 | static const Block *mLitSmokerBlock; 456 | static const Block *mBlastFurnace; 457 | static const Block *mLitBlastFurnace; 458 | static const Block *mBarrel; 459 | static const Block *mLantern; 460 | static const Block *mLavaCauldron; 461 | static const Block *mGrindstone; 462 | static const Block *mBellBlock; 463 | static const Block *mCartographyTableBlock; 464 | static const Block *mFletchingTable; 465 | static const Block *mCampfireBlock; 466 | static const Block *mLoomBlock; 467 | static const Block *mLecternBlock; 468 | static const Block *mWoodBlock; 469 | static const Block *mSweetBerryBushBlock; 470 | static const Block *mComposterBlock; 471 | }; -------------------------------------------------------------------------------- /include/world/World.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct World {}; -------------------------------------------------------------------------------- /include/world/level/Level.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct Actor; 4 | 5 | #include "util/ActorRuntimeID.h" 6 | #include "util/ColorFormat.h" 7 | #include "entity/ability/Abilities.h" 8 | #include "util/GameType.h" 9 | #include "util/Color.h" 10 | #include "world/HitResult.h" 11 | #include "util/SmallSet.h" 12 | #include 13 | #include 14 | 15 | struct Player; 16 | struct LocalPlayer; 17 | 18 | class ClientPlayerEventCoordinator; 19 | 20 | /** 21 | * Proudly done by hand... 22 | */ 23 | 24 | struct PlayerListEntry { 25 | ActorUniqueID uid; 26 | mce::UUID uuid; 27 | std::string name; 28 | std::string skinId; 29 | std::vector> skinData; 30 | std::vector> capeData; 31 | std::string geometryName; 32 | std::string geometryData; 33 | std::string xboxUserId; 34 | std::string platformChatId; 35 | 36 | PlayerListEntry(mce::UUID); 37 | 38 | PlayerListEntry(Player const &); 39 | }; 40 | 41 | struct Level { 42 | uintptr_t **vtable; 43 | char pad[0x60]; 44 | std::vector players; 45 | char pad2[0x310]; 46 | std::vector entities; 47 | char pad3[0x18C8]; 48 | SmallSet globalEntities; 49 | 50 | Actor *fetchEntity(ActorUniqueID, bool) const; 51 | 52 | Actor *getRuntimeEntity(ActorRuntimeID, bool) const; 53 | 54 | HitResult &getHitResult(); 55 | 56 | Player *getRuntimePlayer(ActorRuntimeID) const; 57 | 58 | Player *getPlayer(ActorUniqueID) const; 59 | 60 | Actor *getMob(ActorUniqueID) const; 61 | 62 | mce::Color getPlayerColor(Player const &) const; 63 | 64 | std::unordered_map &getPlayerList(); 65 | 66 | SmallSet &getGlobalEntities(); 67 | 68 | void forEachPlayer(std::function) const; 69 | 70 | void forEachPlayer(std::function); 71 | 72 | Abilities &getPlayerAbilities(ActorUniqueID const &); 73 | 74 | Abilities &getDefaultAbilities(); 75 | 76 | void setPlayerAbilities(ActorUniqueID const &, Abilities); 77 | 78 | // TODO: Fix type 79 | //ColorFormat &getPlayerColor(Player const &) const; 80 | 81 | ClientPlayerEventCoordinator *getClientPlayerEventCoordinator(); 82 | 83 | std::string getLevelId() const; 84 | 85 | bool isLeaveGameDone() const; 86 | 87 | void startLeaveGame(); 88 | 89 | GameType getDefaultGameType() const; 90 | 91 | BlockPos getDefaultSpawn() const; 92 | 93 | unsigned int getActivePlayerCount() const; 94 | 95 | LocalPlayer *getPrimaryLocalPlayer() const; 96 | }; 97 | 98 | static_assert(offsetof(Level, players) == 0x68); 99 | static_assert(offsetof(Level, entities) == 0x390); 100 | static_assert(offsetof(Level, globalEntities) == 0x1C70); -------------------------------------------------------------------------------- /include/world/level/LevelData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct LevelData {}; 4 | -------------------------------------------------------------------------------- /include/world/level/storage/GameRules.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct GameRules {}; 4 | --------------------------------------------------------------------------------