* Improve survival mode stuff.

This commit is contained in:
iProgramInCpp
2023-08-04 11:18:28 +03:00
parent 1921552b18
commit 1386b3d658
20 changed files with 458 additions and 88 deletions

View File

@@ -234,36 +234,24 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY)
m->m_pTextures->loadAndBindTexture("gui/gui_blocks.png");
Tesselator& t = Tesselator::instance;
t.begin();
// if we aren't trying to build the real deal, don't do this. It only does worse
#ifdef ORIGINAL_CODE
t.voidBeginAndEndCalls(true); // to ensure that Gui::renderSlot doesn't end() our tesselator right away?
#endif
int slotX = cenX - 88;
#ifdef ENH_ENABLE_9TH_SLOT
#define HOTBAR_DIFF 0
#else
#define HOTBAR_DIFF 1
#endif
for (int i = 0; i < C_MAX_HOTBAR_ITEMS - HOTBAR_DIFF; i++)
for (int i = 0; i < C_MAX_HOTBAR_ITEMS; i++)
{
renderSlot(i, slotX, height - 19, f);
slotX += 20;
}
#undef HOTBAR_DIFF
slotX = cenX - 88;
for (int i = 0; i < C_MAX_HOTBAR_ITEMS; i++)
{
renderSlotOverlay(i, slotX, height - 19, f);
slotX += 20;
}
field_A3C = false;
#ifdef ORIGINAL_CODE
t.voidBeginAndEndCalls(false);
#endif
t.draw();
// blit the "more items" button
#ifndef ENH_ENABLE_9TH_SLOT
m->m_pTextures->loadAndBindTexture(C_TERRAIN_NAME);
@@ -315,12 +303,30 @@ void Gui::tick()
void Gui::renderSlot(int slot, int x, int y, float f)
{
int itemID = m_pMinecraft->m_pLocalPlayer->m_pInventory->getQuickSlotItemId(slot);
if (itemID < 0)
Inventory* pInv = m_pMinecraft->m_pLocalPlayer->m_pInventory;
ItemInstance* pInst = pInv->getQuickSlotItem(slot);
if (!pInst)
return;
ItemInstance inst(Item::items[itemID], 1, 0);
ItemRenderer::renderGuiItem(m_pMinecraft->m_pFont, m_pMinecraft->m_pTextures, &inst, x, y, true);
if (!pInst->m_itemID)
return;
ItemRenderer::renderGuiItem(m_pMinecraft->m_pFont, m_pMinecraft->m_pTextures, pInst, x, y, true);
}
void Gui::renderSlotOverlay(int slot, int x, int y, float f)
{
Inventory* pInv = m_pMinecraft->m_pLocalPlayer->m_pInventory;
ItemInstance* pInst = pInv->getQuickSlotItem(slot);
if (!pInst)
return;
if (!pInst->m_itemID)
return;
ItemRenderer::renderGuiItemOverlay(m_pMinecraft->m_pFont, m_pMinecraft->m_pTextures, pInst, x, y);
}
int Gui::getSlotIdAt(int mouseX, int mouseY)

View File

@@ -35,6 +35,7 @@ public:
void render(float f, bool bHaveScreen, int mouseX, int mouseY);
void tick();
void renderSlot(int slot, int x, int y, float f);
void renderSlotOverlay(int slot, int x, int y, float f);
int getSlotIdAt(int mx, int my);
bool isInside(int mx, int my);
void handleClick(int id, int mx, int my);

View File

@@ -71,7 +71,7 @@ void IngameBlockSelectionScreen::init()
{
if (pInv->getItem(i)->m_itemID == pInv->getSelectedItemId())
{
m_selectedSlot = i - 9;
m_selectedSlot = i;
break;
}
}
@@ -86,7 +86,11 @@ void IngameBlockSelectionScreen::renderSlot(int index, int x, int y, float f)
if (!pItem)
return;
ItemRenderer::renderGuiItem(m_pMinecraft->m_pFont, m_pMinecraft->m_pTextures, pItem, x, y, pItem != nullptr);
if (!pItem->m_itemID)
return;
ItemRenderer::renderGuiItem(m_pMinecraft->m_pFont, m_pMinecraft->m_pTextures, pItem, x, y, true);
ItemRenderer::renderGuiItemOverlay(m_pMinecraft->m_pFont, m_pMinecraft->m_pTextures, pItem, x, y);
}
void IngameBlockSelectionScreen::renderSlots()