From 2a683c19e41aefa3331cc6fc2b03779aa9a822a2 Mon Sep 17 00:00:00 2001 From: ethxn <163630159+ethxnblxd@users.noreply.github.com> Date: Thu, 19 Mar 2026 19:25:51 +0800 Subject: [PATCH 01/12] Add files via upload --- Minecraft.Client/ChatScreen.cpp | 96 +++++++++++++++++++++++++++----- Minecraft.Client/Minecraft.cpp | 99 +++++++++++++++++++++++++++++---- 2 files changed, 169 insertions(+), 26 deletions(-) diff --git a/Minecraft.Client/ChatScreen.cpp b/Minecraft.Client/ChatScreen.cpp index 53c9072242..af0071d033 100644 --- a/Minecraft.Client/ChatScreen.cpp +++ b/Minecraft.Client/ChatScreen.cpp @@ -6,6 +6,7 @@ #include "..\Minecraft.World\SharedConstants.h" #include "..\Minecraft.World\StringHelpers.h" #include "..\Minecraft.World\ChatPacket.h" +#include "Windows64\KeyboardMouseInput.h" const wstring ChatScreen::allowedChars = SharedConstants::acceptableLetters; vector ChatScreen::s_chatHistory; @@ -85,24 +86,27 @@ void ChatScreen::handleHistoryDown() void ChatScreen::keyPressed(wchar_t ch, int eventKey) { + if (eventKey == Keyboard::KEY_ESCAPE) - { + { minecraft->setScreen(nullptr); return; } + if (eventKey == Keyboard::KEY_RETURN) - { + { wstring trim = trimString(message); - if (trim.length() > 0) - { + if (!trim.empty()) + { if (!minecraft->handleClientSideCommand(trim)) - { + { MultiplayerLocalPlayer* mplp = dynamic_cast(minecraft->player.get()); if (mplp && mplp->connection) mplp->connection->send(shared_ptr(new ChatPacket(trim))); } + if (s_chatHistory.empty() || s_chatHistory.back() != trim) - { + { s_chatHistory.push_back(trim); if (s_chatHistory.size() > CHAT_HISTORY_MAX) s_chatHistory.erase(s_chatHistory.begin()); @@ -111,33 +115,97 @@ void ChatScreen::keyPressed(wchar_t ch, int eventKey) minecraft->setScreen(nullptr); return; } + if (eventKey == Keyboard::KEY_UP) { handleHistoryUp(); return; } if (eventKey == Keyboard::KEY_DOWN) { handleHistoryDown(); return; } + if (eventKey == Keyboard::KEY_LEFT) - { - if (cursorIndex > 0) + { + if (g_KBMInput.IsKeyDown(VK_CONTROL)) + { + // move left by word + while (cursorIndex > 0 && iswspace(message[cursorIndex - 1])) cursorIndex--; + while (cursorIndex > 0 && !iswspace(message[cursorIndex - 1])) cursorIndex--; + } + else if (cursorIndex > 0) + { cursorIndex--; + } return; } + if (eventKey == Keyboard::KEY_RIGHT) - { - if (cursorIndex < static_cast(message.length())) + { + int len = static_cast(message.length()); + if (g_KBMInput.IsKeyDown(VK_CONTROL)) + { + // move right by word + while (cursorIndex < len && !iswspace(message[cursorIndex])) cursorIndex++; + while (cursorIndex < len && iswspace(message[cursorIndex])) cursorIndex++; + } + else if (cursorIndex < len) + { cursorIndex++; + } return; } + + // NEEDS IMPLEMENTING (CTRL + BACKSPACE TO DELETE WORD) + if (eventKey == Keyboard::KEY_BACK && cursorIndex > 0) - { - message.erase(cursorIndex - 1, 1); - cursorIndex--; + { + if (g_KBMInput.IsKeyDown(VK_CONTROL)) + { + return; + } + else + { + message.erase(cursorIndex - 1, 1); + cursorIndex--; + return; + } + + } + + // NEEDS IMPLEMENTING (CTRL + A TO SELECT ALL) + + if (g_KBMInput.IsKeyDown(VK_CONTROL) && g_KBMInput.IsKeyPressed('A')) + { return; } + + // NEEDS IMPLEMENTING (SHIFT + LEFT ARROW TO SELECT CHARACTER) + + if (g_KBMInput.IsKeyDown(VK_SHIFT) && g_KBMInput.IsKeyPressed(VK_LEFT)) + { + return; + } + + // NEEDS IMPLEMENTING (SHIFT + RIGHT ARROW TO SELECT CHARACTER) + + if (g_KBMInput.IsKeyDown(VK_SHIFT) && g_KBMInput.IsKeyPressed(VK_RIGHT)) + { + return; + } + + // NEEDS IMPLEMENTING (TAB TO AUTOFILL USERNAMES e.g( et > TAB > ethxnblxd )) + // if theres multiple usernames then make a gui above the chat window and cycle through them by using tab) + + if (eventKey == Keyboard::KEY_TAB) // NEEDS FIXING OPENS PLAYERLIST IN CHAT WINDOW + { + return; + } + if (isAllowedChatChar(ch) && static_cast(message.length()) < SharedConstants::maxChatLength) - { + { message.insert(cursorIndex, 1, ch); cursorIndex++; } } + +// NEEDS IMPLEMENTING (BLUE CHARACTER SELECTION RENDERING) + void ChatScreen::render(int xm, int ym, float a) { fill(2, height - 14, width - 2, height - 2, 0x80000000); diff --git a/Minecraft.Client/Minecraft.cpp b/Minecraft.Client/Minecraft.cpp index 1ba432fd04..e0f327155d 100644 --- a/Minecraft.Client/Minecraft.cpp +++ b/Minecraft.Client/Minecraft.cpp @@ -36,6 +36,8 @@ #include "FrustumCuller.h" #include "Camera.h" +#include "chrono" + #include "..\Minecraft.World\MobEffect.h" #include "..\Minecraft.World\Difficulty.h" #include "..\Minecraft.World\net.minecraft.world.level.h" @@ -1509,10 +1511,42 @@ void Minecraft::run_middle() } } - if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_DROP)) - localplayers[i]->ullButtonsPressed|=1LL<ullButtonsPressed |= 1LL << MINECRAFT_ACTION_DROPALL; + } + + else if (down) + // CHANGED FROM IsKeyPressed SO YOU CAN HOLD TO DROP (after 0.3 sec delay). + { + auto now = std::chrono::steady_clock::now(); + + if (!wasDown) + { + // first press + localplayers[i]->ullButtonsPressed |= 1LL << MINECRAFT_ACTION_DROP; + pressTime = now; + } + else + { + float held = std::chrono::duration(now - pressTime).count(); + + if (held > 0.3f) + { + localplayers[i]->ullButtonsPressed |= 1LL << MINECRAFT_ACTION_DROP; + } + } + } + + wasDown = down; - if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_CRAFTING) || g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_CRAFTING_ALT)) + if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_CRAFTING)) { if((ui.IsSceneInStack(i, eUIScene_Crafting2x2Menu) || ui.IsSceneInStack(i, eUIScene_Crafting3x3Menu) || ui.IsSceneInStack(i, eUIScene_CreativeMenu) || isClosableByEitherKey) && !isEditing) { @@ -1524,18 +1558,27 @@ void Minecraft::run_middle() } } - for (int slot = 0; slot < 9; slot++) + // PREVENTS SWITCHING HOTBAR SLOTS WHEN IN MENUS + + if (!ui.GetMenuDisplayed(0)) { - if (g_KBMInput.IsKeyPressed('1' + slot)) + for (int slot = 0; slot < 9; slot++) { - if (localplayers[i]->inventory) - localplayers[i]->inventory->selected = slot; + if (g_KBMInput.IsKeyPressed('1' + slot)) + { + if (localplayers[i]->inventory) + localplayers[i]->inventory->selected = slot; + } } } + } + // Utility keys always work regardless of KBM active state - if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_PAUSE) && !ui.GetMenuDisplayed(i)) + Minecraft* pMinecraft = Minecraft::GetInstance(); + + if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_PAUSE) && !ui.GetMenuDisplayed(i) && pMinecraft->screen == NULL) { localplayers[i]->ullButtonsPressed|=1LL<ullButtonsPressed&(1LL<isInputAllowed(MINECRAFT_ACTION_INVENTORY)) { shared_ptr player = Minecraft::GetInstance()->player; - if (!player->isRiding()) - { - ui.PlayUISFX(eSFX_Press); - } + ui.PlayUISFX(eSFX_Press); if(gameMode->isServerControlledInventory()) { @@ -3805,6 +3875,11 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) player->drop(); } + if((player->ullButtonsPressed&(1LL<isInputAllowed(MINECRAFT_ACTION_DROPALL)) + { + player->dropall(); + } + uint64_t ullButtonsPressed=player->ullButtonsPressed; bool selected = false; From 7f7afda1cbd808a2b066a6831dd9e61038c800c7 Mon Sep 17 00:00:00 2001 From: ethxn <163630159+ethxnblxd@users.noreply.github.com> Date: Thu, 19 Mar 2026 19:26:21 +0800 Subject: [PATCH 02/12] Add files via upload --- Minecraft.Client/Windows64/Windows64_Minecraft.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp index 81430ffcc7..bc65929ec5 100644 --- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp +++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp @@ -1802,7 +1802,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, } // TAB opens game info menu. - Vvis :3 - Updated by detectiveren - if (g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_HOST_SETTINGS) && !ui.GetMenuDisplayed(0)) + if (g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_HOST_SETTINGS) && !ui.GetMenuDisplayed(0) && pMinecraft->screen == NULL) { if (Minecraft* pMinecraft = Minecraft::GetInstance()) { @@ -1821,6 +1821,14 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, SetFocus(g_hWnd); } + else if (g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_SLASHCOMMANDCHAT) && app.GetGameStarted() && !ui.GetMenuDisplayed(0) && pMinecraft->screen == NULL) + // Needs to set the message with "/" when pressed. + { + g_KBMInput.ClearCharBuffer(); + pMinecraft->setScreen(new ChatScreen()); + SetFocus(g_hWnd); + } + #if 0 // has the game defined profile data been changed (by a profile load) if(app.uiGameDefinedDataChangedBitmask!=0) From 5b9a3779dc521e8e74b9ad1663befbfdf687cf90 Mon Sep 17 00:00:00 2001 From: ethxn <163630159+ethxnblxd@users.noreply.github.com> Date: Thu, 19 Mar 2026 19:27:19 +0800 Subject: [PATCH 03/12] Add files via upload --- Minecraft.Client/Windows64/Player.h | 559 ++++++++++++++++++++++++++++ 1 file changed, 559 insertions(+) create mode 100644 Minecraft.Client/Windows64/Player.h diff --git a/Minecraft.Client/Windows64/Player.h b/Minecraft.Client/Windows64/Player.h new file mode 100644 index 0000000000..8372bc036a --- /dev/null +++ b/Minecraft.Client/Windows64/Player.h @@ -0,0 +1,559 @@ +#pragma once +using namespace std; + +#include "LivingEntity.h" +#include "Definitions.h" +#include "Abilities.h" +#include "FoodData.h" +#include "PlayerEnderChestContainer.h" +#include "CommandSender.h" +#include "ScoreHolder.h" + +class AbstractContainerMenu; +class Stats; +class FishingHook; +class EntityHorse; +class ItemEntity; +class Slot; +class Pos; +class TileEntity; +class BeaconTileEntity; +class FurnaceTileEntity; +class DispenserTileEntity; +class SignTileEntity; +class BrewingStandTileEntity; +class HopperTileEntity; +class MinecartHopper; +class Inventory; +class Container; +class FoodData; +class DamageSource; +class Merchant; +class PlayerEnderChestContainer; +class GameType; +class Scoreboard; + +class Player : public LivingEntity, public CommandSender, public ScoreHolder +{ +public: + static const int MAX_NAME_LENGTH = 16 + 4; + static const int MAX_HEALTH = 20; + static const int SLEEP_DURATION = 100; + static const int WAKE_UP_DURATION = 10; + + static const int CHAT_VISIBILITY_FULL = 0; + static const int CHAT_VISIBILITY_SYSTEM = 1; + static const int CHAT_VISIBILITY_HIDDEN = 2; + + // 4J-PB - added for a red death fade in the gui + static const int DEATHFADE_DURATION = 21; +private: + static const int FLY_ACHIEVEMENT_SPEED = 25; + + static const int DATA_PLAYER_FLAGS_ID = 16; + static const int DATA_PLAYER_ABSORPTION_ID = 17; + static const int DATA_SCORE_ID = 18; + +protected: + static const int FLAG_HIDE_CAPE = 1; + +public: + shared_ptr inventory; + +private: + shared_ptr enderChestInventory; + +public: + AbstractContainerMenu *inventoryMenu; + AbstractContainerMenu *containerMenu; + +protected: + FoodData foodData; + int jumpTriggerTime; + +public: + BYTE userType; + float oBob, bob; + + wstring name; + int takeXpDelay; + + // 4J-PB - track custom skin + wstring customTextureUrl; + wstring customTextureUrl2; + unsigned int m_uiPlayerCurrentSkin; + void ChangePlayerSkin(); + + // 4J-PB - not needed, since cutomtextureurl2 is the same thing wstring cloakTexture; + + double xCloakO, yCloakO, zCloakO; + double xCloak, yCloak, zCloak; + + // 4J-HG: store display name, added for Xbox One "game display name" + wstring m_displayName; + +protected: + // player sleeping in bed? + bool m_isSleeping; + +public: + Pos *bedPosition; + +private: + int sleepCounter; // animation timer + int deathFadeCounter; // animation timer + +public: + float bedOffsetX, bedOffsetY, bedOffsetZ; + Stats *stats; + +private: + Pos *respawnPosition; + bool respawnForced; + Pos *minecartAchievementPos; + + //4J Gordon: These are in cms, every time they go > 1m they are entered into the stats + int distanceWalk, distanceSwim, distanceFall, distanceClimb, distanceMinecart, distanceBoat, distancePig; + +public: + Abilities abilities; + + int experienceLevel, totalExperience; + float experienceProgress; + + // 4J Stu - Made protected so that we can access it from MultiPlayerLocalPlayer +protected: + shared_ptr useItem; + int useItemDuration; + +protected: + float defaultWalkSpeed; + float defaultFlySpeed; + +private: + int lastLevelUpTime; + +public: + + eINSTANCEOF GetType() { return eTYPE_PLAYER; } + + // 4J Added to default init + void _init(); + + Player(Level *level, const wstring &name); + virtual ~Player(); + +protected: + virtual void registerAttributes(); + virtual void defineSynchedData(); + +public: + shared_ptr getUseItem(); + int getUseItemDuration(); + bool isUsingItem(); int getTicksUsingItem(); + void releaseUsingItem(); + void stopUsingItem(); + virtual bool isBlocking(); + + // 4J Stu - Added for things that should only be ticked once per simulation frame + virtual void updateFrameTick(); + + virtual void tick(); + virtual int getPortalWaitTime(); + virtual int getDimensionChangingDelay(); + virtual void playSound(int iSound, float volume, float pitch); + +protected: + void spawnEatParticles(shared_ptr useItem, int count); + virtual void completeUsingItem(); + +public: + virtual void handleEntityEvent(byte id); + +protected: + bool isImmobile(); + virtual void closeContainer(); + +public: + virtual void ride(shared_ptr e); + void prepareCustomTextures(); + virtual void rideTick(); + virtual void resetPos(); + +protected: + virtual void serverAiStep(); + +public: + virtual void aiStep(); + +private: + virtual void touch(shared_ptr entity); + +public: + virtual int getScore(); + virtual void setScore(int value); + virtual void increaseScore(int amount); + virtual void die(DamageSource *source); + virtual void awardKillScore(shared_ptr victim, int awardPoints); + virtual bool isShootable(); + bool isCreativeModeAllowed(); + virtual shared_ptr drop(bool all); + shared_ptr drop(shared_ptr item); + shared_ptr drop(shared_ptr item, bool randomly); + + virtual shared_ptr dropall(bool all); + shared_ptr dropall(shared_ptr item); + shared_ptr dropall(shared_ptr item, bool randomly); +protected: + virtual void reallyDrop(shared_ptr thrownItem); + +public: + float getDestroySpeed(Tile *tile, bool hasProperTool); + bool canDestroy(Tile *tile); + virtual void readAdditionalSaveData(CompoundTag *entityTag); + virtual void addAdditonalSaveData(CompoundTag *entityTag); + virtual bool openContainer(shared_ptr container); // 4J - added bool return + virtual bool openHopper(shared_ptr container); + virtual bool openHopper(shared_ptr container); + virtual bool openHorseInventory(shared_ptr horse, shared_ptr container); + virtual bool startEnchanting(int x, int y, int z, const wstring &name); // 4J - added bool return + virtual bool startRepairing(int x, int y, int z); // 4J - added bool return + virtual bool startCrafting(int x, int y, int z); // 4J - added bool return + virtual bool openFireworks(int x, int y, int z); // 4J - added + virtual float getHeadHeight(); + + // 4J-PB - added to keep the code happy with the change to make the third person view per player + virtual int ThirdPersonView() {return 0;} + virtual void SetThirdPersonView(int val) {} + +protected: + virtual void setDefaultHeadHeight(); + +public: + shared_ptr fishing; + + virtual bool hurt(DamageSource *source, float dmg); + virtual bool canHarmPlayer(shared_ptr target); + virtual bool canHarmPlayer(wstring targetName); // 4J: Added for ServerPlayer when only player name is provided + +protected: + virtual void hurtArmor(float damage); + +public: + virtual int getArmorValue(); + virtual float getArmorCoverPercentage(); + +protected: + virtual void actuallyHurt(DamageSource *source, float dmg); + +public: + using Entity::interact; + + virtual bool openFurnace(shared_ptr container); // 4J - added bool return + virtual bool openTrap(shared_ptr container); // 4J - added bool return + virtual void openTextEdit(shared_ptr sign); + virtual bool openBrewingStand(shared_ptr brewingStand); // 4J - added bool return + virtual bool openBeacon(shared_ptr beacon); + virtual bool openTrading(shared_ptr traderTarget, const wstring &name); // 4J - added bool return + virtual void openItemInstanceGui(shared_ptr itemInstance); + virtual bool interact(shared_ptr entity); + virtual shared_ptr getSelectedItem(); + void removeSelectedItem(); + virtual double getRidingHeight(); + virtual void attack(shared_ptr entity); + virtual void crit(shared_ptr entity); + virtual void magicCrit(shared_ptr entity); + virtual void respawn(); + +protected: + static void animateRespawn(shared_ptr player, Level *level); + +public: + Slot *getInventorySlot(int slotId); + virtual void remove(); + virtual bool isInWall(); + virtual bool isLocalPlayer(); + + enum BedSleepingResult + { + OK, NOT_POSSIBLE_HERE, NOT_POSSIBLE_NOW, TOO_FAR_AWAY, OTHER_PROBLEM, NOT_SAFE + }; + + virtual BedSleepingResult startSleepInBed(int x, int y, int z, bool bTestUse = false); + +private: + void setBedOffset(int bedDirection); + +public: + /** + * + * @param forcefulWakeUp + * If the player has been forced to wake up. When this happens, + * the client will skip the wake-up animation. For example, when + * the player is hurt or the bed is destroyed. + * @param updateLevelList + * If the level's sleeping player list needs to be updated. This + * is usually the case. + * @param saveRespawnPoint + * TODO + */ + virtual void stopSleepInBed(bool forcefulWakeUp, bool updateLevelList, bool saveRespawnPoint); + +private: + bool checkBed(); + +public: + static Pos *checkBedValidRespawnPosition(Level *level, Pos *pos, bool forced); + float getSleepRotation(); + bool isSleeping(); + bool isSleepingLongEnough(); + int getSleepTimer(); + int getDeathFadeTimer(); + +protected: + bool getPlayerFlag(int flag); + void setPlayerFlag(int flag, bool value); + +public: + /** + * This method is currently only relevant to client-side players. It will + * try to load the messageId from the language file and display it to the + * client. + */ + virtual void displayClientMessage(int messageId); + virtual Pos *getRespawnPosition(); + virtual bool isRespawnForced(); + virtual void setRespawnPosition(Pos *respawnPosition, bool forced); + virtual void awardStat(Stat *stat, byteArray param); + +protected: + void jumpFromGround(); + +public: + virtual void travel(float xa, float ya); + virtual float getSpeed(); + virtual void checkMovementStatistiscs(double dx, double dy, double dz); + +private: + void checkRidingStatistiscs(double dx, double dy, double dz); + + bool m_bAwardedOnARail; + +protected: + virtual void causeFallDamage(float distance); + +public: + virtual void killed(shared_ptr mob); + virtual void makeStuckInWeb(); + virtual Icon *getItemInHandIcon(shared_ptr item, int layer); + virtual shared_ptr getArmor(int pos); + virtual void increaseXp(int i); + virtual void giveExperienceLevels(int amount); + int getXpNeededForNextLevel(); + void causeFoodExhaustion(float amount); + FoodData *getFoodData(); + bool canEat(bool magicalItem); + bool isHurt(); + virtual void startUsingItem(shared_ptr instance, int duration); + virtual bool mayDestroyBlockAt(int x, int y, int z); + virtual bool mayUseItemAt(int x, int y, int z, int face, shared_ptr item); + +protected: + virtual int getExperienceReward(shared_ptr killedBy); + virtual bool isAlwaysExperienceDropper(); + +public: + virtual wstring getAName(); + virtual bool shouldShowName(); + virtual void restoreFrom(shared_ptr oldPlayer, bool restoreAll); + +protected: + bool makeStepSound(); + +public: + void onUpdateAbilities(); + void setGameMode(GameType *mode); + wstring getName(); + virtual wstring getDisplayName(); + virtual wstring getNetworkName(); // 4J: Added + + virtual Level *getCommandSenderWorld(); + + shared_ptr getEnderChestInventory(); + + virtual shared_ptr getCarried(int slot); + virtual shared_ptr getCarriedItem(); + virtual void setEquippedSlot(int slot, shared_ptr item); + virtual bool isInvisibleTo(shared_ptr player); + virtual ItemInstanceArray getEquipmentSlots(); + virtual bool isCapeHidden(); + virtual bool isPushedByWater(); + virtual Scoreboard *getScoreboard(); + virtual Team *getTeam(); + virtual void setAbsorptionAmount(float absorptionAmount); + virtual float getAbsorptionAmount(); + + //////// 4J ///////////////// + + static int hash_fnct(const shared_ptr k); + static bool eq_test(const shared_ptr x, const shared_ptr y); + + // 4J Stu - Added to allow callback to tutorial to stay within Minecraft.Client + // Overidden in LocalPlayer + virtual void onCrafted(shared_ptr item) {} + + // 4J Overriding this so that we can have some different default skins + virtual int getTexture(); // 4J changed from wstring to int + void setPlayerDefaultSkin(EDefaultSkins skin); + EDefaultSkins getPlayerDefaultSkin() { return m_skinIndex; } + virtual void setCustomSkin(DWORD skinId); + DWORD getCustomSkin() {return m_dwSkinId; } + virtual void setCustomCape(DWORD capeId); + DWORD getCustomCape() {return m_dwCapeId; } + + static DWORD getCapeIdFromPath(const wstring &cape); + static wstring getCapePathFromId(DWORD capeId); + static unsigned int getSkinAnimOverrideBitmask(DWORD skinId); + + // 4J Added + void setXuid(PlayerUID xuid); + PlayerUID getXuid() { return m_xuid; } + void setOnlineXuid(PlayerUID xuid) { m_OnlineXuid = xuid; } + PlayerUID getOnlineXuid() { return m_OnlineXuid; } + + void setPlayerIndex(DWORD dwIndex) { m_playerIndex = dwIndex; } + DWORD getPlayerIndex() { return m_playerIndex; } + + void setIsGuest(bool bVal) { m_bIsGuest = bVal; } + bool isGuest() { return m_bIsGuest; } + + void setShowOnMaps(bool bVal) { m_bShownOnMaps = bVal; } + bool canShowOnMaps() { return m_bShownOnMaps && !getPlayerGamePrivilege(ePlayerGamePrivilege_Invisible); } + + virtual void sendMessage(const wstring& message, ChatPacket::EChatPacketMessage type = ChatPacket::e_ChatCustom, int customData = -1, const wstring& additionalMessage = L"") { } +private: + PlayerUID m_xuid; + PlayerUID m_OnlineXuid; + +protected: + bool m_bShownOnMaps; + + bool m_bIsGuest; + +private: + EDefaultSkins m_skinIndex; + DWORD m_dwSkinId,m_dwCapeId; + + // 4J Added - Used to show which colour the player is on the map/behind their name + DWORD m_playerIndex; + + // 4J-PB - to track debug options from the server player + unsigned int m_uiDebugOptions; + +public: + void SetDebugOptions(unsigned int uiVal) { m_uiDebugOptions=uiVal;} + unsigned int GetDebugOptions(void) { return m_uiDebugOptions;} + + void StopSleeping() {} + +public: + // If you add things here, you should also add a message to ClientConnection::displayPrivilegeChanges to alert players to changes + enum EPlayerGamePrivileges + { + ePlayerGamePrivilege_CannotMine = 0, // Only checked if trust system is on + ePlayerGamePrivilege_CannotBuild, // Only checked if trust system is on + ePlayerGamePrivilege_CannotAttackMobs, // Only checked if trust system is on + ePlayerGamePrivilege_CannotAttackPlayers, //Only checked if trust system is on + ePlayerGamePrivilege_Op, + ePlayerGamePrivilege_CanFly, + ePlayerGamePrivilege_ClassicHunger, + ePlayerGamePrivilege_Invisible, + ePlayerGamePrivilege_Invulnerable, + + ePlayerGamePrivilege_CreativeMode, // Used only to transfer across network, should never be used to determine if a player is in creative mode + + ePlayerGamePrivilege_CannotAttackAnimals, // Only checked if trust system is on + ePlayerGamePrivilege_CanUseDoorsAndSwitches, // Only checked if trust system is on + ePlayerGamePrivilege_CanUseContainers, // Only checked if trust system is on + + ePlayerGamePrivilege_CanToggleInvisible, + ePlayerGamePrivilege_CanToggleFly, + ePlayerGamePrivilege_CanToggleClassicHunger, + ePlayerGamePrivilege_CanTeleport, + + // Currently enum is used to bitshift into an unsigned int + ePlayerGamePrivilege_MAX = 32, + ePlayerGamePrivilege_All = 33, + ePlayerGamePrivilege_HOST, + }; +private: + // 4J Added - Used to track what actions players have been allowed to perform by the host + unsigned int m_uiGamePrivileges; + + unsigned int getPlayerGamePrivilege(EPlayerGamePrivileges privilege); +public: + unsigned int getAllPlayerGamePrivileges() { return getPlayerGamePrivilege(ePlayerGamePrivilege_All); } + + static unsigned int getPlayerGamePrivilege(unsigned int uiGamePrivileges, EPlayerGamePrivileges privilege); + void setPlayerGamePrivilege(EPlayerGamePrivileges privilege, unsigned int value); + static void setPlayerGamePrivilege(unsigned int &uiGamePrivileges, EPlayerGamePrivileges privilege, unsigned int value); + + bool isAllowedToUse(Tile *tile); + bool isAllowedToUse(shared_ptr item); + bool isAllowedToInteract(shared_ptr target); + bool isAllowedToMine(); + bool isAllowedToAttackPlayers(); + bool isAllowedToAttackAnimals(); + bool isAllowedToHurtEntity(shared_ptr target); + bool isAllowedToFly(); + bool isAllowedToIgnoreExhaustion(); + bool isAllowedToTeleport(); + bool hasInvisiblePrivilege(); + bool hasInvulnerablePrivilege(); + bool isModerator(); + + static void enableAllPlayerPrivileges(unsigned int &uigamePrivileges, bool enable); + void enableAllPlayerPrivileges(bool enable); + + virtual bool canCreateParticles(); + +public: + // 4J Stu - Added hooks for the game rules + virtual void handleCollectItem(shared_ptr item) {} + + vector *GetAdditionalModelParts(); + void SetAdditionalModelParts(vector *ppAdditionalModelParts); + +#if defined(__PS3__) || defined(__ORBIS__) + enum ePlayerNameValidState + { + ePlayerNameValid_NotSet=0, + ePlayerNameValid_True, + ePlayerNameValid_False + }; + + ePlayerNameValidState GetPlayerNameValidState(); + void SetPlayerNameValidState(bool bState); +#endif +private: + vector *m_ppAdditionalModelParts; + bool m_bCheckedForModelParts; + bool m_bCheckedDLCForModelParts; + +#if defined(__PS3__) || defined(__ORBIS__) + ePlayerNameValidState m_ePlayerNameValidState; // 4J-PB - to ensure we have the characters for this name in our font, or display a player number instead +#endif +}; + +struct PlayerKeyHash +{ + inline int operator() (const shared_ptr k) const + { return Player::hash_fnct (k); } +}; + +struct PlayerKeyEq +{ + inline bool operator() (const shared_ptr x, const shared_ptr y) const + { return Player::eq_test (x, y); } +}; + From 92999fa267aadabe092be97e464c8b3b9e6d7df8 Mon Sep 17 00:00:00 2001 From: ethxn <163630159+ethxnblxd@users.noreply.github.com> Date: Thu, 19 Mar 2026 19:27:47 +0800 Subject: [PATCH 04/12] Delete Minecraft.Client/Windows64/Player.h --- Minecraft.Client/Windows64/Player.h | 559 ---------------------------- 1 file changed, 559 deletions(-) delete mode 100644 Minecraft.Client/Windows64/Player.h diff --git a/Minecraft.Client/Windows64/Player.h b/Minecraft.Client/Windows64/Player.h deleted file mode 100644 index 8372bc036a..0000000000 --- a/Minecraft.Client/Windows64/Player.h +++ /dev/null @@ -1,559 +0,0 @@ -#pragma once -using namespace std; - -#include "LivingEntity.h" -#include "Definitions.h" -#include "Abilities.h" -#include "FoodData.h" -#include "PlayerEnderChestContainer.h" -#include "CommandSender.h" -#include "ScoreHolder.h" - -class AbstractContainerMenu; -class Stats; -class FishingHook; -class EntityHorse; -class ItemEntity; -class Slot; -class Pos; -class TileEntity; -class BeaconTileEntity; -class FurnaceTileEntity; -class DispenserTileEntity; -class SignTileEntity; -class BrewingStandTileEntity; -class HopperTileEntity; -class MinecartHopper; -class Inventory; -class Container; -class FoodData; -class DamageSource; -class Merchant; -class PlayerEnderChestContainer; -class GameType; -class Scoreboard; - -class Player : public LivingEntity, public CommandSender, public ScoreHolder -{ -public: - static const int MAX_NAME_LENGTH = 16 + 4; - static const int MAX_HEALTH = 20; - static const int SLEEP_DURATION = 100; - static const int WAKE_UP_DURATION = 10; - - static const int CHAT_VISIBILITY_FULL = 0; - static const int CHAT_VISIBILITY_SYSTEM = 1; - static const int CHAT_VISIBILITY_HIDDEN = 2; - - // 4J-PB - added for a red death fade in the gui - static const int DEATHFADE_DURATION = 21; -private: - static const int FLY_ACHIEVEMENT_SPEED = 25; - - static const int DATA_PLAYER_FLAGS_ID = 16; - static const int DATA_PLAYER_ABSORPTION_ID = 17; - static const int DATA_SCORE_ID = 18; - -protected: - static const int FLAG_HIDE_CAPE = 1; - -public: - shared_ptr inventory; - -private: - shared_ptr enderChestInventory; - -public: - AbstractContainerMenu *inventoryMenu; - AbstractContainerMenu *containerMenu; - -protected: - FoodData foodData; - int jumpTriggerTime; - -public: - BYTE userType; - float oBob, bob; - - wstring name; - int takeXpDelay; - - // 4J-PB - track custom skin - wstring customTextureUrl; - wstring customTextureUrl2; - unsigned int m_uiPlayerCurrentSkin; - void ChangePlayerSkin(); - - // 4J-PB - not needed, since cutomtextureurl2 is the same thing wstring cloakTexture; - - double xCloakO, yCloakO, zCloakO; - double xCloak, yCloak, zCloak; - - // 4J-HG: store display name, added for Xbox One "game display name" - wstring m_displayName; - -protected: - // player sleeping in bed? - bool m_isSleeping; - -public: - Pos *bedPosition; - -private: - int sleepCounter; // animation timer - int deathFadeCounter; // animation timer - -public: - float bedOffsetX, bedOffsetY, bedOffsetZ; - Stats *stats; - -private: - Pos *respawnPosition; - bool respawnForced; - Pos *minecartAchievementPos; - - //4J Gordon: These are in cms, every time they go > 1m they are entered into the stats - int distanceWalk, distanceSwim, distanceFall, distanceClimb, distanceMinecart, distanceBoat, distancePig; - -public: - Abilities abilities; - - int experienceLevel, totalExperience; - float experienceProgress; - - // 4J Stu - Made protected so that we can access it from MultiPlayerLocalPlayer -protected: - shared_ptr useItem; - int useItemDuration; - -protected: - float defaultWalkSpeed; - float defaultFlySpeed; - -private: - int lastLevelUpTime; - -public: - - eINSTANCEOF GetType() { return eTYPE_PLAYER; } - - // 4J Added to default init - void _init(); - - Player(Level *level, const wstring &name); - virtual ~Player(); - -protected: - virtual void registerAttributes(); - virtual void defineSynchedData(); - -public: - shared_ptr getUseItem(); - int getUseItemDuration(); - bool isUsingItem(); int getTicksUsingItem(); - void releaseUsingItem(); - void stopUsingItem(); - virtual bool isBlocking(); - - // 4J Stu - Added for things that should only be ticked once per simulation frame - virtual void updateFrameTick(); - - virtual void tick(); - virtual int getPortalWaitTime(); - virtual int getDimensionChangingDelay(); - virtual void playSound(int iSound, float volume, float pitch); - -protected: - void spawnEatParticles(shared_ptr useItem, int count); - virtual void completeUsingItem(); - -public: - virtual void handleEntityEvent(byte id); - -protected: - bool isImmobile(); - virtual void closeContainer(); - -public: - virtual void ride(shared_ptr e); - void prepareCustomTextures(); - virtual void rideTick(); - virtual void resetPos(); - -protected: - virtual void serverAiStep(); - -public: - virtual void aiStep(); - -private: - virtual void touch(shared_ptr entity); - -public: - virtual int getScore(); - virtual void setScore(int value); - virtual void increaseScore(int amount); - virtual void die(DamageSource *source); - virtual void awardKillScore(shared_ptr victim, int awardPoints); - virtual bool isShootable(); - bool isCreativeModeAllowed(); - virtual shared_ptr drop(bool all); - shared_ptr drop(shared_ptr item); - shared_ptr drop(shared_ptr item, bool randomly); - - virtual shared_ptr dropall(bool all); - shared_ptr dropall(shared_ptr item); - shared_ptr dropall(shared_ptr item, bool randomly); -protected: - virtual void reallyDrop(shared_ptr thrownItem); - -public: - float getDestroySpeed(Tile *tile, bool hasProperTool); - bool canDestroy(Tile *tile); - virtual void readAdditionalSaveData(CompoundTag *entityTag); - virtual void addAdditonalSaveData(CompoundTag *entityTag); - virtual bool openContainer(shared_ptr container); // 4J - added bool return - virtual bool openHopper(shared_ptr container); - virtual bool openHopper(shared_ptr container); - virtual bool openHorseInventory(shared_ptr horse, shared_ptr container); - virtual bool startEnchanting(int x, int y, int z, const wstring &name); // 4J - added bool return - virtual bool startRepairing(int x, int y, int z); // 4J - added bool return - virtual bool startCrafting(int x, int y, int z); // 4J - added bool return - virtual bool openFireworks(int x, int y, int z); // 4J - added - virtual float getHeadHeight(); - - // 4J-PB - added to keep the code happy with the change to make the third person view per player - virtual int ThirdPersonView() {return 0;} - virtual void SetThirdPersonView(int val) {} - -protected: - virtual void setDefaultHeadHeight(); - -public: - shared_ptr fishing; - - virtual bool hurt(DamageSource *source, float dmg); - virtual bool canHarmPlayer(shared_ptr target); - virtual bool canHarmPlayer(wstring targetName); // 4J: Added for ServerPlayer when only player name is provided - -protected: - virtual void hurtArmor(float damage); - -public: - virtual int getArmorValue(); - virtual float getArmorCoverPercentage(); - -protected: - virtual void actuallyHurt(DamageSource *source, float dmg); - -public: - using Entity::interact; - - virtual bool openFurnace(shared_ptr container); // 4J - added bool return - virtual bool openTrap(shared_ptr container); // 4J - added bool return - virtual void openTextEdit(shared_ptr sign); - virtual bool openBrewingStand(shared_ptr brewingStand); // 4J - added bool return - virtual bool openBeacon(shared_ptr beacon); - virtual bool openTrading(shared_ptr traderTarget, const wstring &name); // 4J - added bool return - virtual void openItemInstanceGui(shared_ptr itemInstance); - virtual bool interact(shared_ptr entity); - virtual shared_ptr getSelectedItem(); - void removeSelectedItem(); - virtual double getRidingHeight(); - virtual void attack(shared_ptr entity); - virtual void crit(shared_ptr entity); - virtual void magicCrit(shared_ptr entity); - virtual void respawn(); - -protected: - static void animateRespawn(shared_ptr player, Level *level); - -public: - Slot *getInventorySlot(int slotId); - virtual void remove(); - virtual bool isInWall(); - virtual bool isLocalPlayer(); - - enum BedSleepingResult - { - OK, NOT_POSSIBLE_HERE, NOT_POSSIBLE_NOW, TOO_FAR_AWAY, OTHER_PROBLEM, NOT_SAFE - }; - - virtual BedSleepingResult startSleepInBed(int x, int y, int z, bool bTestUse = false); - -private: - void setBedOffset(int bedDirection); - -public: - /** - * - * @param forcefulWakeUp - * If the player has been forced to wake up. When this happens, - * the client will skip the wake-up animation. For example, when - * the player is hurt or the bed is destroyed. - * @param updateLevelList - * If the level's sleeping player list needs to be updated. This - * is usually the case. - * @param saveRespawnPoint - * TODO - */ - virtual void stopSleepInBed(bool forcefulWakeUp, bool updateLevelList, bool saveRespawnPoint); - -private: - bool checkBed(); - -public: - static Pos *checkBedValidRespawnPosition(Level *level, Pos *pos, bool forced); - float getSleepRotation(); - bool isSleeping(); - bool isSleepingLongEnough(); - int getSleepTimer(); - int getDeathFadeTimer(); - -protected: - bool getPlayerFlag(int flag); - void setPlayerFlag(int flag, bool value); - -public: - /** - * This method is currently only relevant to client-side players. It will - * try to load the messageId from the language file and display it to the - * client. - */ - virtual void displayClientMessage(int messageId); - virtual Pos *getRespawnPosition(); - virtual bool isRespawnForced(); - virtual void setRespawnPosition(Pos *respawnPosition, bool forced); - virtual void awardStat(Stat *stat, byteArray param); - -protected: - void jumpFromGround(); - -public: - virtual void travel(float xa, float ya); - virtual float getSpeed(); - virtual void checkMovementStatistiscs(double dx, double dy, double dz); - -private: - void checkRidingStatistiscs(double dx, double dy, double dz); - - bool m_bAwardedOnARail; - -protected: - virtual void causeFallDamage(float distance); - -public: - virtual void killed(shared_ptr mob); - virtual void makeStuckInWeb(); - virtual Icon *getItemInHandIcon(shared_ptr item, int layer); - virtual shared_ptr getArmor(int pos); - virtual void increaseXp(int i); - virtual void giveExperienceLevels(int amount); - int getXpNeededForNextLevel(); - void causeFoodExhaustion(float amount); - FoodData *getFoodData(); - bool canEat(bool magicalItem); - bool isHurt(); - virtual void startUsingItem(shared_ptr instance, int duration); - virtual bool mayDestroyBlockAt(int x, int y, int z); - virtual bool mayUseItemAt(int x, int y, int z, int face, shared_ptr item); - -protected: - virtual int getExperienceReward(shared_ptr killedBy); - virtual bool isAlwaysExperienceDropper(); - -public: - virtual wstring getAName(); - virtual bool shouldShowName(); - virtual void restoreFrom(shared_ptr oldPlayer, bool restoreAll); - -protected: - bool makeStepSound(); - -public: - void onUpdateAbilities(); - void setGameMode(GameType *mode); - wstring getName(); - virtual wstring getDisplayName(); - virtual wstring getNetworkName(); // 4J: Added - - virtual Level *getCommandSenderWorld(); - - shared_ptr getEnderChestInventory(); - - virtual shared_ptr getCarried(int slot); - virtual shared_ptr getCarriedItem(); - virtual void setEquippedSlot(int slot, shared_ptr item); - virtual bool isInvisibleTo(shared_ptr player); - virtual ItemInstanceArray getEquipmentSlots(); - virtual bool isCapeHidden(); - virtual bool isPushedByWater(); - virtual Scoreboard *getScoreboard(); - virtual Team *getTeam(); - virtual void setAbsorptionAmount(float absorptionAmount); - virtual float getAbsorptionAmount(); - - //////// 4J ///////////////// - - static int hash_fnct(const shared_ptr k); - static bool eq_test(const shared_ptr x, const shared_ptr y); - - // 4J Stu - Added to allow callback to tutorial to stay within Minecraft.Client - // Overidden in LocalPlayer - virtual void onCrafted(shared_ptr item) {} - - // 4J Overriding this so that we can have some different default skins - virtual int getTexture(); // 4J changed from wstring to int - void setPlayerDefaultSkin(EDefaultSkins skin); - EDefaultSkins getPlayerDefaultSkin() { return m_skinIndex; } - virtual void setCustomSkin(DWORD skinId); - DWORD getCustomSkin() {return m_dwSkinId; } - virtual void setCustomCape(DWORD capeId); - DWORD getCustomCape() {return m_dwCapeId; } - - static DWORD getCapeIdFromPath(const wstring &cape); - static wstring getCapePathFromId(DWORD capeId); - static unsigned int getSkinAnimOverrideBitmask(DWORD skinId); - - // 4J Added - void setXuid(PlayerUID xuid); - PlayerUID getXuid() { return m_xuid; } - void setOnlineXuid(PlayerUID xuid) { m_OnlineXuid = xuid; } - PlayerUID getOnlineXuid() { return m_OnlineXuid; } - - void setPlayerIndex(DWORD dwIndex) { m_playerIndex = dwIndex; } - DWORD getPlayerIndex() { return m_playerIndex; } - - void setIsGuest(bool bVal) { m_bIsGuest = bVal; } - bool isGuest() { return m_bIsGuest; } - - void setShowOnMaps(bool bVal) { m_bShownOnMaps = bVal; } - bool canShowOnMaps() { return m_bShownOnMaps && !getPlayerGamePrivilege(ePlayerGamePrivilege_Invisible); } - - virtual void sendMessage(const wstring& message, ChatPacket::EChatPacketMessage type = ChatPacket::e_ChatCustom, int customData = -1, const wstring& additionalMessage = L"") { } -private: - PlayerUID m_xuid; - PlayerUID m_OnlineXuid; - -protected: - bool m_bShownOnMaps; - - bool m_bIsGuest; - -private: - EDefaultSkins m_skinIndex; - DWORD m_dwSkinId,m_dwCapeId; - - // 4J Added - Used to show which colour the player is on the map/behind their name - DWORD m_playerIndex; - - // 4J-PB - to track debug options from the server player - unsigned int m_uiDebugOptions; - -public: - void SetDebugOptions(unsigned int uiVal) { m_uiDebugOptions=uiVal;} - unsigned int GetDebugOptions(void) { return m_uiDebugOptions;} - - void StopSleeping() {} - -public: - // If you add things here, you should also add a message to ClientConnection::displayPrivilegeChanges to alert players to changes - enum EPlayerGamePrivileges - { - ePlayerGamePrivilege_CannotMine = 0, // Only checked if trust system is on - ePlayerGamePrivilege_CannotBuild, // Only checked if trust system is on - ePlayerGamePrivilege_CannotAttackMobs, // Only checked if trust system is on - ePlayerGamePrivilege_CannotAttackPlayers, //Only checked if trust system is on - ePlayerGamePrivilege_Op, - ePlayerGamePrivilege_CanFly, - ePlayerGamePrivilege_ClassicHunger, - ePlayerGamePrivilege_Invisible, - ePlayerGamePrivilege_Invulnerable, - - ePlayerGamePrivilege_CreativeMode, // Used only to transfer across network, should never be used to determine if a player is in creative mode - - ePlayerGamePrivilege_CannotAttackAnimals, // Only checked if trust system is on - ePlayerGamePrivilege_CanUseDoorsAndSwitches, // Only checked if trust system is on - ePlayerGamePrivilege_CanUseContainers, // Only checked if trust system is on - - ePlayerGamePrivilege_CanToggleInvisible, - ePlayerGamePrivilege_CanToggleFly, - ePlayerGamePrivilege_CanToggleClassicHunger, - ePlayerGamePrivilege_CanTeleport, - - // Currently enum is used to bitshift into an unsigned int - ePlayerGamePrivilege_MAX = 32, - ePlayerGamePrivilege_All = 33, - ePlayerGamePrivilege_HOST, - }; -private: - // 4J Added - Used to track what actions players have been allowed to perform by the host - unsigned int m_uiGamePrivileges; - - unsigned int getPlayerGamePrivilege(EPlayerGamePrivileges privilege); -public: - unsigned int getAllPlayerGamePrivileges() { return getPlayerGamePrivilege(ePlayerGamePrivilege_All); } - - static unsigned int getPlayerGamePrivilege(unsigned int uiGamePrivileges, EPlayerGamePrivileges privilege); - void setPlayerGamePrivilege(EPlayerGamePrivileges privilege, unsigned int value); - static void setPlayerGamePrivilege(unsigned int &uiGamePrivileges, EPlayerGamePrivileges privilege, unsigned int value); - - bool isAllowedToUse(Tile *tile); - bool isAllowedToUse(shared_ptr item); - bool isAllowedToInteract(shared_ptr target); - bool isAllowedToMine(); - bool isAllowedToAttackPlayers(); - bool isAllowedToAttackAnimals(); - bool isAllowedToHurtEntity(shared_ptr target); - bool isAllowedToFly(); - bool isAllowedToIgnoreExhaustion(); - bool isAllowedToTeleport(); - bool hasInvisiblePrivilege(); - bool hasInvulnerablePrivilege(); - bool isModerator(); - - static void enableAllPlayerPrivileges(unsigned int &uigamePrivileges, bool enable); - void enableAllPlayerPrivileges(bool enable); - - virtual bool canCreateParticles(); - -public: - // 4J Stu - Added hooks for the game rules - virtual void handleCollectItem(shared_ptr item) {} - - vector *GetAdditionalModelParts(); - void SetAdditionalModelParts(vector *ppAdditionalModelParts); - -#if defined(__PS3__) || defined(__ORBIS__) - enum ePlayerNameValidState - { - ePlayerNameValid_NotSet=0, - ePlayerNameValid_True, - ePlayerNameValid_False - }; - - ePlayerNameValidState GetPlayerNameValidState(); - void SetPlayerNameValidState(bool bState); -#endif -private: - vector *m_ppAdditionalModelParts; - bool m_bCheckedForModelParts; - bool m_bCheckedDLCForModelParts; - -#if defined(__PS3__) || defined(__ORBIS__) - ePlayerNameValidState m_ePlayerNameValidState; // 4J-PB - to ensure we have the characters for this name in our font, or display a player number instead -#endif -}; - -struct PlayerKeyHash -{ - inline int operator() (const shared_ptr k) const - { return Player::hash_fnct (k); } -}; - -struct PlayerKeyEq -{ - inline bool operator() (const shared_ptr x, const shared_ptr y) const - { return Player::eq_test (x, y); } -}; - From 3351f06c3a1f364e75119b30f760600f5315a9cc Mon Sep 17 00:00:00 2001 From: ethxn <163630159+ethxnblxd@users.noreply.github.com> Date: Thu, 19 Mar 2026 19:28:55 +0800 Subject: [PATCH 05/12] Add files via upload --- Minecraft.World/AbstractContainerMenu.cpp | 4 +- Minecraft.World/Player.cpp | 50 +++++++++++++++++++++++ Minecraft.World/Player.h | 3 ++ 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/Minecraft.World/AbstractContainerMenu.cpp b/Minecraft.World/AbstractContainerMenu.cpp index c98fc22c50..04e2b6a14f 100644 --- a/Minecraft.World/AbstractContainerMenu.cpp +++ b/Minecraft.World/AbstractContainerMenu.cpp @@ -157,8 +157,8 @@ shared_ptr AbstractContainerMenu::clicked(int slotIndex, int butto shared_ptr clickedEntity = nullptr; shared_ptr inventory = player->inventory; - if (slotIndex < 0 || slotIndex >= (int)slots.size()) - return nullptr; + //if (slotIndex < 0 || slotIndex >= (int)slots.size()) + // return nullptr; if (clickType == CLICK_QUICK_CRAFT) { diff --git a/Minecraft.World/Player.cpp b/Minecraft.World/Player.cpp index 00c7148e41..94308ed806 100644 --- a/Minecraft.World/Player.cpp +++ b/Minecraft.World/Player.cpp @@ -1205,6 +1205,56 @@ shared_ptr Player::drop(shared_ptr item, bool randomly return thrownItem; } +shared_ptr Player::dropall(bool all) +{ + return dropall(inventory->removeItem(inventory->selected, all && inventory->getSelected() != nullptr ? inventory->getSelected()->count : inventory->getSelected()->count), false); +} + +shared_ptr Player::dropall(shared_ptr item) +{ + return dropall(item, false); +} + +shared_ptr Player::dropall(shared_ptr item, bool randomly) +{ + if (item == nullptr) return nullptr; + if (item->count == 0) return nullptr; + + shared_ptr thrownItem = std::make_shared(level, x, y - 0.3f + getHeadHeight(), z, item); + thrownItem->throwTime = 20 * 2; + + thrownItem->setThrower(getName()); + + float pow = 0.1f; + if (randomly) + { + float _pow = random->nextFloat() * 0.5f; + float dir = random->nextFloat() * PI * 2; + thrownItem->xd = -sin(dir) * _pow; + thrownItem->zd = cos(dir) * _pow; + thrownItem->yd = 0.2f; + + } + else + { + pow = 0.3f; + thrownItem->xd = -sin(yRot / 180 * PI) * cos(xRot / 180 * PI) * pow; + thrownItem->zd = cos(yRot / 180 * PI) * cos(xRot / 180 * PI) * pow; + thrownItem->yd = -sin(xRot / 180 * PI) * pow + 0.1f; + pow = 0.02f; + + float dir = random->nextFloat() * PI * 2; + pow *= random->nextFloat(); + thrownItem->xd += cos(dir) * pow; + thrownItem->yd += (random->nextFloat() - random->nextFloat()) * 0.1f; + thrownItem->zd += sin(dir) * pow; + } + + reallyDrop(thrownItem); + + return thrownItem; +} + void Player::reallyDrop(shared_ptr thrownItem) { diff --git a/Minecraft.World/Player.h b/Minecraft.World/Player.h index 2e223a1e55..8372bc036a 100644 --- a/Minecraft.World/Player.h +++ b/Minecraft.World/Player.h @@ -201,6 +201,9 @@ class Player : public LivingEntity, public CommandSender, public ScoreHolder shared_ptr drop(shared_ptr item); shared_ptr drop(shared_ptr item, bool randomly); + virtual shared_ptr dropall(bool all); + shared_ptr dropall(shared_ptr item); + shared_ptr dropall(shared_ptr item, bool randomly); protected: virtual void reallyDrop(shared_ptr thrownItem); From 78aafe6f94054253b877b631d62e3212db4f0635 Mon Sep 17 00:00:00 2001 From: ethxn <163630159+ethxnblxd@users.noreply.github.com> Date: Thu, 19 Mar 2026 19:30:00 +0800 Subject: [PATCH 06/12] Add files via upload --- Minecraft.Client/Windows64/KeyboardMouseInput.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Minecraft.Client/Windows64/KeyboardMouseInput.h b/Minecraft.Client/Windows64/KeyboardMouseInput.h index 5c406983f5..2272c969a4 100644 --- a/Minecraft.Client/Windows64/KeyboardMouseInput.h +++ b/Minecraft.Client/Windows64/KeyboardMouseInput.h @@ -23,9 +23,10 @@ class KeyboardMouseInput static const int KEY_SPRINT = VK_CONTROL; static const int KEY_INVENTORY = 'E'; static const int KEY_DROP = 'Q'; - static const int KEY_CRAFTING = 'C'; - static const int KEY_CRAFTING_ALT = 'R'; + static const int KEY_CRAFTING = 'R'; + static const int KEY_ZOOM = 'C'; static const int KEY_CHAT = 'T'; + static const int KEY_SLASHCOMMANDCHAT = VK_OEM_2; static const int KEY_CONFIRM = VK_RETURN; static const int KEY_CANCEL = VK_ESCAPE; static const int KEY_PAUSE = VK_ESCAPE; @@ -39,6 +40,7 @@ class KeyboardMouseInput // todo: implement and shi static const int KEY_SCREENSHOT = VK_F2; + static const int KEY_PICKBLOCK = MOUSE_MIDDLE; void Init(); void Tick(); From 914987dc072775377516639456d59d7e36fc69a1 Mon Sep 17 00:00:00 2001 From: ethxn <163630159+ethxnblxd@users.noreply.github.com> Date: Thu, 19 Mar 2026 19:31:00 +0800 Subject: [PATCH 07/12] Add files via upload --- Minecraft.Client/MultiPlayerLocalPlayer.cpp | 6 ++++++ Minecraft.Client/MultiPlayerLocalPlayer.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/Minecraft.Client/MultiPlayerLocalPlayer.cpp b/Minecraft.Client/MultiPlayerLocalPlayer.cpp index aef7898f25..038963db6f 100644 --- a/Minecraft.Client/MultiPlayerLocalPlayer.cpp +++ b/Minecraft.Client/MultiPlayerLocalPlayer.cpp @@ -179,6 +179,12 @@ shared_ptr MultiplayerLocalPlayer::drop() return nullptr; } +shared_ptr MultiplayerLocalPlayer::dropall() +{ + connection->send(std::make_shared(PlayerActionPacket::DROP_ALL_ITEMS, 0, 0, 0, 0)); + return nullptr; +} + void MultiplayerLocalPlayer::reallyDrop(shared_ptr itemEntity) { } diff --git a/Minecraft.Client/MultiPlayerLocalPlayer.h b/Minecraft.Client/MultiPlayerLocalPlayer.h index e660a96a20..286e48ec82 100644 --- a/Minecraft.Client/MultiPlayerLocalPlayer.h +++ b/Minecraft.Client/MultiPlayerLocalPlayer.h @@ -36,6 +36,9 @@ class MultiplayerLocalPlayer : public LocalPlayer using Player::drop; virtual shared_ptr drop(); + + using Player::dropall; + virtual shared_ptr dropall(); protected: virtual void reallyDrop(shared_ptr itemEntity); public: From 0c41740b3d19cdbb91902acd11a33ddafad8635d Mon Sep 17 00:00:00 2001 From: ethxn <163630159+ethxnblxd@users.noreply.github.com> Date: Thu, 19 Mar 2026 19:31:36 +0800 Subject: [PATCH 08/12] Add files via upload --- Minecraft.Client/Common/App_enums.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Minecraft.Client/Common/App_enums.h b/Minecraft.Client/Common/App_enums.h index 15a179787b..aa27254f90 100644 --- a/Minecraft.Client/Common/App_enums.h +++ b/Minecraft.Client/Common/App_enums.h @@ -862,6 +862,7 @@ enum EControllerActions MINECRAFT_ACTION_INVENTORY, MINECRAFT_ACTION_PAUSEMENU, MINECRAFT_ACTION_DROP, + MINECRAFT_ACTION_DROPALL, MINECRAFT_ACTION_SNEAK_TOGGLE, MINECRAFT_ACTION_CRAFTING, MINECRAFT_ACTION_RENDER_THIRD_PERSON, From e5265f4f3857fc2e21ad15687fc317561b77b121 Mon Sep 17 00:00:00 2001 From: ethxnblxd Date: Fri, 20 Mar 2026 21:00:56 +0800 Subject: [PATCH 09/12] =?UTF-8?q?=E2=9C=85=20Added=20hold=20Q=20to=20drop?= =?UTF-8?q?=20items=20repetitively?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Added Ctrl + Q to drop slot/stack ✅ Added prevention of switching hotbar slots whilst in menus [⚠️PARTIALLY COMPLETE] Added dropping items in the inventory menu by selecting and clicking outside of the inventory menu to drop (left click = stack, right click = 1 item) (havent yet implemented Q dropping or CTRL + Q dropping for menus) ✅ Fixed pressing escape to exit chat opens pause menu ✅ Added ctrl + (left/right arrow to jump words when typing) ✅ Fixed Tab Key opening PlayerList whilst being in chat ✅ added '/' bind to open chat with a slash for command execution [⚠️PARTIALLY COMPLETE] added support for CTRL + Backspace to delete a full word when chatting (doesnt execute properly) --- Minecraft.Client/ChatScreen.cpp | 43 +++++++++++++++++++++++++---- Minecraft.World/SharedConstants.cpp | 10 +++++-- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/Minecraft.Client/ChatScreen.cpp b/Minecraft.Client/ChatScreen.cpp index af0071d033..22c37849b1 100644 --- a/Minecraft.Client/ChatScreen.cpp +++ b/Minecraft.Client/ChatScreen.cpp @@ -7,6 +7,7 @@ #include "..\Minecraft.World\StringHelpers.h" #include "..\Minecraft.World\ChatPacket.h" #include "Windows64\KeyboardMouseInput.h" +#include "Common\UI\UIComponent_DebugUIConsole.h" const wstring ChatScreen::allowedChars = SharedConstants::acceptableLetters; vector ChatScreen::s_chatHistory; @@ -23,6 +24,12 @@ ChatScreen::ChatScreen() frame = 0; cursorIndex = 0; s_historyIndex = -1; + + if (g_KBMInput.IsKeyPressed(VK_OEM_2)) + { + message.insert(cursorIndex, 1, L'/'); + cursorIndex++; + } } void ChatScreen::init() @@ -150,21 +157,45 @@ void ChatScreen::keyPressed(wchar_t ch, int eventKey) return; } - // NEEDS IMPLEMENTING (CTRL + BACKSPACE TO DELETE WORD) - if (eventKey == Keyboard::KEY_BACK && cursorIndex > 0) { + std::wstring trim; + if (g_KBMInput.IsKeyDown(VK_CONTROL)) { - return; + trim = L"CTRL + BACK PRESSED"; + + size_t start = cursorIndex; + + while (start > 0 && iswspace(message[start - 1])) + start--; + + while (start > 0 && !iswspace(message[start - 1])) + start--; + + message.erase(start, cursorIndex - start); + cursorIndex = start; } else { + trim = L"BACK PRESSED"; + message.erase(cursorIndex - 1, 1); cursorIndex--; - return; } + // PRINTING OUT WHEN TRIGGERED FOR DEBUGGING + + wstring trim1 = trimString(trim); + + if (!minecraft->handleClientSideCommand(trim1)) + { + MultiplayerLocalPlayer* mplp = dynamic_cast(minecraft->player.get()); + if (mplp && mplp->connection) + mplp->connection->send(std::make_shared(trim1)); + } + + return; } // NEEDS IMPLEMENTING (CTRL + A TO SELECT ALL) @@ -191,12 +222,12 @@ void ChatScreen::keyPressed(wchar_t ch, int eventKey) // NEEDS IMPLEMENTING (TAB TO AUTOFILL USERNAMES e.g( et > TAB > ethxnblxd )) // if theres multiple usernames then make a gui above the chat window and cycle through them by using tab) - if (eventKey == Keyboard::KEY_TAB) // NEEDS FIXING OPENS PLAYERLIST IN CHAT WINDOW + if (eventKey == Keyboard::KEY_TAB) { return; } - if (isAllowedChatChar(ch) && static_cast(message.length()) < SharedConstants::maxChatLength) + if (!g_KBMInput.IsKeyDown(VK_CONTROL) && isAllowedChatChar(ch) && static_cast(message.length()) < SharedConstants::maxChatLength) // BLOCKS CTRL CHARS FROM BEING PARSED { message.insert(cursorIndex, 1, ch); cursorIndex++; diff --git a/Minecraft.World/SharedConstants.cpp b/Minecraft.World/SharedConstants.cpp index 00ff3a0510..9e6743606e 100644 --- a/Minecraft.World/SharedConstants.cpp +++ b/Minecraft.World/SharedConstants.cpp @@ -32,9 +32,13 @@ wstring SharedConstants::readAcceptableChars() bool SharedConstants::isAllowedChatCharacter(char ch) { - //return ch != '§' && (acceptableLetters.indexOf(ch) >= 0 || (int) ch > 32); - // 4J Unused - return true; + // SHOULD block control chars but it doesnt for some reason... (ctrl+backspace) + // also removed the S symbol because we can just make color codes not work in chat. + + if (std::iscntrl(static_cast(ch))) + return false; + + return acceptableLetters.find(ch) != std::string::npos || std::isprint(static_cast(ch)); } wstring SharedConstants::acceptableLetters; From dc98d89d5c073e500d148f333f4a68ff63a8dc81 Mon Sep 17 00:00:00 2001 From: ethxnblxd Date: Fri, 20 Mar 2026 21:06:28 +0800 Subject: [PATCH 10/12] recommit --- Minecraft.Client/ChatScreen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Minecraft.Client/ChatScreen.cpp b/Minecraft.Client/ChatScreen.cpp index 22c37849b1..02f0c5fc44 100644 --- a/Minecraft.Client/ChatScreen.cpp +++ b/Minecraft.Client/ChatScreen.cpp @@ -227,7 +227,7 @@ void ChatScreen::keyPressed(wchar_t ch, int eventKey) return; } - if (!g_KBMInput.IsKeyDown(VK_CONTROL) && isAllowedChatChar(ch) && static_cast(message.length()) < SharedConstants::maxChatLength) // BLOCKS CTRL CHARS FROM BEING PARSED + if (isAllowedChatChar(ch) && static_cast(message.length()) < SharedConstants::maxChatLength) { message.insert(cursorIndex, 1, ch); cursorIndex++; From 299e5380c169247545b56d9f56adfefe32d09f5d Mon Sep 17 00:00:00 2001 From: ethxnblxd Date: Fri, 20 Mar 2026 21:21:30 +0800 Subject: [PATCH 11/12] another recommit --- Minecraft.Client/Minecraft.cpp | 2 +- Minecraft.Client/Windows64/KeyboardMouseInput.h | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Minecraft.Client/Minecraft.cpp b/Minecraft.Client/Minecraft.cpp index e0f327155d..90d7b7c507 100644 --- a/Minecraft.Client/Minecraft.cpp +++ b/Minecraft.Client/Minecraft.cpp @@ -1546,7 +1546,7 @@ void Minecraft::run_middle() wasDown = down; - if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_CRAFTING)) + if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_CRAFTING) || g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_CRAFTING_ALT)) { if((ui.IsSceneInStack(i, eUIScene_Crafting2x2Menu) || ui.IsSceneInStack(i, eUIScene_Crafting3x3Menu) || ui.IsSceneInStack(i, eUIScene_CreativeMenu) || isClosableByEitherKey) && !isEditing) { diff --git a/Minecraft.Client/Windows64/KeyboardMouseInput.h b/Minecraft.Client/Windows64/KeyboardMouseInput.h index 2272c969a4..5569e684b3 100644 --- a/Minecraft.Client/Windows64/KeyboardMouseInput.h +++ b/Minecraft.Client/Windows64/KeyboardMouseInput.h @@ -23,8 +23,8 @@ class KeyboardMouseInput static const int KEY_SPRINT = VK_CONTROL; static const int KEY_INVENTORY = 'E'; static const int KEY_DROP = 'Q'; - static const int KEY_CRAFTING = 'R'; - static const int KEY_ZOOM = 'C'; + static const int KEY_CRAFTING = 'C'; + static const int KEY_CRAFTING_ALT = 'R'; static const int KEY_CHAT = 'T'; static const int KEY_SLASHCOMMANDCHAT = VK_OEM_2; static const int KEY_CONFIRM = VK_RETURN; @@ -40,7 +40,6 @@ class KeyboardMouseInput // todo: implement and shi static const int KEY_SCREENSHOT = VK_F2; - static const int KEY_PICKBLOCK = MOUSE_MIDDLE; void Init(); void Tick(); From 6b0b5ff0ada20e205256084ab66d4582306991d9 Mon Sep 17 00:00:00 2001 From: ethxnblxd Date: Fri, 20 Mar 2026 21:23:40 +0800 Subject: [PATCH 12/12] another recommit --- Minecraft.Client/ChatScreen.cpp | 12 ++++++------ Minecraft.Client/Minecraft.cpp | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Minecraft.Client/ChatScreen.cpp b/Minecraft.Client/ChatScreen.cpp index 02f0c5fc44..9d1107cb36 100644 --- a/Minecraft.Client/ChatScreen.cpp +++ b/Minecraft.Client/ChatScreen.cpp @@ -188,12 +188,12 @@ void ChatScreen::keyPressed(wchar_t ch, int eventKey) wstring trim1 = trimString(trim); - if (!minecraft->handleClientSideCommand(trim1)) - { - MultiplayerLocalPlayer* mplp = dynamic_cast(minecraft->player.get()); - if (mplp && mplp->connection) - mplp->connection->send(std::make_shared(trim1)); - } + //if (!minecraft->handleClientSideCommand(trim1)) + //{ + // MultiplayerLocalPlayer* mplp = dynamic_cast(minecraft->player.get()); + // if (mplp && mplp->connection) + // mplp->connection->send(std::make_shared(trim1)); + //} return; } diff --git a/Minecraft.Client/Minecraft.cpp b/Minecraft.Client/Minecraft.cpp index 90d7b7c507..3a9f83b7ca 100644 --- a/Minecraft.Client/Minecraft.cpp +++ b/Minecraft.Client/Minecraft.cpp @@ -2635,7 +2635,8 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) *piUse=IDS_TOOLTIPS_BLOCK; break; - // QUICK EQUIP FOR ARMOR (TOOLTIPS ONLY) + // QUICK EQUIP FOR ARMOR (TOOLTIPS ONLY) + // NEEDS LOGIC IMPLEMENTATION! // LEATHER case Item::helmet_leather_Id: