feat(TU31): classic crafting (#48)

credits: comicgab
This commit is contained in:
SevenToaster509
2026-05-01 19:44:30 +03:00
committed by GitHub
parent a51d7ae834
commit 05d7ccb6d4
32 changed files with 819 additions and 186 deletions
@@ -1,72 +1,171 @@
#include "stdafx.h"
#include "IUIScene_InventoryMenu.h"
#include "../../../Minecraft.World/net.minecraft.world.inventory.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h"
#include "..\..\Minecraft.h"
#include "..\..\MultiPlayerLocalPlayer.h"
IUIScene_AbstractContainerMenu::ESceneSection IUIScene_InventoryMenu::GetSectionAndSlotInDirection( ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY )
IUIScene_AbstractContainerMenu::ESceneSection IUIScene_InventoryMenu::GetSectionAndSlotInDirection(ESceneSection eSection, ETapState eTapDirection, int* piTargetX, int* piTargetY)
{
ESceneSection newSection = eSection;
Minecraft* pMinecraft = Minecraft::GetInstance();
// Find the new section if there is one
switch( eSection )
{
case eSectionInventoryArmor:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionInventoryInventory;
}
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionInventoryUsing;
}
break;
case eSectionInventoryInventory:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionInventoryUsing;
}
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionInventoryArmor;
}
break;
case eSectionInventoryUsing:
if(eTapDirection == eTapStateDown)
{
newSection = eSectionInventoryArmor;
}
else if(eTapDirection == eTapStateUp)
{
newSection = eSectionInventoryInventory;
}
break;
default:
assert( false );
break;
}
ESceneSection newSection = eSection;
int xOffset = 0;
int yOffset = 0;
updateSlotPosition(eSection, newSection, eTapDirection, piTargetX, piTargetY, 0);
//auto containerData = this->m_containerData;
return newSection;
switch (eSection)
{
case eSectionInventoryInventory:
if (eTapDirection == eTapStateDown)
{
newSection = eSectionInventoryUsing;
}
else if (eTapDirection == eTapStateUp)
{
if (app.GetGameSettings(getPad(), eGameSetting_ClassicCrafting) && *piTargetX >= 3)
{
if (*piTargetX < 7) {
newSection = eSectionInventoryCraftingGrid;
xOffset = 5;
}
else {
newSection = eSectionInventoryCraftingResult;
}
}
else
{
newSection = eSectionInventoryArmor;
}
}
break;
case eSectionInventoryUsing:
if (eTapDirection == eTapStateUp)
{
newSection = eSectionInventoryInventory;
}
else if (eTapDirection == eTapStateDown)
{
if (app.GetGameSettings(getPad(), eGameSetting_ClassicCrafting) && *piTargetX >= 3)
{
if (*piTargetX < 7) {
newSection = eSectionInventoryCraftingGrid;
xOffset = 5;
}
else {
newSection = eSectionInventoryCraftingResult;
}
}
else
{
newSection = eSectionInventoryArmor;
}
}
break;
case eSectionInventoryArmor:
if (eTapDirection == eTapStateDown)
{
newSection = eSectionInventoryInventory;
}
else if (eTapDirection == eTapStateUp)
{
newSection = eSectionInventoryUsing;
}
else if (eTapDirection == eTapStateLeft && app.GetGameSettings(getPad(), eGameSetting_ClassicCrafting))
{
newSection = eSectionInventoryCraftingResult;
}
else if (eTapDirection == eTapStateRight && app.GetGameSettings(getPad(), eGameSetting_ClassicCrafting))
{
newSection = eSectionInventoryCraftingGrid;
xOffset = 1;
yOffset = 1;
}
break;
case eSectionInventoryCraftingGrid:
if (app.GetGameSettings(getPad(), eGameSetting_ClassicCrafting))
{
if (eTapDirection == eTapStateUp)
{
newSection = eSectionInventoryUsing;
xOffset = -5;
}
else if (eTapDirection == eTapStateDown)
{
newSection = eSectionInventoryInventory;
xOffset = -5;
}
else if (eTapDirection == eTapStateLeft)
{
newSection = eSectionInventoryArmor;
yOffset = -1;
}
else if (eTapDirection == eTapStateRight)
{
newSection = eSectionInventoryCraftingResult;
}
}
break;
case eSectionInventoryCraftingResult:
if (app.GetGameSettings(getPad(), eGameSetting_ClassicCrafting))
{
if (eTapDirection == eTapStateUp)
{
newSection = eSectionInventoryUsing;
xOffset = -8;
}
else if (eTapDirection == eTapStateDown)
{
newSection = eSectionInventoryInventory;
xOffset = -8;
}
else if (eTapDirection == eTapStateLeft)
{
newSection = eSectionInventoryCraftingGrid;
//*piTargetX = containerData->getSectionColumns(eSectionInventoryCraftingGrid);
}
else if (eTapDirection == eTapStateRight)
{
newSection = eSectionInventoryArmor;
}
}
break;
default:
assert(false);
break;
}
IUIScene_AbstractContainerMenu::updateSlotPosition(eSection, newSection, eTapDirection, piTargetX, piTargetY, xOffset, yOffset);
return newSection;
}
int IUIScene_InventoryMenu::getSectionStartOffset(ESceneSection eSection)
{
int offset = 0;
switch( eSection )
{
case eSectionInventoryArmor:
offset = InventoryMenu::ARMOR_SLOT_START;
break;
case eSectionInventoryInventory:
offset = InventoryMenu::INV_SLOT_START;
break;
case eSectionInventoryUsing:
offset = InventoryMenu::INV_SLOT_START + 27;
break;
default:
assert( false );
break;
}
return offset;
int offset = 0;
switch (eSection)
{
case eSectionInventoryArmor:
offset = InventoryMenu::ARMOR_SLOT_START;
break;
case eSectionInventoryInventory:
offset = InventoryMenu::INV_SLOT_START;
break;
case eSectionInventoryUsing:
offset = InventoryMenu::INV_SLOT_START + 27;
break;
case eSectionInventoryCraftingGrid:
offset = InventoryMenu::CRAFT_SLOT_START;
break;
case eSectionInventoryCraftingResult:
offset = InventoryMenu::RESULT_SLOT;
break;
default:
assert(false);
break;
}
return offset;
}