From 760484e546fb3acc69a1584175df154c510752c5 Mon Sep 17 00:00:00 2001 From: Langtanium <94726057+Langtanium@users.noreply.github.com> Date: Wed, 15 Apr 2026 20:00:28 -0700 Subject: [PATCH] Squashed commit of the following: commit b40530fa5e12bdd0e2d03686b111964f9c5b3359 Author: Langtanium <94726057+Langtanium@users.noreply.github.com> Date: Wed Apr 15 19:59:46 2026 -0700 Implemented skin offsets in UI Added code to render skin offsets in the skin select UI. commit a8384d984089b989a162550705dee7a505412e22 Author: Langtanium <94726057+Langtanium@users.noreply.github.com> Date: Wed Apr 15 19:38:08 2026 -0700 Partially implemented offsets Added code that visually shifts the player's model parts, but only in game not in the skin select UI. commit 875100cf9afe7df258dc653a4b33857d3cd285c1 Author: Langtanium <94726057+Langtanium@users.noreply.github.com> Date: Wed Apr 15 16:48:03 2026 -0700 Minor change Simplified redundant conditions in HumanoidModel.cpp commit 96f683d1fb93d09a49987460ef698e0d125c2c93 Merge: db685a74 24c74aa2 Author: Langtanium <94726057+Langtanium@users.noreply.github.com> Date: Tue Apr 14 16:37:30 2026 -0700 Merge branch 'feat/64x64-skins' into feat/skin-offsets commit db685a74f34d02cc83e33ab97c5a7ad9a62ef023 Author: Langtanium <94726057+Langtanium@users.noreply.github.com> Date: Tue Apr 14 15:35:38 2026 -0700 Fixed skin offset data Fixed skin offsets so they now return the actual data instead of the defaults, added a few minor tweaks, and added code in PlayerRenderer.cpp to access offsets (Can read the offsets but can not apply them). commit aa769d54adb8f5bf96c75d10766422d23cc9129a Author: Langtanium <94726057+Langtanium@users.noreply.github.com> Date: Sat Apr 11 19:36:52 2026 -0700 Fixed crashes Fixed code for offsets preventing crashes. The amount of offsets is correctly obtain, but lacks the actual data. commit f18ac12cc072db74ed9b8da937e00c2e15f889a0 Merge: 8e76763a fd2fd659 Author: Langtanium <94726057+Langtanium@users.noreply.github.com> Date: Fri Apr 10 16:06:57 2026 -0700 Merge branch 'feat/64x64-skins' into feat/skin-offsets commit 8e76763a3ddeaff943243fd0469d6c4a7b12b6c1 Author: Langtanium <94726057+Langtanium@users.noreply.github.com> Date: Tue Apr 7 16:50:43 2026 -0700 Made more changes Made more changes in files to support skin offsets. The game still crashes when trying to load skins. commit 1a8f3532979033717044e74e6ceb766e23e35032 Merge: a1d9ae59 bb5fa506 Author: Langtanium <94726057+Langtanium@users.noreply.github.com> Date: Tue Apr 7 13:12:39 2026 -0700 Merge branch 'feat/64x64-skins' into feat/skin-offsets commit a1d9ae591ac27117626aac708a4204a9e2451684 Author: Langtanium <94726057+Langtanium@users.noreply.github.com> Date: Fri Apr 3 21:50:42 2026 -0700 Added small additions Added more code referencing skin offsets. Still doesn't work correctly. commit d28a751d9ca0527854e40be82e7841a650c2f189 Merge: 3888de7a 8bf03435 Author: Langtanium <94726057+Langtanium@users.noreply.github.com> Date: Thu Apr 2 17:09:08 2026 -0700 Merge branch 'smartcmd:main' into feat/skin-offsets commit 3888de7ab401d9562b7b922eca8b898aa73ba024 Author: Langtanium <94726057+Langtanium@users.noreply.github.com> Date: Thu Apr 2 17:07:48 2026 -0700 Added code for skin offsets Added code to the file which have the functionality to get skin boxes and duplicated the functionality for skin offsets. The code causes the game to crash when switching to third person. The error occurs with the skin offsets returning as an empty class object. --- Minecraft.Client/ClientConnection.cpp | 7 +- Minecraft.Client/Common/Consoles_App.cpp | 60 +++++++++- Minecraft.Client/Common/Consoles_App.h | 6 + Minecraft.Client/Common/DLC/DLCSkinFile.cpp | 27 +++-- .../Common/UI/UIControl_PlayerSkinPreview.cpp | 3 +- .../Common/UI/UIControl_PlayerSkinPreview.h | 1 + .../Common/UI/UIScene_SkinSelectMenu.cpp | 38 +++++++ .../Common/UI/UIScene_SkinSelectMenu.h | 1 + .../XUI/XUI_Ctrl_MinecraftSkinPreview.h | 2 + Minecraft.Client/HumanoidModel.cpp | 107 ++++++++++++++++-- Minecraft.Client/HumanoidModel.h | 6 +- Minecraft.Client/LocalPlayer.cpp | 4 + Minecraft.Client/LocalPlayer.h | 2 + Minecraft.Client/PlayerConnection.cpp | 14 ++- Minecraft.Client/PlayerRenderer.cpp | 5 +- Minecraft.Client/SkinOffset.h | 11 +- Minecraft.World/Entity.cpp | 7 +- Minecraft.World/Player.cpp | 58 ++++++++++ Minecraft.World/Player.h | 6 + Minecraft.World/TextureAndGeometryPacket.cpp | 69 ++++++++++- Minecraft.World/TextureAndGeometryPacket.h | 5 +- 21 files changed, 407 insertions(+), 32 deletions(-) diff --git a/Minecraft.Client/ClientConnection.cpp b/Minecraft.Client/ClientConnection.cpp index e30e89b4e..66d2bacff 100644 --- a/Minecraft.Client/ClientConnection.cpp +++ b/Minecraft.Client/ClientConnection.cpp @@ -2711,7 +2711,7 @@ void ClientConnection::handleTextureAndGeometry(shared_ptrdwSkinID); - send(std::make_shared(packet->textureName, pbData, dwBytes, app.GetAdditionalSkinBoxes(packet->dwSkinID), uiAnimOverrideBitmask)); + send(std::make_shared(packet->textureName, pbData, dwBytes, app.GetAdditionalSkinBoxes(packet->dwSkinID), app.GetModelOffsets(packet->dwSkinID), uiAnimOverrideBitmask)); } } } @@ -2728,6 +2728,11 @@ void ClientConnection::handleTextureAndGeometry(shared_ptrdwSkinID,packet->BoxDataA,packet->dwBoxC); } + // Add the offet data + if(packet->dwOffsetC!=0) + { + app.SetSkinOffsets(packet->dwSkinID,packet->OffsetDataA,packet->dwOffsetC); + } // Add the anim override app.SetAnimOverrideBitmask(packet->dwSkinID,packet->uiAnimOverrideBitmask); diff --git a/Minecraft.Client/Common/Consoles_App.cpp b/Minecraft.Client/Common/Consoles_App.cpp index 2dd3882eb..81e24adb7 100644 --- a/Minecraft.Client/Common/Consoles_App.cpp +++ b/Minecraft.Client/Common/Consoles_App.cpp @@ -196,6 +196,7 @@ CMinecraftApp::CMinecraftApp() InitializeCriticalSection(&csTMSPPDownloadQueue); InitializeCriticalSection(&csAdditionalModelParts); InitializeCriticalSection(&csAdditionalSkinBoxes); + InitializeCriticalSection(&csModelOffsets); InitializeCriticalSection(&csAnimOverrideBitmask); InitializeCriticalSection(&csMemFilesLock); InitializeCriticalSection(&csMemTPDLock); @@ -9201,7 +9202,7 @@ bool CMinecraftApp::DLCContentRetrieved(eDLCMarketplaceType eType) void CMinecraftApp::SetAdditionalSkinBoxes(DWORD dwSkinID, SKIN_BOX *SkinBoxA, DWORD dwSkinBoxC) { EntityRenderer *renderer = EntityRenderDispatcher::instance->getRenderer(eTYPE_PLAYER); - unsigned int m_uiAnimOverrideBitmask = Player::getSkinAnimOverrideBitmask(dwSkinID); + unsigned int m_uiAnimOverrideBitmask = GetAnimOverrideBitmask(dwSkinID); Model *pModel; if (m_uiAnimOverrideBitmask&(1<getModelClassic(); @@ -9237,10 +9238,30 @@ void CMinecraftApp::SetAdditionalSkinBoxes(DWORD dwSkinID, SKIN_BOX *SkinBoxA, D } +void CMinecraftApp::SetSkinOffsets(DWORD dwSkinID, SKIN_OFFSET *SkinOffsetA, DWORD dwSkinOffsetC) +{ + vector *pvSkinOffset = new vector; + + EnterCriticalSection( &csModelOffsets ); + + app.DebugPrintf("*** SetAdditionalSkinBoxes - Inserting model parts for skin %d from array of Skin Boxes\n",dwSkinID&0x0FFFFFFF); + + for(unsigned int i=0;ipush_back(&SkinOffsetA[i]); + } + + + m_SkinOffsets.insert( std::pair *>(dwSkinID, pvSkinOffset) ); + + LeaveCriticalSection( &csModelOffsets ); + +} + vector * CMinecraftApp::SetAdditionalSkinBoxes(DWORD dwSkinID, vector *pvSkinBoxA) { EntityRenderer *renderer = EntityRenderDispatcher::instance->getRenderer(eTYPE_PLAYER); - unsigned int m_uiAnimOverrideBitmask = Player::getSkinAnimOverrideBitmask(dwSkinID); + unsigned int m_uiAnimOverrideBitmask = GetAnimOverrideBitmask(dwSkinID); Model *pModel; if (m_uiAnimOverrideBitmask&(1<getModelClassic(); @@ -9272,6 +9293,24 @@ vector * CMinecraftApp::SetAdditionalSkinBoxes(DWORD dwSkinID, vect return pvModelPart; } +vector * CMinecraftApp::SetSkinOffsets(DWORD dwSkinID, vector *pvSkinOffsetA) +{ + vector *pvModelOffset = new vector; + + EnterCriticalSection( &csModelOffsets ); + app.DebugPrintf("*** SetSkinOffsets - Inserting model offsets for skin %d from array of Skin Offsets\n",dwSkinID&0x0FFFFFFF); + + for( auto& it : *pvSkinOffsetA ) + { + pvModelOffset->push_back(it); + } + + m_SkinOffsets.emplace(dwSkinID, pvSkinOffsetA); + + LeaveCriticalSection( &csModelOffsets ); + return pvModelOffset; +} + vector *CMinecraftApp::GetAdditionalModelParts(DWORD dwSkinID) { @@ -9307,6 +9346,23 @@ vector *CMinecraftApp::GetAdditionalSkinBoxes(DWORD dwSkinID) return pvSkinBoxes; } +vector *CMinecraftApp::GetModelOffsets(DWORD dwSkinID) +{ + EnterCriticalSection( &csModelOffsets ); + vector *pvModelOffsets=nullptr; + if(m_SkinOffsets.size()>0) + { + auto it = m_SkinOffsets.find(dwSkinID); + if(it!=m_SkinOffsets.end()) + { + pvModelOffsets = (*it).second; + } + } + + LeaveCriticalSection( &csModelOffsets ); + return pvModelOffsets; +} + unsigned int CMinecraftApp::GetAnimOverrideBitmask(DWORD dwSkinID) { EnterCriticalSection( &csAnimOverrideBitmask ); diff --git a/Minecraft.Client/Common/Consoles_App.h b/Minecraft.Client/Common/Consoles_App.h index 0c1c261ef..d7905d1b6 100644 --- a/Minecraft.Client/Common/Consoles_App.h +++ b/Minecraft.Client/Common/Consoles_App.h @@ -21,6 +21,7 @@ using namespace std; #include ".\GameRules\ConsoleGameRulesConstants.h" #include ".\GameRules\GameRuleManager.h" #include "..\SkinBox.h" +#include "..\SkinOffset.h" #include "..\ArchiveFile.h" typedef struct _JoinFromInviteData @@ -824,6 +825,7 @@ private: CRITICAL_SECTION csTMSPPDownloadQueue; CRITICAL_SECTION csAdditionalModelParts; CRITICAL_SECTION csAdditionalSkinBoxes; + CRITICAL_SECTION csModelOffsets; CRITICAL_SECTION csAnimOverrideBitmask; bool m_bCorruptSaveDeleted; @@ -845,6 +847,9 @@ public: vector * SetAdditionalSkinBoxes(DWORD dwSkinID, vector *pvSkinBoxA); vector *GetAdditionalModelParts(DWORD dwSkinID); vector *GetAdditionalSkinBoxes(DWORD dwSkinID); + void SetSkinOffsets(DWORD dwSkinID, SKIN_OFFSET *SkinOffsetA, DWORD dwSkinOffsetC); + vector * SetSkinOffsets(DWORD dwSkinID, vector *pvSkinOffsetA); + vector *GetModelOffsets(DWORD dwSkinID); void SetAnimOverrideBitmask(DWORD dwSkinID,unsigned int uiAnimOverrideBitmask); unsigned int GetAnimOverrideBitmask(DWORD dwSkinID); @@ -875,6 +880,7 @@ private: // vector of additional skin model parts, indexed by the skin texture id unordered_map *> m_AdditionalModelParts; unordered_map *> m_AdditionalSkinBoxes; + unordered_map *> m_SkinOffsets; unordered_map m_AnimOverrides; diff --git a/Minecraft.Client/Common/DLC/DLCSkinFile.cpp b/Minecraft.Client/Common/DLC/DLCSkinFile.cpp index 9b519e289..e693601cc 100644 --- a/Minecraft.Client/Common/DLC/DLCSkinFile.cpp +++ b/Minecraft.Client/Common/DLC/DLCSkinFile.cpp @@ -110,7 +110,7 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type, const wstring break; case DLCManager::e_DLCParamType_Box: { - WCHAR wchBodyPart[11]; + WCHAR wchBodyPart[10]; SKIN_BOX *pSkinBox = new SKIN_BOX; ZeroMemory(pSkinBox,sizeof(SKIN_BOX)); @@ -118,7 +118,7 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type, const wstring // 4J Stu - The Xbox version used swscanf_s which isn't available in GCC. swscanf(value.c_str(), L"%10ls%f%f%f%f%f%f%f%f%f%f%f", wchBodyPart, #else - swscanf_s(value.c_str(), L"%9ls%f%f%f%f%f%f%f%f%f%f%f", wchBodyPart,11, + swscanf_s(value.c_str(), L"%9ls%f%f%f%f%f%f%f%f%f%f%f", wchBodyPart,10, #endif &pSkinBox->fX, &pSkinBox->fY, @@ -231,18 +231,31 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type, const wstring break; case DLCManager::e_DLCParamType_Offset: { - WCHAR wchBodyPart[2]; + WCHAR wchBodyPart[10]; + wchar_t wchDirection[2]; SKIN_OFFSET *pSkinOffset = new SKIN_OFFSET; ZeroMemory(pSkinOffset,sizeof(SKIN_OFFSET)); - + #ifdef __PS3__ // 4J Stu - The Xbox version used swscanf_s which isn't available in GCC. - swscanf(value.c_str(), L"%10ls%f%f", wchBodyPart, + swscanf(value.c_str(), L"%10ls%2ls%f", wchBodyPart, #else - swscanf_s(value.c_str(), L"%9ls%f%f", wchBodyPart,2, + swscanf_s(value.c_str(), L"%9ls%2ls%f", wchBodyPart,10, wchDirection,2, #endif - &pSkinOffset->fD, &pSkinOffset->fO); + + if(wcscmp(wchDirection,L"X")==0) + { + pSkinOffset->fD=eOffsetDirection_X; + } + else if (wcscmp(wchDirection,L"Y")==0) + { + pSkinOffset->fD=eOffsetDirection_Y; + } + else if(wcscmp(wchDirection,L"Z")==0) + { + pSkinOffset->fD=eOffsetDirection_Z; + } if(wcscmp(wchBodyPart,L"HEAD")==0) { diff --git a/Minecraft.Client/Common/UI/UIControl_PlayerSkinPreview.cpp b/Minecraft.Client/Common/UI/UIControl_PlayerSkinPreview.cpp index be6169c3d..c2a2edf7d 100644 --- a/Minecraft.Client/Common/UI/UIControl_PlayerSkinPreview.cpp +++ b/Minecraft.Client/Common/UI/UIControl_PlayerSkinPreview.cpp @@ -132,6 +132,7 @@ void UIControl_PlayerSkinPreview::SetTexture(const wstring &url, TEXTURE_NAME ba } m_pvAdditionalModelParts=app.GetAdditionalModelParts(app.getSkinIdFromPath(m_customTextureUrl)); + m_pvModelOffsets=app.GetModelOffsets(app.getSkinIdFromPath(m_customTextureUrl)); } void UIControl_PlayerSkinPreview::SetFacing(ESkinPreviewFacing facing, bool bAnimate /*= false*/) @@ -365,7 +366,7 @@ void UIControl_PlayerSkinPreview::render(EntityRenderer *renderer, double x, dou glEnable(GL_ALPHA_TEST); //model->prepareMobModel(mob, wp, ws, a); - model->render(nullptr, wp, ws, bob, headRot - bodyRot, headRotx, _scale, true); + model->render(nullptr, wp, ws, bob, headRot - bodyRot, headRotx, _scale, true, m_pvModelOffsets); /*for (int i = 0; i < MAX_ARMOR_LAYERS; i++) { if (prepareArmor(mob, i, a)) diff --git a/Minecraft.Client/Common/UI/UIControl_PlayerSkinPreview.h b/Minecraft.Client/Common/UI/UIControl_PlayerSkinPreview.h index a7c3126e1..4dd64382a 100644 --- a/Minecraft.Client/Common/UI/UIControl_PlayerSkinPreview.h +++ b/Minecraft.Client/Common/UI/UIControl_PlayerSkinPreview.h @@ -53,6 +53,7 @@ private: ESkinPreviewAnimations m_currentAnimation; //vector *m_pvAdditionalBoxes; vector *m_pvAdditionalModelParts; + vector *m_pvModelOffsets; public: enum ESkinPreviewFacing { diff --git a/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.cpp index 2c179d9d7..869f9e512 100644 --- a/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.cpp @@ -59,6 +59,7 @@ UIScene_SkinSelectMenu::UIScene_SkinSelectMenu(int iPad, void *initData, UILayer m_selectedSkinPath = L""; m_selectedCapePath = L""; m_vAdditionalSkinBoxes = nullptr; + m_vSkinOffsets = nullptr; m_bSlidingSkins = false; m_bAnimatingMove = false; @@ -662,6 +663,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() m_selectedSkinPath = skinFile->getPath(); m_selectedCapePath = skinFile->getParameterAsString(DLCManager::e_DLCParamType_Cape); m_vAdditionalSkinBoxes = skinFile->getAdditionalBoxes(); + m_vSkinOffsets = skinFile->getOffsets(); skinName = skinFile->getParameterAsString( DLCManager::e_DLCParamType_DisplayName ); skinOrigin = skinFile->getParameterAsString( DLCManager::e_DLCParamType_ThemeName ); @@ -684,6 +686,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() m_selectedSkinPath = L""; m_selectedCapePath = L""; m_vAdditionalSkinBoxes = nullptr; + m_vSkinOffsets = nullptr; switch(m_packIndex) { @@ -726,6 +729,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() m_selectedSkinPath = skinFile->getPath(); m_selectedCapePath = skinFile->getParameterAsString(DLCManager::e_DLCParamType_Cape); m_vAdditionalSkinBoxes = skinFile->getAdditionalBoxes(); + m_vSkinOffsets = skinFile->getOffsets(); skinName = skinFile->getParameterAsString( DLCManager::e_DLCParamType_DisplayName ); skinOrigin = skinFile->getParameterAsString( DLCManager::e_DLCParamType_ThemeName ); @@ -773,6 +777,17 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() pAdditionalModelParts = app.SetAdditionalSkinBoxes(skinFile->getSkinID(),m_vAdditionalSkinBoxes); } } + + if(m_vSkinOffsets && m_vSkinOffsets->size()!=0) + { + // add the boxes to the humanoid model, but only if we've not done this already + + vector *pModelOffsets = app.GetModelOffsets(skinFile->getSkinID()); + if(pModelOffsets==nullptr) + { + pModelOffsets = app.SetSkinOffsets(skinFile->getSkinID(),m_vSkinOffsets); + } + } if(skinFile!=nullptr) { @@ -790,6 +805,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() wstring otherSkinPath = L""; wstring otherCapePath = L""; vector *othervAdditionalSkinBoxes=nullptr; + vector *othervSkinOffsets=nullptr; wchar_t chars[256]; // turn off all displays @@ -844,6 +860,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() otherSkinPath = skinFile->getPath(); otherCapePath = skinFile->getParameterAsString(DLCManager::e_DLCParamType_Cape); othervAdditionalSkinBoxes = skinFile->getAdditionalBoxes(); + othervSkinOffsets = skinFile->getOffsets(); backupTexture = TN_MOB_CHAR; } else @@ -851,6 +868,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() otherSkinPath = L""; otherCapePath = L""; othervAdditionalSkinBoxes=nullptr; + othervSkinOffsets=nullptr; switch(m_packIndex) { case SKIN_SELECT_PACK_DEFAULT: @@ -870,6 +888,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() otherSkinPath = skinFile->getPath(); otherCapePath = skinFile->getParameterAsString(DLCManager::e_DLCParamType_Cape); othervAdditionalSkinBoxes = skinFile->getAdditionalBoxes(); + othervSkinOffsets = skinFile->getOffsets(); backupTexture = TN_MOB_CHAR; } } @@ -887,6 +906,14 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() pAdditionalModelParts = app.SetAdditionalSkinBoxes(skinFile->getSkinID(),othervAdditionalSkinBoxes); } } + if(othervSkinOffsets && othervSkinOffsets->size()!=0) + { + vector *pModelOffsets = app.GetModelOffsets(skinFile->getSkinID()); + if(pModelOffsets==nullptr) + { + pModelOffsets = app.SetSkinOffsets(skinFile->getSkinID(),othervSkinOffsets); + } + } // 4J-PB - anim override needs set before SetTexture if(skinFile!=nullptr) { @@ -915,6 +942,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() otherSkinPath = skinFile->getPath(); otherCapePath = skinFile->getParameterAsString(DLCManager::e_DLCParamType_Cape); othervAdditionalSkinBoxes = skinFile->getAdditionalBoxes(); + othervSkinOffsets = skinFile->getOffsets(); backupTexture = TN_MOB_CHAR; } else @@ -922,6 +950,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() otherSkinPath = L""; otherCapePath = L""; othervAdditionalSkinBoxes=nullptr; + othervSkinOffsets=nullptr; switch(m_packIndex) { case SKIN_SELECT_PACK_DEFAULT: @@ -941,6 +970,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() otherSkinPath = skinFile->getPath(); otherCapePath = skinFile->getParameterAsString(DLCManager::e_DLCParamType_Cape); othervAdditionalSkinBoxes = skinFile->getAdditionalBoxes(); + othervSkinOffsets = skinFile->getOffsets(); backupTexture = TN_MOB_CHAR; } } @@ -958,6 +988,14 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() pAdditionalModelParts = app.SetAdditionalSkinBoxes(skinFile->getSkinID(),othervAdditionalSkinBoxes); } } + if(othervSkinOffsets && othervSkinOffsets->size()!=0) + { + vector *pModelOffsets = app.GetModelOffsets(skinFile->getSkinID()); + if(pModelOffsets==nullptr) + { + pModelOffsets = app.SetSkinOffsets(skinFile->getSkinID(),othervSkinOffsets); + } + } // 4J-PB - anim override needs set before SetTexture if(skinFile) { diff --git a/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.h b/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.h index 60579ac60..5c8ac817c 100644 --- a/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.h +++ b/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.h @@ -104,6 +104,7 @@ private: DWORD m_originalSkinId; wstring m_currentSkinPath, m_selectedSkinPath, m_selectedCapePath; vector *m_vAdditionalSkinBoxes; + vector *m_vSkinOffsets; bool m_bSlidingSkins, m_bAnimatingMove; ESkinSelectNavigation m_currentNavigation; diff --git a/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSkinPreview.h b/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSkinPreview.h index 22f4991b2..9789ecec8 100644 --- a/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSkinPreview.h +++ b/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSkinPreview.h @@ -5,6 +5,7 @@ #include "..\..\Textures.h" //#include "..\..\Xbox\DLC\DLCSkinFile.h" #include "..\..\Model.h" +#include "..\..\SkinOffset.h" using namespace std; @@ -103,4 +104,5 @@ private: ESkinPreviewAnimations m_currentAnimation; //vector *m_pvAdditionalBoxes; vector *m_pvAdditionalModelParts; + vector *m_pvModelOffsets; }; \ No newline at end of file diff --git a/Minecraft.Client/HumanoidModel.cpp b/Minecraft.Client/HumanoidModel.cpp index f5d31924c..7610c9d43 100644 --- a/Minecraft.Client/HumanoidModel.cpp +++ b/Minecraft.Client/HumanoidModel.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include "HumanoidModel.h" #include "..\Minecraft.World\Mth.h" -#include "..\Minecraft.World\Entity.h" +#include "..\Minecraft.World\Player.h" #include "ModelPart.h" // 4J added @@ -119,7 +119,7 @@ ModelPart * HumanoidModel::AddOrRetrievePart(SKIN_BOX *pBox) return pNewBox; } -void HumanoidModel::_init(float g, float yOffset, int texWidth, int texHeight, bool slimHands, bool isArmor) +void HumanoidModel::_init(float g, float yOffset, int texWidth, int texHeight, bool slim, bool isArmor) { this->texWidth = texWidth; this->texHeight = texHeight; @@ -210,12 +210,12 @@ void HumanoidModel::_init(float g, float yOffset, int texWidth, int texHeight, b sleeve0 = new ModelPart(this, 24 + 16, 32); sleeve1 = new ModelPart(this, 32 + 16, 48); - if (slimHands == false) + if (!slim) { sleeve0->addHumanoidBox(-3, -2, -2, 4, 12, 4, g + 0.25); // Sleeve0 sleeve1->addHumanoidBox(-1, -2, -2, 4, 12, 4, g + 0.25); // Sleeve1 } - else if (slimHands == true) + else if (slim) { sleeve0->addHumanoidBox(-2, -2, -2, 3, 12, 4, g + 0.25); // Sleeve0 Slim sleeve1->addHumanoidBox(-1, -2, -2, 3, 12, 4, g + 0.25); // Sleeve1 Slim @@ -231,12 +231,12 @@ void HumanoidModel::_init(float g, float yOffset, int texWidth, int texHeight, b arm1->bMirror = true; } - if (slimHands == false) + if (!slim) { arm0->addHumanoidBox(-3, -2, -2, 4, 12, 4, g); // Arm0 arm1->addHumanoidBox(-1, -2, -2, 4, 12, 4, g); // Arm1 } - else if (slimHands == true) + else if (slim) { arm0->addHumanoidBox(-2, -2, -2, 3, 12, 4, g); // Arm0 Slim arm1->addHumanoidBox(-1, -2, -2, 3, 12, 4, g); // Arm1 Slim @@ -350,12 +350,12 @@ HumanoidModel::HumanoidModel(float g, float yOffset, int texWidth, int texHeight _init(g,yOffset,texWidth,texHeight, false, false); } -HumanoidModel::HumanoidModel(float g, float yOffset, int texWidth, int texHeight, bool slimHands) : Model() +HumanoidModel::HumanoidModel(float g, float yOffset, int texWidth, int texHeight, bool slim) : Model() { - _init(g,yOffset,texWidth,texHeight, slimHands, false); + _init(g,yOffset,texWidth,texHeight, slim, false); } -void HumanoidModel::render(shared_ptr entity, float time, float r, float bob, float yRot, float xRot, float scale, bool usecompiled) +void HumanoidModel::render(shared_ptr entity, float time, float r, float bob, float yRot, float xRot, float scale, bool usecompiled, vector *modelOffsets) { if(entity != nullptr) { @@ -385,12 +385,100 @@ void HumanoidModel::render(shared_ptr entity, float time, float r, float } else { + shared_ptr player = dynamic_pointer_cast(entity); + vector headOffsets = {0, 0, 0}; + vector bodyOffsets = {0, 0, 0}; + vector arm0Offsets = {0, 0, 0}; + vector arm1Offsets = {0, 0, 0}; + vector leg0Offsets = {0, 0, 0}; + vector leg1Offsets = {0, 0, 0}; + vector* pModelOffsets = nullptr; + if (player != nullptr) + pModelOffsets = player->GetModelOffsets(); + else if (modelOffsets != nullptr) + pModelOffsets = modelOffsets; + if (pModelOffsets != nullptr) + { + for( SKIN_OFFSET *pModelOffset : *pModelOffsets ) + { + switch (pModelOffset->ePart) + { + case eBodyOffset_Head: + if(pModelOffset->fD == 1) + headOffsets[0] = pModelOffset->fO; + else if(pModelOffset->fD == 2) + headOffsets[1] = pModelOffset->fO; + else if(pModelOffset->fD == 3) + headOffsets[2] = pModelOffset->fO; + break; + case eBodyOffset_Body: + if(pModelOffset->fD == 1) + bodyOffsets[0] = pModelOffset->fO; + else if(pModelOffset->fD == 2) + bodyOffsets[1] = pModelOffset->fO; + else if(pModelOffset->fD == 3) + bodyOffsets[2] = pModelOffset->fO; + break; + case eBodyOffset_Arm0: + if(pModelOffset->fD == 1) + arm0Offsets[0] = pModelOffset->fO; + else if(pModelOffset->fD == 2) + arm0Offsets[1] = pModelOffset->fO; + else if(pModelOffset->fD == 3) + arm0Offsets[2] = pModelOffset->fO; + break; + case eBodyOffset_Arm1: + if(pModelOffset->fD == 1) + arm1Offsets[0] = pModelOffset->fO; + else if(pModelOffset->fD == 2) + arm1Offsets[1] = pModelOffset->fO; + else if(pModelOffset->fD == 3) + arm1Offsets[2] = pModelOffset->fO; + break; + case eBodyOffset_Leg0: + if(pModelOffset->fD == 1) + leg0Offsets[0] = pModelOffset->fO; + else if(pModelOffset->fD == 2) + leg0Offsets[1] = pModelOffset->fO; + else if(pModelOffset->fD == 3) + leg0Offsets[2] = pModelOffset->fO; + break; + case eBodyOffset_Leg1: + if(pModelOffset->fD == 1) + leg1Offsets[0] = pModelOffset->fO; + else if(pModelOffset->fD == 2) + leg1Offsets[1] = pModelOffset->fO; + else if(pModelOffset->fD == 3) + leg1Offsets[2] = pModelOffset->fO; + break; + } + } + } + + glPushMatrix(); + glTranslatef(headOffsets[0]/16.0f, headOffsets[1]/16.0f, headOffsets[2]/16.0f); head->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0&&(!(m_uiAnimOverrideBitmask&(1<0||!m_isArmor)); + glPopMatrix(); + glPushMatrix(); + glTranslatef(bodyOffsets[0]/16.0f, bodyOffsets[1]/16.0f, bodyOffsets[2]/16.0f); body->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0&&(!(m_uiAnimOverrideBitmask&(1<0||!m_isArmor)); + glPopMatrix(); + glPushMatrix(); + glTranslatef(arm0Offsets[0]/16.0f, arm0Offsets[1]/16.0f, arm0Offsets[2]/16.0f); arm0->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0&&(!(m_uiAnimOverrideBitmask&(1<0||!m_isArmor)); + glPopMatrix(); + glPushMatrix(); + glTranslatef(arm1Offsets[0]/16.0f, arm1Offsets[1]/16.0f, arm1Offsets[2]/16.0f); arm1->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0&&(!(m_uiAnimOverrideBitmask&(1<0||!m_isArmor)); + glPopMatrix(); + glPushMatrix(); + glTranslatef(leg0Offsets[0]/16.0f, leg0Offsets[1]/16.0f, leg0Offsets[2]/16.0f); leg0->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0&&(!(m_uiAnimOverrideBitmask&(1<0||!m_isArmor)); + glPopMatrix(); + glPushMatrix(); + glTranslatef(leg1Offsets[0]/16.0f, leg1Offsets[1]/16.0f, leg1Offsets[2]/16.0f); leg1->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0&&(!(m_uiAnimOverrideBitmask&(1<0||!m_isArmor)); + glPopMatrix(); hair->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); if (jacket != 0) jacket->render(scale, usecompiled,(m_uiAnimOverrideBitmask&(1<0); @@ -687,6 +775,7 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot, float arm0->xRot += ((float) (Mth::sin(bob * 0.067f)) * 0.05f); arm1->xRot -= ((float) (Mth::sin(bob * 0.067f)) * 0.05f); } + if (jacket != 0) { jacket->x = body->x; diff --git a/Minecraft.Client/HumanoidModel.h b/Minecraft.Client/HumanoidModel.h index 504c1d182..99c821f4a 100644 --- a/Minecraft.Client/HumanoidModel.h +++ b/Minecraft.Client/HumanoidModel.h @@ -77,13 +77,13 @@ public: (1< entity, float time, float r, float bob, float yRot, float xRot, float scale, bool usecompiled); + HumanoidModel(float g, float yOffset, int texWidth, int texHeight, bool slim); + virtual void render(shared_ptr entity, float time, float r, float bob, float yRot, float xRot, float scale, bool usecompiled, vector *modelOffsets = nullptr); virtual void setupAnim(float time, float r, float bob, float yRot, float xRot, float scale, shared_ptr entity, unsigned int uiBitmaskOverrideAnim = 0); void renderHair(float scale, bool usecompiled); void renderEars(float scale, bool usecompiled); diff --git a/Minecraft.Client/LocalPlayer.cpp b/Minecraft.Client/LocalPlayer.cpp index 7988416ad..d1c012998 100644 --- a/Minecraft.Client/LocalPlayer.cpp +++ b/Minecraft.Client/LocalPlayer.cpp @@ -1696,3 +1696,7 @@ void LocalPlayer::SetPlayerAdditionalModelParts(vectorpAdditionalMo { m_pAdditionalModelParts=pAdditionalModelParts; } +void LocalPlayer::SetPlayerModelOffsets(vectorpModelOffsets) +{ + m_pModelOffsets=pModelOffsets; +} diff --git a/Minecraft.Client/LocalPlayer.h b/Minecraft.Client/LocalPlayer.h index 2198c489e..88d43b3df 100644 --- a/Minecraft.Client/LocalPlayer.h +++ b/Minecraft.Client/LocalPlayer.h @@ -211,9 +211,11 @@ public: virtual void handleCollectItem(shared_ptr item); void SetPlayerAdditionalModelParts(vectorpAdditionalModelParts); + void SetPlayerModelOffsets(vectorpModelOffsets); private: vector m_pAdditionalModelParts; + vector m_pModelOffsets; }; diff --git a/Minecraft.Client/PlayerConnection.cpp b/Minecraft.Client/PlayerConnection.cpp index d1e1d511a..ccf830427 100644 --- a/Minecraft.Client/PlayerConnection.cpp +++ b/Minecraft.Client/PlayerConnection.cpp @@ -891,9 +891,10 @@ void PlayerConnection::handleTextureAndGeometry(shared_ptr *pvSkinBoxes = app.GetAdditionalSkinBoxes(packet->dwSkinID); + vector *pvSkinOffsets = app.GetModelOffsets(packet->dwSkinID); unsigned int uiAnimOverrideBitmask= app.GetAnimOverrideBitmask(packet->dwSkinID); - send(std::make_shared(packet->textureName, pbData, dwTextureBytes, pvSkinBoxes, uiAnimOverrideBitmask)); + send(std::make_shared(packet->textureName, pbData, dwTextureBytes, pvSkinBoxes, pvSkinOffsets, uiAnimOverrideBitmask)); } } else @@ -917,6 +918,14 @@ void PlayerConnection::handleTextureAndGeometry(shared_ptrdwSkinID,packet->BoxDataA,packet->dwBoxC); } + // add the offsets to the app list + if(packet->dwOffsetC!=0) + { +#ifndef _CONTENT_PACKAGE + wprintf(L"Adding skin offsets for skin id %X, offset count %d\n",packet->dwSkinID,packet->dwOffsetC); +#endif + app.SetSkinOffsets(packet->dwSkinID,packet->OffsetDataA,packet->dwOffsetC); + } // Add the anim override app.SetAnimOverrideBitmask(packet->dwSkinID,packet->uiAnimOverrideBitmask); @@ -966,9 +975,10 @@ void PlayerConnection::handleTextureAndGeometryReceived(const wstring &textureNa // get the data from the app DWORD dwSkinID = app.getSkinIdFromPath(textureName); vector *pvSkinBoxes = app.GetAdditionalSkinBoxes(dwSkinID); + vector *pvSkinOffsets = app.GetModelOffsets(dwSkinID); unsigned int uiAnimOverrideBitmask= app.GetAnimOverrideBitmask(dwSkinID); - send(std::make_shared(textureName, pbData, dwTextureBytes, pvSkinBoxes, uiAnimOverrideBitmask)); + send(std::make_shared(textureName, pbData, dwTextureBytes, pvSkinBoxes, pvSkinOffsets, uiAnimOverrideBitmask)); } m_texturesRequested.erase(it); } diff --git a/Minecraft.Client/PlayerRenderer.cpp b/Minecraft.Client/PlayerRenderer.cpp index 61a0af8ff..6fb9f0f2a 100644 --- a/Minecraft.Client/PlayerRenderer.cpp +++ b/Minecraft.Client/PlayerRenderer.cpp @@ -167,8 +167,8 @@ void PlayerRenderer::render(shared_ptr _mob, double x, double y, double if(mob == nullptr) return; if(mob->hasInvisiblePrivilege()) return; - if (mob != nullptr && humanoidModelClassic != nullptr && (mob->getCustomSkin() == 18 || mob->getAnimOverrideBitmask()&(1<getCustomSkin() >= 8 && mob->getCustomSkin() <= 17) || mob->getAnimOverrideBitmask()&(1<getCustomSkin() == 18 || mob->getAnimOverrideBitmask()&(1<getCustomSkin() >= 8 && mob->getCustomSkin() <= 17) || mob->getAnimOverrideBitmask()&(1< item = mob->inventory->getSelected(); @@ -274,6 +274,7 @@ void PlayerRenderer::render(shared_ptr _mob, double x, double y, double pModelPart->visible=false; } } + armorParts1->bowAndArrow = armorParts2->bowAndArrow = resModel->bowAndArrow = false; armorParts1->sneaking = armorParts2->sneaking = resModel->sneaking = false; armorParts1->holdingRightHand = armorParts2->holdingRightHand = resModel->holdingRightHand = 0; diff --git a/Minecraft.Client/SkinOffset.h b/Minecraft.Client/SkinOffset.h index 39f3780a0..bba7bcc2a 100644 --- a/Minecraft.Client/SkinOffset.h +++ b/Minecraft.Client/SkinOffset.h @@ -31,10 +31,17 @@ enum eBodyOffset }; +enum eOffsetDirection +{ + eOffsetDirection_Unknown=0, + eOffsetDirection_X, + eOffsetDirection_Y, + eOffsetDirection_Z +}; + typedef struct { eBodyOffset ePart; - string fD; - float fO; + float fD, fO; } SKIN_OFFSET; diff --git a/Minecraft.World/Entity.cpp b/Minecraft.World/Entity.cpp index 924312e59..1aabc350e 100644 --- a/Minecraft.World/Entity.cpp +++ b/Minecraft.World/Entity.cpp @@ -2128,7 +2128,12 @@ unsigned int Entity::getAnimOverrideBitmask() (1<SetAdditionalModelParts(nullptr); + this->SetModelOffsets(nullptr); } @@ -759,6 +765,12 @@ unsigned int Player::getSkinAnimOverrideBitmask(DWORD skinId) return bitmask; } +vector *Player::getSkinModelOffsets(DWORD skinId) +{ + vector *skinOffsets = app.GetModelOffsets(skinId); + return skinOffsets; +} + void Player::setXuid(PlayerUID xuid) { m_xuid = xuid; @@ -3148,11 +3160,57 @@ vector *Player::GetAdditionalModelParts() return m_ppAdditionalModelParts; } +vector *Player::GetModelOffsets() +{ + if(m_ppModelOffsets==nullptr && !m_bCheckedForModelOffsets) + { + bool hasCustomTexture = !customTextureUrl.empty(); + bool customTextureIsDefaultSkin = customTextureUrl.substr(0,3).compare(L"def") == 0; + + // see if we can find the parts + m_ppModelOffsets=app.GetModelOffsets(m_dwSkinId); + + // If it's a default texture (which has no parts), we have the parts, or we already have the texture (in which case we should have parts if there are any) then we are done + if(!hasCustomTexture || customTextureIsDefaultSkin || m_ppModelOffsets != nullptr || app.IsFileInMemoryTextures(customTextureUrl)) + { + m_bCheckedForModelOffsets=true; + } + if(m_ppModelOffsets == nullptr && !m_bCheckedDLCForModelOffsets) + { + m_bCheckedDLCForModelOffsets = true; + + // we don't have the data from the dlc skin yet + app.DebugPrintf("m_bCheckedForModelOffsets Couldn't get model offsets for skin %X\n",m_dwSkinId); + + // do we have it from the DLC pack? + DLCSkinFile *pDLCSkinFile = app.m_dlcManager.getSkinFile(this->customTextureUrl); + + if(pDLCSkinFile!=nullptr) + { + DWORD dwBoxC=pDLCSkinFile->getOffsetsCount(); + if(dwBoxC!=0) + { + app.DebugPrintf("m_bCheckedForModelOffsets Got model offsets from DLCskin for skin %X\n",m_dwSkinId); + m_ppModelOffsets=app.SetSkinOffsets(m_dwSkinId,pDLCSkinFile->getOffsets()); + } + + m_bCheckedForModelOffsets=true; + } + } + } + return m_ppModelOffsets; +} + void Player::SetAdditionalModelParts(vector *ppAdditionalModelParts) { m_ppAdditionalModelParts=ppAdditionalModelParts; } +void Player::SetModelOffsets(vector *ppModelOffsets) +{ + m_ppModelOffsets=ppModelOffsets; +} + #if defined(__PS3__) || defined(__ORBIS__) Player::ePlayerNameValidState Player::GetPlayerNameValidState(void) diff --git a/Minecraft.World/Player.h b/Minecraft.World/Player.h index 2e223a1e5..8cb219742 100644 --- a/Minecraft.World/Player.h +++ b/Minecraft.World/Player.h @@ -411,6 +411,7 @@ public: static DWORD getCapeIdFromPath(const wstring &cape); static wstring getCapePathFromId(DWORD capeId); static unsigned int getSkinAnimOverrideBitmask(DWORD skinId); + vector *getSkinModelOffsets(DWORD skinId); // 4J Added void setXuid(PlayerUID xuid); @@ -520,6 +521,8 @@ public: vector *GetAdditionalModelParts(); void SetAdditionalModelParts(vector *ppAdditionalModelParts); + vector *GetModelOffsets(); + void SetModelOffsets(vector *ppModelOffsets); #if defined(__PS3__) || defined(__ORBIS__) enum ePlayerNameValidState @@ -536,6 +539,9 @@ private: vector *m_ppAdditionalModelParts; bool m_bCheckedForModelParts; bool m_bCheckedDLCForModelParts; + vector *m_ppModelOffsets; + bool m_bCheckedForModelOffsets; + bool m_bCheckedDLCForModelOffsets; #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 diff --git a/Minecraft.World/TextureAndGeometryPacket.cpp b/Minecraft.World/TextureAndGeometryPacket.cpp index 41fe933fe..c777f961b 100644 --- a/Minecraft.World/TextureAndGeometryPacket.cpp +++ b/Minecraft.World/TextureAndGeometryPacket.cpp @@ -12,7 +12,9 @@ TextureAndGeometryPacket::TextureAndGeometryPacket() this->dwTextureBytes = 0; this->pbData = nullptr; this->dwBoxC = 0; + this->dwOffsetC = 0; this->BoxDataA = nullptr; + this->OffsetDataA = nullptr; uiAnimOverrideBitmask=0; } @@ -43,7 +45,9 @@ TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, P this->pbData = pbData; this->dwTextureBytes = dwBytes; this->dwBoxC = 0; + this->dwOffsetC = 0; this->BoxDataA=nullptr; + this->OffsetDataA=nullptr; this->uiAnimOverrideBitmask=0; } @@ -62,6 +66,7 @@ TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, P this->dwTextureBytes = dwBytes; this->uiAnimOverrideBitmask = pDLCSkinFile->getAnimOverrideBitmask(); this->dwBoxC = pDLCSkinFile->getAdditionalBoxesCount(); + this->dwOffsetC = pDLCSkinFile->getOffsetsCount(); if(this->dwBoxC!=0) { this->BoxDataA= new SKIN_BOX [this->dwBoxC]; @@ -77,9 +82,24 @@ TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, P { this->BoxDataA=nullptr; } + if(this->dwOffsetC!=0) + { + this->OffsetDataA= new SKIN_OFFSET [this->dwOffsetC]; + vector *pSkinOffsets=pDLCSkinFile->getOffsets(); + int iCount=0; + + for(auto& pSkinOffset : *pSkinOffsets) + { + this->OffsetDataA[iCount++]=*pSkinOffset; + } + } + else + { + this->OffsetDataA=nullptr; + } } -TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, PBYTE pbData, DWORD dwBytes,vector *pvSkinBoxes, unsigned int uiAnimOverrideBitmask) +TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, PBYTE pbData, DWORD dwBytes, vector *pvSkinBoxes, vector *pvSkinOffsets, unsigned int uiAnimOverrideBitmask) { this->textureName = textureName; @@ -109,6 +129,22 @@ TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, P this->BoxDataA[iCount++]=*pSkinBox; } } + if(pvSkinOffsets==nullptr) + { + this->dwOffsetC=0; + this->OffsetDataA=nullptr; + } + else + { + this->dwOffsetC = static_cast(pvSkinOffsets->size()); + this->OffsetDataA= new SKIN_OFFSET [this->dwOffsetC]; + int iCount=0; + + for(auto& pSkinOffset : *pvSkinOffsets) + { + this->OffsetDataA[iCount++]=*pSkinOffset; + } + } } @@ -148,6 +184,7 @@ void TextureAndGeometryPacket::read(DataInputStream *dis) //throws IOException uiAnimOverrideBitmask = dis->readInt(); short rawBoxC = dis->readShort(); + short rawOffsetC = dis->readShort(); if (rawBoxC <= 0) { dwBoxC = 0; @@ -160,11 +197,27 @@ void TextureAndGeometryPacket::read(DataInputStream *dis) //throws IOException dwBoxC = 0; // sane limit for skin boxes } } + if (rawOffsetC <= 0) + { + dwOffsetC = 0; + } + else + { + dwOffsetC = (DWORD)(unsigned short)rawOffsetC; + if (dwOffsetC > 256) + { + dwOffsetC = 0; // sane limit for skin offsets + } + } if(dwBoxC>0) { this->BoxDataA= new SKIN_BOX [dwBoxC]; } + if(dwOffsetC>0) + { + this->OffsetDataA= new SKIN_OFFSET [dwOffsetC]; + } for(DWORD i=0;iBoxDataA[i].fM = dis->readFloat(); this->BoxDataA[i].fS = dis->readFloat(); } + for(DWORD i=0;iOffsetDataA[i].ePart = static_cast(dis->readShort()); + this->OffsetDataA[i].fD = dis->readFloat(); + this->OffsetDataA[i].fO = dis->readFloat(); + } } void TextureAndGeometryPacket::write(DataOutputStream *dos) //throws IOException @@ -210,6 +269,14 @@ void TextureAndGeometryPacket::write(DataOutputStream *dos) //throws IOException dos->writeFloat(this->BoxDataA[i].fM); dos->writeFloat(this->BoxDataA[i].fS); } + + dos->writeShort(static_cast(dwOffsetC)); + for(DWORD i=0;iwriteShort(static_cast(this->OffsetDataA[i].ePart)); + dos->writeFloat(this->OffsetDataA[i].fD); + dos->writeFloat(this->OffsetDataA[i].fO); + } } int TextureAndGeometryPacket::getEstimatedSize() diff --git a/Minecraft.World/TextureAndGeometryPacket.h b/Minecraft.World/TextureAndGeometryPacket.h index 8577f03df..370d0b9b1 100644 --- a/Minecraft.World/TextureAndGeometryPacket.h +++ b/Minecraft.World/TextureAndGeometryPacket.h @@ -4,6 +4,7 @@ using namespace std; #include "Packet.h" #include "..\Minecraft.Client\Model.h" #include "..\Minecraft.Client\SkinBox.h" +#include "..\Minecraft.Client\SkinOffset.h" class DLCSkinFile; @@ -15,14 +16,16 @@ public: PBYTE pbData; DWORD dwTextureBytes; SKIN_BOX *BoxDataA; + SKIN_OFFSET *OffsetDataA; DWORD dwBoxC; + DWORD dwOffsetC; unsigned int uiAnimOverrideBitmask; TextureAndGeometryPacket(); ~TextureAndGeometryPacket(); TextureAndGeometryPacket(const wstring &textureName, PBYTE pbData, DWORD dwBytes); TextureAndGeometryPacket(const wstring &textureName, PBYTE pbData, DWORD dwBytes, DLCSkinFile *pDLCSkinFile); - TextureAndGeometryPacket(const wstring &textureName, PBYTE pbData, DWORD dwBytes, vector *pvSkinBoxes, unsigned int uiAnimOverrideBitmask); + TextureAndGeometryPacket(const wstring &textureName, PBYTE pbData, DWORD dwBytes, vector *pvSkinBoxes, vector *pvSkinOffsets, unsigned int uiAnimOverrideBitmask); virtual void handle(PacketListener *listener); virtual void read(DataInputStream *dis);