├── GraphicPack ├── patch_codelib.asm └── rules.txt ├── include ├── minecraft │ ├── ui │ │ ├── group │ │ │ └── UIGroup.h │ │ ├── fui │ │ │ └── fuiFile.h │ │ ├── control │ │ │ ├── UIControl_Base.h │ │ │ ├── object │ │ │ │ ├── UIControl_Button.h │ │ │ │ ├── UIControl_Label.h │ │ │ │ ├── UIControl_List.h │ │ │ │ ├── UIControl_ButtonList.h │ │ │ │ ├── UIControl_CheckboxButtonList.h │ │ │ │ └── UIControl_MultiList.h │ │ │ ├── util │ │ │ │ └── UIString.h │ │ │ └── UIControl.h │ │ ├── scene │ │ │ ├── SettingsMenu.h │ │ │ ├── Scenes │ │ │ │ ├── UIScene_HowToPlayMenu.h │ │ │ │ └── UIScene_DebugMenu.h │ │ │ └── UIScene.h │ │ ├── layer │ │ │ └── UILayer.h │ │ └── Gui.h │ ├── nbt │ │ ├── Tag.h │ │ ├── ListTag.h │ │ └── CompundTag.h │ ├── util │ │ ├── VTable.h │ │ ├── pair.h │ │ ├── ClickType.h │ │ ├── InteractionHand.h │ │ ├── FoodData.h │ │ ├── SoundSource.h │ │ ├── ParticleType.h │ │ ├── GameType.h │ │ ├── DamageSource.h │ │ ├── unordered_map.h │ │ ├── TelemetryManager.h │ │ ├── EntityTickCache.h │ │ ├── HitResult.h │ │ ├── FloatConverter.h │ │ ├── EquipmentSlot.h │ │ ├── Direction.h │ │ ├── ePARTICLE_TYPE.h │ │ ├── Matrix4.h │ │ ├── VTable_Entity.h │ │ ├── Abilities.h │ │ ├── MenuBuilder.h │ │ ├── BlockPos.h │ │ ├── AABB.h │ │ ├── VTable_TelemetryManager.h │ │ ├── MallocOperator.h │ │ ├── Vec3.h │ │ ├── VTable_UIScene.h │ │ └── Other.h │ ├── entity │ │ ├── Monster.h │ │ ├── ItemFrame.h │ │ ├── Painting.h │ │ ├── SpectralArrow.h │ │ ├── TippableArrow.h │ │ ├── AgableMob.h │ │ ├── effect │ │ │ ├── MobEffect.h │ │ │ └── MobEffectInstance.h │ │ ├── PathfinderMob.h │ │ ├── player │ │ │ ├── PlayerUID.h │ │ │ ├── RemotePlayer.h │ │ │ └── ServerPlayer.h │ │ ├── Zombie.h │ │ ├── Slime.h │ │ ├── Animal.h │ │ ├── PrimedTnt.h │ │ ├── Sheep.h │ │ ├── EvocationFangs.h │ │ ├── Minecart.h │ │ ├── ArmorStand.h │ │ ├── AreaEffectCloud.h │ │ ├── Mob.h │ │ └── ItemEntity.h │ ├── container │ │ ├── Container.h │ │ ├── AbstractContainerMenu.h │ │ ├── SimpleContainer.h │ │ └── Inventory.h │ ├── network │ │ ├── packet │ │ │ ├── Packet.h │ │ │ ├── serverbound │ │ │ │ ├── ServerboundPreLoginPacket.h │ │ │ │ ├── ServerboundSetCreativeModeSlotPacket.h │ │ │ │ ├── ServerboundInteractPacket.h │ │ │ │ ├── ServerboundPlayerActionPacket.h │ │ │ │ ├── ServerboundContainerClickPacket.h │ │ │ │ ├── ServerboundUseItemOnPacket.h │ │ │ │ └── ServerboundMovePlayerPacket.h │ │ │ ├── clientbound │ │ │ │ ├── ClientbooundSetEntityMotionPacket.h │ │ │ │ ├── ClientboundBlockUpdatePacket.h │ │ │ │ ├── ClientboundSoundPacket.h │ │ │ │ └── ClientboundChatPacket.h │ │ │ ├── CraftItemPacket.h │ │ │ └── DisconnectPacket.h │ │ ├── listener │ │ │ └── ClientPacketListener.h │ │ └── server │ │ │ ├── MinecraftServer.h │ │ │ └── PlayerList.h │ ├── client │ │ ├── app │ │ │ ├── System.h │ │ │ ├── CProfile.h │ │ │ ├── ConsoleUIController.h │ │ │ ├── Options.h │ │ │ ├── CMinecraftApp.h │ │ │ └── CInput.h │ │ ├── resource │ │ │ ├── texture │ │ │ │ ├── TextureAtlas.h │ │ │ │ └── Textures.h │ │ │ ├── NonNullList.h │ │ │ ├── shared_ptr.h │ │ │ ├── vector.h │ │ │ ├── ResourceLocation.h │ │ │ └── wstring.h │ │ ├── file │ │ │ ├── FileOutputStream.h │ │ │ ├── FileInputStream.h │ │ │ └── File.h │ │ └── C4JThreadImpl.h │ ├── blockentity │ │ ├── BlockEntity.h │ │ ├── TheEndGatewayEntity.h │ │ └── SignBlockEntity.h │ ├── rendering │ │ ├── Tesselator.h │ │ ├── Font.h │ │ ├── CameraController.h │ │ ├── buffer │ │ │ ├── BufferedImage.h │ │ │ └── BufferBuilder.h │ │ └── GlStateManager.h │ ├── world │ │ ├── gamemode │ │ │ └── ServerPlayerGameMode.h │ │ └── ServerLevel.h │ ├── item │ │ ├── BlockItem.h │ │ ├── BowItem.h │ │ ├── ItemInstance.h │ │ └── Item.h │ └── block │ │ └── Block.h ├── code │ ├── startup.h │ ├── Func.h │ ├── mem.h │ ├── Random.h │ ├── code.h │ └── tcpgecko.h ├── exports │ ├── exports.h │ ├── curl_functions.h │ ├── kernel.h │ ├── os_functions.h │ └── socket_functions.h └── xf │ ├── Benchmark.h │ ├── ItemInstanceHelper.h │ └── Vector.h ├── Main.cpp ├── examples ├── Fly.cpp ├── Packets.cpp ├── Gui.cpp ├── NNIDChange.cpp ├── Effects.cpp ├── Panorama.cpp ├── SignCommands.cpp ├── WorldProtection.cpp ├── Curl.cpp ├── CustomUIScene.cpp ├── AddCreativeMenuItem.cpp ├── BookChat.cpp ├── WorldChat.cpp ├── SimpleContainer.cpp ├── NoteBlockSounds.cpp ├── MemoryViewer.cpp ├── 3DRender.cpp ├── SpawnEntities.cpp └── CustomItem.cpp ├── link.ld └── README.md /GraphicPack/patch_codelib.asm: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /include/minecraft/ui/group/UIGroup.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace mc { 4 | class UIGroup { 5 | 6 | }; 7 | } -------------------------------------------------------------------------------- /include/minecraft/ui/fui/fuiFile.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace mc { 4 | class fuiFile { 5 | public: 6 | uint8_t filler[0xF0]; 7 | }; 8 | } -------------------------------------------------------------------------------- /include/minecraft/nbt/Tag.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace mc { 6 | class Tag { 7 | public: 8 | uint32_t field_0x0; 9 | }; 10 | } -------------------------------------------------------------------------------- /include/minecraft/util/VTable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace mc { 6 | class VTable { 7 | public: 8 | MC_VFUNC(void, void, signature); 9 | }; 10 | } -------------------------------------------------------------------------------- /include/minecraft/entity/Monster.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "PathfinderMob.h" 4 | 5 | namespace mc { 6 | class Monster : public PathfinderMob { 7 | public: 8 | 9 | }; 10 | } -------------------------------------------------------------------------------- /include/minecraft/util/pair.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace mstd { 4 | template 5 | struct pair { 6 | public: 7 | T1 t1; 8 | T2 t2; 9 | }; 10 | } -------------------------------------------------------------------------------- /include/minecraft/util/ClickType.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace mc { 4 | class ClickType { 5 | public: 6 | enum eClickType : int { 7 | A_PRESS, X_PRESS 8 | }; 9 | }; 10 | } -------------------------------------------------------------------------------- /include/code/startup.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void _main(); 4 | 5 | extern "C" __attribute__((section(".entry"))) void entry() { 6 | asm volatile("_entry_main:"); 7 | _main(); 8 | asm volatile("_entry_main_end:"); 9 | } -------------------------------------------------------------------------------- /GraphicPack/rules.txt: -------------------------------------------------------------------------------- 1 | [Definition] 2 | titleIds = 00050000101D9D00,00050000101D7500,00050000101DBE00 3 | name = Code Lib 4 | path = Minecraft: Wii U Edition/Mods/Code Lib 5 | description = https://github.com/David-xF/CodeLib 6 | version = 7 -------------------------------------------------------------------------------- /include/minecraft/util/InteractionHand.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace mc { 4 | class InteractionHand { 5 | public: 6 | enum EInteractionHand : int { 7 | MAIN_HAND, OFF_HAND 8 | }; 9 | }; 10 | } -------------------------------------------------------------------------------- /include/exports/exports.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "curl_functions.h" 4 | #include "gx2_functions.h" 5 | #include "kernel.h" 6 | #include "memory.h" 7 | #include "os_functions.h" 8 | #include "socket_functions.h" 9 | #include "vpad_functions.h" -------------------------------------------------------------------------------- /include/minecraft/container/Container.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace mc { 6 | class Container { 7 | public: 8 | uint32_t field_0x0; 9 | uint32_t field_0x4; 10 | uint32_t field_0x8; 11 | }; 12 | } -------------------------------------------------------------------------------- /include/minecraft/ui/control/UIControl_Base.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "UIControl.h" 6 | 7 | namespace mc { 8 | class UIControl_Base : public UIControl { 9 | public: 10 | uint8_t _filler[0xC]; 11 | }; 12 | } -------------------------------------------------------------------------------- /include/minecraft/ui/control/object/UIControl_Button.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../UIControl_Base.h" 6 | 7 | namespace mc { 8 | class UIControl_Button : public UIControl_Base { 9 | public: 10 | uint32_t field_0x5C; 11 | }; 12 | } -------------------------------------------------------------------------------- /include/minecraft/entity/ItemFrame.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Entity.h" 4 | 5 | namespace mc { 6 | class ItemFrame : public Entity { 7 | public: 8 | static uint64_t GetType() { 9 | return code::Func()(); 10 | } 11 | }; 12 | } -------------------------------------------------------------------------------- /include/minecraft/entity/Painting.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Entity.h" 4 | 5 | namespace mc { 6 | class Painting : public Entity { 7 | public: 8 | static uint64_t GetType() { 9 | return code::Func()(); 10 | } 11 | }; 12 | } -------------------------------------------------------------------------------- /include/minecraft/network/packet/Packet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace mc { 6 | class Packet { 7 | public: 8 | uint64_t time; 9 | uint8_t unk_1; 10 | uint8_t unk_2; 11 | uint8_t unk_3; 12 | uint8_t unk_4; 13 | void* vtbl; 14 | }; 15 | } -------------------------------------------------------------------------------- /include/minecraft/entity/SpectralArrow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Entity.h" 4 | 5 | namespace mc { 6 | class SpectralArrow : public Entity { 7 | public: 8 | static uint64_t GetType() { 9 | return code::Func()(); 10 | } 11 | }; 12 | } -------------------------------------------------------------------------------- /include/minecraft/entity/TippableArrow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Entity.h" 4 | 5 | namespace mc { 6 | class TippableArrow : public Entity { 7 | public: 8 | static uint64_t GetType() { 9 | return code::Func()(); 10 | } 11 | }; 12 | } -------------------------------------------------------------------------------- /include/minecraft/util/FoodData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace mc { 6 | class FoodData { 7 | public: 8 | uint32_t foodLevel; 9 | float saturationLevel; 10 | uint32_t exhaustion; 11 | uint32_t field_0xC; 12 | uint32_t lastFoodLevel; 13 | }; 14 | } -------------------------------------------------------------------------------- /include/minecraft/util/SoundSource.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace mc { 4 | class SoundSource { 5 | public: 6 | enum ESoundSource : int { 7 | unk_0x0, 8 | unk_0x1, 9 | noteblock, 10 | lightningBolt, 11 | unk_0x4, 12 | monster, 13 | entity, 14 | player 15 | }; 16 | }; 17 | } -------------------------------------------------------------------------------- /include/minecraft/util/ParticleType.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "ePARTICLE_TYPE.h" 6 | 7 | namespace mc { 8 | class ParticleType { 9 | public: 10 | static ParticleType* byId(ePARTICLE_TYPE type) { 11 | return code::Func()(type); 12 | } 13 | }; 14 | } -------------------------------------------------------------------------------- /include/minecraft/ui/control/util/UIString.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace mc { 6 | class UIString { 7 | public: 8 | UIString(const wchar_t* str) { 9 | code::Func()(this, str); 10 | } 11 | 12 | uint32_t field_0x0; 13 | uint32_t field_0x4; 14 | }; 15 | } -------------------------------------------------------------------------------- /include/minecraft/entity/AgableMob.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "PathfinderMob.h" 4 | 5 | namespace mc { 6 | class AgableMob : public PathfinderMob { 7 | public: 8 | uint32_t field_0x730; 9 | uint32_t field_0x734; 10 | uint32_t field_0x738; 11 | uint32_t field_0x73C; 12 | uint32_t field_0x740; 13 | uint32_t field_0x744; 14 | }; 15 | } -------------------------------------------------------------------------------- /include/minecraft/util/GameType.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace mc { 6 | class GameType { 7 | public: 8 | static GameType* byId(int id) { 9 | return code::Func()(id); 10 | } 11 | 12 | int getId() { 13 | return code::Func()(this); 14 | } 15 | }; 16 | } -------------------------------------------------------------------------------- /include/minecraft/network/packet/serverbound/ServerboundPreLoginPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../Packet.h" 4 | #include "../../../client/resource/wstring.h" 5 | 6 | namespace mc { 7 | class ServerboundPreLoginPacket : public Packet { 8 | public: 9 | uint32_t unk_0x10; 10 | uint32_t unk_0x14; 11 | uint32_t gameVersion; 12 | mstd::wstring nnid; 13 | }; 14 | } -------------------------------------------------------------------------------- /include/minecraft/entity/effect/MobEffect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace mc { 6 | class MobEffect { 7 | public: 8 | static MobEffect* byId(int id) { 9 | return code::Func()(id); 10 | } 11 | 12 | int getId() { 13 | return code::Func()(this); 14 | } 15 | }; 16 | } -------------------------------------------------------------------------------- /include/minecraft/client/app/System.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace mc { 6 | class System { 7 | public: 8 | static uint64_t processTimeInMilliSecs() { 9 | return code::Func()(); 10 | } 11 | 12 | static uint64_t processTimeInNanoSecs() { 13 | return code::Func()(); 14 | } 15 | }; 16 | } -------------------------------------------------------------------------------- /include/minecraft/blockentity/BlockEntity.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../util/BlockPos.h" 4 | 5 | namespace mc { 6 | class BlockEntity { 7 | public: 8 | uint32_t field_0x0; 9 | uint32_t field_0x4; 10 | uint32_t field_0x8; 11 | uint32_t field_0xC; 12 | mc::BlockPos position; 13 | uint32_t field_0x1C; 14 | uint32_t field_0x20; 15 | uint32_t field_0x24; 16 | }; 17 | } -------------------------------------------------------------------------------- /include/minecraft/client/resource/texture/TextureAtlas.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../wstring.h" 6 | 7 | namespace mc { 8 | class TextureAtlas { 9 | public: 10 | void addIcon(uint32_t x, uint32_t y, mstd::wstring iconName) { 11 | code::Func()(this, 0, y, x, iconName); 12 | } 13 | }; 14 | } -------------------------------------------------------------------------------- /include/minecraft/util/DamageSource.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../client/resource/shared_ptr.h" 6 | 7 | namespace mc { 8 | class DamageSource { 9 | public: 10 | static DamageSource* CreatePlayerAttack(const mc_boost::shared_ptr& player) { 11 | return code::Func&>()(player); 12 | } 13 | }; 14 | } -------------------------------------------------------------------------------- /include/code/Func.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace code { 6 | template 7 | class Func { 8 | public: 9 | // Added this so i can Replace Stuff Easier 10 | inline constexpr uint32_t addr() { return _addr; } 11 | inline constexpr ret operator()(Args... args) { 12 | return ((ret(*)(Args...))(_addr))(args...); 13 | } 14 | }; 15 | } -------------------------------------------------------------------------------- /include/minecraft/util/unordered_map.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace mc_boost { 4 | namespace unordered { 5 | template 6 | class unordered_map { 7 | public: 8 | uint32_t field_0x0; 9 | uint32_t field_0x4; 10 | uint32_t field_0x8; 11 | uint32_t field_0xC; 12 | uint32_t field_0x10; 13 | uint32_t field_0x14; 14 | }; 15 | } 16 | } -------------------------------------------------------------------------------- /Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int c_main(void*) { 5 | // Init Export Functions and other Stuff 6 | code::init(); 7 | 8 | // Your Code here gets executed in a thread 9 | 10 | return 0; 11 | } 12 | 13 | // Gets Called once at startup 14 | void _main() { 15 | mc::C4JThreadImpl* thread = new mc::C4JThreadImpl(c_main, nullptr, "Setup Thread", 0x200); 16 | thread->Run(); 17 | thread->SetDeleteOnExit(true); 18 | } -------------------------------------------------------------------------------- /include/code/mem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace code { 6 | class Mem { 7 | private: 8 | uint32_t base; 9 | 10 | public: 11 | Mem(uint32_t addr) { base = addr; } 12 | 13 | Mem operator[](int offset) { 14 | return Mem(as() + offset); 15 | } 16 | 17 | template 18 | T& as() { 19 | return *reinterpret_cast(base); 20 | } 21 | }; 22 | } -------------------------------------------------------------------------------- /include/minecraft/rendering/Tesselator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "buffer/BufferBuilder.h" 6 | 7 | namespace mc { 8 | class Tesselator { 9 | public: 10 | static Tesselator* getInstance() { 11 | return code::Func()(); 12 | } 13 | 14 | BufferBuilder* getBuilder() { 15 | return code::Func()(this); 16 | } 17 | }; 18 | } -------------------------------------------------------------------------------- /include/minecraft/ui/scene/SettingsMenu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace mc { 4 | class SettingsMenu : public UIScene { 5 | public: 6 | SettingsMenu() 7 | { 8 | code::Func()(this); 9 | } 10 | SettingsMenu(uint32_t ID, void* WhatIsThis, struct UILayer* layer) 11 | { 12 | code::Func()(this, ID, WhatIsThis, layer); 13 | } 14 | 15 | 16 | 17 | }; 18 | } -------------------------------------------------------------------------------- /include/minecraft/util/TelemetryManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "./VTable_TelemetryManager.h" 5 | 6 | namespace mc { 7 | class TelemetryManager { 8 | public: 9 | uint32_t field_0x0; 10 | uint32_t field_0x4; 11 | uint32_t field_0x8; 12 | uint32_t field_0xC; 13 | uint32_t field_0x10; 14 | uint32_t field_0x14; 15 | uint32_t field_0x18; 16 | uint32_t field_0x1C; 17 | uint32_t field_0x20; 18 | VTable_TelemetryManager* Vtbl; 19 | }; 20 | } -------------------------------------------------------------------------------- /include/minecraft/ui/control/object/UIControl_Label.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../UIControl_Base.h" 6 | 7 | namespace mc { 8 | class UIControl_Label : public UIControl_Base { 9 | public: 10 | UIControl_Label() 11 | { 12 | code::Func()(this); 13 | } 14 | UIControl_Label(UIControl_Label* _this) 15 | { 16 | code::Func()(_this); 17 | } 18 | uint32_t field_0x5C; 19 | }; 20 | } -------------------------------------------------------------------------------- /include/minecraft/container/AbstractContainerMenu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../client/resource/shared_ptr.h" 6 | #include "../client/resource/vector.h" 7 | 8 | namespace mc { 9 | class AbstractContainerMenu { 10 | public: 11 | mstd::vector>& getItems() { 12 | return code::Func>&, 0x02033EA0, AbstractContainerMenu*>()(this); 13 | } 14 | }; 15 | } -------------------------------------------------------------------------------- /include/minecraft/entity/PathfinderMob.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Mob.h" 4 | 5 | namespace mc { 6 | class PathfinderMob : public Mob { 7 | public: 8 | uint32_t field_0x708; 9 | uint32_t field_0x70C; 10 | uint32_t field_0x710; 11 | uint32_t field_0x714; 12 | uint32_t field_0x718; 13 | uint32_t field_0x71C; 14 | uint32_t field_0x720; 15 | uint32_t field_0x724; 16 | uint32_t field_0x728; 17 | uint32_t field_0x72C; 18 | }; 19 | } -------------------------------------------------------------------------------- /examples/Fly.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | DECL_FUNCTION(void, tick__11LocalPlayerFv, mc::LocalPlayer* lPlayer) { 6 | lPlayer->abilities.canFly = true; 7 | } 8 | 9 | int c_main(void*) { 10 | code::init(); 11 | 12 | REPLACE(0x031e3a80, tick__11LocalPlayerFv); 13 | 14 | return 0; 15 | } 16 | 17 | void _main() { 18 | mc::C4JThreadImpl* thread = new mc::C4JThreadImpl(c_main, nullptr, "Setup Thread", 0x200); 19 | thread->Run(); 20 | thread->SetDeleteOnExit(true); 21 | } -------------------------------------------------------------------------------- /include/minecraft/client/resource/NonNullList.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace mc { 4 | template 5 | class NonNullList { 6 | public: 7 | void* field_0x0; 8 | int size; 9 | T* start; 10 | T* finish; 11 | 12 | typedef T* iter; 13 | typedef const T* citer; 14 | 15 | iter begin() { return start; } 16 | citer begin() const { return start; } 17 | iter end() { return finish; } 18 | citer end() const { return finish; } 19 | }; 20 | } -------------------------------------------------------------------------------- /include/minecraft/entity/player/PlayerUID.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace mc { 6 | class PlayerUID { 7 | public: 8 | bool operator==(const PlayerUID& playerUID) { 9 | return code::Func()(this, playerUID); 10 | } 11 | 12 | bool operator!=(const PlayerUID& playerUID) { 13 | return code::Func()(this, playerUID); 14 | } 15 | 16 | uint32_t uid[5]; 17 | }; 18 | } -------------------------------------------------------------------------------- /link.ld: -------------------------------------------------------------------------------- 1 | OUTPUT_ARCH(powerpc) 2 | ENTRY(entry) 3 | 4 | MEMORY { 5 | TEXT_MEM : ORIGIN = 0x01800000, LENGTH = 0x10000000 6 | } 7 | 8 | SECTIONS { 9 | .text : 10 | { 11 | *(.entry) 12 | *(.text.*) 13 | *(.gcc_except_table) 14 | *(.gcc_except_table.*) 15 | *(.sdata) 16 | *(.sdata.*) 17 | *(.rodata) 18 | *(.rodata.*) 19 | *(.bss) 20 | *(.bss.*) 21 | *(.sbss) 22 | *(.sbss.*) 23 | *(.data) 24 | *(.data.*) 25 | *(.ext) 26 | *(.ext.*) 27 | data_end = .; 28 | __end__ = .; 29 | } > TEXT_MEM 30 | } 31 | -------------------------------------------------------------------------------- /include/minecraft/entity/Zombie.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Monster.h" 4 | 5 | namespace mc { 6 | class Zombie : public Monster { 7 | public: 8 | Zombie(struct Level* _level) { 9 | code::Func()(this, _level); 10 | } 11 | 12 | uint32_t field_0x730; 13 | uint32_t field_0x734; 14 | uint32_t field_0x738; 15 | uint32_t field_0x73C; 16 | uint32_t field_0x740; 17 | uint32_t field_0x744; 18 | uint32_t field_0x748; 19 | uint32_t field_0x74C; 20 | }; 21 | } -------------------------------------------------------------------------------- /include/minecraft/entity/Slime.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Mob.h" 4 | 5 | namespace mc { 6 | class Slime : public Mob { 7 | public: 8 | Slime(struct Level* _level) { 9 | code::Func()(this, _level); 10 | } 11 | 12 | void setSize(int size, bool unk) { 13 | code::Func()(this, size, unk); 14 | } 15 | 16 | uint32_t field_0x708; 17 | uint32_t field_0x70C; 18 | uint32_t field_0x710; 19 | uint32_t field_0x714; 20 | }; 21 | } -------------------------------------------------------------------------------- /include/minecraft/client/resource/shared_ptr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace mc_boost { 4 | template 5 | class shared_ptr { 6 | public: 7 | shared_ptr(T* p) { 8 | ptr = p; 9 | cnt = 0; 10 | } 11 | 12 | shared_ptr(T* p, uint32_t c) { 13 | ptr = p; 14 | cnt = c; 15 | } 16 | 17 | shared_ptr() { 18 | ptr = 0; 19 | cnt = 0; 20 | } 21 | 22 | T* operator->() const { return ptr; } 23 | T& operator[](int i) const { return ptr[i]; } 24 | 25 | T* get() const { return ptr; } 26 | private: 27 | T* ptr; 28 | uint32_t cnt; 29 | }; 30 | } -------------------------------------------------------------------------------- /include/minecraft/util/EntityTickCache.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "BlockPos.h" 6 | 7 | namespace mc { 8 | class EntityTickCache { 9 | public: 10 | uint32_t field_0x0; 11 | uint32_t field_0x4; 12 | uint32_t field_0x8; 13 | uint32_t field_0xC; 14 | uint32_t field_0x10; 15 | uint32_t field_0x14; 16 | uint32_t field_0x18; 17 | uint32_t field_0x1C; 18 | uint32_t field_0x20; 19 | BlockPos pos1; 20 | BlockPos pos2; 21 | uint32_t field_0x3C; 22 | uint32_t field_0x40; 23 | uint32_t field_0x44; 24 | uint32_t field_0x48; 25 | uint32_t field_0x4C; 26 | }; 27 | } -------------------------------------------------------------------------------- /include/minecraft/util/HitResult.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../client/resource/shared_ptr.h" 6 | #include "BlockPos.h" 7 | 8 | namespace mc { 9 | class HitResult { 10 | public: 11 | HitResult(const mc_boost::shared_ptr& entity) { 12 | code::Func&>()(this, entity); 13 | } 14 | 15 | mc::BlockPos pos; 16 | uint32_t field_0xC; 17 | uint32_t field_0x10; 18 | struct AABB* aabb; 19 | uint32_t field_0x18; 20 | uint32_t field_0x1C; 21 | }; 22 | } -------------------------------------------------------------------------------- /include/minecraft/entity/Animal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "AgableMob.h" 4 | 5 | namespace mc { 6 | class Animal : public AgableMob { 7 | public: 8 | uint32_t field_0x748; 9 | uint32_t field_0x74C; 10 | uint32_t field_0x750; 11 | uint32_t field_0x754; 12 | uint32_t field_0x758; 13 | uint32_t field_0x75C; 14 | uint32_t field_0x760; 15 | uint32_t field_0x764; 16 | uint32_t field_0x768; 17 | uint32_t field_0x76C; 18 | uint32_t field_0x770; 19 | uint32_t field_0x774; 20 | uint32_t field_0x778; 21 | uint32_t field_0x77C; 22 | }; 23 | } -------------------------------------------------------------------------------- /include/minecraft/ui/control/UIControl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace mc { 4 | class UIControl { 5 | public: 6 | uint32_t field_0x0; 7 | uint32_t field_0x4; 8 | uint32_t field_0x8; 9 | uint32_t field_0xC; 10 | uint32_t field_0x10; 11 | uint32_t field_0x14; 12 | uint32_t field_0x18; 13 | uint32_t field_0x1C; 14 | uint32_t field_0x20; 15 | uint32_t field_0x24; 16 | uint32_t field_0x28; 17 | uint32_t field_0x2C; 18 | uint32_t field_0x30; 19 | uint32_t field_0x34; 20 | uint32_t field_0x38; 21 | uint32_t field_0x3C; 22 | uint32_t field_0x40; 23 | uint32_t field_0x44; 24 | uint32_t field_0x48; 25 | uint32_t field_0x4C; 26 | }; 27 | } -------------------------------------------------------------------------------- /include/minecraft/client/file/FileOutputStream.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "File.h" 6 | 7 | namespace mc { 8 | class FileOutputStream { 9 | public: 10 | FileOutputStream(const File& file) { 11 | code::Func()(this, file); 12 | } 13 | 14 | void write(char c) { 15 | code::Func()(this, c); 16 | } 17 | 18 | void close() { 19 | code::Func()(this); 20 | } 21 | 22 | uint32_t field_0x0; 23 | uint32_t field_0x4; 24 | }; 25 | } -------------------------------------------------------------------------------- /include/minecraft/entity/PrimedTnt.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Entity.h" 6 | 7 | namespace mc { 8 | class PrimedTnt : public Entity { 9 | public: 10 | PrimedTnt(struct Level* _level) { 11 | code::Func()(this, _level); 12 | } 13 | 14 | void setFuse(int fuse) { 15 | code::Func()(this, fuse); 16 | } 17 | 18 | DEFINE_STATIC_DEF_VAR(struct VTable_Entity*, vtbl, 0x10225758); 19 | 20 | uint32_t field_0x350; 21 | uint32_t field_0x354; 22 | int fuseTimer; // I think 23 | uint32_t field_0x35C; 24 | }; 25 | } -------------------------------------------------------------------------------- /include/minecraft/util/FloatConverter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace mc { 6 | int toInt(float input) { 7 | bool negative = input < 0.0f; 8 | if (negative) input *= -1.0f; 9 | 10 | uint32_t output = static_cast(input); 11 | if (negative) { 12 | output -= 0x80000000; 13 | output = 0x80000000 - output; 14 | output -= 1; 15 | } 16 | 17 | return output; 18 | } 19 | 20 | float toFloat(int input) { 21 | bool negative = 0 > input; 22 | unsigned int output_tmp = negative ? -input : input; 23 | float output = static_cast(output_tmp); 24 | return negative ? -output : output; 25 | } 26 | } -------------------------------------------------------------------------------- /include/minecraft/world/gamemode/ServerPlayerGameMode.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../../client/resource/shared_ptr.h" 6 | #include "../../util/BlockPos.h" 7 | 8 | namespace mc { 9 | class ServerPlayerGameMode { 10 | public: 11 | void getServerPlayer(const mc_boost::shared_ptr& player) { 12 | code::Func&>()(this, player); 13 | } 14 | 15 | static code::Func _destroyBlock; 16 | void destroyBlock(const mc::BlockPos& pos) { 17 | _destroyBlock(this, pos); 18 | } 19 | }; 20 | } -------------------------------------------------------------------------------- /include/minecraft/util/EquipmentSlot.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../client/resource/wstring.h" 6 | 7 | namespace mc { 8 | class EquipmentSlot { 9 | public: 10 | static EquipmentSlot* RIGHT_HAND asm("0x104C2778"); 11 | static EquipmentSlot* LEFT_HAND asm("0x104C277C"); 12 | static EquipmentSlot* BOOTS asm("0x104C2780"); 13 | static EquipmentSlot* LEGGINGS asm("0x104C2784"); 14 | static EquipmentSlot* CHEST asm("0x104C2788"); 15 | static EquipmentSlot* HEAD asm("0x104C278C"); 16 | 17 | uint32_t field_0x0; 18 | uint32_t field_0x4; 19 | uint32_t field_0x8; 20 | uint32_t field_0xC; 21 | mstd::wstring str; 22 | }; 23 | } -------------------------------------------------------------------------------- /include/minecraft/entity/player/RemotePlayer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Player.h" 6 | 7 | // 0318ABFC 8 | namespace mc { 9 | class RemotePlayer : public Player { 10 | public: 11 | static uint64_t GetType() { 12 | return code::Func()(); 13 | } 14 | 15 | struct GameType* GetGameType() { 16 | return code::Func()(this); 17 | } 18 | 19 | uint32_t field_0x868; 20 | uint32_t field_0x86C; 21 | uint32_t field_0x870; 22 | uint32_t field_0x874; 23 | uint32_t field_0x878; 24 | uint32_t field_0x87C; 25 | uint32_t field_0x880; 26 | struct GameType* gameType; 27 | }; 28 | }; -------------------------------------------------------------------------------- /include/minecraft/network/packet/clientbound/ClientbooundSetEntityMotionPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../Packet.h" 6 | 7 | namespace mc { 8 | class ClientboundSetEntityMotionPacket : public Packet { 9 | public: 10 | ClientboundSetEntityMotionPacket(int id, double x, double y, double z) { 11 | code::Func()(this, id, x, y, z); 12 | } 13 | 14 | uint32_t field_0x10; 15 | uint32_t field_0x14; 16 | uint32_t field_0x18; 17 | uint32_t field_0x1C; 18 | uint32_t field_0x20; 19 | uint32_t field_0x24; 20 | uint32_t field_0x28; 21 | uint32_t field_0x2C; 22 | }; 23 | } -------------------------------------------------------------------------------- /include/minecraft/ui/control/object/UIControl_List.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../UIControl_Base.h" 6 | 7 | namespace mc { 8 | class UIControl_List : public UIControl_Base { 9 | public: 10 | UIControl_List() 11 | { 12 | code::Func()(this); 13 | } 14 | UIControl_List(UIControl_List* _this) 15 | { 16 | code::Func()(_this); 17 | } 18 | void init(int i) 19 | { 20 | code::Func()(this, i); 21 | } 22 | void addElement(uint32_t EUICon, int id) 23 | { 24 | code::Func()(this, EUICon, id); 25 | } 26 | 27 | uint32_t field_0x5C; 28 | }; 29 | } -------------------------------------------------------------------------------- /include/minecraft/network/packet/CraftItemPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Packet.h" 6 | 7 | namespace mc { 8 | class CraftItemPacket : public Packet { 9 | public: 10 | CraftItemPacket(int a, int b, int c) { 11 | code::Func()(this, a, b, c); 12 | } 13 | 14 | uint32_t field_0x10; 15 | uint32_t field_0x14; 16 | uint32_t field_0x18; 17 | uint32_t field_0x1C; 18 | uint32_t field_0x20; 19 | uint32_t field_0x24; 20 | uint32_t field_0x28; 21 | uint32_t field_0x2C; 22 | uint32_t field_0x30; 23 | uint32_t field_0x34; 24 | uint32_t field_0x38; 25 | uint32_t field_0x3C; 26 | }; 27 | } -------------------------------------------------------------------------------- /include/minecraft/client/resource/vector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace mstd { 4 | template 5 | class vector { 6 | public: 7 | typedef T* iter; 8 | typedef const T* citer; 9 | 10 | iter begin() { return &start[0]; } 11 | citer begin() const { return &start[0]; } 12 | iter end() { return &start[size()]; } 13 | citer end() const { return &start[size()]; } 14 | 15 | T operator[](int i) { 16 | return this->start[i]; 17 | } 18 | 19 | int size() { 20 | return ((int) finish - (int) start) / sizeof(T); 21 | } 22 | 23 | uint32_t unk_0x0; 24 | T* start; 25 | T* finish; 26 | T* end_of_storage; 27 | }; 28 | } -------------------------------------------------------------------------------- /include/minecraft/network/packet/clientbound/ClientboundBlockUpdatePacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../Packet.h" 6 | 7 | #include "../../../util/BlockPos.h" 8 | 9 | namespace mc { 10 | class ClientboundBlockUpdatePacket : public Packet { 11 | public: 12 | ClientboundBlockUpdatePacket(struct Level* level, const BlockPos& pos) { 13 | code::Func()(this, level, pos); 14 | } 15 | 16 | uint32_t field_0x10; 17 | uint32_t field_0x14; 18 | uint32_t field_0x18; 19 | uint32_t field_0x1C; 20 | uint32_t field_0x20; 21 | uint32_t field_0x24; 22 | uint32_t field_0x28; 23 | uint32_t field_0x2C; 24 | }; 25 | } -------------------------------------------------------------------------------- /include/minecraft/client/app/CProfile.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../resource/wstring.h" 6 | 7 | namespace mc { 8 | class CProfile { 9 | public: 10 | static CProfile* GetProfile() { 11 | #ifdef CEMU 12 | return code::Mem(0x105CFA58).as(); 13 | #else 14 | return code::Mem(0x10AD1C58).as(); 15 | #endif 16 | } 17 | 18 | void CreatePresenceString(uint32_t id, const mstd::wstring& wcstr) { 19 | code::Func()(this, id, wcstr); 20 | } 21 | 22 | void SetPresenceString(uint32_t id) { 23 | code::Func()(this, id); 24 | } 25 | }; 26 | } -------------------------------------------------------------------------------- /include/minecraft/network/packet/serverbound/ServerboundSetCreativeModeSlotPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../Packet.h" 6 | 7 | #include "../../../client/resource/shared_ptr.h" 8 | 9 | namespace mc { 10 | class ServerboundSetCreativeModeSlotPacket : public Packet { 11 | public: 12 | ServerboundSetCreativeModeSlotPacket(int slot, const mc_boost::shared_ptr& item) { 13 | code::Func&>()(this, slot, item); 14 | } 15 | 16 | uint32_t field_0x10; 17 | uint32_t field_0x14; 18 | int slotNum; 19 | mc_boost::shared_ptr iteminstance; 20 | uint32_t field_0x24; 21 | }; 22 | } -------------------------------------------------------------------------------- /include/minecraft/client/app/ConsoleUIController.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "../../ui/scene/UIScene.h" 5 | 6 | namespace mc { 7 | class ConsoleUIController { 8 | public: 9 | static ConsoleUIController* getInstance() { 10 | #ifdef CEMU 11 | return (ConsoleUIController*) 0x104F73E0; 12 | #else 13 | return (ConsoleUIController*) 0x109F95E0; 14 | #endif 15 | } 16 | 17 | void PlayUISFX(struct SoundEvent* sound) { 18 | code::Func()(this, sound); 19 | } 20 | 21 | void TouchBoxRebuild(UIScene* scene) { 22 | code::Func()(this, scene); 23 | } 24 | }; 25 | } -------------------------------------------------------------------------------- /include/minecraft/network/packet/serverbound/ServerboundInteractPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../Packet.h" 6 | 7 | #include "../../../util/InteractionHand.h" 8 | 9 | #include "../../../client/resource/shared_ptr.h" 10 | 11 | namespace mc { 12 | class ServerboundInteractPacket : public Packet { 13 | public: 14 | ServerboundInteractPacket(const mc_boost::shared_ptr& entity) { 15 | code::Func&>()(this, entity); 16 | } 17 | 18 | uint32_t field_0x10; 19 | uint32_t field_0x14; 20 | uint32_t entityId; 21 | InteractionHand::EInteractionHand action; 22 | uint32_t field_0x20; 23 | uint32_t field_0x24; 24 | }; 25 | } -------------------------------------------------------------------------------- /include/minecraft/client/C4JThreadImpl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace mc { 6 | class C4JThreadImpl { 7 | public: 8 | C4JThreadImpl(int(*func)(void*), void* data, const char* name, int stack_size) { 9 | code::Func()(this, func, data, name, stack_size); 10 | } 11 | 12 | void SetDeleteOnExit(bool ex) { 13 | code::Func()(this, ex); 14 | } 15 | 16 | void Run() { 17 | code::Func()(this); 18 | } 19 | 20 | bool isRunning() { 21 | return code::Func()(this); 22 | } 23 | 24 | uint8_t data[0x78]; 25 | }; 26 | } -------------------------------------------------------------------------------- /include/minecraft/network/listener/ClientPacketListener.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../../client/resource/shared_ptr.h" 6 | 7 | namespace mc { 8 | class ClientPacketListener { 9 | public: 10 | void send(mc_boost::shared_ptr packet) { 11 | code::Func>()(this, packet); 12 | } 13 | 14 | void sendCommand(uint32_t commandAddr = 0x10303000) { 15 | code::Func()(this, commandAddr); 16 | } 17 | 18 | void handleSoundEvent(const mc_boost::shared_ptr& packet) { 19 | code::Func&>()(this, packet); 20 | } 21 | }; 22 | } -------------------------------------------------------------------------------- /include/minecraft/entity/effect/MobEffectInstance.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace mc { 6 | class MobEffectInstance { 7 | public: 8 | MobEffectInstance(struct MobEffect* eff) { 9 | code::Func()(this, eff); 10 | } 11 | 12 | int getDuration() { 13 | return code::Func()(this); 14 | } 15 | 16 | int getAmplifier() { 17 | return code::Func()(this); 18 | } 19 | 20 | struct MobEffect* effect; 21 | int duration; 22 | int amplifier; 23 | bool field_0xC; 24 | bool field_0xD; 25 | bool ambient; 26 | bool visible; 27 | uint32_t field_0x10; 28 | }; 29 | } -------------------------------------------------------------------------------- /include/minecraft/entity/Sheep.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Animal.h" 6 | 7 | namespace mc { 8 | class Sheep : public Animal { 9 | public: 10 | Sheep(struct Level* _level) { 11 | code::Func()(this, _level); 12 | } 13 | 14 | void registerGoals() { 15 | code::Func()(this); 16 | } 17 | 18 | static uint64_t GetType() { 19 | return code::Func()(); 20 | } 21 | 22 | DEFINE_STATIC_DEF_VAR(struct VTable_Entity*, vtbl, 0x10242E30); 23 | 24 | uint32_t field_0x780; 25 | uint32_t field_0x784; 26 | uint32_t field_0x788; 27 | uint32_t field_0x78C; 28 | uint32_t field_0x790; 29 | uint32_t field_0x794; 30 | }; 31 | } -------------------------------------------------------------------------------- /include/minecraft/rendering/Font.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../client/resource/wstring.h" 6 | 7 | #define FONT_CHAR_HEIGHT 8 8 | 9 | namespace mc { 10 | class Font { 11 | public: 12 | int width(const mstd::wstring& wstr) { 13 | return code::Func()(this, wstr); 14 | } 15 | 16 | void drawShadow(const mstd::wstring& wstr, uint32_t arg1, uint32_t arg2, uint32_t arg3) { 17 | code::Func()(this, wstr, arg1, arg2, arg3); 18 | } 19 | 20 | void draw(const mstd::wstring& wstr, uint32_t arg1, uint32_t arg2, uint32_t arg3) { 21 | code::Func()(this, wstr, arg1, arg2, arg3, 0, 1); 22 | } 23 | }; 24 | } -------------------------------------------------------------------------------- /include/minecraft/util/Direction.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace mc { 4 | class Direction { 5 | public: 6 | #ifdef CEMU 7 | static Direction* down asm("0x104C24A0"); 8 | static Direction* up asm("0x104C24A4"); 9 | static Direction* north asm("0x104C24A8"); 10 | static Direction* south asm("0x104C24AC"); 11 | static Direction* west asm("0x104C24B0"); 12 | static Direction* east asm("0x104C24B4"); 13 | #else 14 | static Direction* down asm("0x109C46A0"); 15 | static Direction* up asm("0x109C46A4"); 16 | static Direction* north asm("0x109C46A8"); 17 | static Direction* south asm("0x109C46AC"); 18 | static Direction* west asm("0x109C46B0"); 19 | static Direction* east asm("0x109C46B4"); 20 | #endif 21 | }; 22 | } -------------------------------------------------------------------------------- /include/minecraft/item/BlockItem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Item.h" 4 | 5 | #include "../util/BlockPos.h" 6 | #include "../client/resource/shared_ptr.h" 7 | 8 | namespace mc { 9 | class BlockItem : public Item { 10 | public: 11 | BlockItem(struct Block* block) { 12 | code::Func()(this, block); 13 | } 14 | 15 | bool mayPlace(struct Level* level, const BlockPos& pos, struct Direction* dir, const mc_boost::shared_ptr& player, const mc_boost::shared_ptr& item) { 16 | return code::Func&, const mc_boost::shared_ptr&>()(this, level, pos, dir, player, item); 17 | } 18 | 19 | uint32_t field_0x78; 20 | }; 21 | } -------------------------------------------------------------------------------- /include/minecraft/util/ePARTICLE_TYPE.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace mc { 4 | enum ePARTICLE_TYPE : int { 5 | NONE = 0, SMOKE = 1, NOTE = 2, PORTAL = 3, EXPLODE = 5, FLAME = 6, 6 | LAVA = 7, FOOTSTEP = 8, DROPLET = 9, LARGE_SMOKE = 10, RED_DUST = 11, 7 | SNOWBALL_POOF = 12, SNOW_SHOVEL = 13, SLIME = 14, HEART = 15, DEPTH_SUSPEND = 17, 8 | CRITICAL_HIT = 18, HUGE_EXPLOSION = 19, LARGE_EXPLODE = 20, TOWN_AURA = 21, 9 | SPELL = 22, WITCH_MAGIC = 23, MOB_SPELL = 24, MOB_SPELL_AMBIANT = 25, DRIP_WATER = 27, 10 | DRIP_LAVA = 28, ENCHANTMENT_TABLE = 29, ANGRY_VILLAGER = 31, HAPPY_VILLAGER = 32, 11 | FIREWORKS_SPARK = 33, WAKE = 34, INSTANT_SPELL = 36, CLOUD = 37, BARRIER = 38, ICON_CRACK = 39, 12 | BLOCK_DUST = 40, SPLASH = 41, DRAGON_BREATH = 44, END_ROD = 45, BLACK_HEART = 46, 13 | FALLING_DUST = 48, TOTEM = 49, SPIT = 51, 14 | }; 15 | } -------------------------------------------------------------------------------- /include/minecraft/network/packet/DisconnectPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Packet.h" 6 | 7 | namespace mc { 8 | class DisconnectPacket : public Packet { 9 | public: 10 | enum eDisconnectReason : int { 11 | CONNECTION_LOST = 0, 12 | HOST_LEFT = 1, 13 | KICKED_FOR_FLYING = 7, 14 | KICKED_FROM_THE_GAME = 8, 15 | SERVER_IS_FULL = 13, 16 | OLDER_VERSION = 14, 17 | NEWER_VERSION = 15, 18 | CONTENT_PRIVILEGE_TOO_LOW = 20, 19 | TOO_RESTRICTIVE = 21, 20 | NOT_FRIENDS_WITH_ANYONE = 25, 21 | PREVIOUSLY_KICKED = 26, 22 | FRIENDS_OF_FRIENDS = 27, 23 | MII_ALREADY_SELECTED = 30, 24 | NO_GAME_FOUND = 32, 25 | }; 26 | 27 | uint32_t field_0x10; 28 | uint32_t field_0x14; 29 | eDisconnectReason reason; 30 | }; 31 | } -------------------------------------------------------------------------------- /include/minecraft/ui/layer/UILayer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../../client/resource/vector.h" 6 | 7 | #include "../../util/unordered_map.h" 8 | #include "../../util/pair.h" 9 | 10 | namespace mc { 11 | class UILayer { 12 | public: 13 | 14 | 15 | void updateFocusState(bool flag) 16 | { 17 | code::Func()(this, flag); 18 | } 19 | 20 | mstd::vector scenes; 21 | mstd::vector components; 22 | mstd::vector field_0x20; 23 | mstd::vector field_0x30; 24 | mc_boost::unordered::unordered_map> componentVisibility; 25 | bool field_0x58; 26 | bool field_0x59; 27 | bool field_0x5A; 28 | bool field_0x5B; 29 | int field_0x5C; 30 | int field_0x60; 31 | struct UIGroup* group; 32 | }; 33 | } -------------------------------------------------------------------------------- /include/minecraft/client/app/Options.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace mc { 6 | class Options { 7 | public: 8 | float musicVolume; 9 | float soundVolume; 10 | float mouseSensitivity; 11 | int field_0xC; 12 | int viewDistance; 13 | char bobView; 14 | char anaglyph3d; 15 | char hasAdvancedOpenGL; 16 | char field_0x17; 17 | int FPSCap; 18 | char hasFancyGraphics; 19 | char ao; 20 | char clouds_; 21 | char field_0x1F; 22 | char filler_0xB4[0xB4]; 23 | int difficulty; 24 | bool renderNames; 25 | bool field_0xD9; 26 | bool field_0xDA; 27 | bool field_0xDB; 28 | int field_0xDC; 29 | int renderDebug; 30 | char filler_0x34[0x34]; 31 | float guiScale; 32 | float particles; 33 | float FOV; 34 | float gamma; 35 | }; 36 | } -------------------------------------------------------------------------------- /include/minecraft/blockentity/TheEndGatewayEntity.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "BlockEntity.h" 6 | 7 | namespace mc { 8 | class TheEndGatewayEntity : public BlockEntity { 9 | public: 10 | void save(struct CompoundTag* tag) { 11 | code::Func()(this, tag); 12 | } 13 | 14 | void load(struct CompoundTag* tag) { 15 | code::Func()(this, tag); 16 | } 17 | 18 | void SetExitPortal(struct BlockPos* pos) { 19 | code::Func()(this, pos); 20 | } 21 | 22 | uint32_t field_0x28; 23 | uint32_t field_0x2C; 24 | uint32_t field_0x30; 25 | struct BlockPos* exitPortal; 26 | uint32_t field_0x38; 27 | uint32_t field_0x3C; 28 | }; 29 | } -------------------------------------------------------------------------------- /include/minecraft/network/packet/serverbound/ServerboundPlayerActionPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../Packet.h" 6 | 7 | #include "../../../util/BlockPos.h" 8 | 9 | namespace mc { 10 | class ServerboundPlayerActionPacket : public Packet { 11 | public: 12 | enum Action : int { 13 | START_BREAKING, STOP_BREAKING, FINISH_BREAKING, DROP_ALL, DROP_SINGLE, RELEASE, SWAP_HANDS 14 | }; 15 | 16 | ServerboundPlayerActionPacket(Action arg2, const BlockPos& pos, const struct Direction* dir, int arg5) { 17 | code::Func()(this, arg2, pos, dir, arg5); 18 | } 19 | 20 | uint32_t field_0x10; 21 | uint32_t field_0x14; 22 | BlockPos position; 23 | struct Direction* direction; 24 | uint32_t _action; 25 | uint32_t field_0x2C; 26 | }; 27 | } -------------------------------------------------------------------------------- /include/minecraft/client/resource/texture/Textures.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../wstring.h" 6 | 7 | namespace mc { 8 | class Textures { 9 | public: 10 | void loadTexture(struct BufferedImage* img, int id) { 11 | code::Func()(this, img, id); 12 | } 13 | 14 | void bind(int id) { 15 | code::Func()(this, id); 16 | } 17 | 18 | uint32_t loadMemTexture(const mstd::wstring& str, int unk) { 19 | return code::Func()(this, str, unk); 20 | } 21 | 22 | void reloadall() { 23 | code::Func()(this); 24 | } 25 | 26 | void releaseTexture(int id) { 27 | code::Func()(this, id); 28 | } 29 | }; 30 | } -------------------------------------------------------------------------------- /include/minecraft/util/Matrix4.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "FloatConverter.h" 6 | 7 | namespace mc { 8 | template 9 | class Matrix4 { 10 | public: 11 | Matrix4(T standartVal) { 12 | for (int i = 0; i < 4; i++) { 13 | for (int j = 0; j < 4; j++) { 14 | data[i][j] = standartVal; 15 | } 16 | } 17 | } 18 | 19 | Matrix4() = default; 20 | 21 | T getData(int a, int b) { 22 | return data[a][b]; 23 | } 24 | 25 | void copy(Matrix4 other) { 26 | for (int i = 0; i < 4; i++) { 27 | for (int j = 0; j < 4; j++) { 28 | data[i][j] = other.getData(i, j); 29 | } 30 | } 31 | } 32 | 33 | Matrix4 operator=(Matrix4 other) { 34 | copy(other); 35 | return *this; 36 | } 37 | 38 | T data[4][4]; 39 | }; 40 | } -------------------------------------------------------------------------------- /include/minecraft/network/server/MinecraftServer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace mc { 6 | class MinecraftServer { 7 | public: 8 | static MinecraftServer* getInstance() { 9 | #ifdef CEMU 10 | return code::Mem(0x104CB6FC).as(); 11 | #else 12 | return code::Mem(0x109CD8FC).as(); 13 | #endif 14 | } 15 | 16 | struct ServerLevel* getLevel(int i) { 17 | return code::Func()(this, i); 18 | } 19 | 20 | struct PlayerList* getPlayers() { 21 | return code::Func()(this); 22 | } 23 | 24 | uint32_t field_0x0; 25 | uint32_t field_0x4; 26 | uint32_t field_0x8; 27 | uint32_t field_0xC; 28 | uint32_t field_0x10; 29 | struct PlayerList* field_0x14; 30 | uint32_t field_0x18; 31 | 32 | }; 33 | } -------------------------------------------------------------------------------- /include/minecraft/ui/Gui.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../client/resource/wstring.h" 6 | 7 | namespace mc { 8 | class Gui { 9 | public: 10 | void addMessage(const mstd::wstring& wstr, int unk_0x0, bool unk_0x1, bool unk_0x2, bool unk_0x3, bool unk_0x4) { 11 | code::Func()(this, wstr, unk_0x0, unk_0x1, unk_0x2, unk_0x3, unk_0x4); 12 | } 13 | 14 | void setSingleMessage(const mstd::wstring& wstr, int a, int b) { 15 | code::Func()(this, wstr, a, b); 16 | } 17 | 18 | void displayClientMessage(int LocalisationID) { 19 | code::Func()(this, LocalisationID, 0); 20 | } 21 | 22 | void RenderSlot(int a, int b, int c, float d) { 23 | code::Func()(this, a, b, c, d); 24 | } 25 | }; 26 | }; -------------------------------------------------------------------------------- /include/minecraft/nbt/ListTag.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Tag.h" 4 | #include "../client/resource/vector.h" 5 | #include "../client/resource/wstring.h" 6 | 7 | namespace mc { 8 | class ListTag : public Tag { 9 | public: 10 | ListTag(int i) { 11 | code::Func()(this, i); 12 | } 13 | 14 | void add(Tag* tag) { 15 | code::Func()(this, tag); 16 | } 17 | 18 | void getString(int index, const mstd::wstring& str) { 19 | code::Func()(this, index, str); 20 | } 21 | 22 | int size() { 23 | return code::Func()(this); 24 | } 25 | 26 | void toString(const mstd::wstring& output_str) { 27 | code::Func()(this, output_str); 28 | } 29 | 30 | mstd::vector tags; 31 | uint32_t maxSize; // I think 32 | }; 33 | } -------------------------------------------------------------------------------- /include/minecraft/util/VTable_Entity.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "VTable.h" 4 | 5 | #include "../client/resource/shared_ptr.h" 6 | #include "../util/InteractionHand.h" 7 | 8 | namespace mc { 9 | struct VTable_Entity : public VTable { 10 | public: 11 | MC_VFUNC(void, struct Entity, __pure_virtual_called); 12 | MC_VFUNC(void, struct Entity, __dt__6EntityFv); 13 | MC_VFUNC(void, struct Entity, fjDerivedCtorCalls__6EntityFv); 14 | MC_VFUNC(void, struct Entity, kill__6EntityFv); 15 | MC_VFUNC(void, struct Entity, __pure_virtual_called_2); 16 | MC_VFUNC(void, struct Entity, resetPos__6EntityFv); 17 | MC_VFUNC(void, struct Entity, remove__6EntityFv); 18 | MC_VFUNC(void, struct Entity, setDropContainerContent__6EntityFb); 19 | MC_VFUNC(void, struct Entity, setSize__6EntityFfT1); 20 | MC_VFUNC(void, struct Entity, setPos__6EntityFdN21); 21 | MC_VFUNC(void, struct Entity, tick__6EntityFv); 22 | MC_VFUNC(void, struct Entity, baseTick__6EntityFv); 23 | }; 24 | } -------------------------------------------------------------------------------- /include/minecraft/rendering/CameraController.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../client/resource/vector.h" 6 | 7 | namespace mc { 8 | class CameraController { 9 | public: 10 | double* getCurrentPos() { 11 | return code::Func()(this); 12 | } 13 | 14 | double* getCurrentRot() { 15 | return code::Func()(this); 16 | } 17 | 18 | uint32_t field_0x0; 19 | mstd::vector field_0x4; 20 | mstd::vector field_0x14; 21 | uint32_t field_0x24; 22 | uint32_t field_0x28; 23 | uint32_t field_0x2C; 24 | uint32_t field_0x30; 25 | uint32_t currentPos; 26 | uint32_t currentRot; 27 | uint32_t field_0x3C; 28 | uint32_t field_0x40; 29 | uint32_t field_0x44; 30 | uint32_t field_0x48; 31 | uint32_t field_0x4C; 32 | uint32_t field_0x50; 33 | uint32_t field_0x54; 34 | }; 35 | } -------------------------------------------------------------------------------- /examples/Packets.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | void packets() { 6 | mc::ClientPacketListener* listener = mc::Minecraft::getInstance()->getConnection(0); 7 | // This also works: mc::ClientPacketListener* listener = mc::Minecraft::getInstance()->thePlayer->listener; 8 | 9 | // Packets get Deleted Automatically after Sending! 10 | 11 | // Sends a Move Player Packet with Position (25, 30, 35) and Yaw/Pitch 180/90 while being on a Block and not Flying 12 | listener->send(new mc::ServerboundMovePlayerPacket(25, 30, 35, 180, 90, true, false)); 13 | } 14 | 15 | DECL_HOOK(onFrameInGame, void) { 16 | START_BUTTONCHECK(button & VPAD_BUTTON_RIGHT, packets(), button) 17 | END_BUTTONCHECK() 18 | } 19 | 20 | int c_main(void*) { 21 | code::init(); 22 | 23 | HOOK(0x02D9CAD0, onFrameInGame, 0); 24 | 25 | return 0; 26 | } 27 | 28 | void _main() { 29 | mc::C4JThreadImpl* thread = new mc::C4JThreadImpl(c_main, nullptr, "Setup Thread", 0x200); 30 | thread->Run(); 31 | thread->SetDeleteOnExit(true); 32 | } -------------------------------------------------------------------------------- /include/minecraft/item/BowItem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Item.h" 6 | 7 | namespace mc { 8 | class BowItem : public Item { 9 | public: 10 | BowItem() { 11 | code::Func()(this); 12 | } 13 | 14 | Item* releaseUsing(const mc_boost::shared_ptr& instance, struct Level* level, const mc_boost::shared_ptr& entity, int idk) { 15 | return code::Func&, struct Level*, const mc_boost::shared_ptr&, int>()(this, instance, level, entity, idk); 16 | } 17 | 18 | #ifdef CEMU 19 | DEFINE_STATIC_DEF_VAR(struct VTable_Item*, vtbl, 0x10061554); 20 | #else 21 | DEFINE_STATIC_DEF_VAR(struct VTable_Item*, vtbl, 0x10563754); 22 | #endif 23 | DEFINE_STATIC_DEF_VAR(int, itemId, 261); 24 | 25 | uint32_t field_0x78; 26 | uint32_t field_0x7C; 27 | uint32_t field_0x80; 28 | }; 29 | } -------------------------------------------------------------------------------- /include/minecraft/client/file/FileInputStream.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "File.h" 6 | 7 | namespace mc { 8 | class FileInputStream { 9 | public: 10 | FileInputStream(const File& file) { 11 | code::Func()(this, file); 12 | } 13 | 14 | char read() { 15 | return code::Func()(this); 16 | } 17 | 18 | void read(void* unk) { 19 | code::Func()(this, unk); 20 | } 21 | 22 | void skip(int l) { 23 | code::Func()(this, l); 24 | } 25 | 26 | int filesize() { 27 | return code::Func()(this); 28 | } 29 | 30 | void close() { 31 | code::Func()(this); 32 | } 33 | 34 | uint32_t field_0x0; 35 | uint32_t field_0x4; 36 | uint32_t field_0x8; 37 | }; 38 | } -------------------------------------------------------------------------------- /include/minecraft/client/resource/ResourceLocation.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "wstring.h" 6 | 7 | namespace mc { 8 | class ResourceLocation { 9 | public: 10 | ResourceLocation(const mstd::wstring& str1, const mstd::wstring& str2) { 11 | code::Func()(this, str1, str2); 12 | } 13 | 14 | uint32_t field_0x0; 15 | uint32_t field_0x4; 16 | uint32_t field_0x8; 17 | uint32_t field_0xC; 18 | uint32_t field_0x10; 19 | uint32_t field_0x14; 20 | uint32_t field_0x18; 21 | uint32_t field_0x1C; 22 | uint32_t field_0x20; 23 | uint32_t field_0x24; 24 | uint32_t field_0x28; 25 | uint32_t field_0x2C; 26 | uint32_t field_0x30; 27 | uint32_t field_0x34; 28 | uint32_t field_0x38; 29 | uint32_t field_0x3C; 30 | uint32_t field_0x40; 31 | uint32_t field_0x44; 32 | uint32_t field_0x48; 33 | uint32_t field_0x4C; 34 | }; 35 | } -------------------------------------------------------------------------------- /include/minecraft/util/Abilities.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace mc { 6 | class Abilities { 7 | public: 8 | bool operator==(const Abilities& abilities) { 9 | return code::Func()(this, abilities); 10 | } 11 | 12 | float getFlyingSpeed() { 13 | return code::Func()(this); 14 | } 15 | 16 | void setFlyingSpeed(float newSpeed) { 17 | code::Func()(this, newSpeed); 18 | } 19 | 20 | float getWalkingSpeed() { 21 | return code::Func()(this); 22 | } 23 | 24 | void setWalkingSpeed(float newSpeed) { 25 | code::Func()(this, newSpeed); 26 | } 27 | 28 | bool isInvulnerable; 29 | bool isFlying; 30 | bool canFly; 31 | bool canInstaBuild; 32 | float field_0x4; 33 | float flySpeed; 34 | float walkSpeed; 35 | }; 36 | } -------------------------------------------------------------------------------- /examples/Gui.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | DECL_HOOK(onFrameInGame, void) { 7 | xf::GUI::DrawHelper::renderSetup(); 8 | mc::Font* font = mc::Minecraft::getInstance()->defaultFonts; 9 | // Display "Hello World" at x = 5, y = 5, with color white [Format ARGB] 10 | xf::GUI::DrawHelper::DisplayText(font, L"Hello World", 1.0f, 5, 5, 0xFFFFFFFF); 11 | } 12 | 13 | DECL_HOOK(onFrameInMenu, void) { 14 | xf::GUI::DrawHelper::renderSetup(); 15 | mc::Font* font = mc::Minecraft::getInstance()->defaultFonts; 16 | // Display "Hello World" at x = 5, y = 5, with color white [Format ARGB] 17 | xf::GUI::DrawHelper::DisplayText(font, L"Hello World", 1.0f, 5, 5, 0xFFFFFFFF); 18 | } 19 | 20 | int c_main(void*) { 21 | code::init(); 22 | 23 | HOOK(0x02D9CAD0, onFrameInGame, 0); 24 | HOOK(0x02D9C8B0, onFrameInMenu, 0); 25 | 26 | return 0; 27 | } 28 | 29 | void _main() { 30 | mc::C4JThreadImpl* thread = new mc::C4JThreadImpl(c_main, nullptr, "Setup Thread", 0x200); 31 | thread->Run(); 32 | thread->SetDeleteOnExit(true); 33 | } -------------------------------------------------------------------------------- /examples/NNIDChange.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | int swkbd_callback(void* data, bool unk) { 6 | wchar_t* nnidAddr = (wchar_t*) data; 7 | wchar_t buff[17]; 8 | mc::CInput::GetInput()->GetText(buff, 17); 9 | 10 | // Override the NNID Address, with input from Keyboard 11 | mc_swprintf(nnidAddr, 17, L"%ls", buff); 12 | mc_printf(L"[NNID] Changed NNID to %ls", buff); 13 | return 0; 14 | } 15 | 16 | void openNNIDChangeKeyboard() { 17 | wchar_t* nnidAddr = getNNID(); 18 | mc::CInput::GetInput()->RequestKeyboard(L"", nnidAddr, 0, 16, swkbd_callback, nnidAddr, mc::CInput::KeyboardMode::NNID); 19 | } 20 | 21 | DECL_HOOK(onFrameInGame, void) { 22 | START_BUTTONCHECK(button & VPAD_BUTTON_RIGHT, openNNIDChangeKeyboard(), button) 23 | END_BUTTONCHECK() 24 | } 25 | 26 | int c_main(void*) { 27 | code::init(); 28 | 29 | HOOK(0x02D9CAD0, onFrameInGame, 0); 30 | 31 | return 0; 32 | } 33 | 34 | void _main() { 35 | mc::C4JThreadImpl* thread = new mc::C4JThreadImpl(c_main, nullptr, "Setup Thread", 0x200); 36 | thread->Run(); 37 | thread->SetDeleteOnExit(true); 38 | } -------------------------------------------------------------------------------- /include/minecraft/network/packet/serverbound/ServerboundContainerClickPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../Packet.h" 6 | 7 | #include "../../../client/resource/vector.h" 8 | #include "../../../client/resource/shared_ptr.h" 9 | 10 | #include "../../../util/ClickType.h" 11 | 12 | namespace mc { 13 | class ServerboundContainerClickPacket : public Packet { 14 | public: 15 | ServerboundContainerClickPacket(int a, int b, int c, ClickType::eClickType type, const mc_boost::shared_ptr& item, short s) { 16 | code::Func&, short>()(this, a, b, c, type, item, s); 18 | } 19 | 20 | uint32_t field_0x10; 21 | uint32_t field_0x14; 22 | uint32_t containerId; 23 | uint32_t slotNum; 24 | uint32_t buttonNum; 25 | uint32_t uid; 26 | mstd::vector> items; 27 | ClickType::eClickType clickType; 28 | uint32_t numSlots; 29 | }; 30 | } -------------------------------------------------------------------------------- /include/minecraft/client/app/CMinecraftApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../resource/wstring.h" 4 | 5 | namespace mc { 6 | class CMinecraftApp { 7 | public: 8 | void AddMemoryTextureFile(const mstd::wstring& name, uint8_t* data, uint32_t size) { 9 | code::Func()(this, name, data, size); 10 | } 11 | 12 | static const mstd::wstring& getSkinPathFromId(void* ptr, uint32_t id) { 13 | return code::Func()(ptr, id); 14 | } 15 | 16 | void SetAppPaused(bool b) { 17 | code::Func()(this, b); 18 | } 19 | 20 | bool isAppPaused() { 21 | return code::Func()(this); 22 | } 23 | 24 | static CMinecraftApp* getInstance() { 25 | #ifdef CEMU 26 | return code::Mem(0x10528DC0).as(); 27 | #else 28 | return code::Mem(0x10A2AFC0).as(); 29 | #endif 30 | } 31 | }; 32 | } -------------------------------------------------------------------------------- /include/minecraft/entity/EvocationFangs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Entity.h" 4 | 5 | namespace mc { 6 | class EvocationFangs : public Entity { 7 | public: 8 | EvocationFangs(struct Level* _level) { 9 | code::Func()(this, _level); 10 | } 11 | 12 | void setOwner(const mc_boost::shared_ptr& entity) { 13 | code::Func&>()(this, entity); 14 | } 15 | 16 | static uint64_t GetType() { 17 | return code::Func()(); 18 | } 19 | 20 | uint32_t field_0x350; 21 | uint32_t field_0x354; 22 | uint32_t field_0x358; 23 | uint32_t field_0x35C; 24 | uint32_t field_0x360; 25 | uint32_t field_0x364; 26 | uint32_t field_0x368; 27 | uint32_t field_0x36C; 28 | uint32_t field_0x370; 29 | uint32_t field_0x374; 30 | uint32_t field_0x378; 31 | uint32_t field_0x37C; 32 | uint32_t field_0x380; 33 | uint32_t field_0x384; 34 | }; 35 | } -------------------------------------------------------------------------------- /include/minecraft/network/packet/serverbound/ServerboundUseItemOnPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../Packet.h" 6 | 7 | #include "../../../util/BlockPos.h" 8 | #include "../../../util/InteractionHand.h" 9 | 10 | namespace mc { 11 | class ServerboundUseItemOnPacket : public Packet { 12 | public: 13 | // ServerboundUseItemOnPacket::ServerboundUseItemOnPacket(const BlockPos&, const struct Direction*, InteractionHand::EInteractionHand, float, float, float) 14 | ServerboundUseItemOnPacket(const BlockPos& pos, const struct Direction* dir, InteractionHand::EInteractionHand hand, float unk1, float unk2, float unk3) { 15 | code::Func()(this, pos, dir, hand, unk1, unk2, unk3); 16 | } 17 | 18 | uint32_t field_0x10; 19 | uint32_t field_0x14; 20 | BlockPos position; 21 | struct Direction* direction; 22 | InteractionHand::EInteractionHand e_hand; 23 | float clickX; 24 | float clickY; 25 | float clickZ; 26 | }; 27 | } -------------------------------------------------------------------------------- /include/minecraft/client/app/CInput.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace mc { 6 | class CInput { 7 | public: 8 | enum KeyboardMode : int { 9 | FULL = 0, 10 | NUMPAD = 1, 11 | UTF8 = 2, 12 | NNID = 3 13 | }; 14 | 15 | static inline CInput* GetInput() { 16 | #ifdef CEMU 17 | return code::Mem(0x1058EC6C).as(); 18 | #else 19 | return code::Mem(0x10A90E6C).as(); 20 | #endif 21 | } 22 | 23 | void GetText(const wchar_t* buffer, int32_t length) { 24 | code::Func()(this, buffer, length); 25 | } 26 | 27 | bool RequestKeyboard(const wchar_t* nothing, const wchar_t* default_text, uint32_t unk_Ui0, uint32_t max_size, int(*call_back)(void *, bool), void* arg1, KeyboardMode eKeyboardMode) { 28 | return code::Func()(this, nothing, default_text, unk_Ui0, max_size, call_back, arg1, eKeyboardMode); 29 | } 30 | 31 | }; 32 | } -------------------------------------------------------------------------------- /include/minecraft/util/MenuBuilder.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | 7 | namespace mc { 8 | 9 | class MenuBuilder { 10 | public: 11 | void ADD(const mc_boost::shared_ptr& InstanceSharedPtr, mc::ItemInstance Instance) 12 | { 13 | mc::ItemInstance::toShared(InstanceSharedPtr, &Instance); 14 | code::Func&>()(this, InstanceSharedPtr); 15 | } 16 | 17 | void ITEM_BLOCKSTATE(uint32_t BlockState) 18 | { 19 | code::Func()(this, BlockState); 20 | } 21 | 22 | 23 | 24 | 25 | // NEITHER OF THESE WORK AT THE TIME BEING 26 | void BANNER(uint32_t DyeColor, uint32_t BannerPattern_PTR) //NEEDS DYECOLOUR AND BANNERPATTERN BUILDERS 27 | { 28 | code::Func()(this, DyeColor, BannerPattern_PTR); 29 | } 30 | 31 | void POTION(mc::Item* item, uint32_t Potion_PTR) //NEEDS POTION BUILDER 32 | { 33 | code::Func()(this, item, Potion_PTR); 34 | } 35 | }; 36 | } -------------------------------------------------------------------------------- /examples/Effects.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | DECL_FUNCTION(void, ServerPlayer_tick, mc::ServerPlayer* player) { 6 | real_ServerPlayer_tick(player); 7 | 8 | mc::MobEffect* effect = mc::MobEffect::byId(1); // Speed 9 | if (!player->hasEffect(effect)) { 10 | mc::MobEffectInstance* effectInstance = new mc::MobEffectInstance(effect); 11 | effectInstance->amplifier = 0; // 0 = Level 1 | 1 = Level 2... 12 | effectInstance->duration = 30 * 20; // 30 Seconds 13 | effectInstance->visible = false; // Not Visible 14 | 15 | // Must be ServerPlayer (NOT LocalPlayer) 16 | player->addEffect(effectInstance, nullptr); 17 | 18 | wchar_t temp[0xA0]; 19 | mc_swprintf(temp, 0xA0, L"Gave you Effect %ls", getEffectName(effect->getId())); 20 | player->listener->send(new mc::ClientboundChatPacket(temp)); 21 | } 22 | } 23 | 24 | int c_main(void*) { 25 | code::init(); 26 | 27 | REPLACE(mc::ServerPlayer::_tick.addr(), ServerPlayer_tick); 28 | 29 | return 0; 30 | } 31 | 32 | void _main() { 33 | mc::C4JThreadImpl* thread = new mc::C4JThreadImpl(c_main, nullptr, "Setup Thread", 0x200); 34 | thread->Run(); 35 | thread->SetDeleteOnExit(true); 36 | } -------------------------------------------------------------------------------- /include/code/Random.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace code { 6 | uint32_t mLehmer = 0; 7 | 8 | class Random { 9 | public: 10 | static uint32_t Lehmer32() { 11 | mLehmer += 0xE120FC15; 12 | uint64_t tmp; 13 | tmp = (uint64_t) mLehmer * 0x4A39B70D; 14 | uint32_t m1 = (tmp >> 32) ^ tmp; 15 | tmp = (uint64_t) m1 * 0x12FAD5C9; 16 | uint32_t m2 = (tmp >> 32) ^ tmp; 17 | return m2; 18 | } 19 | 20 | static uint32_t next(uint32_t min, uint32_t max) { 21 | for (uint32_t i = 0; i < 10; i++) Lehmer32(); 22 | return ((Lehmer32() % (max - min + 1)) + min); 23 | } 24 | 25 | static float nextFloat() { 26 | for (uint32_t i = 0; i < next(3, 8); i++) Lehmer32(); 27 | int first = next(0, 1000000); 28 | float result = first / 1000000; 29 | return result; 30 | } 31 | 32 | static double nextDouble() { 33 | for (uint32_t i = 0; i < next(3, 8); i++) Lehmer32(); 34 | int first = next(0, 1000000); 35 | double result = first / 1000000; 36 | return result; 37 | } 38 | }; 39 | } -------------------------------------------------------------------------------- /include/minecraft/entity/Minecart.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Entity.h" 4 | 5 | namespace mc { 6 | class Minecart : public Entity { 7 | public: 8 | Minecart(struct Level* _level) { 9 | code::Func()(this, _level); 10 | } 11 | 12 | static code::Func _getMaxSpeed; 13 | static double getMaxSpeed() { 14 | return _getMaxSpeed(); 15 | } 16 | 17 | static uint64_t GetType() { 18 | return code::Func()(); 19 | } 20 | 21 | uint32_t field_0x350; 22 | uint32_t field_0x354; 23 | uint32_t field_0x358; 24 | uint32_t field_0x35C; 25 | uint32_t field_0x360; 26 | uint32_t field_0x364; 27 | uint32_t field_0x368; 28 | uint32_t field_0x36C; 29 | uint32_t field_0x370; 30 | uint32_t field_0x374; 31 | uint32_t field_0x378; 32 | uint32_t field_0x37C; 33 | uint32_t field_0x380; 34 | uint32_t field_0x384; 35 | uint32_t field_0x388; 36 | uint32_t field_0x38C; 37 | uint32_t field_0x390; 38 | uint32_t field_0x394; 39 | uint32_t field_0x398; 40 | uint32_t field_0x39C; 41 | }; 42 | } -------------------------------------------------------------------------------- /include/minecraft/util/BlockPos.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace mc { 6 | class BlockPos { 7 | public: 8 | BlockPos(int _x, int _y, int _z) { 9 | code::Func()(this, _x, _y, _z); 10 | } 11 | 12 | BlockPos(struct Entity* entity) { 13 | code::Func()(this, entity); 14 | } 15 | 16 | BlockPos() = default; 17 | 18 | BlockPos operator+(mc::BlockPos pos) { 19 | return BlockPos(x + pos.x, y + pos.y, z + pos.z); 20 | } 21 | 22 | bool operator==(const BlockPos& pos) { 23 | return code::Func()(this, pos); 24 | } 25 | 26 | bool operator!=(const BlockPos& pos) { 27 | return code::Func()(this, pos); 28 | } 29 | 30 | template 31 | void forBox(int radius, void(*func)(mc::BlockPos pos, T& context), T context) { 32 | for (int _x = -radius; _x <= radius; _x++) { 33 | for (int _y = -radius; _y <= radius; _y++) { 34 | for (int _z = -radius; _z <= radius; _z++) { 35 | func({_x + x, _y + y, _z + z}, context); 36 | } 37 | } 38 | } 39 | } 40 | 41 | int x; 42 | int y; 43 | int z; 44 | }; 45 | } -------------------------------------------------------------------------------- /examples/Panorama.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | int imgId = 0; 7 | 8 | DECL_FUNCTION(void, panorama, void* uicomp, int a, int b, int c) { 9 | if (imgId == 0) { 10 | mc::File file(L"custom_panorama.png"); 11 | if (!file.exists()) { 12 | real_panorama(uicomp, a, b, c); 13 | return; 14 | } 15 | mc::FileInputStream in(file); 16 | int bufferSize = in.filesize(); 17 | uint8_t* buffer = new uint8_t[bufferSize + 5]; 18 | 19 | for (int i = 0; i < bufferSize; i++) { 20 | buffer[i] = in.read(); 21 | } 22 | 23 | in.close(); 24 | 25 | mc::BufferedImage* image = new mc::BufferedImage(buffer, bufferSize); 26 | imgId = mc::GlStateManager::genTexture(); 27 | mc::Minecraft::getInstance()->textures->loadTexture(image, imgId); 28 | } 29 | 30 | xf::GUI::DrawHelper::renderSetup(); 31 | xf::GUI::DrawHelper::DisplayBox2D(0, 0, WIDTH, HEIGHT, imgId); 32 | } 33 | 34 | int c_main(void*) { 35 | code::init(); 36 | 37 | REPLACE(0x02e0b3a4, panorama); 38 | 39 | return 0; 40 | } 41 | 42 | void _main() { 43 | mc::C4JThreadImpl* thread = new mc::C4JThreadImpl(c_main, nullptr, "Setup Thread", 0x200); 44 | thread->Run(); 45 | thread->SetDeleteOnExit(true); 46 | } -------------------------------------------------------------------------------- /include/minecraft/entity/ArmorStand.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "LivingEntity.h" 4 | 5 | namespace mc { 6 | class ArmorStand : public LivingEntity { 7 | public: 8 | ArmorStand(struct Level* _level) { 9 | code::Func()(this, _level); 10 | } 11 | 12 | void setShorArms(bool state) { 13 | code::Func()(this, state); 14 | } 15 | 16 | void setItemSlot(struct EquipmentSlot* slot, const mc_boost::shared_ptr& item) { 17 | code::Func&>()(this, slot, item); 18 | } 19 | 20 | static uint64_t GetType() { 21 | return code::Func()(); 22 | } 23 | 24 | uint32_t field_0x5F0; 25 | uint32_t field_0x5F4; 26 | uint32_t field_0x5F8; 27 | uint32_t field_0x5FC; 28 | uint32_t field_0x600; 29 | uint32_t field_0x604; 30 | uint32_t field_0x608; 31 | uint32_t field_0x60C; 32 | uint32_t field_0x610; 33 | uint32_t field_0x614; 34 | uint32_t field_0x618; 35 | uint32_t field_0x61C; 36 | uint32_t field_0x620; 37 | uint32_t field_0x624; 38 | }; 39 | } -------------------------------------------------------------------------------- /include/code/code.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "mem.h" 4 | #include "Func.h" 5 | #include "startup.h" 6 | #include "Random.h" 7 | 8 | #include "tcpgecko.h" 9 | #include "wups.h" 10 | 11 | #include 12 | 13 | namespace code { 14 | void init() { 15 | InitTCPGecko(); 16 | InitWups(); 17 | 18 | // Remove Whatever you don't need (Will Reduce File Size) 19 | InitSocketFunctionPointers(); 20 | InitKernelFunctionPointers(); 21 | InitVPadFunctionPointers(); 22 | InitMemoryFunctionPointers(); 23 | InitOSFunctionPointers(); 24 | InitGX2FunctionPointers(); 25 | InitLibCurlFunctionPointers(); 26 | 27 | memoryInitialize(); 28 | } 29 | } 30 | 31 | #define WIDTH 640 32 | #define HEIGHT 360 33 | 34 | #define MC_CHECK_SIZE(type, size) static_assert(sizeof(mc::type) == size, #type " has invalid size.") 35 | 36 | #define MC_VFUNC(return_type, class_type, function_name, ...) \ 37 | int flag_##function_name; \ 38 | return_type(*function_name)(class_type* _this, ##__VA_ARGS__) 39 | 40 | #define DEFINE_STATIC_DEF_VAR(type, name, addr) \ 41 | static inline type default_##name = (type) addr; 42 | 43 | #define DEFINE_STATIC_VAR(type, name, addr) \ 44 | static inline type name = (type) addr; 45 | 46 | // WHEN CEMU IS DEFINED THE MC_LIB USES CEMU POINTERS 47 | #define CEMU -------------------------------------------------------------------------------- /include/minecraft/network/packet/serverbound/ServerboundMovePlayerPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../Packet.h" 6 | 7 | namespace mc { 8 | class ServerboundMovePlayerPacket : public Packet { 9 | public: 10 | ServerboundMovePlayerPacket(double x, double y, double z, bool isOnGround, bool isFlying) { 11 | code::Func()(this, isOnGround, isFlying, x, y, y, z); 12 | } 13 | 14 | ServerboundMovePlayerPacket(double x, double y, double z, float yaw, float pitch, bool isOnGround, bool isFlying) { 15 | code::Func()(this, isOnGround, isFlying, x, y, z, yaw, pitch); 16 | } 17 | 18 | ServerboundMovePlayerPacket(float yaw, float pitch, bool isOnGround, bool isFlying) { 19 | code::Func()(this, isOnGround, isFlying, yaw, pitch); 20 | } 21 | 22 | uint32_t field_0x10; 23 | uint32_t field_0x14; 24 | double x; 25 | double y; 26 | double Z; 27 | float yaw; 28 | float pitch; 29 | uint32_t field_0x38; 30 | uint32_t field_0x3C; 31 | }; 32 | } -------------------------------------------------------------------------------- /include/xf/Benchmark.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace xf { 6 | enum T_UNIT { 7 | MILLI, NANO 8 | }; 9 | class Benchmark { 10 | public: 11 | template 12 | static uint64_t measure(T* funcPtr, T_UNIT unit, Args... args) { 13 | switch (unit) { 14 | case MILLI: 15 | return measureMilli(funcPtr, args...); 16 | break; 17 | case NANO: 18 | return measureNano(funcPtr, args...); 19 | break; 20 | default: 21 | return measureMilli(funcPtr, args...); 22 | break; 23 | } 24 | } 25 | 26 | template 27 | static uint64_t measureMilli(T* funcPtr, Args... args) { 28 | uint64_t startTime = mc::System::processTimeInMilliSecs(); 29 | funcPtr(args...); 30 | return mc::System::processTimeInMilliSecs() - startTime; 31 | } 32 | 33 | template 34 | static uint64_t measureNano(T* funcPtr, Args... args) { 35 | uint64_t startTime = mc::System::processTimeInNanoSecs(); 36 | funcPtr(args...); 37 | return mc::System::processTimeInNanoSecs() - startTime; 38 | } 39 | }; 40 | } -------------------------------------------------------------------------------- /include/minecraft/rendering/buffer/BufferedImage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../../client/resource/wstring.h" 6 | 7 | namespace mc { 8 | class BufferedImage { 9 | public: 10 | BufferedImage(uint8_t* buffer, uint32_t size) { 11 | code::Func()(this, buffer, size); 12 | } 13 | 14 | BufferedImage(const mstd::wstring& path1, bool unk, bool unk2, const mstd::wstring& path2, int unk3) { 15 | code::Func()(this, path1, unk, unk2, path2, unk3); 16 | } 17 | 18 | int getWidth() { 19 | return code::Func()(this); 20 | } 21 | 22 | int getHeight() { 23 | return code::Func()(this); 24 | } 25 | 26 | uint32_t field_0x0; 27 | uint32_t field_0x4; 28 | uint32_t field_0x8; 29 | uint32_t field_0xC; 30 | uint32_t field_0x10; 31 | uint32_t field_0x14; 32 | uint32_t field_0x18; 33 | uint32_t field_0x1C; 34 | uint32_t field_0x20; 35 | uint32_t field_0x24; 36 | uint32_t field_0x28; 37 | uint32_t field_0x2C; 38 | uint32_t field_0x30; 39 | }; 40 | } -------------------------------------------------------------------------------- /include/minecraft/client/file/File.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../resource/wstring.h" 6 | #include "../resource/vector.h" 7 | 8 | namespace mc { 9 | class File { 10 | public: 11 | File(const mstd::wstring& path) { 12 | code::Func()(this, path); 13 | } 14 | 15 | File() = default; 16 | 17 | bool exists() { 18 | return code::Func()(this); 19 | } 20 | 21 | void _delete() { 22 | code::Func()(this); 23 | } 24 | 25 | void getPath(const mstd::wstring& str) { 26 | code::Func()(this, str); 27 | } 28 | 29 | mstd::vector& getFiles() { 30 | return code::Func&, 0x02324220, File*>()(this); 31 | } 32 | 33 | void getName(const mstd::wstring& name) { 34 | code::Func()(this, name); 35 | } 36 | 37 | uint32_t field_0x0; 38 | uint32_t field_0x4; 39 | uint32_t field_0x8; 40 | uint32_t field_0xC; 41 | uint32_t field_0x10; 42 | uint32_t field_0x14; 43 | uint32_t field_0x18; 44 | uint32_t field_0x1C; 45 | }; 46 | } -------------------------------------------------------------------------------- /examples/SignCommands.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | DECL_FUNCTION(bool, executeClickCommands__15SignBlockEntityFQ2_5boost25shared_ptr__tm__8_6Player, mc::SignBlockEntity* sign, mc_boost::shared_ptr player) { 6 | mc::ServerPlayer* sPlayer = nullptr;; 7 | for (mc_boost::shared_ptr& s_player : mc::MinecraftServer::getInstance()->getPlayers()->players) { 8 | if (player->colourIndex == s_player->colourIndex) { 9 | sPlayer = s_player.get(); 10 | } 11 | } 12 | 13 | if (!sPlayer) return true; 14 | 15 | // What to do when the Sign gets clicked 16 | sPlayer->listener->send(new mc::ClientboundChatPacket(sign->line1)); 17 | sPlayer->listener->send(new mc::ClientboundChatPacket(sign->line2)); 18 | sPlayer->listener->send(new mc::ClientboundChatPacket(sign->line3)); 19 | sPlayer->listener->send(new mc::ClientboundChatPacket(sign->line4)); 20 | 21 | return true; 22 | } 23 | 24 | int c_main(void*) { 25 | code::init(); 26 | 27 | REPLACE(mc::SignBlockEntity::_executeClickCommands.addr(), executeClickCommands__15SignBlockEntityFQ2_5boost25shared_ptr__tm__8_6Player); 28 | 29 | return 0; 30 | } 31 | 32 | void _main() { 33 | mc::C4JThreadImpl* thread = new mc::C4JThreadImpl(c_main, nullptr, "Setup Thread", 0x200); 34 | thread->Run(); 35 | thread->SetDeleteOnExit(true); 36 | } -------------------------------------------------------------------------------- /examples/WorldProtection.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | DECL_FUNCTION(void, ServerPlayerGameMode_breakBlock, mc::ServerPlayerGameMode* gameMode, const mc::BlockPos& pos) { 6 | mc_boost::shared_ptr player; 7 | gameMode->getServerPlayer(player); 8 | 9 | mc::ServerLevel* level = mc::MinecraftServer::getInstance()->getLevel(0); 10 | int radius = 1; 11 | for (int x = -radius; x <= radius; x++) { 12 | for (int y = -radius; y <= radius; y++) { 13 | for (int z = -radius; z <= radius; z++) { 14 | // Send an Update Packet back to let the Player know that the block is still there 15 | mc_boost::shared_ptr packet(new mc::ClientboundBlockUpdatePacket(level, {pos.x + x, pos.y + y, pos.z + z})); 16 | player->listener->send(packet); 17 | } 18 | } 19 | } 20 | 21 | // No real_ServerPlayerGameMode_breakBlock Because we don't want to break the Block (It gets Canceled) 22 | } 23 | 24 | int c_main(void*) { 25 | code::init(); 26 | 27 | REPLACE(mc::ServerPlayerGameMode::_destroyBlock.addr(), ServerPlayerGameMode_breakBlock); 28 | 29 | return 0; 30 | } 31 | 32 | void _main() { 33 | mc::C4JThreadImpl* thread = new mc::C4JThreadImpl(c_main, nullptr, "Setup Thread", 0x200); 34 | thread->Run(); 35 | thread->SetDeleteOnExit(true); 36 | } -------------------------------------------------------------------------------- /include/minecraft/client/resource/wstring.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace mstd { 7 | class wstring { 8 | public: 9 | wstring(const wchar_t* str) { 10 | code::Func()(this, str); 11 | } 12 | 13 | wstring() = default; 14 | 15 | const wchar_t* c_str() const { 16 | return (length > 7) ? pointer : str; 17 | } 18 | 19 | const wstring& assign(const wchar_t* _str, int _length) { 20 | 21 | this->str[0] = 0; 22 | this->length2 = 7; 23 | this->length = 0; 24 | return code::Func()(this, _str, _length); 25 | } 26 | 27 | const wstring& assign(const char* _str, int _length) { 28 | 29 | this->str[0] = 0; 30 | this->length2 = 7; 31 | this->length = 0; 32 | return code::Func()(this, _str, _length); 33 | } 34 | 35 | bool operator==(const wchar_t* _str) { 36 | const wchar_t* __str = c_str(); 37 | return wcscmp(__str, _str); 38 | } 39 | 40 | uint32_t unk_0x0; // 0x00 41 | wchar_t str[8]; // 0x04 42 | wchar_t* pointer; // 0x14 43 | uint32_t length; // 0x18 44 | uint32_t length2; // 0x1C 45 | }; 46 | } -------------------------------------------------------------------------------- /include/minecraft/blockentity/SignBlockEntity.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "BlockEntity.h" 6 | 7 | #include "../client/resource/shared_ptr.h" 8 | #include "../client/resource/wstring.h" 9 | 10 | namespace mc { 11 | class SignBlockEntity : public BlockEntity { 12 | public: 13 | void SetMessage(int index, const mstd::wstring& message) { 14 | code::Func()(this, index, message); 15 | } 16 | 17 | const mc_boost::shared_ptr& getUpdatePacket() { 18 | return code::Func&, 0x029144b8, SignBlockEntity*>()(this); 19 | } 20 | 21 | static uint64_t getType() { 22 | return code::Func()(); 23 | } 24 | 25 | static code::Func> _executeClickCommands; 26 | bool executeClickCommands(mc_boost::shared_ptr player) { 27 | return _executeClickCommands(this, player); 28 | } 29 | 30 | uint32_t field_0x28; 31 | uint32_t field_0x2C; 32 | uint32_t field_0x30; 33 | uint32_t field_0x34; 34 | uint32_t field_0x38; 35 | uint32_t field_0x3C; 36 | uint32_t field_0x40; 37 | uint32_t field_0x44; 38 | uint32_t field_0x48; 39 | uint32_t field_0x4C; 40 | uint32_t field_0x50; 41 | mstd::wstring line1; 42 | mstd::wstring line2; 43 | mstd::wstring line3; 44 | mstd::wstring line4; 45 | uint32_t field_0xC8; 46 | uint32_t field_0xCC; 47 | }; 48 | } -------------------------------------------------------------------------------- /examples/Curl.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | int WriteCallback(char* contents, int size, int nmemb, xf::String* userp) { 7 | for (int i = 0; i < (size * nmemb); i++) { 8 | userp->operator+=(contents[i]); 9 | } 10 | return size*nmemb; 11 | } 12 | 13 | bool hasSentMessage = false; 14 | DECL_FUNCTION(void, LocalPlayer_swing, mc::LocalPlayer* player, int hand) { 15 | if (!hasSentMessage) { 16 | void* curl = curl_easy_init(); 17 | if (curl) { 18 | xf::String str = ""; 19 | // Use HTTP with Port 80, Don't use HTTPS because Curl doesn't use SSL Certificates 20 | curl_easy_setopt(curl, CURLOPT_URL, "http://david-xf.de/logs"); 21 | curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, (void*) WriteCallback); 22 | curl_easy_setopt(curl, CURLOPT_FILE, &str); 23 | int res = curl_easy_perform(curl); 24 | curl_easy_cleanup(curl); 25 | 26 | mc_printf(L"Response: %d Content: %s", res, str.c_str()); 27 | hasSentMessage = true; 28 | } 29 | } 30 | 31 | real_LocalPlayer_swing(player, hand); 32 | } 33 | 34 | int c_main(void*) { 35 | code::init(); 36 | 37 | REPLACE(mc::LocalPlayer::_swing.addr(), LocalPlayer_swing); 38 | 39 | return 0; 40 | } 41 | 42 | void _main() { 43 | mc::C4JThreadImpl* thread = new mc::C4JThreadImpl(c_main, nullptr, "Setup Thread", 0x200); 44 | thread->Run(); 45 | thread->SetDeleteOnExit(true); 46 | } -------------------------------------------------------------------------------- /include/minecraft/ui/control/object/UIControl_ButtonList.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "./UIControl_List.h" 6 | #include "../../scene/UIScene.h" 7 | 8 | namespace mc { 9 | class UIControl_ButtonList : public UIControl_List { 10 | public: 11 | UIControl_ButtonList() 12 | { 13 | code::Func()(this); 14 | } 15 | UIControl_ButtonList(UIControl_ButtonList* _this) 16 | { 17 | code::Func()(_this); 18 | } 19 | 20 | void addItem(mstd::wstring* Str, uint32_t i) 21 | { 22 | code::Func()(this, Str, i); 23 | } 24 | void setupControl(UIScene* scene, uint32_t fuiNode, mstd::wstring* Str) 25 | { 26 | code::Func()(this, scene, fuiNode, Str); 27 | } 28 | 29 | uint32_t field_0x60; 30 | uint32_t field_0x64; 31 | uint32_t field_0x68; 32 | uint32_t field_0x6C; 33 | uint32_t field_0x70; 34 | uint32_t field_0x74; 35 | uint32_t field_0x78; 36 | uint32_t field_0x7C; 37 | uint32_t field_0x80; 38 | uint32_t field_0x84; 39 | uint32_t field_0x88; 40 | uint32_t field_0x8C; 41 | uint32_t field_0x90; 42 | uint32_t field_0x94; 43 | uint32_t field_0x98; 44 | uint32_t field_0x9C; 45 | uint32_t field_0xA0; 46 | uint32_t field_0xA4; 47 | uint32_t field_0xA8; 48 | uint32_t field_0xAC; 49 | uint32_t field_0xB0; 50 | uint32_t field_0xB4; 51 | }; 52 | } -------------------------------------------------------------------------------- /include/minecraft/network/packet/clientbound/ClientboundSoundPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../Packet.h" 6 | #include "../../../util/SoundEvent.h" 7 | #include "../../../util/SoundSource.h" 8 | 9 | namespace mc { 10 | class ClientboundSoundPacket : public Packet { 11 | public: 12 | // ClientboundSoundPacket::ClientboundSoundPacket(SoundEvent const *, SoundSource::ESoundSource, double, double, double, float, float) 13 | ClientboundSoundPacket(SoundEvent* sound, SoundSource::ESoundSource source, double x, double y, double z, float vol, float pitch) { 14 | code::Func()(this, sound, source, x, y, z, vol, pitch); 15 | } 16 | 17 | ClientboundSoundPacket(SoundEvent* sound, float vol = 1.0f, float pitch = 1.0f) { 18 | code::Func()(this, sound, vol, pitch); 19 | } 20 | 21 | uint32_t field_0x10; 22 | uint32_t field_0x14; 23 | SoundEvent* sound; 24 | SoundSource::ESoundSource source; 25 | uint32_t field_0x20; 26 | uint32_t field_0x24; 27 | uint32_t field_0x28; 28 | float volume; 29 | float pitch; 30 | bool playUi; 31 | bool looping; 32 | bool field_0x36; 33 | bool field_0x37; 34 | uint32_t soundInstance; // idk which type 35 | int entityId; 36 | }; 37 | } -------------------------------------------------------------------------------- /include/minecraft/util/AABB.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Vec3.h" 6 | 7 | namespace mc { 8 | class AABB { 9 | public: 10 | AABB(double x1, double y1, double z1, double x2, double y2, double z2) { 11 | code::Func()(this, x1, y1, z1, x2, y2, z2); 12 | } 13 | 14 | AABB(const AABB& aabb) { 15 | code::Func()(this, aabb); 16 | } 17 | 18 | AABB(int x1, int y1, int z1, int x2, int y2, int z2) { 19 | code::Func()(this, 20 | toFloat(x1), toFloat(y1), toFloat(z1), 21 | toFloat(x2), toFloat(y2), toFloat(z2) 22 | ); 23 | } 24 | 25 | AABB(Vec3 _min, Vec3 _max) { 26 | code::Func()(this, _min.x, _min.y, _min.z, _max.x, _max.y, _max.z); 27 | } 28 | 29 | void set(const AABB* aabb) { 30 | code::Func()(this, aabb); 31 | } 32 | 33 | AABB move(double x, double y, double z) { 34 | return code::Func()(this, x, y, z); 35 | } 36 | 37 | static void CreateNewThreadStorage() { 38 | code::Func()(); 39 | } 40 | 41 | Vec3 min; 42 | Vec3 max; 43 | }; 44 | } -------------------------------------------------------------------------------- /include/code/tcpgecko.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define EXPORT_DECL(res, func, ...) res(*func)(__VA_ARGS__) = 0; 6 | #define EXPORT_VAR(type, var) type var; 7 | 8 | EXPORT_DECL(int, OSDynLoad_Acquire, const char* rpl, uint32_t* handle); 9 | EXPORT_DECL(int, OSDynLoad_FindExport, uint32_t handle, int isData, const char* symbol, void* address); 10 | 11 | #define EXPORT_FUNC_WRITE(func, val) *(uint32_t*)(((uint32_t)&func) + 0) = (uint32_t)val 12 | #define OS_FIND_EXPORT(handle, func) funcPointer = 0; \ 13 | OSDynLoad_FindExport(handle, 0, #func, &funcPointer); \ 14 | EXPORT_FUNC_WRITE(func, funcPointer); 15 | 16 | #define MINECRAFT 17 | //#define MARIO_KART 18 | 19 | #ifdef MINECRAFT 20 | #define AcquireAddress 0x038071E4 21 | #define FindExportAddress 0x038077B0 22 | #elif ifdef MARIO_KART 23 | #define AcquireAddress 0x0249EAC8 24 | #define FindExportAddress 0x026789DC 25 | #else 26 | #define AcquireAddress 0x0 27 | #define FindExportAddress 0x0 28 | #endif 29 | 30 | int32_t targetAddr(uint32_t instructionAddress) { 31 | uint32_t instruction = code::Mem(instructionAddress).as(); 32 | int32_t li = instruction & 0x03FFFFFC; 33 | return (li & 0x02000000) ? (li - 0x04000000) : li; 34 | } 35 | 36 | void InitTCPGecko() { 37 | OSDynLoad_Acquire = (int(*)(const char*, uint32_t*)) targetAddr(AcquireAddress); 38 | OSDynLoad_FindExport = (int(*)(uint32_t, int, const char*, void*)) targetAddr(FindExportAddress); 39 | } -------------------------------------------------------------------------------- /include/minecraft/network/packet/clientbound/ClientboundChatPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../../../client/resource/wstring.h" 6 | #include "../../../client/resource/vector.h" 7 | 8 | #include "../Packet.h" 9 | #include "../../../util/Other.h" 10 | 11 | namespace mc { 12 | class ClientboundChatPacket : public Packet { 13 | public: 14 | ClientboundChatPacket(const mstd::wstring& str) { 15 | uint32_t temp[20]; 16 | code::Func()(this, str, temp, 0x46); 17 | } 18 | 19 | template 20 | ClientboundChatPacket(const mstd::wstring& str, Args... args) { 21 | wchar_t _temp[0xA0]; 22 | mc_swprintf(_temp, 0xA0, str.c_str(), args...); 23 | uint32_t temp[20]; 24 | code::Func()(this, _temp, temp, 0x46); 25 | } 26 | 27 | mstd::vector str_v; 28 | uint32_t field_0x20; 29 | uint32_t field_0x24; 30 | uint32_t field_0x28; 31 | uint32_t field_0x2C; 32 | uint32_t field_0x30; 33 | uint32_t field_0x34; 34 | uint32_t field_0x38; 35 | uint32_t field_0x3C; 36 | uint32_t field_0x40; 37 | uint32_t field_0x44; 38 | uint32_t field_0x48; 39 | uint32_t field_0x4C; 40 | uint32_t field_0x50; 41 | uint32_t field_0x54; 42 | uint32_t field_0x58; 43 | uint32_t field_0x5C; 44 | uint32_t field_0x60; 45 | uint32_t field_0x64; 46 | }; 47 | } -------------------------------------------------------------------------------- /include/minecraft/ui/control/object/UIControl_CheckboxButtonList.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "./UIControl_List.h" 6 | #include "../../scene/UIScene.h" 7 | 8 | namespace mc { 9 | class UIControl_CheckboxButtonList : public UIControl_List { 10 | public: 11 | UIControl_CheckboxButtonList() 12 | { 13 | code::Func()(this); 14 | } 15 | UIControl_CheckboxButtonList(UIControl_CheckboxButtonList* _this) 16 | { 17 | code::Func()(_this); 18 | } 19 | 20 | void setupControl(UIScene* scene, uint32_t fuiNode, mstd::wstring* Str) 21 | { 22 | code::Func()(this, scene, fuiNode, Str); 23 | } 24 | 25 | void addItem(mstd::wstring* Str, uint32_t id, bool checked, mstd::wstring* Icon) 26 | { 27 | code::Func()(this, Str, id, checked, Icon); 28 | } 29 | 30 | 31 | uint32_t field_0x60; 32 | uint32_t field_0x64; 33 | uint32_t field_0x68; 34 | uint32_t field_0x6C; 35 | uint32_t field_0x70; 36 | uint32_t field_0x74; 37 | uint32_t field_0x78; 38 | uint32_t field_0x7C; 39 | uint32_t field_0x80; 40 | uint32_t field_0x84; 41 | uint32_t field_0x88; 42 | uint32_t field_0x8C; 43 | uint32_t field_0x90; 44 | uint32_t field_0x94; 45 | uint32_t field_0x98; 46 | uint32_t field_0x9C; 47 | uint32_t field_0xA0; 48 | uint32_t field_0xA4; 49 | uint32_t field_0xA8; 50 | uint32_t field_0xAC; 51 | uint32_t field_0xB0; 52 | uint32_t field_0xB4; 53 | }; 54 | } -------------------------------------------------------------------------------- /include/minecraft/rendering/buffer/BufferBuilder.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace mc { 6 | class BufferBuilder { 7 | public: 8 | void begin(int mode = 3) { 9 | code::Func()(this, mode); 10 | } 11 | 12 | void color(int color, int alpha) { 13 | code::Func()(this, color, alpha); 14 | } 15 | 16 | void vertexUV(float x, float y, float z, float u, float v) { 17 | code::Func()(this, x, y, z, u, v); 18 | } 19 | 20 | // fixCoordinates = Fix Coordinates for 3D Rendering 21 | void vertex(float x, float y, float z = 0.0f, bool fixCoordinates = false) { 22 | #ifdef CEMU 23 | double fx = fixCoordinates ? (x - code::Mem(0x104CAA18).as()) : (x); 24 | double fy = fixCoordinates ? (y - code::Mem(0x104CAA20).as()) : (y); 25 | double fz = fixCoordinates ? (z - code::Mem(0x104CAA28).as()) : (z); 26 | #else 27 | double fx = fixCoordinates ? (x - code::Mem(0x109CCC18).as()) : (x); 28 | double fy = fixCoordinates ? (y - code::Mem(0x109CCC20).as()) : (y); 29 | double fz = fixCoordinates ? (z - code::Mem(0x109CCC28).as()) : (z); 30 | #endif 31 | code::Func()(this, fx, fy, fz); 32 | } 33 | 34 | void end() { 35 | code::Func()(this); 36 | } 37 | }; 38 | } -------------------------------------------------------------------------------- /include/minecraft/util/VTable_TelemetryManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "VTable.h" 4 | 5 | #include "../client/resource/shared_ptr.h" 6 | #include "../util/InteractionHand.h" 7 | #include "./TelemetryManager.h" 8 | 9 | namespace mc { 10 | struct VTable_TelemetryManager : public VTable { 11 | public: 12 | 13 | MC_VFUNC(void, struct TelemetryManager, __dt); 14 | MC_VFUNC(void, struct TelemetryManager, Init); 15 | MC_VFUNC(void, struct TelemetryManager, Tick); 16 | MC_VFUNC(void, struct TelemetryManager, Flush); 17 | MC_VFUNC(void, struct TelemetryManager, RecordPlayerSessionStart); 18 | MC_VFUNC(void, struct TelemetryManager, RecordPlayerSessionExit); 19 | MC_VFUNC(void, struct TelemetryManager, RecordHeartBeat); 20 | MC_VFUNC(void, struct TelemetryManager, RecordLevelStart); 21 | MC_VFUNC(void, struct TelemetryManager, RecordLevelExit); 22 | MC_VFUNC(void, struct TelemetryManager, RecordLevelSaveOrCheckpoint); 23 | MC_VFUNC(void, struct TelemetryManager, RecordLevelResume); 24 | MC_VFUNC(void, struct TelemetryManager, RecordPauseOrInactive); 25 | MC_VFUNC(void, struct TelemetryManager, RecordUnpauseOrActive); 26 | MC_VFUNC(void, struct TelemetryManager, RecordMenuShown, uint32_t, uint32_t, uint32_t); 27 | MC_VFUNC(void, struct TelemetryManager, RecordAchievementUnlocked); 28 | MC_VFUNC(void, struct TelemetryManager, RecordMediaShareUpload); 29 | MC_VFUNC(void, struct TelemetryManager, RecordUpsellPresented); 30 | MC_VFUNC(void, struct TelemetryManager, RecordUpsellResponded); 31 | }; 32 | } -------------------------------------------------------------------------------- /examples/CustomUIScene.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | 6 | DECL_FUNCTION(uint32_t, NavigateToScene, mc::UILayer* _this, uint32_t p2, uint32_t SceneID, uint32_t p4) { 7 | 8 | switch(SceneID) 9 | { 10 | case(0xd): // Check for unused UIScene ID 11 | { 12 | mc::UIScene_DebugMenu* debug = new mc::UIScene_DebugMenu(p2, p4, (uint32_t)_this); 13 | uint32_t SubSceneType = debug->vtbl->getSubSceneType(debug); 14 | (*(mc::TelemetryManager**)0x104f6970)->Vtbl->RecordMenuShown(*((mc::TelemetryManager**)0x104f6970), p2, SceneID, SubSceneType); 15 | 16 | 17 | uint32_t LayerSceneStart = (uint32_t)_this->scenes.start; 18 | uint32_t TempValue = 0; 19 | uint32_t LayerSceneFinish = (uint32_t)_this->scenes.finish - LayerSceneStart >> 2; 20 | 21 | 22 | if ((LayerSceneStart != 0) && (LayerSceneFinish != 0)) { 23 | TempValue = LayerSceneStart; 24 | if (LayerSceneStart != 0) { 25 | TempValue = LayerSceneFinish; 26 | } 27 | debug->SetBackScene(*((mc::UIScene**)(LayerSceneStart + (TempValue + -1) * 4))); 28 | } 29 | 30 | code::Func()((uint32_t*)&_this->scenes, &debug); // vector.push_back 31 | _this->updateFocusState(false); 32 | debug->vtbl->tick(debug); 33 | return 1; 34 | } 35 | break; 36 | default: 37 | return real_NavigateToScene(Scene, p2, SceneID, p4); 38 | break; 39 | } 40 | return real_NavigateToScene(Scene, p2, SceneID, p4); 41 | } 42 | 43 | int c_main(void*) { 44 | code::init(); 45 | 46 | REPLACE(0x02e8461c, NavigateToScene); 47 | 48 | return 0; 49 | } 50 | 51 | void _main() { 52 | mc::C4JThreadImpl* thread = new mc::C4JThreadImpl(c_main, nullptr, "Setup Thread", 0x200); 53 | thread->Run(); 54 | thread->SetDeleteOnExit(true); 55 | } 56 | -------------------------------------------------------------------------------- /examples/AddCreativeMenuItem.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | 6 | mc_boost::shared_ptr publicItemInstancePtr; 7 | 8 | DECL_FUNCTION(void, MenuBuilder_Block, mc::MenuBuilder* builder, uint32_t State) { 9 | 10 | // run normal function to add block 11 | real_MenuBuilder_Block(builder, State); 12 | 13 | if(State == mc::Block::byId(52)->defaultBlockState()) // if block is a monster spawner(ID 52) 14 | { 15 | builder->ITEM_BLOCKSTATE(mc::Block::byId(166)->defaultBlockState()); // add barrier 16 | builder->ADD(publicItemInstancePtr, mc::ItemInstance(mc::Item::byId(2255), 1, 0)); // add 4j debug item 17 | } 18 | 19 | } 20 | 21 | DECL_FUNCTION(void, MenuBuilder_Item, mc::MenuBuilder* builder, const mc_boost::shared_ptr& instance) { 22 | 23 | // run normal function to add item 24 | real_MenuBuilder_Item(builder, instance); 25 | 26 | 27 | if(instance.get()->item->getId() == 399) // if Item is a nether star(ID 399) 28 | { 29 | builder->ITEM_BLOCKSTATE(mc::Block::byId(166)->defaultBlockState()); // add barrier 30 | builder->ADD(publicItemInstancePtr, mc::ItemInstance(mc::Item::byId(2255), 1, 0)); // add 4j debug item 31 | } 32 | 33 | 34 | } 35 | 36 | 37 | int c_main(void*) { 38 | // Init Export Functions and other Stuff 39 | code::init(); 40 | 41 | REPLACE(0x02ECCD20, MenuBuilder_Block); // replace MenuBuilder::ITEM_BLOCKSTATE((BlockState const *)) 42 | REPLACE(0x02F0F424, MenuBuilder_Item); // replace MenuBuilder::ADD((const boost::shared_ptr&)) 43 | 44 | return 0; 45 | } 46 | 47 | // Gets Called once at startup 48 | void _main() { 49 | mc::C4JThreadImpl* thread = new mc::C4JThreadImpl(c_main, nullptr, "Setup Thread", 0x200); 50 | thread->Run(); 51 | thread->SetDeleteOnExit(true); 52 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CodeLib 2 | This is a Code Library for the Minecraft Wii U Edition, which can only be used with the [`Cemu Emulator`](https://github.com/cemu-project/Cemu). 3 | 4 | # Discord 5 | The Discord Server can be Accessed here https://david-xf.de/discord or https://discord.com/invite/xumaYBBhJv 6 | 7 | # Building 8 | You need to have [`devkitPro`](https://devkitpro.org/wiki/Getting_Started) and [`Python`](https://www.python.org/) Installed. After that You can build this with the Command `make all`. 9 | 10 | After building, your Graphic Pack is finished and can be found at [`./GraphicPack`](https://github.com/David-xF/CodeLib/tree/main/GraphicPack). Insert this Folder into your `Cemu/graphicPacks` Folder and Start Cemu. After starting Cemu go to `Options -> Graphic packs`. 11 | There you will find your Graphis Pack which you can then Enable or Disable. `Enable/Disable it Before Starting Minecraft!` 12 | 13 | # Information 14 | You can set your `ASM_PATH` in the [`Makefile`](https://github.com/David-xF/CodeLib/blob/main/Makefile) to the path of your .asm File so you don't always have to replace it manually. 15 | 16 | If any Button Checks don't Work, you might have the Wrong Input Settings set, please check if your `Emulated Controller` is set to `Wii U Gamepad` as it is required. 17 | 18 | If you want to Fix most Pointers which are used on Wii U for example: `0x109C61B0` do `-0x502200` and you will get `0x104C3FB0`. Which can be used with Cemu. The same is for Reverse, just do `+0x502200` and then it can be used with Wii U. 19 | 20 | # Contributors 21 | [`David xF`](https://github.com/David-xF), [`literallyuki`](https://github.com/literallyuki), [`Syoch`](https://github.com/Syoch), [`xenona (xenrelle)`](https://github.com/xenrelle), [`Miku666`](https://github.com/NessieHax), [`PhoenixARC`](https://github.com/PhoenixARC), [`Inupong`](https://discord.gg/k4dEAu2FrM) -------------------------------------------------------------------------------- /examples/BookChat.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | DECL_FUNCTION(void, ServerPlayer_tick, mc::ServerPlayer* player) { 7 | real_ServerPlayer_tick(player); 8 | 9 | mc::ItemInstance* item = player->inventory->getSelected().get(); 10 | if (item->item == mc::Item::byId(387) && item->hasTag() && item->getCount() != 0) { 11 | mstd::wstring strTitle; 12 | mstd::wstring strAuthor; 13 | item->tag->getString(strTitle, L"title"); 14 | item->tag->getString(strAuthor, L"author"); 15 | 16 | wchar_t temp[0x40]; 17 | mc_swprintf(temp, 0x40, L"%s%ls: %ls", player->isModerator() ? "[Moderator] " : "", strAuthor.c_str(), strTitle.c_str()); 18 | 19 | for (mc_boost::shared_ptr& _player : mc::MinecraftServer::getInstance()->getPlayers()->players) { 20 | _player->listener->send(new mc::ClientboundChatPacket(temp)); 21 | _player->listener->send(new mc::ClientboundSoundPacket(mc::SoundEvent::note_hat)); 22 | } 23 | 24 | if (item->item != mc::Item::byId(386)) { 25 | mc::ItemInstance* chat = new mc::ItemInstance(mc::Item::byId(386), item->getCount()); 26 | xf::ItemInstanceHelper::setName(chat, L"Book Chat"); 27 | item->item = mc::Item::byId(0); 28 | item->count = 0; 29 | player->inventory->setItem(player->inventory->selectedSlot, chat); 30 | } 31 | } 32 | } 33 | 34 | int c_main(void*) { 35 | code::init(); 36 | 37 | REPLACE(mc::ServerPlayer::_tick.addr(), ServerPlayer_tick); 38 | 39 | return 0; 40 | } 41 | 42 | void _main() { 43 | mc::C4JThreadImpl* thread = new mc::C4JThreadImpl(c_main, nullptr, "Setup Thread", 0x200); 44 | thread->Run(); 45 | thread->SetDeleteOnExit(true); 46 | } -------------------------------------------------------------------------------- /include/minecraft/block/Block.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace mc { 6 | class Block { 7 | public: 8 | uint32_t defaultBlockState() { 9 | return code::Func()(this); 10 | } 11 | 12 | static Block* byId(int id) { 13 | return code::Func()(id); 14 | } 15 | 16 | static Block* byItem(struct Item* item) { 17 | return code::Func()(item); 18 | } 19 | 20 | bool isIndestructible() { 21 | return code::Func()(this); 22 | } 23 | 24 | uint32_t field_0x0; 25 | uint32_t field_0x4; 26 | uint32_t field_0x8; 27 | uint32_t field_0xC; 28 | uint32_t field_0x10; 29 | uint32_t field_0x14; 30 | uint32_t field_0x18; 31 | uint32_t field_0x1C; 32 | uint32_t field_0x20; 33 | uint32_t field_0x24; 34 | uint32_t field_0x28; 35 | uint32_t field_0x2C; 36 | uint32_t field_0x30; 37 | uint32_t field_0x34; 38 | uint32_t field_0x38; 39 | uint32_t field_0x3C; 40 | float destroySpeed; 41 | uint32_t field_0x44; 42 | uint32_t field_0x48; 43 | uint32_t field_0x4C; 44 | uint32_t baseItemType; 45 | uint32_t field_0x54; 46 | uint32_t field_0x58; 47 | struct SoundType* soundType; 48 | uint32_t field_0x60; 49 | uint32_t field_0x64; 50 | uint32_t field_0x68; 51 | uint32_t field_0x6C; 52 | uint32_t field_0x70; 53 | uint32_t defBlockState; 54 | uint32_t field_0x78; 55 | uint32_t field_0x7C; 56 | uint32_t field_0x80; 57 | uint32_t field_0x84; 58 | uint32_t field_0x88; 59 | uint32_t field_0x8C; 60 | }; 61 | } -------------------------------------------------------------------------------- /include/minecraft/world/ServerLevel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Level.h" 6 | 7 | #include "../client/resource/shared_ptr.h" 8 | 9 | namespace mc { 10 | class ServerLevel : public Level { 11 | public: 12 | void sendParticle(const struct ParticleType* type, double x, double y, double z, int amount, double unk_0, double unk_1, double unk_2, double unk_3, uint32_t n = 0x16600000) { 13 | uint32_t array[2] = { 0x0000105F, 0x00000000 }; 14 | uint32_t array2[2] = { (uint32_t) array, 0x00000001 }; 15 | code::Func()(this, type, x, y, z, amount, unk_0, unk_1, unk_2, unk_3, array2, n); 16 | } 17 | 18 | void sendParticle(const struct ParticleType* type, double x, double y, double z, int amount, double unk_0, double unk_1, double unk_2, double unk_3, uint32_t n, double r, double g, double b) { 19 | uint32_t array[2] = { 0x0000105F, 0x00000000 }; 20 | uint32_t array2[2] = { (uint32_t) array, 0x00000001 }; 21 | code::Func()(this, type, x, y, z, amount, unk_0, unk_1, unk_2, unk_3, array2, n, r, g, b); 22 | } 23 | 24 | void addEntity(const mc_boost::shared_ptr& entity) { 25 | code::Func&>()(this, entity->this_shared); 26 | } 27 | 28 | void addGlobalEntity(const mc_boost::shared_ptr& entity) { 29 | code::Func&>()(this, entity->this_shared); 30 | } 31 | }; 32 | } -------------------------------------------------------------------------------- /include/exports/curl_functions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define CURLOPTTYPE_LONG 00000 6 | #define CURLOPTTYPE_OBJECTPOINT 10000 7 | #define CURLOPTTYPE_FUNCTIONPOINT 20000 8 | #define CURLOPTTYPE_OFF_T 30000 9 | 10 | #define CINIT(name, type, number) CURLOPT_##name = CURLOPTTYPE_##type + number 11 | 12 | #define CURL_ERROR_SIZE 256 13 | 14 | enum CURLOption : int { 15 | CINIT(FILE, OBJECTPOINT, 1), 16 | CINIT(URL, OBJECTPOINT, 2), 17 | CINIT(PORT, LONG, 3), 18 | CINIT(INFILE, OBJECTPOINT, 9), 19 | CINIT(ERRORBUFFER, OBJECTPOINT, 10), 20 | CINIT(WRITEFUNCTION, FUNCTIONPOINT, 11), 21 | CINIT(READFUNCTION, FUNCTIONPOINT, 12), 22 | CINIT(IDK, OBJECTPOINT, 12), 23 | CINIT(POSTFIELDS, OBJECTPOINT, 15), 24 | CINIT(USERAGENT, OBJECTPOINT, 18), 25 | CINIT(HTTPHEADER, OBJECTPOINT, 23), 26 | CINIT(CUSTOMREQUEST, OBJECTPOINT, 36), 27 | CINIT(POST, LONG, 47), 28 | CINIT(POSTFIELDSIZE, LONG, 60), 29 | }; 30 | 31 | struct curl_slist { 32 | 33 | }; 34 | 35 | EXPORT_DECL(void*, curl_easy_init, void); 36 | EXPORT_DECL(void, curl_easy_cleanup, void*); 37 | EXPORT_DECL(int, curl_easy_perform, void*); 38 | EXPORT_DECL(void, curl_easy_setopt, void*, CURLOption, const void*); 39 | EXPORT_DECL(curl_slist*, curl_slist_append, curl_slist* list, const char* string); 40 | 41 | void InitLibCurlFunctionPointers(void) { 42 | unsigned int* funcPointer = 0; 43 | uint32_t libcurl_handle; 44 | OSDynLoad_Acquire("nlibcurl.rpl", &libcurl_handle); 45 | OS_FIND_EXPORT(libcurl_handle, curl_easy_init); 46 | OS_FIND_EXPORT(libcurl_handle, curl_easy_cleanup); 47 | OS_FIND_EXPORT(libcurl_handle, curl_easy_perform); 48 | OS_FIND_EXPORT(libcurl_handle, curl_easy_setopt); 49 | OS_FIND_EXPORT(libcurl_handle, curl_slist_append); 50 | } -------------------------------------------------------------------------------- /include/minecraft/ui/scene/Scenes/UIScene_HowToPlayMenu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | #include "../../control/object/UIControl_ButtonList.h" 5 | namespace mc { 6 | class UIScene_HowToPlayMenu : public UIScene { 7 | public: 8 | UIScene_HowToPlayMenu(uint32_t ID ,uint32_t FuncMaybe ,uint32_t layer) 9 | { 10 | code::Func()(this, ID, layer); // UIScene::UIScene 11 | this->vtbl = (mc::VTable_UIScene*)0x1038574c; 12 | 13 | UIControl_ButtonList(&this->HowToList); 14 | this->initialiseMovie(); 15 | 16 | wchar_t* LLG = new wchar_t[0x40]; 17 | mc_swprintf(LLG, 0x40, L" -- %#p -- %#p", this->UIControl_Vector.start, this->UIControl_Vector.finish); 18 | Log(LLG); 19 | 20 | this->HowToList.init(0); 21 | 22 | for(int i = 0; i < 33; i++) 23 | { 24 | wchar_t* String = mc::Minecraft::getString( *((uint32_t*)(0x104ca2d0 + (4 * i))) ); 25 | this->HowToList.addItem(new mstd::wstring(String), i); 26 | } 27 | 28 | this->doHorizontalResizeCheck(); 29 | this->field_0x17C = 0; 30 | ((ConsoleUIController*)0x104f73e0)->TouchBoxRebuild(this); 31 | } 32 | 33 | void mapElementsAndNames() 34 | { 35 | uint32_t fuiRoot = code::Func()(this->fuiFile); // fuiFile::getRootNode 36 | 37 | mstd::wstring* HowToPlayStr = new mstd::wstring(L""); 38 | HowToPlayStr->assign("HowToList", 9); 39 | 40 | this->HowToList.setupControl(this, fuiRoot, HowToPlayStr); 41 | 42 | UIControl_ButtonList* ControlPTR = &this->HowToList; 43 | 44 | code::Func()((uint32_t*)&this->UIControl_Vector, &ControlPTR); // vector.push_back 45 | } 46 | 47 | static void Log(const wchar_t* text) 48 | { 49 | code::Func()("%ls\n", text); 50 | } 51 | 52 | 53 | UIControl_ButtonList HowToList; 54 | uint32_t field_0x17C; 55 | 56 | }; 57 | } -------------------------------------------------------------------------------- /include/minecraft/util/MallocOperator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | void _delete(void* ptr) { 10 | code::Func()(ptr); 11 | } 12 | 13 | template 14 | T* _new(size_t size) { 15 | T* t = code::Func()(sizeof(T) * size); 16 | memset(t, 0, sizeof(T) * size); 17 | return t; 18 | } 19 | 20 | void* operator new(size_t size) { 21 | return _new(size); 22 | } 23 | 24 | void* operator new[](size_t size) { 25 | return _new(size); 26 | } 27 | 28 | void operator delete(void* ptr) _GLIBCXX_USE_NOEXCEPT { 29 | return _delete(ptr); 30 | } 31 | 32 | void operator delete[](void* ptr) _GLIBCXX_USE_NOEXCEPT { 33 | return _delete(ptr); 34 | } 35 | 36 | namespace mstd { 37 | // See StackOverflow replies to this answer for important commentary about inheriting from std::allocator before replicating this code. 38 | // https://stackoverflow.com/questions/826569/compelling-examples-of-custom-c-allocators 39 | template 40 | class allocator : public std::allocator { 41 | public: 42 | template 43 | struct rebind { 44 | typedef allocator<_Tp1> other; 45 | }; 46 | 47 | T* allocate(size_t n, const void* hint = nullptr) { 48 | return _new(n); 49 | } 50 | 51 | void deallocate(T* p, size_t n) { 52 | return _delete(p); 53 | } 54 | 55 | allocator() throw(): std::allocator() { } 56 | allocator(const allocator &a) throw(): std::allocator(a) { } 57 | template 58 | allocator(const allocator &a) throw(): std::allocator(a) { } 59 | ~allocator() throw() { } 60 | }; 61 | 62 | typedef std::basic_string, allocator> xf_string; 63 | typedef std::basic_string, allocator> xf_wstring; 64 | } -------------------------------------------------------------------------------- /include/exports/kernel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | EXPORT_DECL(void, DCFlushRange, const void* addr, uint32_t length); 6 | EXPORT_DECL(void*, OSEffectiveToPhysical, const void*); 7 | EXPORT_DECL(void, OSFatal, const char *msg); 8 | 9 | void SC0x25_KernelCopyData(unsigned int addr, unsigned int src, unsigned int len) { 10 | asm volatile("li 0, 0x2500"); 11 | asm volatile("sc"); 12 | asm volatile("blr"); 13 | } 14 | 15 | void InitKernelFunctionPointers() { 16 | uint32_t coreinit_handle; 17 | uint32_t* funcPointer = 0; 18 | OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); 19 | OS_FIND_EXPORT(coreinit_handle, DCFlushRange); 20 | OS_FIND_EXPORT(coreinit_handle, OSEffectiveToPhysical); 21 | OS_FIND_EXPORT(coreinit_handle, OSFatal); 22 | } 23 | 24 | // TODO Variable size, not hard-coded 25 | #define DATA_BUFFER_SIZE 0x20 26 | unsigned char* kernelCopyBufferOld[DATA_BUFFER_SIZE]; 27 | 28 | void kernelCopyData(unsigned char* destinationBuffer, unsigned char* sourceBuffer, unsigned int length) { 29 | if (length > DATA_BUFFER_SIZE) { 30 | OSFatal("Kernel copy buffer size exceeded"); 31 | } 32 | 33 | memcpy(kernelCopyBufferOld, sourceBuffer, length); 34 | SC0x25_KernelCopyData((unsigned int) OSEffectiveToPhysical(destinationBuffer), (unsigned int) &kernelCopyBufferOld, 35 | length); 36 | DCFlushRange(destinationBuffer, (uint32_t) length); 37 | } 38 | 39 | unsigned char* kernelCopyBuffer[sizeof(int)]; 40 | 41 | void kernelCopyInt(unsigned char* destinationBuffer, unsigned char* sourceBuffer, unsigned int length) { 42 | memcpy(kernelCopyBuffer, sourceBuffer, length); 43 | unsigned int destinationAddress = (unsigned int) OSEffectiveToPhysical(destinationBuffer); 44 | SC0x25_KernelCopyData(destinationAddress, (unsigned int) &kernelCopyBuffer, length); 45 | DCFlushRange(destinationBuffer, (uint32_t) length); 46 | } 47 | 48 | void writeKernelMemory(const void* address, uint32_t value) { 49 | ((int*) kernelCopyBuffer)[0] = value; 50 | kernelCopyInt((unsigned char*) address, (unsigned char*) kernelCopyBuffer, sizeof(int)); 51 | } -------------------------------------------------------------------------------- /include/minecraft/item/ItemInstance.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace mc { 6 | class ItemInstance { 7 | public: 8 | ItemInstance(struct Item* item, int amount) { 9 | code::Func()(this, item, amount); 10 | } 11 | 12 | ItemInstance(struct Item* item, int amount, int aux) { 13 | code::Func()(this, item, amount, aux); 14 | } 15 | 16 | static void toShared(const mc_boost::shared_ptr& ret, ItemInstance* src) { 17 | code::Func&, ItemInstance*>()(ret, src); 18 | } 19 | 20 | void setAuxValue(int val) { 21 | code::Func()(this, val); 22 | } 23 | 24 | struct CompoundTag* getTag() { 25 | return code::Func()(this); 26 | } 27 | 28 | void setTag(struct CompoundTag* _tag) { 29 | code::Func()(this, _tag); 30 | } 31 | 32 | bool hasTag() { 33 | return code::Func()(this); 34 | } 35 | 36 | int getCount() { 37 | return code::Func()(this); 38 | } 39 | 40 | void setCount(int c) { 41 | code::Func()(this, c); 42 | } 43 | 44 | uint32_t field_0x0; 45 | uint32_t field_0x4; 46 | int count; // i think 47 | uint32_t field_0xC; 48 | struct Item* item; 49 | struct CompoundTag* tag; 50 | uint32_t field_0x18; 51 | int aux; 52 | uint32_t field_0x20; 53 | uint32_t field_0x24; 54 | uint32_t field_0x28; 55 | uint32_t field_0x2C; 56 | uint32_t field_0x30; 57 | uint32_t field_0x34; 58 | uint32_t field_0x38; 59 | uint32_t field_0x3C; 60 | uint32_t field_0x40; 61 | }; 62 | } 63 | -------------------------------------------------------------------------------- /include/minecraft/ui/scene/UIScene.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../client/resource/vector.h" 4 | namespace mc { 5 | class UIScene { 6 | public: 7 | UIScene() 8 | { 9 | code::Func()(this); 10 | } 11 | UIScene(uint32_t ID ,uint32_t FuncMaybe ,uint32_t layer) 12 | { 13 | code::Func()(this, ID, FuncMaybe, layer); 14 | } 15 | UIScene(uint32_t ID ,uint32_t layer) 16 | { 17 | code::Func()(this, ID, layer); 18 | } 19 | 20 | void initialiseMovie() 21 | { 22 | code::Func()(this); 23 | } 24 | void doHorizontalResizeCheck() 25 | { 26 | code::Func()(this); 27 | } 28 | void SetBackScene(UIScene* BackScene) 29 | { 30 | code::Func()(this, BackScene); 31 | } 32 | 33 | uint32_t field_0x0; 34 | uint32_t UIScontrol; 35 | uint32_t field_0x8; 36 | uint32_t field_0xC; 37 | uint32_t field_0x10; 38 | uint32_t field_0x14; 39 | uint32_t field_0x18; 40 | uint32_t field_0x1C; 41 | uint32_t fuiFile; 42 | uint32_t field_0x24; 43 | uint32_t field_0x28; 44 | uint32_t field_0x2C; 45 | uint32_t field_0x30; 46 | uint32_t field_0x34; 47 | uint32_t field_0x38; 48 | uint32_t field_0x3C; 49 | uint32_t field_0x40; 50 | uint32_t field_0x44; 51 | uint32_t field_0x48; 52 | uint32_t field_0x4C; 53 | uint32_t field_0x50; 54 | uint32_t field_0x54; 55 | uint32_t field_0x58; 56 | uint32_t field_0x5C; 57 | uint32_t field_0x60; 58 | float Opacity; 59 | uint32_t field_0x68; 60 | UIScene* backScene; 61 | uint32_t field_0x70; 62 | uint32_t field_0x74; 63 | uint32_t field_0x78; 64 | uint32_t field_0x7C; 65 | uint32_t field_0x80; 66 | uint32_t field_0x84; 67 | uint32_t field_0x88; 68 | mstd::vector UIControl_Vector; 69 | struct UILayer* UILayer; 70 | uint32_t field_0xA0; 71 | uint32_t UISceneID; 72 | uint32_t field_0xA8; 73 | uint32_t field_0xAC; 74 | uint32_t field_0xB0; 75 | uint32_t field_0xB4; 76 | uint32_t field_0xB8; 77 | uint32_t field_0xBC; 78 | uint32_t field_0xC0; 79 | struct VTable_UIScene* vtbl; 80 | 81 | }; 82 | } -------------------------------------------------------------------------------- /examples/WorldChat.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | // Works only as Host (Other People can also send Messages) 6 | DECL_FUNCTION(void, ServerGamePacketListenerImpl_handleChat, mc::ServerGamePacketListenerImpl* listener, const mc_boost::shared_ptr& packet) { 7 | if (packet->str_v[0].length == 0) return; // No Empty Message 8 | mstd::wstring msg = packet->str_v[0]; 9 | memset((void*) &msg.c_str()[msg.length], 0x0, sizeof(wchar_t)); // I don't know why 10 | 11 | bool isOnlyWhiteSpace = true; 12 | for (int i = 0; i < msg.length; i++) { 13 | wchar_t _char = msg.c_str()[i]; 14 | if (_char != L' ') { 15 | isOnlyWhiteSpace = false; 16 | break; 17 | } 18 | } 19 | 20 | if (isOnlyWhiteSpace) return; // No Empty Message 21 | 22 | wchar_t temp[150]; 23 | mstd::wstring playerName; 24 | listener->player->getDisplayName(playerName); 25 | mc_swprintf(temp, 150, L"<%ls> %ls", playerName.c_str(), msg.c_str()); 26 | mc::MinecraftServer::getInstance()->getPlayers()->broadcastAll(new mc::ClientboundChatPacket(temp)); 27 | mc::MinecraftServer::getInstance()->getPlayers()->broadcastAll(new mc::ClientboundSoundPacket(mc::SoundEvent::note_hat, 1.0f, 1.0f)); 28 | } 29 | 30 | void openKeyboard() { 31 | mc::CInput::GetInput()->RequestKeyboard(L"", L"", 0, 140, [](void*, bool) -> int { 32 | wchar_t temp[141]; 33 | mc::CInput::GetInput()->GetText(temp, 141); 34 | 35 | mc::Minecraft::getInstance()->getConnection(0)->send(new mc::ClientboundChatPacket(temp)); 36 | return 0; 37 | }, nullptr, mc::CInput::KeyboardMode::FULL); 38 | } 39 | 40 | DECL_HOOK(onFrameInGame, void) { 41 | START_BUTTONCHECK(button & VPAD_BUTTON_RIGHT, openKeyboard(), button) 42 | END_BUTTONCHECK() 43 | } 44 | 45 | int c_main(void*) { 46 | code::init(); 47 | 48 | REPLACE(mc::ServerGamePacketListenerImpl::_handleChat.addr(), ServerGamePacketListenerImpl_handleChat); 49 | HOOK(0x02D9CAD0, onFrameInGame, 0); 50 | 51 | return 0; 52 | } 53 | 54 | void _main() { 55 | mc::C4JThreadImpl* thread = new mc::C4JThreadImpl(c_main, nullptr, "Setup Thread", 0x200); 56 | thread->Run(); 57 | thread->SetDeleteOnExit(true); 58 | } -------------------------------------------------------------------------------- /include/minecraft/container/SimpleContainer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../client/resource/wstring.h" 6 | #include "../client/resource/shared_ptr.h" 7 | #include "../client/resource/vector.h" 8 | 9 | #include "Container.h" 10 | 11 | namespace mc { 12 | class SimpleContainer { 13 | public: 14 | SimpleContainer(int unk_0x0, int unk_0x1, const mstd::wstring& str, int size) { 15 | code::Func()(this, unk_0x0, unk_0x1, str, size); 16 | } 17 | 18 | SimpleContainer() = default; 19 | 20 | static void toShared(const mc_boost::shared_ptr& ret, SimpleContainer* src) { 21 | code::Func&, SimpleContainer*>()(ret, src); 22 | } 23 | 24 | void getItem(uint32_t slot, const mc_boost::shared_ptr& item) { 25 | code::Func&, uint32_t>()(this, item, slot); 26 | } 27 | 28 | void addItem(int slot, const mc_boost::shared_ptr& item) { 29 | code::Func&>()(this, slot, item); 30 | } 31 | 32 | void setItem(int slot, const mc_boost::shared_ptr& item) { 33 | code::Func&>()(this, slot, item); 34 | } 35 | 36 | void clearContent() { 37 | code::Func()(this); 38 | } 39 | 40 | uint32_t field_0x0; 41 | mstd::wstring field_0x4; 42 | uint32_t field_0x24; 43 | uint32_t field_0x28; 44 | uint32_t maxSlots; // I think 45 | uint32_t field_0x30; 46 | uint32_t field_0x34; 47 | mstd::vector listeners; 48 | uint32_t field_0x48; 49 | uint32_t field_0x4C; 50 | uint32_t field_0x50; 51 | uint32_t field_0x54; 52 | uint32_t field_0x58; 53 | Container container; 54 | }; 55 | } -------------------------------------------------------------------------------- /include/minecraft/network/server/PlayerList.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../../client/resource/shared_ptr.h" 6 | #include "../../client/resource/vector.h" 7 | 8 | namespace mc { 9 | class PlayerList { 10 | public: 11 | int getMaxPlayers() { 12 | return code::Func()(this); 13 | } 14 | 15 | int getPlayerCount() { 16 | return code::Func()(this); 17 | } 18 | 19 | void broadcastAll(const mc_boost::shared_ptr& packet) { 20 | code::Func&>()(this, packet); 21 | } 22 | 23 | static code::Func _tick; 24 | void tick() { 25 | _tick(this); 26 | } 27 | 28 | mstd::vector> players; 29 | uint32_t field_0x10; 30 | uint32_t field_0x14; 31 | uint32_t field_0x18; 32 | uint32_t field_0x1C; 33 | uint32_t field_0x20; 34 | uint32_t field_0x24; 35 | uint32_t field_0x28; 36 | uint32_t field_0x2C; 37 | uint32_t field_0x30; 38 | uint32_t field_0x34; 39 | uint32_t field_0x38; 40 | uint32_t field_0x3C; 41 | uint32_t field_0x40; 42 | uint32_t field_0x44; 43 | uint32_t field_0x48; 44 | uint32_t field_0x4C; 45 | uint32_t field_0x50; 46 | uint32_t field_0x54; 47 | uint32_t field_0x58; 48 | uint32_t field_0x5C; 49 | uint32_t field_0x60; 50 | uint32_t field_0x64; 51 | uint32_t field_0x68; 52 | uint32_t field_0x6C; 53 | uint32_t field_0x70; 54 | uint32_t field_0x74; 55 | uint32_t field_0x78; 56 | uint32_t field_0x7C; 57 | uint32_t field_0x80; 58 | uint32_t field_0x84; 59 | uint32_t field_0x88; 60 | uint32_t field_0x8C; 61 | uint32_t field_0x90; 62 | uint32_t field_0x94; 63 | uint32_t field_0x98; 64 | uint32_t field_0x9C; 65 | uint32_t field_0xA0; 66 | uint32_t field_0xA4; 67 | uint32_t field_0xA8; 68 | uint32_t field_0xAC; 69 | uint32_t field_0xB0; 70 | uint32_t field_0xB4; 71 | uint32_t field_0xB8; 72 | uint32_t field_0xBC; 73 | uint32_t field_0xC0; 74 | uint32_t field_0xC4; 75 | uint32_t field_0xC8; 76 | uint32_t field_0xCC; 77 | uint32_t field_0xD0; 78 | uint32_t field_0xD4; 79 | uint32_t field_0xD8; 80 | uint32_t field_0xDC; 81 | uint32_t field_0xE0; 82 | uint32_t field_0xE4; 83 | uint32_t field_0xE8; 84 | uint32_t field_0xEC; 85 | uint32_t field_0xF0; 86 | }; 87 | } -------------------------------------------------------------------------------- /examples/SimpleContainer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | DECL_FUNCTION(void, ServerPlayer_Swing, mc::ServerPlayer* player, mc::InteractionHand::EInteractionHand eHand) { 6 | real_ServerPlayer_Swing(player, eHand); 7 | 8 | // Creates a Container with the Name "Menu" and sets its size to 27 9 | mc::SimpleContainer* cont = new mc::SimpleContainer(0, 0, L"Menu", 27); 10 | mc_boost::shared_ptr shared; 11 | // I don't know why this is needded, but it is 12 | mc::SimpleContainer::toShared(shared, cont); 13 | 14 | // Set every Item to Stone with the Amount of i + 1 15 | for (int i = 0; i < 27; i++) shared->setItem(i, new mc::ItemInstance(mc::Item::byId(1), i + 1)); 16 | 17 | // Opens Container for Player (Must be ServerPlayer if you want it to work with other Players) 18 | player->openContainer(&shared->container); 19 | } 20 | 21 | DECL_FUNCTION(void, ServerGamePacketListenerImpl_handleContainerClick, mc::ServerGamePacketListenerImpl* listener, const mc_boost::shared_ptr& packet) { 22 | mc::ServerPlayer* player = listener->player.get(); 23 | int maxSlots = player->currentContainer->getItems().size(); 24 | if (packet->slotNum >= maxSlots || 0 > packet->slotNum) return real_ServerGamePacketListenerImpl_handleContainerClick(listener, packet); 25 | 26 | mc::ItemInstance* clickedItem = player->currentContainer->getItems()[packet->slotNum].get(); 27 | 28 | wchar_t temp[0x60]; 29 | mc_swprintf(temp, 0x60, L"You clicked on Item %d with Item Slot %d [Has Tag %s]", clickedItem->item->getId(), packet->slotNum, clickedItem->hasTag() ? "True" : "False"); 30 | listener->send(new mc::ClientboundChatPacket(temp)); 31 | listener->send(new mc::ClientboundSoundPacket(mc::SoundEvent::note_hat)); 32 | 33 | // If you want to cancel this Packet don't call real_ServerGamePacketListenerImpl_handleContainerClick 34 | // And Refresh the container with player->refreshContainer(player->currentContainer); 35 | real_ServerGamePacketListenerImpl_handleContainerClick(listener, packet); 36 | } 37 | 38 | int c_main(void*) { 39 | code::init(); 40 | 41 | REPLACE(mc::ServerPlayer::_swing.addr(), ServerPlayer_Swing); 42 | REPLACE(mc::ServerGamePacketListenerImpl::_handleContainerClick.addr(), ServerGamePacketListenerImpl_handleContainerClick); 43 | 44 | return 0; 45 | } 46 | 47 | void _main() { 48 | mc::C4JThreadImpl* thread = new mc::C4JThreadImpl(c_main, nullptr, "Setup Thread", 0x200); 49 | thread->Run(); 50 | thread->SetDeleteOnExit(true); 51 | } -------------------------------------------------------------------------------- /include/minecraft/entity/AreaEffectCloud.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Entity.h" 4 | 5 | namespace mc { 6 | class AreaEffectCloud : public Entity { 7 | public: 8 | AreaEffectCloud(struct Level* _level) { 9 | code::Func()(this, _level); 10 | } 11 | 12 | int getDuration() { 13 | return code::Func()(this); 14 | } 15 | 16 | void setDuration(int dur) { 17 | code::Func()(this, dur); 18 | } 19 | 20 | void setParticle(struct ParticleType* type) { 21 | code::Func()(this, type); 22 | } 23 | 24 | void setRadius(float r) { 25 | code::Func()(this, r); 26 | } 27 | 28 | void particleSpawnRateOnTick(int rate) { 29 | code::Func()(this, rate); 30 | } 31 | 32 | void setPotion(struct Potion* potion) { 33 | code::Func()(this, potion); 34 | } 35 | 36 | void setRadiusPerTick(float r) { 37 | code::Func()(this, r); 38 | } 39 | 40 | void setRadiusOnUse(float r) { 41 | code::Func()(this, r); 42 | } 43 | 44 | static uint64_t GetType() { 45 | return code::Func()(); 46 | } 47 | 48 | uint32_t field_0x350; 49 | uint32_t field_0x354; 50 | uint32_t field_0x358; 51 | uint32_t field_0x35C; 52 | uint32_t field_0x360; 53 | uint32_t field_0x364; 54 | uint32_t field_0x368; 55 | uint32_t field_0x36C; 56 | uint32_t field_0x370; 57 | uint32_t field_0x374; 58 | uint32_t field_0x378; 59 | uint32_t field_0x37C; 60 | uint32_t field_0x380; 61 | uint32_t field_0x384; 62 | uint32_t field_0x388; 63 | uint32_t field_0x38C; 64 | uint32_t field_0x390; 65 | uint32_t field_0x394; 66 | uint32_t field_0x398; 67 | uint32_t field_0x39C; 68 | uint32_t field_0x3A0; 69 | uint32_t field_0x3A4; 70 | uint32_t field_0x3A8; 71 | uint32_t field_0x3AC; 72 | uint32_t field_0x3B0; 73 | uint32_t field_0x3B4; 74 | uint32_t field_0x3B8; 75 | uint32_t field_0x3BC; 76 | }; 77 | } -------------------------------------------------------------------------------- /include/minecraft/container/Inventory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Container.h" 6 | 7 | #include "../client/resource/shared_ptr.h" 8 | #include "../client/resource/NonNullList.h" 9 | 10 | namespace mc { 11 | class Inventory : public Container { 12 | public: 13 | void dropAll() { 14 | code::Func()(this); 15 | } 16 | 17 | void clearContent() { 18 | code::Func()(this); 19 | } 20 | 21 | void setItem(uint32_t index, const mc_boost::shared_ptr& item) { 22 | code::Func&>()(this, index, item); 23 | } 24 | 25 | void setChanged() { 26 | code::Func()(this); 27 | } 28 | 29 | const mc_boost::shared_ptr& getSelected() { 30 | return code::Func&, 0x02497F7C, Inventory*>()(this); 31 | } 32 | 33 | void add(int slot, const mc_boost::shared_ptr& item) { 34 | code::Func&>()(this, slot, item); 35 | } 36 | 37 | void getItem(uint32_t slot, const mc_boost::shared_ptr& item) { 38 | code::Func&, uint32_t>()(this, item, slot); 39 | } 40 | 41 | uint32_t field_0xC; 42 | uint32_t field_0x10; 43 | uint32_t field_0x14; 44 | uint32_t field_0x18; 45 | uint32_t field_0x1C; 46 | uint32_t field_0x20; 47 | uint32_t field_0x24; 48 | uint32_t field_0x28; // unk 49 | uint32_t field_0x2C; 50 | uint32_t field_0x30; 51 | uint32_t field_0x34; 52 | NonNullList> list; 53 | uint32_t field_0x48; 54 | uint32_t field_0x4C; 55 | uint32_t field_0x50; 56 | uint32_t field_0x54; 57 | uint32_t field_0x58; 58 | uint32_t field_0x5C; 59 | uint32_t field_0x60; 60 | uint32_t field_0x64; 61 | uint32_t field_0x68; 62 | int selectedSlot; // from 0 - 8 63 | uint32_t field_0x70; 64 | uint32_t field_0x74; 65 | uint32_t field_0x78; 66 | uint32_t field_0x7C; 67 | uint32_t field_0x80; 68 | uint32_t field_0x84; 69 | uint32_t field_0x88; 70 | }; 71 | } -------------------------------------------------------------------------------- /include/minecraft/entity/Mob.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "LivingEntity.h" 4 | 5 | namespace mc { 6 | class Mob : public LivingEntity { 7 | public: 8 | void setNoAi(bool state) { 9 | code::Func()(this, state); 10 | } 11 | 12 | uint32_t field_0x5F0; 13 | uint32_t field_0x5F4; 14 | uint32_t field_0x5F8; 15 | uint32_t field_0x5FC; 16 | uint32_t field_0x600; 17 | uint32_t field_0x604; 18 | uint32_t field_0x608; 19 | uint32_t field_0x60C; 20 | uint32_t field_0x610; 21 | uint32_t field_0x614; 22 | uint32_t field_0x618; 23 | uint32_t field_0x61C; 24 | uint32_t field_0x620; 25 | uint32_t field_0x624; 26 | uint32_t field_0x628; 27 | uint32_t field_0x62C; 28 | uint32_t field_0x630; 29 | uint32_t field_0x634; 30 | uint32_t field_0x638; 31 | uint32_t field_0x63C; 32 | uint32_t field_0x640; 33 | uint32_t field_0x644; 34 | uint32_t field_0x648; 35 | uint32_t field_0x64C; 36 | uint32_t field_0x650; 37 | uint32_t field_0x654; 38 | uint32_t field_0x658; 39 | uint32_t field_0x65C; 40 | uint32_t field_0x660; 41 | uint32_t field_0x664; 42 | uint32_t field_0x668; 43 | uint32_t field_0x66C; 44 | uint32_t field_0x670; 45 | uint32_t field_0x674; 46 | uint32_t field_0x678; 47 | uint32_t field_0x67C; 48 | uint32_t field_0x680; 49 | uint32_t field_0x684; 50 | uint32_t field_0x688; 51 | uint32_t field_0x68C; 52 | uint32_t field_0x690; 53 | uint32_t field_0x694; 54 | uint32_t field_0x698; 55 | uint32_t field_0x69C; 56 | uint32_t field_0x6A0; 57 | uint32_t field_0x6A4; 58 | uint32_t field_0x6A8; 59 | uint32_t field_0x6AC; 60 | uint32_t field_0x6B0; 61 | uint32_t field_0x6B4; 62 | uint32_t field_0x6B8; 63 | uint32_t field_0x6BC; 64 | uint32_t field_0x6C0; 65 | uint32_t field_0x6C4; 66 | uint32_t field_0x6C8; 67 | uint32_t field_0x6CC; 68 | uint32_t field_0x6D0; 69 | uint32_t field_0x6D4; 70 | uint32_t field_0x6D8; 71 | uint32_t field_0x6DC; 72 | uint32_t field_0x6E0; 73 | uint32_t field_0x6E4; 74 | uint32_t field_0x6E8; 75 | uint32_t field_0x6EC; 76 | uint32_t field_0x6F0; 77 | uint32_t field_0x6F4; 78 | uint32_t field_0x6F8; 79 | uint32_t field_0x6FC; 80 | uint32_t field_0x700; 81 | uint32_t field_0x704; 82 | }; 83 | } -------------------------------------------------------------------------------- /include/minecraft/item/Item.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../client/resource/ResourceLocation.h" 6 | #include "../client/resource/wstring.h" 7 | 8 | namespace mc { 9 | class Item { 10 | public: 11 | Item() { 12 | code::Func()(this); 13 | } 14 | 15 | void HandEquipped() { 16 | code::Func()(this); 17 | } 18 | 19 | void setMaxDamage(uint32_t arg1) { 20 | code::Func()(this, arg1); 21 | } 22 | 23 | void setCraftingRemainingItem(uint32_t arg1) { 24 | code::Func()(this, arg1); 25 | } 26 | 27 | void setStackedByData(bool arg1) { 28 | code::Func()(this, arg1); 29 | } 30 | 31 | void setMaxStackSize(int size) { 32 | code::Func()(this, size); 33 | } 34 | 35 | static bool isItemABlock(int id) { 36 | return code::Func()(id); 37 | } 38 | 39 | uint32_t getBaseItemType() { 40 | return code::Func()(this); 41 | } 42 | 43 | uint32_t getMaxStackSize() { 44 | return code::Func()(this); 45 | } 46 | 47 | void setIconName(const mstd::wstring& name) { 48 | code::Func()(this, name); 49 | } 50 | 51 | void setAllowOffhand(bool allow) { 52 | code::Func()(this, allow); 53 | } 54 | 55 | bool isHandEquipped() { 56 | return code::Func()(this); 57 | } 58 | 59 | static Item* byId(int id) { 60 | return code::Func()(id); 61 | } 62 | 63 | static void registerItem(int id, const ResourceLocation& loc, Item* item) { 64 | code::Func()(id, loc, item); 65 | } 66 | 67 | int getId() { 68 | return code::Func()(this); 69 | } 70 | 71 | uint32_t field_0x0; 72 | uint32_t field_0x4; 73 | uint32_t field_0x8; 74 | uint32_t maxStackSize; 75 | uint32_t maxDamage; 76 | uint32_t field_0x14; 77 | uint32_t field_0x18; 78 | uint32_t field_0x1C; 79 | uint32_t field_0x20; 80 | uint32_t field_0x24; 81 | mstd::wstring unk_str; 82 | uint32_t field_0x48; 83 | uint32_t field_0x4C; 84 | mstd::wstring iconName; 85 | uint32_t field_0x70; 86 | struct VTable_Item* vtbl; 87 | }; 88 | } -------------------------------------------------------------------------------- /include/minecraft/entity/ItemEntity.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace mc { 6 | class ItemEntity { 7 | public: 8 | ItemEntity(struct Level* _level) { 9 | code::Func()(this, _level); 10 | } 11 | 12 | ItemEntity(struct Level* _level, double x, double y, double z) { 13 | code::Func()(this, _level, x, y, z); 14 | } 15 | 16 | ItemEntity(struct Level* _level, double x, double y, double z, const mc_boost::shared_ptr& item) { 17 | code::Func&>()(this, _level, x, y, z, item); 18 | } 19 | 20 | void setItem(const mc_boost::shared_ptr& item) { 21 | code::Func&>()(this, item); 22 | } 23 | 24 | void setPickUpDelay(int delay) { 25 | code::Func()(this, delay); 26 | } 27 | 28 | void setNeverPickUp() { 29 | code::Func()(this); 30 | } 31 | 32 | void setDefaultPickUpDelay() { 33 | code::Func()(this); 34 | } 35 | 36 | void playerTouch(const mc_boost::shared_ptr& player) { 37 | code::Func&>()(this, player); 38 | } 39 | 40 | void setShortLifeTime() { 41 | code::Func()(this); 42 | } 43 | 44 | static uint64_t GetType() { 45 | return code::Func()(); 46 | } 47 | 48 | int lifeTime; 49 | int pickUpDelay; 50 | uint32_t field_0x358; 51 | uint32_t field_0x35C; 52 | uint32_t field_0x360; 53 | uint32_t field_0x364; 54 | uint32_t field_0x368; 55 | uint32_t field_0x36C; 56 | uint32_t field_0x370; 57 | uint32_t field_0x374; 58 | uint32_t field_0x378; 59 | uint32_t field_0x37C; 60 | uint32_t field_0x380; 61 | uint32_t field_0x384; 62 | uint32_t field_0x388; 63 | uint32_t field_0x38C; 64 | uint32_t field_0x390; 65 | uint32_t field_0x394; 66 | uint32_t field_0x398; 67 | uint32_t field_0x39C; 68 | uint32_t field_0x3A0; 69 | uint32_t field_0x3A4; 70 | uint32_t field_0x3A8; 71 | uint32_t field_0x3AC; 72 | uint32_t field_0x3B0; 73 | uint32_t field_0x3B4; 74 | uint32_t field_0x3B8; 75 | uint32_t field_0x3BC; 76 | }; 77 | } -------------------------------------------------------------------------------- /examples/NoteBlockSounds.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | void playSound(mc::SoundEvent* sound, int pitch) { 6 | if (pitch == -1) return; 7 | 8 | mstd::wstring name; 9 | sound->getName(name); 10 | mc_printf(L"Played Sound %ls with Pitch %d", name.c_str(), pitch); 11 | for (mc_boost::shared_ptr& player : mc::Minecraft::getInstance()->thePlayer->lvl->players) { 12 | if (player->uuid == mc::Minecraft::getInstance()->thePlayer->uuid) { 13 | mc::Minecraft::getInstance()->thePlayer->playSound(sound, 1.0f, mc::SoundEvent::getNoteBlockPitch(pitch)); 14 | } else { 15 | mc::Minecraft::getInstance()->getConnection(0)->send(new mc::ClientboundSoundPacket(sound, mc::SoundSource::noteblock, player->position.x, player->position.y, player->position.z, 1.0f, mc::SoundEvent::getNoteBlockPitch(pitch))); 16 | } 17 | } 18 | } 19 | 20 | int playNoteBlockThread(void*) { 21 | uint64_t lastTime = mc::System::processTimeInMilliSecs(); 22 | const float timeBetweenSound = 0.25f; 23 | 24 | // -1 = No Sound 25 | const int totalSounds = 29; 26 | int wood[totalSounds] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; 27 | int wool[totalSounds] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; 28 | int dirt[totalSounds] = { 6, 8, 10, 6, 6, 8, 10, 6, 10, 11, 13, -1, 10, 11, 13, -1, 13, 15, 13, 11, 10, 6, -1, 13, 15, 13, 11, 10, 6}; 29 | 30 | int currSoundIndex = 0; 31 | while (true) { 32 | uint64_t currTime = mc::System::processTimeInMilliSecs(); 33 | float deltaTime = mc::toFloat(currTime - lastTime) / 1000.0f; 34 | if (deltaTime >= timeBetweenSound) { 35 | lastTime = currTime; 36 | 37 | playSound(mc::SoundEvent::note_bassattack, wood[currSoundIndex]); 38 | playSound(mc::SoundEvent::block_note_guitar, wool[currSoundIndex]); 39 | playSound(mc::SoundEvent::note_harp, dirt[currSoundIndex]); 40 | 41 | currSoundIndex++; 42 | if (totalSounds == currSoundIndex) break; 43 | } 44 | } 45 | 46 | return 0; 47 | } 48 | 49 | DECL_FUNCTION(void, LocalPlayer_swing, mc::LocalPlayer* player, mc::InteractionHand::EInteractionHand hand) { 50 | real_LocalPlayer_swing(player, hand); 51 | 52 | mc::C4JThreadImpl* thread = new mc::C4JThreadImpl(playNoteBlockThread, nullptr, "Note Block Thread", 0x200); 53 | thread->Run(), 54 | thread->SetDeleteOnExit(true); 55 | } 56 | 57 | int c_main(void*) { 58 | code::init(); 59 | 60 | REPLACE(mc::LocalPlayer::_swing.addr(), LocalPlayer_swing); 61 | 62 | return 0; 63 | } 64 | 65 | void _main() { 66 | mc::C4JThreadImpl* thread = new mc::C4JThreadImpl(c_main, nullptr, "Setup Thread", 0x200); 67 | thread->Run(); 68 | thread->SetDeleteOnExit(true); 69 | } -------------------------------------------------------------------------------- /include/minecraft/util/Vec3.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "FloatConverter.h" 6 | 7 | namespace mc { 8 | class Vec3 { 9 | public: 10 | Vec3(double _x, double _y, double _z) { 11 | x = _x; 12 | y = _y; 13 | z = _z; 14 | } 15 | 16 | Vec3() = default; 17 | 18 | double distance(Vec3 other) { 19 | return sqrt( 20 | pow(x - other.x, 2.0) + 21 | pow(y - other.y, 2.0) + 22 | pow(z - other.z, 2.0) 23 | ); 24 | } 25 | 26 | Vec3 operator+(Vec3 other) { 27 | return Vec3(x + other.x, y + other.y, z + other.z); 28 | } 29 | 30 | Vec3 operator+(double amt) { 31 | return Vec3(x + amt, y + amt, z + amt); 32 | } 33 | 34 | Vec3 operator+(float amt) { 35 | return Vec3(x + amt, y + amt, z + amt); 36 | } 37 | 38 | Vec3 operator-(Vec3 other) { 39 | return Vec3(x - other.x, y - other.y, z - other.z); 40 | } 41 | 42 | Vec3 operator-(double amt) { 43 | return Vec3(x - amt, y - amt, z - amt); 44 | } 45 | 46 | Vec3 operator-(float amt) { 47 | return Vec3(x - amt, y - amt, z - amt); 48 | } 49 | 50 | Vec3 operator*(Vec3 other) { 51 | return Vec3(x * other.x, y * other.y, z * other.z); 52 | } 53 | 54 | Vec3 operator*(double amt) { 55 | return Vec3(x * amt, y * amt, z * amt); 56 | } 57 | 58 | Vec3 operator*(float mult) { 59 | return Vec3(x * mult, y * mult, z * mult); 60 | } 61 | 62 | Vec3 operator/(Vec3 other) { 63 | return Vec3(x / other.x, y / other.y, z / other.z); 64 | } 65 | 66 | Vec3 operator/(double amt) { 67 | return Vec3(x / amt, y / amt, z / amt); 68 | } 69 | 70 | Vec3 operator/(float mult) { 71 | return Vec3(x / mult, y / mult, z / mult); 72 | } 73 | 74 | Vec3 operator=(Vec3 other) { 75 | x = other.x; 76 | y = other.y; 77 | z = other.z; 78 | 79 | return *this; 80 | } 81 | 82 | Vec3 operator*=(double amt) { 83 | x *= amt; 84 | y *= amt; 85 | z *= amt; 86 | 87 | return *this; 88 | } 89 | 90 | bool operator==(Vec3 other) { 91 | bool b_x = x == other.x; 92 | bool b_y = y == other.y; 93 | bool b_z = z == other.z; 94 | 95 | return b_x && b_y && b_z; 96 | } 97 | 98 | bool operator!=(Vec3 other) { 99 | bool b_x = x != other.x; 100 | bool b_y = y != other.y; 101 | bool b_z = z != other.z; 102 | 103 | return b_x && b_y && b_z; 104 | } 105 | 106 | double x; 107 | double y; 108 | double z; 109 | }; 110 | } -------------------------------------------------------------------------------- /examples/MemoryViewer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | uint32_t startAddr = 0x02000000; 8 | bool isShowing = false; 9 | 10 | void displayCheck() { 11 | START_BUTTONCHECK(button & VPAD_BUTTON_RIGHT, isShowing = !isShowing, button) 12 | ADD_BUTTONCHECK(button & VPAD_BUTTON_LEFT, mc::CInput::GetInput()->RequestKeyboard(L"", xf::WString::intToHexStr(startAddr).c_str(), 0, 8, [](void*, bool) -> int { 13 | wchar_t temp[9]; 14 | mc::CInput::GetInput()->GetText(temp, 9); 15 | 16 | uint32_t addr = xf::WString::hexStrToInt(temp); 17 | addr /= 0x10; 18 | addr *= 0x10; 19 | startAddr = addr; 20 | 21 | return 0; 22 | }, nullptr, mc::CInput::KeyboardMode::FULL)) 23 | END_BUTTONCHECK() 24 | } 25 | 26 | void scrollCheck() { 27 | START_TIMED_BUTTONCHECK(button & VPAD_BUTTON_DOWN, startAddr += 0x10, button, 200, 30) 28 | ADD_TIMED_BUTTONCHECK(button & VPAD_BUTTON_UP, startAddr -= 0x10) 29 | END_TIMED_BUTTONCHECK() 30 | 31 | if (0x02000000 > startAddr) startAddr = 0x02000000; 32 | } 33 | 34 | void memoryViewer() { 35 | displayCheck(); 36 | scrollCheck(); 37 | if (isShowing) { 38 | xf::GUI::DrawHelper::renderSetup(); 39 | mc::Font* font = mc::Minecraft::getInstance()->defaultFonts; 40 | xf::GUI::DrawHelper::DisplayText(font, L"Address", 1.0f, 5.0f, 5.0f); 41 | 42 | const float space = 13.0f; 43 | for (int i = 0; i < 16; i++) { 44 | for (int j = 0; j < 5; j++) { 45 | wchar_t temp[0x40]; 46 | mc_swprintf(temp, 0x40, L"%08X", j == 0 ? startAddr + (i * 0x10) : code::Mem(startAddr + (j * 0x4) - 0x4 + (i * 0x10)).as()); 47 | xf::GUI::DrawHelper::DisplayText(font, temp, 1.0f, 5.0f + (j * 70.0f), 5.0f + space + (space * i)); 48 | } 49 | } 50 | 51 | xf::Vector> vec = { {L"LocalPlayer*", 0x0}, {L"Minecraft*", 0x0}, {L"Level*", 0x0} }; 52 | mc::Minecraft* minecraft = mc::Minecraft::getInstance(); 53 | vec[0].t2 = minecraft->thePlayer; 54 | vec[1].t2 = minecraft; 55 | vec[2].t2 = minecraft->thePlayer->lvl; 56 | 57 | float yOffset = 0; 58 | for (mstd::pair& pair : vec){ 59 | wchar_t temp[0x40]; 60 | mc_swprintf(temp, 0x40, L"%08X", pair.t2); 61 | xf::GUI::DrawHelper::DisplayText(font, pair.t1, 1.0f, WIDTH - (WIDTH * (12.0f / 100.0f)), 5 + yOffset); 62 | xf::GUI::DrawHelper::DisplayText(font, temp, 1.0f, WIDTH - (WIDTH * (12.0f / 100.0f)), 5 + yOffset + space); 63 | yOffset += space * 3.0f; 64 | } 65 | } 66 | } 67 | 68 | DECL_HOOK(onFrameInGame, void) { 69 | memoryViewer(); 70 | } 71 | 72 | int c_main(void*) { 73 | code::init(); 74 | 75 | HOOK(0x02D9CAD0, onFrameInGame, 0); 76 | 77 | return 0; 78 | } 79 | 80 | void _main() { 81 | mc::C4JThreadImpl* thread = new mc::C4JThreadImpl(c_main, nullptr, "Setup Thread", 0x200); 82 | thread->Run(); 83 | thread->SetDeleteOnExit(true); 84 | } -------------------------------------------------------------------------------- /include/xf/ItemInstanceHelper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace xf { 6 | class ItemInstanceHelper { 7 | public: 8 | enum eOperator : int { 9 | PLUS = 0, 10 | PLUS_PERCENT = 1 11 | }; 12 | 13 | static void setName(mc::ItemInstance* _item, mstd::wstring const & name) { 14 | if (!_item->tag) _item->setTag(new mc::CompoundTag()); 15 | 16 | if (!_item->tag->contains(L"display")) { 17 | mc::CompoundTag* tag = new mc::CompoundTag(); 18 | _item->tag->put(L"display", tag); 19 | } 20 | 21 | mc::CompoundTag* tag = _item->tag->getCompound(L"display"); 22 | if (tag->contains(L"Name")) tag->remove(L"Name"); 23 | tag->putString(L"Name", name); 24 | } 25 | 26 | static void addEnchant(mc::ItemInstance* _item, int ench, int lvl) { 27 | if (!_item->tag) _item->setTag(new mc::CompoundTag()); 28 | 29 | bool isAlreadyThere = _item->tag->contains(L"ench"); 30 | if (!isAlreadyThere) { 31 | mc::ListTag* list = new mc::ListTag(0); 32 | _item->tag->put(L"ench", list); 33 | } 34 | 35 | mc::ListTag* list = _item->tag->getList(L"ench", 10); 36 | mc::CompoundTag* newTag = new mc::CompoundTag(); 37 | 38 | newTag->putShort(L"id", ench); 39 | newTag->putShort(L"lvl", lvl); 40 | 41 | list->add(newTag); 42 | } 43 | 44 | static void addAttrib(mc::ItemInstance* _item, int id, double amt, int op, mstd::wstring const & str) { 45 | if (!_item->tag) _item->setTag(new mc::CompoundTag()); 46 | 47 | bool isAlreadyThere = _item->tag->contains(L"AttributeModifiers"); 48 | if (!isAlreadyThere) { 49 | mc::ListTag* list = new mc::ListTag(0); 50 | _item->tag->put(L"AttributeModifiers", list); 51 | } 52 | 53 | mc::ListTag* list = _item->tag->getList(L"AttributeModifiers", 10); 54 | mc::CompoundTag* newTag = new mc::CompoundTag(); 55 | 56 | newTag->putInt(L"ID", id); 57 | newTag->putDouble(L"Amount", amt); 58 | newTag->putInt(L"Operation", op); 59 | newTag->putString(L"Slot", str); 60 | 61 | list->add(newTag); 62 | } 63 | 64 | static void addPotionEffect(mc::ItemInstance* _item, int id, int amplifier, int duration) { 65 | if (!_item->tag) _item->setTag(new mc::CompoundTag()); 66 | 67 | bool isAlreadyThere = _item->tag->contains(L"CustomPotionEffects"); 68 | if (!isAlreadyThere) { 69 | mc::ListTag* list = new mc::ListTag(0); 70 | _item->tag->put(L"CustomPotionEffects", list); 71 | } 72 | 73 | mc::ListTag* list = _item->tag->getList(L"CustomPotionEffects", 10); 74 | mc::CompoundTag* newTag = new mc::CompoundTag(); 75 | 76 | newTag->putByte(L"Ambient", false); 77 | newTag->putByte(L"Amplifier", amplifier); 78 | newTag->putByte(L"Id", id); 79 | newTag->putByte(L"ShowParticles", true); 80 | newTag->putInt(L"Duration", duration); 81 | 82 | list->add(newTag); 83 | } 84 | }; 85 | } -------------------------------------------------------------------------------- /examples/3DRender.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | void drawLine(mc::BufferBuilder* builder, mc::Vec3 pos1, mc::Vec3 pos2) { 7 | builder->vertex(pos1.x, pos1.y, pos1.z, true); 8 | builder->vertex(pos2.x, pos2.y, pos2.z, true); 9 | } 10 | 11 | void drawLineBox(mc::AABB box, uint32_t rgb = 0xFFFFFF, uint32_t a = 0xFF) { 12 | mc::BufferBuilder* builder = mc::Tesselator::getInstance()->getBuilder(); 13 | mc::GlStateManager::disableTexture(); 14 | mc::GlStateManager::lineWidth(5); 15 | mc::GlStateManager::pushMatrix(); 16 | builder->begin(MC_GL_LINES); 17 | builder->color(rgb, a); 18 | // Bottom 19 | drawLine(builder, {box.min.x, box.min.y, box.min.z}, {box.max.x, box.min.y, box.min.z}); 20 | drawLine(builder, {box.max.x, box.min.y, box.min.z}, {box.max.x, box.min.y, box.max.z}); 21 | drawLine(builder, {box.max.x, box.min.y, box.max.z}, {box.min.x, box.min.y, box.max.z}); 22 | drawLine(builder, {box.min.x, box.min.y, box.max.z}, {box.min.x, box.min.y, box.min.z}); 23 | 24 | // Top 25 | drawLine(builder, {box.min.x, box.max.y, box.min.z}, {box.max.x, box.max.y, box.min.z}); 26 | drawLine(builder, {box.max.x, box.max.y, box.min.z}, {box.max.x, box.max.y, box.max.z}); 27 | drawLine(builder, {box.max.x, box.max.y, box.max.z}, {box.min.x, box.max.y, box.max.z}); 28 | drawLine(builder, {box.min.x, box.max.y, box.max.z}, {box.min.x, box.max.y, box.min.z}); 29 | 30 | // Lines from Buttom to Top 31 | drawLine(builder, {box.min.x, box.min.y, box.min.z}, {box.min.x, box.max.y, box.min.z}); 32 | drawLine(builder, {box.max.x, box.min.y, box.min.z}, {box.max.x, box.max.y, box.min.z}); 33 | drawLine(builder, {box.min.x, box.min.y, box.max.z}, {box.min.x, box.max.y, box.max.z}); 34 | drawLine(builder, {box.max.x, box.min.y, box.max.z}, {box.max.x, box.max.y, box.max.z}); 35 | 36 | builder->end(); 37 | mc::GlStateManager::popMatrix(); 38 | } 39 | 40 | DECL_FUNCTION(void, LevelRenderer_renderEntities, void* c, const mc_boost::shared_ptr& entity, void* b, float a) { 41 | real_LevelRenderer_renderEntities(c, entity, b, a); // Must be Called first 42 | 43 | mc::GlStateManager::disableCull(); 44 | mc::GlStateManager::disableLighting(); 45 | mc::GlStateManager::enableDepthTest(); 46 | mc::GlStateManager::enableBlend(); 47 | mc::GlStateManager::blendFunc(4, 5); 48 | mc::GlStateManager::disableFog(); 49 | 50 | // Draws a White Cube at (0, 50, 0) with size (1, 1, 1) 51 | xf::GUI::DrawHelper::DisplayBox3D(0, 50, 0, 1, 1, 1, 0xFFFFFF, 0xFF, true); // Must be set to True 52 | // Draws a Red Cube with Half Transparency at (0, 50, 5) with size (1, 1, 1) 53 | xf::GUI::DrawHelper::DisplayBox3D(0, 50, 5, 1, 1, 1, 0xFF0000, 0xFF / 2, true); 54 | 55 | // Draws a Purple Line Box at (0, 50, -5) with size (1, 1, 1) 56 | drawLineBox({{0, 50, -5}, {1, 51, -4}}, 0xFF00FF, 0xFF); 57 | 58 | mc::GlStateManager::disableBlend(); 59 | mc::GlStateManager::enableCull(); 60 | } 61 | 62 | int c_main(void*) { 63 | code::init(); 64 | 65 | REPLACE(0x031B8298, LevelRenderer_renderEntities); 66 | 67 | return 0; 68 | } 69 | 70 | void _main() { 71 | mc::C4JThreadImpl* thread = new mc::C4JThreadImpl(c_main, nullptr, "Setup Thread", 0x200); 72 | thread->Run(); 73 | thread->SetDeleteOnExit(true); 74 | } -------------------------------------------------------------------------------- /include/exports/os_functions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | EXPORT_DECL(void, OSScreenInit, void); 6 | EXPORT_DECL(void, OSScreenShutdown, void); 7 | EXPORT_DECL(unsigned int, OSScreenGetBufferSizeEx, unsigned int bufferNum); 8 | EXPORT_DECL(int, OSScreenSetBufferEx, unsigned int bufferNum, void *addr); 9 | EXPORT_DECL(int, OSScreenEnableEx, unsigned int bufferNum, int enable); 10 | EXPORT_DECL(int, OSScreenClearBufferEx, unsigned int bufferNum, unsigned int temp); 11 | EXPORT_DECL(int, OSScreenPutFontEx, unsigned int bufferNum, unsigned int posX, unsigned int posY, const char *buffer); 12 | EXPORT_DECL(int, OSScreenFlipBuffersEx, unsigned int bufferNum); 13 | 14 | EXPORT_DECL(int, OSCreateThread, void *thread, int(*callback)(int, void * ), int argc, void *args, uint32_t stack, uint32_t stack_size, int priority, uint32_t attr); 15 | EXPORT_DECL(int, OSResumeThread, void *thread); 16 | 17 | EXPORT_DECL(void, OSConsoleWrite, const char* msg, int size); 18 | 19 | EXPORT_DECL(int, MCP_Open, void); 20 | EXPORT_DECL(int, MCP_GetDeviceId, int handle, uint64_t* devideId); 21 | EXPORT_DECL(int, MCP_Close, int handle); 22 | 23 | EXPORT_DECL(void, OSSetExceptionCallback, uint8_t exceptionType, uint8_t(*callback)(void*)); 24 | 25 | #define PRINTF_TEXT(x, y, ...) { \ 26 | snprintf(messageBuffer, 80, __VA_ARGS__); \ 27 | OSScreenPutFontEx(0, x, y, messageBuffer); \ 28 | OSScreenPutFontEx(1, x, y, messageBuffer); \ 29 | } 30 | #define PRINT_TEXT(x, y, message) { \ 31 | OSScreenPutFontEx(0, x, y, message); \ 32 | OSScreenPutFontEx(1, x, y, message); \ 33 | } 34 | 35 | #define OS_THREAD_ATTR_AFFINITY_NONE 0x0007u // affinity to run on every core 36 | #define OS_THREAD_ATTR_AFFINITY_CORE0 0x0001u // run only on core0 37 | #define OS_THREAD_ATTR_AFFINITY_CORE1 0x0002u // run only on core1 38 | #define OS_THREAD_ATTR_AFFINITY_CORE2 0x0004u // run only on core2 39 | #define OS_THREAD_ATTR_DETACH 0x0008u // detached 40 | #define OS_THREAD_ATTR_PINNED_AFFINITY 0x0010u // pinned (affinitized) to a single core 41 | #define OS_THREAD_ATTR_CHECK_STACK_USE 0x0040u // check for stack usage 42 | #define OS_THREAD_ATTR_NAME_SENT 0x0080u // debugger has seen the name 43 | #define OS_THREAD_ATTR_LAST (OS_THREAD_ATTR_DETACH | OS_THREAD_ATTR_PINNED_AFFINITY | OS_THREAD_ATTR_AFFINITY_NONE) 44 | 45 | 46 | void InitOSFunctionPointers() { 47 | uint32_t coreinit_handle; 48 | uint32_t* funcPointer = 0; 49 | OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); 50 | OS_FIND_EXPORT(coreinit_handle, OSScreenInit); 51 | OS_FIND_EXPORT(coreinit_handle, OSScreenShutdown); 52 | OS_FIND_EXPORT(coreinit_handle, OSScreenGetBufferSizeEx); 53 | OS_FIND_EXPORT(coreinit_handle, OSScreenSetBufferEx); 54 | OS_FIND_EXPORT(coreinit_handle, OSScreenEnableEx); 55 | OS_FIND_EXPORT(coreinit_handle, OSScreenClearBufferEx); 56 | OS_FIND_EXPORT(coreinit_handle, OSScreenPutFontEx); 57 | OS_FIND_EXPORT(coreinit_handle, OSScreenFlipBuffersEx); 58 | 59 | OS_FIND_EXPORT(coreinit_handle, OSCreateThread); 60 | OS_FIND_EXPORT(coreinit_handle, OSResumeThread); 61 | 62 | OS_FIND_EXPORT(coreinit_handle, OSConsoleWrite); 63 | 64 | OS_FIND_EXPORT(coreinit_handle, MCP_Open); 65 | OS_FIND_EXPORT(coreinit_handle, MCP_GetDeviceId); 66 | OS_FIND_EXPORT(coreinit_handle, MCP_Close); 67 | 68 | OS_FIND_EXPORT(coreinit_handle, OSSetExceptionCallback); 69 | } -------------------------------------------------------------------------------- /include/minecraft/ui/scene/Scenes/UIScene_DebugMenu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../control/object/UIControl_MultiList.h" 4 | #include "../../control/object/UIControl_ButtonList.h" 5 | #include "../../control/object/UIControl_CheckboxButtonList.h" 6 | #include "../../../util/VTable_UIScene.h" 7 | 8 | namespace mc { 9 | class UIScene_DebugMenu : public UIScene { 10 | public: 11 | UIScene_DebugMenu(uint32_t ID ,uint32_t FuncMaybe ,uint32_t layer) 12 | { 13 | code::Func()(this, ID, layer); // UIScene::UIScene 14 | 15 | VTable_UIScene* DebugUIVtbl = new VTable_UIScene; 16 | memcpy(DebugUIVtbl, (VTable_UIScene*)0x1038574c, sizeof(VTable_UIScene)); 17 | DebugUIVtbl->mapElementsAndNames = &mapElementsAndNames; 18 | DebugUIVtbl->getMoviePath = &getMoviePath; 19 | 20 | this->vtbl = DebugUIVtbl; 21 | 22 | UIControl_MultiList(&this->HowToList); 23 | this->initialiseMovie(); 24 | 25 | uint32_t options[] = { 26 | ((uint32_t)(L"Load Saves From Local Folder Mode")), 27 | ((uint32_t)(L"Write Saves To Local Folder Mode")), 28 | ((uint32_t)(L"Freeze Players")), 29 | ((uint32_t)(L"Display Safe Area")), 30 | ((uint32_t)(L"Mobs don't attack")), 31 | ((uint32_t)(L"Freeze Time")), 32 | ((uint32_t)(L"Disable Weather")), 33 | ((uint32_t)(L"Craft Anything")), 34 | ((uint32_t)(L"Use DPad for debug")), 35 | ((uint32_t)(L"Mobs don't tick")), 36 | ((uint32_t)(L"Art tools")), 37 | ((uint32_t)(L"Show UI Console")), 38 | ((uint32_t)(L"Distributable Save")), 39 | ((uint32_t)(L"Debug Leaderboards")), 40 | ((uint32_t)(L"Height-Water Maps")), 41 | ((uint32_t)(L"Superflat Nether")), 42 | ((uint32_t)(L"More lightning when thundering")), 43 | ((uint32_t)(L"Biome override")), 44 | ((uint32_t)(L"Go To Overworld")), 45 | ((uint32_t)(L"Unlock All DLC")), 46 | ((uint32_t)(L"Show Marketing Guide")) 47 | }; 48 | int i = 0; 49 | for(uint32_t option : options) 50 | { 51 | this->HowToList.AddNewCheckbox(*(new mstd::wstring(((wchar_t*)option))), i, false); 52 | i++; 53 | } 54 | 55 | this->doHorizontalResizeCheck(); 56 | this->field_0x17C = 0; 57 | ((ConsoleUIController*)0x104f73e0)->TouchBoxRebuild(this); 58 | } 59 | 60 | static void getMoviePath(UIScene* scene, mstd::wstring& string) 61 | { 62 | string.str[0] = 0; 63 | string.length2 = 7; 64 | string.length = 0; 65 | string.assign(L"DebugOptionsMenu", 16); 66 | } 67 | 68 | static int getSceneType(UIScene* scene) 69 | { 70 | return 0xD; 71 | } 72 | 73 | static bool mapElementsAndNames(UIScene* scene) 74 | { 75 | uint32_t fuiRoot = code::Func()(scene->fuiFile); // fuiFile::getRootNode 76 | 77 | mstd::wstring* HowToPlayStr = new mstd::wstring(L""); 78 | HowToPlayStr->assign("DebugOptionsList", 16); 79 | 80 | ((UIScene_DebugMenu*)scene)->HowToList.setupControl(scene, fuiRoot, HowToPlayStr); 81 | 82 | UIControl_MultiList* ControlPTR = &((UIScene_DebugMenu*)scene)->HowToList; 83 | 84 | code::Func()((uint32_t*)&scene->UIControl_Vector, &ControlPTR); // vector.push_back 85 | return true; 86 | } 87 | static void Log(const wchar_t* text) 88 | { 89 | code::Func()("%ls\n", text); 90 | } 91 | 92 | 93 | UIControl_MultiList HowToList; 94 | uint32_t field_0x17C; 95 | 96 | }; 97 | } 98 | -------------------------------------------------------------------------------- /include/minecraft/nbt/CompundTag.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Tag.h" 6 | #include "ListTag.h" 7 | #include "../client/resource/wstring.h" 8 | 9 | namespace mc { 10 | class CompoundTag : public Tag { 11 | public: 12 | CompoundTag() { 13 | code::Func()(this); 14 | } 15 | 16 | void putInt(const mstd::wstring& str, int b) { 17 | code::Func()(this, str, b); 18 | } 19 | 20 | void putFloat(const mstd::wstring& str, float f) { 21 | code::Func()(this, str, f); 22 | } 23 | 24 | void putDouble(const mstd::wstring& str, double f) { 25 | code::Func()(this, str, f); 26 | } 27 | 28 | void putString(const mstd::wstring& str, const mstd::wstring& str2) { 29 | code::Func()(this, str, str2); 30 | } 31 | 32 | void putBoolean(const mstd::wstring& str, bool b) { 33 | code::Func()(this, str, b); 34 | } 35 | 36 | void putShort(const mstd::wstring& str, int16_t b) { 37 | code::Func()(this, str, b); 38 | } 39 | 40 | void put(const mstd::wstring& str, Tag* tag) { 41 | code::Func()(this, str, tag); 42 | } 43 | 44 | void putByte(const mstd::wstring& str, uint8_t b) { 45 | code::Func()(this, str, b); 46 | } 47 | 48 | bool contains(const mstd::wstring& str) { 49 | return code::Func()(this, str); 50 | } 51 | 52 | bool equals(Tag* tag) { 53 | return code::Func()(this, tag); 54 | } 55 | 56 | void remove(const mstd::wstring& str) { 57 | code::Func()(this, str); 58 | } 59 | 60 | ListTag* getList(const mstd::wstring& str, int unk) { 61 | return code::Func()(this, str, unk); 62 | } 63 | 64 | CompoundTag* getCompound(const mstd::wstring& str) { 65 | return code::Func()(this, str); 66 | } 67 | 68 | void getString(const mstd::wstring& ret, const mstd::wstring& str) { 69 | return code::Func()(this, ret, str); 70 | } 71 | 72 | void toString(const mstd::wstring& output_str) { 73 | code::Func()(this, output_str); 74 | } 75 | 76 | int getInt(const mstd::wstring& str) { 77 | return code::Func()(this, str); 78 | } 79 | 80 | uint32_t field_0x4; 81 | uint32_t field_0x8; 82 | uint32_t entries; 83 | uint32_t field_0x10; 84 | uint32_t field_0x14; 85 | uint32_t field_0x18; 86 | 87 | }; 88 | } -------------------------------------------------------------------------------- /examples/SpawnEntities.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | mc::Vec3 getLookAt(float yaw, float pitch) { 7 | return mc::Vec3( 8 | fabs(sinf(degToRad(pitch - 90.0f))) * sinf(degToRad(yaw - 180.0f)), 9 | sinf(degToRad(pitch - 180.0f)), 10 | fabs(sinf(degToRad(pitch - 90.0f))) * cosf(degToRad(yaw)) 11 | ); 12 | } 13 | 14 | mc::AreaEffectCloud* spawnHologram(mc::Vec3 pos, const wchar_t* name, mc::ServerPlayer* player) { 15 | mc::AreaEffectCloud* cloud = new mc::AreaEffectCloud(player->lvl); 16 | cloud->setupForSpawn(name, player); 17 | cloud->setCustomNameVisible(true); 18 | cloud->moveTo(pos); 19 | cloud->setParticle(mc::ParticleType::byId(mc::ePARTICLE_TYPE::NONE)); 20 | cloud->setDuration(0x7FFF0000); 21 | cloud->setRadiusOnUse(0.0f); 22 | cloud->setRadiusPerTick(0.0f); 23 | cloud->setRadius(1.0f); 24 | player->listener->server->getLevel(0)->addEntity(cloud); 25 | 26 | return cloud; 27 | } 28 | 29 | DECL_FUNCTION(void, ServerPlayer_swing, mc::ServerPlayer* player, mc::InteractionHand::EInteractionHand hand) { 30 | spawnHologram(player->position + mc::Vec3(0.0f, 1.0f / 3.0f + 1.5f, 5.0f), L"§bMinigame §7[v0.0]", player); 31 | spawnHologram(player->position + mc::Vec3(0.0f, 1.5f, 5.0f), L"§eCLICK TO PLAY", player); 32 | spawnHologram(player->position + mc::Vec3(0.0f, 1.5f, 0.0f), L"§8[§7Lv69§8] §cZombie §a100§7/§a100§cHP", player); 33 | 34 | mc::Zombie* zombie = new mc::Zombie(player->lvl); 35 | zombie->setupForSpawn(L"", player); // Leave Empty for no Name 36 | zombie->setNoAi(true); 37 | zombie->setInvulnerable(true); 38 | zombie->setNoGravity(true); 39 | zombie->setSilent(true); 40 | zombie->moveTo(player->position); 41 | player->listener->server->getLevel(0)->addEntity(zombie); 42 | 43 | mc::Zombie* zombie2 = new mc::Zombie(player->lvl); 44 | zombie2->setupForSpawn(L"", player); 45 | zombie2->setNoAi(true); 46 | zombie2->setInvulnerable(true); 47 | zombie2->setNoGravity(true); 48 | zombie2->setSilent(true); 49 | zombie2->moveTo(player->position + mc::Vec3(0.0f, 0.0f, 5.0f)); 50 | player->listener->server->getLevel(0)->addEntity(zombie2); 51 | 52 | mc::PrimedTnt* tnt = new mc::PrimedTnt(player->lvl); 53 | tnt->setupForSpawn(L"", player); 54 | tnt->setFuse(20 * 12); // 12 Seconds 55 | tnt->push(0.0f, 1.45f, 0.0f); 56 | tnt->moveTo(player->position); 57 | player->listener->server->getLevel(0)->addEntity(tnt); 58 | 59 | mc::Sheep* sheep = new mc::Sheep(player->lvl); 60 | sheep->setupForSpawn(L"", player); 61 | sheep->setInvulnerable(true); 62 | sheep->moveTo(player->position); 63 | player->listener->server->getLevel(0)->addEntity(sheep); 64 | 65 | sheep->startRiding(tnt, false); 66 | 67 | mc::Slime* slime = new mc::Slime(player->lvl); 68 | slime->setupForSpawn(L"", player); 69 | slime->setInvulnerable(true); 70 | slime->moveTo(player->position); 71 | player->listener->server->getLevel(0)->addEntity(slime); 72 | 73 | slime->startRiding(sheep, false); 74 | 75 | real_ServerPlayer_swing(player, hand); 76 | } 77 | 78 | int c_main(void*) { 79 | code::init(); 80 | 81 | REPLACE(mc::ServerPlayer::_swing.addr(), ServerPlayer_swing); 82 | 83 | return 0; 84 | } 85 | 86 | void _main() { 87 | mc::C4JThreadImpl* thread = new mc::C4JThreadImpl(c_main, nullptr, "Setup Thread", 0x200); 88 | thread->Run(); 89 | thread->SetDeleteOnExit(true); 90 | } -------------------------------------------------------------------------------- /include/exports/socket_functions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | uint32_t hostIpAddress = 0; 6 | 7 | #define INADDR_ANY 0 8 | 9 | #define AF_INET 2 10 | 11 | #define SOCK_STREAM 1 12 | #define SOCK_DGRAM 2 13 | 14 | #define IPPROTO_IP 0 15 | #define IPPROTO_TCP 6 16 | #define IPPROTO_UDP 17 17 | 18 | #define TCP_NODELAY 0x2004 19 | 20 | #define SOL_SOCKET -1 21 | #define SO_REUSEADDR 0x0004 22 | #define SO_NONBLOCK 0x1016 23 | #define SO_MYADDR 0x1013 24 | 25 | #define htonl(x) x 26 | #define htons(x) x 27 | #define ntohl(x) x 28 | #define ntohs(x) x 29 | 30 | struct in_addr { 31 | uint32_t s_addr; 32 | }; 33 | 34 | struct sockaddr_in { 35 | short sin_family; 36 | unsigned short sin_port; 37 | in_addr sin_addr; 38 | char sin_zero[8]; 39 | }; 40 | 41 | struct sockaddr { 42 | unsigned short sa_family; 43 | char sa_data[14]; 44 | }; 45 | 46 | EXPORT_DECL(int, socket_lib_init, void); 47 | EXPORT_DECL(int, socket_lib_finish, void); 48 | EXPORT_DECL(int, socket, int domain, int type, int protocol); 49 | EXPORT_DECL(int, socketclose, int s); 50 | EXPORT_DECL(int, connect, int s, void* addr, int addrlen); 51 | EXPORT_DECL(int, bind, int s, sockaddr* name, int namelen); 52 | EXPORT_DECL(int, listen, int s,uint32_t backlog); 53 | EXPORT_DECL(int, accept, int s, sockaddr* addr, int* addrlen); 54 | EXPORT_DECL(int, send, int s, const void* buffer, int size, int flags); 55 | EXPORT_DECL(int, recv, int s, void* buffer, int size, int flags); 56 | EXPORT_DECL(int, sendto, int s, const void* buffer, int size, int flags, const sockaddr* dest, int dest_len); 57 | EXPORT_DECL(int, setsockopt, int s, int level, int optname, void* optval, int optlen); 58 | EXPORT_DECL(char*, inet_ntoa, in_addr in); 59 | EXPORT_DECL(int, inet_aton, const char* cp, in_addr* inp); 60 | 61 | void InitSocketFunctionPointers(void) { 62 | uint32_t nsysnet_handle; 63 | uint32_t* funcPointer = 0; 64 | OSDynLoad_Acquire("nsysnet.rpl", &nsysnet_handle); 65 | 66 | uint32_t nn_ac_handle; 67 | int(*ACInitialize)(); 68 | int(*ACGetStartupId) (uint32_t* id); 69 | int(*ACConnectWithConfigId) (uint32_t id); 70 | int(*ACGetAssignedAddress) (uint32_t* ip); 71 | OSDynLoad_Acquire("nn_ac.rpl", &nn_ac_handle); 72 | OSDynLoad_FindExport(nn_ac_handle, 0, "ACInitialize", &ACInitialize); 73 | OSDynLoad_FindExport(nn_ac_handle, 0, "ACGetStartupId", &ACGetStartupId); 74 | OSDynLoad_FindExport(nn_ac_handle, 0, "ACConnectWithConfigId",&ACConnectWithConfigId); 75 | OSDynLoad_FindExport(nn_ac_handle, 0, "ACGetAssignedAddress",&ACGetAssignedAddress); 76 | 77 | OS_FIND_EXPORT(nsysnet_handle, socket_lib_init); 78 | OS_FIND_EXPORT(nsysnet_handle, socket_lib_finish); 79 | OS_FIND_EXPORT(nsysnet_handle, socket); 80 | OS_FIND_EXPORT(nsysnet_handle, socketclose); 81 | OS_FIND_EXPORT(nsysnet_handle, connect); 82 | OS_FIND_EXPORT(nsysnet_handle, bind); 83 | OS_FIND_EXPORT(nsysnet_handle, listen); 84 | OS_FIND_EXPORT(nsysnet_handle, accept); 85 | OS_FIND_EXPORT(nsysnet_handle, send); 86 | OS_FIND_EXPORT(nsysnet_handle, recv); 87 | OS_FIND_EXPORT(nsysnet_handle, sendto); 88 | OS_FIND_EXPORT(nsysnet_handle, setsockopt); 89 | OS_FIND_EXPORT(nsysnet_handle, inet_ntoa); 90 | OS_FIND_EXPORT(nsysnet_handle, inet_aton); 91 | 92 | uint32_t nn_startupid; 93 | ACInitialize(); 94 | ACGetStartupId(&nn_startupid); 95 | ACConnectWithConfigId(nn_startupid); 96 | ACGetAssignedAddress(&hostIpAddress); 97 | 98 | socket_lib_init(); 99 | } -------------------------------------------------------------------------------- /examples/CustomItem.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | 6 | 7 | xf::Vector AtlasPTRs = {}; 8 | 9 | mc::Vec3 getLookAt(float yaw, float pitch) { 10 | return mc::Vec3( 11 | fabs(sinf(degToRad(pitch - 90.0f))) * sinf(degToRad(yaw - 180.0f)), 12 | sinf(degToRad(pitch - 180.0f)), 13 | fabs(sinf(degToRad(pitch - 90.0f))) * cosf(degToRad(yaw)) 14 | ); 15 | } 16 | 17 | namespace mc { 18 | VTable_Item* TestItem_default_vtbl = nullptr; 19 | class TestItem : public BowItem { 20 | public: 21 | TestItem() : BowItem() { 22 | if (!TestItem_default_vtbl) { 23 | TestItem_default_vtbl = (VTable_Item*) new uint8_t[sizeof(VTable_Item)]; 24 | memcpy(TestItem_default_vtbl, BowItem::default_vtbl, sizeof(VTable_Item)); 25 | TestItem_default_vtbl->releaseUsing = &TestItem::releaseUsing; 26 | TestItem_default_vtbl->hurtEnemy = &TestItem::hurtEnemy; 27 | TestItem_default_vtbl->mineBlock = &TestItem::mineBlock; 28 | } 29 | 30 | vtbl = TestItem_default_vtbl; 31 | iconName = Item::byId(BowItem::default_itemId)->iconName.c_str(); 32 | } 33 | 34 | static Item* releaseUsing(Item* _this, const mc_boost::shared_ptr& instance, struct Level* level, const mc_boost::shared_ptr& entity, int duration) { 35 | Vec3 lookAt = getLookAt(entity->yaw, entity->pitch); 36 | lookAt *= 3.0f; 37 | entity->push(lookAt.x, lookAt.y, lookAt.z); 38 | return _this; 39 | } 40 | 41 | static bool hurtEnemy(Item* _this, const mc_boost::shared_ptr& item, const mc_boost::shared_ptr& attacked, const mc_boost::shared_ptr& attacker) { 42 | Vec3 lookAt = getLookAt(attacker->yaw, attacker->pitch); 43 | lookAt *= 3.0f; 44 | attacker->push(lookAt.x, lookAt.y, lookAt.z); 45 | return false; 46 | } 47 | 48 | static bool mineBlock(Item* _this, const mc_boost::shared_ptr& item, struct Level* lvl, const struct BlockState* state, const BlockPos& pos, mc_boost::shared_ptr& entity) { 49 | mc_printf(L"Broke Block At (%d %d %d)", pos.x, pos.y, pos.z); 50 | return false; 51 | } 52 | }; 53 | } 54 | 55 | DECL_FUNCTION(void, MinecraftWorld_RunStaticCtors__Fv, void) { 56 | real_MinecraftWorld_RunStaticCtors__Fv(); 57 | 58 | // Something like minecraft:bow would be modded:custom_item 59 | mc::ResourceLocation loc(L"modded", L"custom_item"); 60 | mc::TestItem* testItem = new mc::TestItem(); 61 | testItem->iconName = L"custom_texture_name"; //sets the custom item's texture to your custom icon 62 | 63 | // Set Item Id to 1, so we can get it from the Creative Inventory, see AddCreativeMenuItem.h to use a custom ID 64 | mc::Item::registerItem(1, loc, testItem); 65 | } 66 | 67 | DECL_FUNCTION(void, LoadUVs, mc::TextureAtlas* AtlasAddr) { 68 | real_LoadUVs(AtlasAddr); 69 | AtlasPTRs.push_back(AtlasAddr); // this func only gets called twice, so index 0 is terrain, 1 is items 70 | 71 | if(AtlasPTRs.getSize() == 2){ 72 | AtlasPTRs[1]->addIcon(6, 16, L"custom_texture_name"); // Add texture by X, Y, and iconName in the items.png atlas 73 | 74 | } 75 | } 76 | 77 | int c_main(void*) { 78 | code::init(); 79 | 80 | REPLACE(0x026112C0, MinecraftWorld_RunStaticCtors__Fv); 81 | 82 | REPLACE(0x03367220, LoadUVs); // Create custom iconNames 83 | 84 | return 0; 85 | } 86 | 87 | void _main() { 88 | mc::C4JThreadImpl* thread = new mc::C4JThreadImpl(c_main, nullptr, "Setup Thread", 0x200); 89 | thread->Run(); 90 | thread->SetDeleteOnExit(true); 91 | } -------------------------------------------------------------------------------- /include/minecraft/util/VTable_UIScene.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "VTable.h" 4 | 5 | #include "../client/resource/shared_ptr.h" 6 | #include "../util/InteractionHand.h" 7 | #include "../util/BlockPos.h" 8 | 9 | namespace mc { 10 | struct VTable_UIScene : public VTable { 11 | public: 12 | 13 | MC_VFUNC(void, struct UIScene, reloadMovie); 14 | MC_VFUNC(void, struct UIScene, needsReloaded); 15 | MC_VFUNC(void, struct UIScene, hasMovie); 16 | MC_VFUNC(void, struct UIScene, updateSafeZone); 17 | MC_VFUNC(void, struct UIScene, updateViewportTouchOffset); 18 | MC_VFUNC(void, struct UIScene, getSafeZoneHalfHeight); 19 | MC_VFUNC(void, struct UIScene, getSafeZoneHalfWidth); 20 | MC_VFUNC(void, struct UIScene, getMoviePath, mstd::wstring&); 21 | MC_VFUNC(bool, struct UIScene, mapElementsAndNames); 22 | MC_VFUNC(void, struct UIScene, __dt); 23 | MC_VFUNC(int, struct UIScene, getSceneType); 24 | MC_VFUNC(uint32_t, struct UIScene, getSubSceneType); 25 | MC_VFUNC(void, struct UIScene, tick); 26 | MC_VFUNC(void, struct UIScene, SetFocusToElement); 27 | MC_VFUNC(void, struct UIScene, handleTimerComplete); 28 | MC_VFUNC(void, struct UIScene, stealsFocus); 29 | MC_VFUNC(void, struct UIScene, hasFocus); 30 | MC_VFUNC(void, struct UIScene, updateTooltips); 31 | MC_VFUNC(void, struct UIScene, updateComponents); 32 | MC_VFUNC(void, struct UIScene, handleGainFocus); 33 | MC_VFUNC(void, struct UIScene, handleLoseFocus); 34 | MC_VFUNC(void, struct UIScene, hidesLowerScenes); 35 | MC_VFUNC(void, struct UIScene, blocksInput); 36 | MC_VFUNC(void, struct UIScene, GetMainPanel); 37 | MC_VFUNC(void, struct UIScene, render); 38 | MC_VFUNC(void, struct UIScene, customDraw); 39 | MC_VFUNC(void, struct UIScene, allowRepeat); 40 | MC_VFUNC(void, struct UIScene, handleInput, int, int, bool ,bool ,bool ,bool); 41 | MC_VFUNC(void, struct UIScene, handleDestroy); 42 | MC_VFUNC(void, struct UIScene, handlePreUnloadForReload); 43 | MC_VFUNC(void, struct UIScene, handlePreReload); 44 | MC_VFUNC(void, struct UIScene, handleReload); 45 | MC_VFUNC(void, struct UIScene, handlePress); 46 | MC_VFUNC(void, struct UIScene, handleFocusChange); 47 | MC_VFUNC(void, struct UIScene, handleInitFocus); 48 | MC_VFUNC(void, struct UIScene, handleCheckboxToggled); 49 | MC_VFUNC(void, struct UIScene, handleCheckboxElementToggled); 50 | MC_VFUNC(void, struct UIScene, handleSliderMove); 51 | MC_VFUNC(void, struct UIScene, handleSliderElementMove); 52 | MC_VFUNC(void, struct UIScene, handleAnimationEnd); 53 | MC_VFUNC(void, struct UIScene, handleSelectionChanged); 54 | MC_VFUNC(void, struct UIScene, handleRequestMoreData); 55 | MC_VFUNC(void, struct UIScene, handleTouchBoxRebuild); 56 | MC_VFUNC(void, struct UIScene, HandleDLCMountingComplete); 57 | MC_VFUNC(void, struct UIScene, HandleDLCInstalled); 58 | MC_VFUNC(void, struct UIScene, HandleDLCLicenseChange); 59 | MC_VFUNC(void, struct UIScene, HandleTMSBanFileRetrieved); 60 | MC_VFUNC(void, struct UIScene, HandleMessage); 61 | MC_VFUNC(void, struct UIScene, HandleSaveDeviceRemoved); 62 | MC_VFUNC(void, struct UIScene, handleUnlockFullVersion); 63 | MC_VFUNC(void, struct UIScene, handleTouchInput); 64 | MC_VFUNC(void, struct UIScene, isReadyToDelete); 65 | }; 66 | } -------------------------------------------------------------------------------- /include/minecraft/rendering/GlStateManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "buffer/BufferedImage.h" 6 | 7 | #define MC_GL_ZERO 0 8 | #define MC_GL_ONE 1 9 | #define MC_GL_SRC_ALPHA 4 10 | #define MC_GL_ONE_MINUS_SRC_ALPHA 5 11 | 12 | #define MC_GL_TRIANGLES 0 13 | #define MC_GL_TRIANGLE_FAN 1 14 | #define MC_GL_QUADS 2 15 | #define MC_GL_QUADS_STRIP 3 16 | #define MC_GL_LINES 4 17 | #define MC_GL_LINES_STRIP 5 18 | 19 | #define MC_GL_MODELVIEW 0 20 | #define MC_GL_PROJECTION 1 21 | #define MC_GL_TEXTURE 2 22 | 23 | namespace mc { 24 | class GlStateManager { 25 | public: 26 | static void disableDepthTest() { 27 | code::Func()(); 28 | } 29 | 30 | static void lineWidth(float size) { 31 | code::Func()(size); 32 | } 33 | 34 | static void enableDepthTest() { 35 | code::Func()(); 36 | } 37 | 38 | static void pushMatrix() { 39 | code::Func()(); 40 | } 41 | 42 | static void scalef(float x, float y, float z) { 43 | code::Func()(x, y, z); 44 | } 45 | 46 | static void translatef(float x, float y, float z) { 47 | code::Func()(x, y, z); 48 | } 49 | 50 | static void rotatef(float x, float y, float z, float w) { 51 | code::Func()(x, y, z, w); 52 | } 53 | 54 | static void popMatrix() { 55 | code::Func()(); 56 | } 57 | 58 | static void disableTexture() { 59 | code::Func()(); 60 | } 61 | 62 | static int genTexture() { 63 | return code::Func()(); 64 | } 65 | 66 | static void enableTexture() { 67 | code::Func()(); 68 | } 69 | 70 | static void depthMask(bool arg1) { 71 | code::Func()(arg1); 72 | } 73 | 74 | static void ortho(double arg1, double arg2, double arg3, double arg4, double arg5, double arg6) { 75 | code::Func()(arg1, arg2, arg3, arg4, arg5, arg6); 76 | } 77 | 78 | static void matrixMode(uint32_t arg1) { 79 | code::Func()(arg1); 80 | } 81 | 82 | static void loadIdentity() { 83 | code::Func()(); 84 | } 85 | 86 | static void disableCull() { 87 | code::Func()(); 88 | } 89 | 90 | static void enableCull() { 91 | code::Func()(); 92 | } 93 | 94 | static void clear(int i) { 95 | code::Func()(i); 96 | } 97 | 98 | static void enableBlend() { 99 | code::Func()(); 100 | } 101 | 102 | static void disableBlend() { 103 | code::Func()(); 104 | } 105 | 106 | static void blendFunc(uint32_t arg1, uint32_t arg2) { 107 | code::Func()(arg1, arg2); 108 | } 109 | 110 | static void disableLighting() { 111 | code::Func()(); 112 | } 113 | 114 | static void color4f(double r, double g, double b, double a) { 115 | code::Func()(r, g, b, a); 116 | } 117 | 118 | static void disableFog() { 119 | code::Func()(); 120 | } 121 | }; 122 | } -------------------------------------------------------------------------------- /include/minecraft/ui/control/object/UIControl_MultiList.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "./UIControl_List.h" 6 | #include "../../scene/UIScene.h" 7 | 8 | namespace mc { 9 | class UIControl_MultiList : public UIControl_List { 10 | public: 11 | UIControl_MultiList() 12 | { 13 | code::Func()(this); 14 | } 15 | 16 | UIControl_MultiList(UIControl_MultiList* _this) 17 | { 18 | code::Func()(_this); 19 | } 20 | 21 | void setupControl(UIScene* scene, uint32_t fuiNode, mstd::wstring* Str) 22 | { 23 | code::Func()(this, scene, fuiNode, Str); 24 | } 25 | 26 | void AddNewButton(const mstd::wstring& string, uint32_t ID, bool Enabled) 27 | { 28 | code::Func()(this, string, ID, Enabled); 29 | } 30 | 31 | void AddNewCheckbox(const mstd::wstring& string, uint32_t ID, bool Enabled) 32 | { 33 | code::Func()(this, string, ID, Enabled); 34 | } 35 | 36 | void AddNewLabel(const mstd::wstring& string, uint32_t ID) 37 | { 38 | code::Func()(this, string, ID); 39 | } 40 | 41 | void AddNewMenuButton(const mstd::wstring& string, uint32_t ID) 42 | { 43 | code::Func()(this, string, ID); 44 | } 45 | 46 | void AddNewTextInput(const mstd::wstring& string, uint32_t ID, uint32_t Limit) 47 | { 48 | code::Func()(this, string, ID, Limit); 49 | } 50 | 51 | void AddNewSlider(const mstd::wstring& string, bool Enabled, uint32_t ID, uint32_t Index, uint32_t Minimum, uint32_t Maximum) 52 | { 53 | code::Func()(this, string, ID, Minimum, Maximum, Index, Enabled, Maximum, Minimum); 54 | } 55 | 56 | void removeItem(uint32_t ID, bool Condition) 57 | { 58 | code::Func()(this, ID, Condition); 59 | } 60 | void EnableItem(uint32_t ID, bool Condition, bool Condition2) 61 | { 62 | code::Func()(this, ID, Condition, Condition2); 63 | } 64 | void ToggleCheckbox(uint32_t ID, bool Condition, bool Condition2) 65 | { 66 | code::Func()(this, ID, Condition, Condition2); 67 | } 68 | void ToggleSlider(uint32_t ID, uint32_t Value, bool Condition) 69 | { 70 | code::Func()(this, ID, Value, Condition); 71 | } 72 | 73 | void SetItemLabel(wchar_t* string, uint32_t ID, bool Enabled) 74 | { 75 | uint32_t UIString = code::Func()(0, string); 76 | code::Func()(this, ID, UIString, Enabled, Enabled, Enabled); 77 | } 78 | uint32_t field_0x60; 79 | uint32_t field_0x64; 80 | uint32_t field_0x68; 81 | uint32_t field_0x6C; 82 | uint32_t field_0x70; 83 | uint32_t field_0x74; 84 | uint32_t field_0x78; 85 | uint32_t field_0x7C; 86 | uint32_t field_0x80; 87 | uint32_t field_0x84; 88 | uint32_t field_0x88; 89 | uint32_t field_0x8C; 90 | uint32_t field_0x90; 91 | uint32_t field_0x94; 92 | uint32_t field_0x98; 93 | uint32_t field_0x9C; 94 | uint32_t field_0xA0; 95 | uint32_t field_0xA4; 96 | uint32_t field_0xA8; 97 | uint32_t field_0xAC; 98 | uint32_t field_0xB0; 99 | uint32_t field_0xB4; 100 | uint32_t field_0xB8; 101 | uint32_t field_0xBC; 102 | }; 103 | } -------------------------------------------------------------------------------- /include/xf/Vector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | namespace xf { 9 | template 10 | class Vector { 11 | public: 12 | Vector() { 13 | data = nullptr; 14 | length = 0; 15 | } 16 | 17 | Vector(std::initializer_list list) { 18 | data = _new(list.size()); 19 | length = list.size(); 20 | 21 | int index = 0; 22 | for (T t : list) { 23 | data[index++] = t; 24 | } 25 | } 26 | 27 | Vector(T t) { 28 | data = _new(1); 29 | length = 1; 30 | 31 | data[0] = t; 32 | } 33 | 34 | Vector(Vector& t) { 35 | data = _new(t.getSize()); 36 | length = t.getSize(); 37 | 38 | int n = 0; 39 | for (T _t : t) { 40 | data[n++] = _t; 41 | } 42 | } 43 | 44 | ~Vector() { 45 | // _delete(data); 46 | } 47 | 48 | void push_back(T t) { 49 | if (!data || length == 0) { 50 | data = _new(1); 51 | length = 1; 52 | 53 | data[0] = t; 54 | } else { 55 | length++; 56 | T* n_data = _new(length); 57 | for (int i = 0; i < length - 1; i++) n_data[i] = data[i]; 58 | n_data[length - 1] = t; 59 | _delete(data); 60 | data = n_data; 61 | } 62 | } 63 | 64 | void push_front(T t) { 65 | if (!data || length == 0) { 66 | data = _new(1); 67 | length = 1; 68 | 69 | data[0] = t; 70 | } else { 71 | length++; 72 | T* n_data = _new(length); 73 | for (int i = 0; i < length - 1; i++) n_data[i + 1] = data[i]; 74 | n_data[0] = t; 75 | _delete(data); 76 | data = n_data; 77 | } 78 | } 79 | 80 | void pop_front() { 81 | for (int i = 1; i < length; i++) { 82 | data[i - 1] = data[i]; 83 | } 84 | 85 | length == 0 ? length = 0 : length -= 1; 86 | } 87 | 88 | void clear() { 89 | length = 0; 90 | if (data) _delete(data); 91 | data = nullptr; 92 | } 93 | 94 | void pop_back() { 95 | length -= 1; 96 | } 97 | 98 | bool isEmpty() { 99 | return length == 0; 100 | } 101 | 102 | T& random() { 103 | return data[code::Random::next(0, length - 1)]; 104 | } 105 | 106 | T& front() { return data[0]; } 107 | T& back() { return data[length - 1]; } 108 | 109 | T& operator[](int index) { 110 | if (0 > index) return data[length + index]; 111 | return data[index]; 112 | } 113 | 114 | T operator[](int index) const { 115 | if (0 > index) return data[length + index]; 116 | return data[index]; 117 | } 118 | 119 | xf::Vector& operator=(xf::Vector other) { 120 | clear(); 121 | for (T t : other) { 122 | push_back(t); 123 | } 124 | 125 | return *this; 126 | } 127 | 128 | T* getData() const { return data; } 129 | const int getSize() { return length; } 130 | int getSize() const { return length; } 131 | 132 | void setData(T* newData, int newLength) { 133 | data = newData; 134 | length = newLength; 135 | } 136 | 137 | // Used for 138 | // for (T t : this) {} 139 | typedef T* iter; 140 | typedef const T* citer; 141 | 142 | iter begin() { return &data[0]; } 143 | citer begin() const { return &data[0]; } 144 | iter end() { return &data[length]; } 145 | citer end() const { return &data[length]; } 146 | 147 | private: 148 | T* data; 149 | int length; 150 | }; 151 | } -------------------------------------------------------------------------------- /include/minecraft/util/Other.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define GET_LR(valName) \ 6 | uint32_t valName; \ 7 | asm volatile("mflr %0" : "=r" (valName)); 8 | 9 | wchar_t* getNNID() { 10 | wchar_t* nnidAddr = ((wchar_t*) ((uint32_t) code::Mem(0x104CCB18).as() + 0x50)); // Miku666 11 | return nnidAddr; 12 | } 13 | 14 | wchar_t* getEffectName(int id) { 15 | const wchar_t* names[] = { 16 | L"NULL", L"Speed", L"Slowness", L"Haste", L"Mining Fatigue", L"Strength", L"Instant Health", L"Instant Damage", L"Jump Boost", 17 | L"Nausea", L"Regeneration", L"Resistance", L"Fire Resistance", L"Water Breathing", L"Invisibility", L"Blindness", L"Night Vision", 18 | L"Hunger", L"Weakness", L"Poison", L"Wither", L"Health Boost", L"Absorption", L"Saturation", L"Glowing", L"Levitation", L"Luck", 19 | L"Bad Luck" 20 | }; 21 | 22 | int size = sizeof(names) / sizeof(names[0]); 23 | if (id >= size) return (wchar_t*) L"NULL"; 24 | return (wchar_t*) names[id % size]; 25 | } 26 | 27 | void mc_wcscpy(const wchar_t* out, const wchar_t* in) { 28 | code::Func()(out, in); 29 | } 30 | 31 | int mc_wcslen(const wchar_t* in) { 32 | return code::Func()(in); 33 | } 34 | 35 | template 36 | static void mc_swprintf(const wchar_t* outputPointer, uint32_t size, const wchar_t* __format, Args... args) { 37 | code::Func()(outputPointer, size, __format, args...); 38 | } 39 | 40 | template 41 | static void mc_snprintf(const char* outputPointer, uint32_t size, const char* __format, Args... args) { 42 | code::Func()(outputPointer, size, __format, args...); 43 | } 44 | 45 | static float degToRad(float deg) { 46 | return (deg * M_PI / 180.0f); 47 | } 48 | 49 | static float radToDeg(float rad) { 50 | return (rad * 180.0f / M_PI); 51 | } 52 | 53 | char* wcharToChar(const wchar_t* str, int length = 0) { 54 | bool found = length != 0; 55 | while (!found) { 56 | if (str[length++] == 0x0) { 57 | found = true; 58 | length--; 59 | } 60 | if (length >= 250) return (char*) ""; 61 | } 62 | 63 | char* newStr = _new(length + 1); 64 | for (int i = 0; i < length; i++) { 65 | newStr[i] = str[i]; 66 | } 67 | 68 | newStr[length] = 0; 69 | return newStr; 70 | } 71 | 72 | wchar_t* charToWChar(const char* str, int length = 0) { 73 | bool found = length != 0; 74 | while (!found) { 75 | if (str[length++] == 0x0) { 76 | found = true; 77 | length--; 78 | } 79 | if (length >= 250) return (wchar_t*) L""; 80 | } 81 | 82 | wchar_t* newStr = _new(length + 1); 83 | for (int i = 0; i < length; i++) { 84 | newStr[i] = str[i]; 85 | } 86 | 87 | newStr[length] = 0; 88 | return newStr; 89 | } 90 | 91 | // https://stackoverflow.com/questions/2249110/how-do-i-make-a-portable-isnan-isinf-function 92 | int isinf(double x) { 93 | union { uint64_t u; double f; } ieee754; 94 | ieee754.f = x; 95 | return ((unsigned) (ieee754.u >> 32) & 0x7fffffff) == 0x7ff00000 && 96 | ((unsigned) ieee754.u == 0 ); 97 | } 98 | 99 | // https://stackoverflow.com/questions/2249110/how-do-i-make-a-portable-isnan-isinf-function 100 | int isnan(double x) { 101 | union { uint64_t u; double f; } ieee754; 102 | ieee754.f = x; 103 | return ((unsigned) (ieee754.u >> 32) & 0x7fffffff) + 104 | ((unsigned) ieee754.u != 0) > 0x7ff00000; 105 | } 106 | 107 | char* toCStr(float input, int decimalPlaces = 5) { 108 | uint32_t a0 = *(uint32_t*) &input; 109 | bool isNegative = (a0 & 0x80000000) == 0x80000000; 110 | if (isNegative) a0 -= 0x80000000; 111 | float a1 = *(float*) &a0; 112 | uint32_t multip = 1; 113 | for (int i = 0; i < decimalPlaces; i++) multip *= 10; 114 | uint32_t a = static_cast(a1 * mc::toFloat(multip)); 115 | uint32_t a_dec = a % multip; 116 | a = (a - a_dec) / multip; 117 | wchar_t strTemp[0x20]; 118 | if (isnan(input)) { 119 | mc_swprintf(strTemp, 0x20, L"NaN"); 120 | } else if (isinf(input)) { 121 | mc_swprintf(strTemp, 0x20, L"Inf"); 122 | } else if (isNegative) { 123 | wchar_t strTemp2[0x20]; 124 | mc_swprintf(strTemp2, 0x20, L"-%d.%s0%dd", a, "%", decimalPlaces); 125 | mc_swprintf(strTemp, 0x20, strTemp2, a_dec); 126 | } else { 127 | wchar_t strTemp2[0x20]; 128 | mc_swprintf(strTemp2, 0x20, L"%d.%s0%dd", a, "%", decimalPlaces); 129 | mc_swprintf(strTemp, 0x20, strTemp2, a_dec); 130 | } 131 | return wcharToChar(strTemp, 0x20); 132 | } -------------------------------------------------------------------------------- /include/minecraft/entity/player/ServerPlayer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Player.h" 6 | 7 | #include "../../client/resource/shared_ptr.h" 8 | 9 | namespace mc { 10 | // 03299F8C 11 | class ServerPlayer : public Player { 12 | public: 13 | void teleportTo(double _x, double _y, double _z) { 14 | code::Func()(this, _x, _y, _z); 15 | } 16 | 17 | void disconnect() { 18 | code::Func()(this); 19 | } 20 | 21 | static code::Func _tick; 22 | void tick() { 23 | _tick(this); 24 | } 25 | 26 | static code::Func _swing; 27 | void swing(InteractionHand::EInteractionHand hand) { 28 | _swing(this, hand); 29 | } 30 | 31 | static code::Func&> _attack; 32 | void attack(const mc_boost::shared_ptr& entity) { 33 | _attack(this, entity); 34 | } 35 | 36 | bool isSpectator() { 37 | return code::Func()(this); 38 | } 39 | 40 | bool isCreative() { 41 | return code::Func()(this); 42 | } 43 | 44 | void openContainer(const mc_boost::shared_ptr& cont) { 45 | code::Func&>()(this, cont); 46 | } 47 | 48 | void closeContainer() { 49 | code::Func()(this); 50 | } 51 | 52 | void openTextEdit(const mc_boost::shared_ptr& entity) { 53 | code::Func&>()(this, entity); 54 | } 55 | 56 | void giveExperienceLevels(int _level) { 57 | code::Func()(this, _level); 58 | } 59 | 60 | void setGameMode(const struct GameType* _type) { 61 | code::Func()(this, _type); 62 | } 63 | 64 | void refreshContainer(struct AbstractContainerMenu* _container) { 65 | code::Func()(this, _container); 66 | } 67 | 68 | void addEffect(struct MobEffectInstance* effect, const mc_boost::shared_ptr& entity) { 69 | code::Func&>()(this, effect, entity); 70 | } 71 | 72 | static uint64_t GetType() { 73 | return code::Func()(); 74 | } 75 | 76 | void startRiding(const mc_boost::shared_ptr& ent) { 77 | code::Func&>()(this, ent); 78 | } 79 | 80 | struct ServerPlayerGameMode* gamemode; 81 | struct ServerGamePacketListenerImpl* listener; 82 | uint32_t field_0x874; 83 | uint32_t field_0x878; 84 | uint32_t field_0x87C; 85 | uint32_t field_0x890; 86 | uint32_t field_0x894; 87 | uint32_t field_0x898; 88 | uint32_t field_0x89C; 89 | uint32_t field_0x8A0; 90 | uint32_t field_0x8A4; 91 | uint32_t field_0x8A8; 92 | uint32_t field_0x8AC; 93 | uint32_t field_0x8B0; 94 | uint32_t field_0x8B4; 95 | uint32_t field_0x8B8; 96 | uint32_t field_0x8BC; 97 | uint32_t field_0x8C0; 98 | uint32_t field_0x8C4; 99 | uint32_t field_0x8C8; 100 | uint32_t field_0x8CC; 101 | uint32_t field_0x8D0; 102 | uint32_t field_0x8D4; 103 | uint32_t field_0x8D8; 104 | uint32_t field_0x8DC; 105 | uint32_t field_0x8E0; 106 | uint32_t field_0x8E4; 107 | uint32_t field_0x8E8; 108 | uint32_t field_0x8EC; 109 | uint32_t field_0x8F0; 110 | uint32_t field_0x8F4; 111 | uint32_t field_0x8F8; 112 | uint32_t field_0x8FC; 113 | uint32_t field_0x900; // Send Update Packet??? 114 | uint32_t field_0x904; 115 | uint32_t field_0x908; 116 | uint32_t field_0x90C; 117 | uint32_t field_0x910; 118 | uint32_t field_0x914; 119 | uint32_t field_0x918; 120 | uint32_t field_0x91C; 121 | uint32_t field_0x920; 122 | uint32_t field_0x924; 123 | uint32_t field_0x928; 124 | uint32_t field_0x92C; 125 | uint32_t field_0x930; 126 | uint32_t field_0x934; 127 | uint32_t field_0x938; 128 | uint32_t field_0x93C; 129 | uint32_t field_0x940; 130 | uint32_t field_0x944; 131 | }; 132 | } --------------------------------------------------------------------------------