Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions GameMods.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#define ENH_ALLOW_SCROLL_WHEEL // Allow use of the scroll wheel to change selected inventory slots
#define ENH_3D_INVENTORY_TILES // Uses 3D rendered inventory tiles, use with ENH_SHADE_HELD_TILES to render correctly.
#define ENH_MENU_BACKGROUND // Renders a spinning panorama (if it's available) in the background of the main menu
#define ENH_GUI_ITEM_POP // Calls Inventory::tick() to create the "pop" animation for items that enter the hotbar. This function was not present on Pocket Edition.

// TODO: Implement this permanently?
#define ENH_IMPROVED_SAVING // Improve world saving. The original Minecraft doesn't always really save for some reason
Expand Down
54 changes: 51 additions & 3 deletions compat/PlatformDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,54 @@
#include <TargetConditionals.h>
#endif

#define MC_TARGET_OS_SIMULATOR (TARGET_OS_SIMULATOR || TARGET_IPHONE_SIMULATOR)
#define MC_TARGET_OS_IOS (TARGET_OS_IPHONE && (TARGET_OS_IOS || !defined(TARGET_OS_IOS)))
#define MC_TARGET_OS_MAC (TARGET_OS_MAC)
/* Apple - Mac OS X / macOS */
#if (TARGET_OS_MAC && (TARGET_OS_OSX || !defined(TARGET_OS_OSX)))
#define MC_PLATFORM_MAC 1
#else
#define MC_PLATFORM_MAC 0
#endif

/* Apple - iPhoneOS / iOS */
#if (TARGET_OS_IPHONE && (TARGET_OS_IOS || !defined(TARGET_OS_IOS)))
#define MC_PLATFORM_IOS 1
#else
#define MC_PLATFORM_IOS 0
#endif

/* Apple - Device Simulator */
#define MC_PLATFORM_SIMULATOR (TARGET_OS_SIMULATOR || TARGET_IPHONE_SIMULATOR)

/* Microsoft - Xbox */
#ifdef _XBOX
#define MC_PLATFORM_XBOX 1
#else
#define MC_PLATFORM_XBOX 0
#endif

/* Microsoft - Xbox One */
#if (defined (_DURANGO) || defined(_XBOX_ONE))
#define MC_PLATFORM_XBOXONE 1
#else
#define MC_PLATFORM_XBOXONE 0
#endif

/* Microsoft - Xbox 360 */
#if (defined (X360) && !MC_PLATFORM_XBOXONE)
#define MC_PLATFORM_XBOX360 1
#else
#define MC_PLATFORM_XBOX360 0
#endif

/* Microsoft - Original Xbox */
#if (defined (_XBOX) && !MC_PLATFORM_XBOX360 && !MC_PLATFORM_XBOXONE && !defined(WINDOWS_STORE_RT))
#define MC_PLATFORM_XBOXOG 1
#else
#define MC_PLATFORM_XBOXOG 0
#endif

/* Microsoft - Windows PC */
#if (defined (_WIN32) && !MC_PLATFORM_XBOX && !defined(WINDOWS_PHONE_8) && !defined(WINDOWS_STORE_RT))
#define MC_PLATFORM_WINPC 1
#else
#define MC_PLATFORM_WINPC 0
#endif
2 changes: 1 addition & 1 deletion platforms/ios/minecraftpeViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ - (void)updateDrawSize
// I guess when the device is sideways, the view doesn't rotate to be upright?
Minecraft::width = self.height; // drawWidth
Minecraft::height = self.width; // drawHeight
Minecraft::setGuiScaleMultiplier(self->viewScale);
Minecraft::setRenderScaleMultiplier(self->viewScale);
self->_app->sizeUpdate(self.height / self->viewScale, self.width / self->viewScale); // windowWidth, windowHeight
NSLog(@"Updated draw size to %d, %d\n", self.height, self.width);
}
Expand Down
170 changes: 79 additions & 91 deletions platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion platforms/sdl/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ static void resize()

// Update the scale multiplier. We use the same value, because we pass to `sizeUpdate`, the window width/height.
// They will be multiplied by the GUI scale multiplier, becoming the drawwidth and drawheight, times the decided on GUI scale.
Minecraft::setGuiScaleMultiplier(g_fPointToPixelScale);
Minecraft::setRenderScaleMultiplier(g_fPointToPixelScale);

// give it an update.
// As said before, internally, this multiplies by the GUI scale multiplier
Expand Down
28 changes: 16 additions & 12 deletions source/client/app/Minecraft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@
// custom:
#include "client/renderer/PatchManager.hpp"

float Minecraft::_renderScaleMultiplier = 1.0f;

int Minecraft::width = C_DEFAULT_SCREEN_WIDTH;
int Minecraft::height = C_DEFAULT_SCREEN_HEIGHT;
float Minecraft::guiScaleMultiplier = 1.0f;
bool Minecraft::useAmbientOcclusion = false;
int Minecraft::customDebugId = 0;

Expand Down Expand Up @@ -267,11 +268,6 @@ void Minecraft::setGameMode(GameType gameType)
}
}

void Minecraft::setGuiScaleMultiplier(float f)
{
guiScaleMultiplier = f;
}

void Minecraft::handleBuildAction(const BuildActionIntention& action)
{
LocalPlayer* player = m_pLocalPlayer;
Expand Down Expand Up @@ -489,7 +485,7 @@ void Minecraft::tickInput()
if (item != nullptr)
{
ItemInstance itemDrop = m_pLocalPlayer->isSurvival() ? item->remove(1) : ItemInstance(*item);
itemDrop.m_amount = 1;
itemDrop.m_count = 1;
m_pLocalPlayer->drop(&itemDrop);
}
}
Expand Down Expand Up @@ -714,6 +710,12 @@ void Minecraft::tick()

if (m_pLevel && !isGamePaused())
{
m_pLevel->m_difficulty = m_options->m_difficulty;
if (m_pLevel->m_bIsMultiplayer)
{
m_pLevel->m_difficulty = 3;
}

m_pGameMode->tick();
m_pGameRenderer->tick();
m_pLevelRenderer->tick();
Expand Down Expand Up @@ -987,7 +989,7 @@ void Minecraft::prepareLevel(const std::string& unused)
void Minecraft::sizeUpdate(int newWidth, int newHeight)
{
// re-calculate the GUI scale.
Gui::InvGuiScale = getBestScaleForThisScreenSize(newWidth, newHeight) / guiScaleMultiplier;
Gui::InvGuiScale = getBestScaleForThisScreenSize(newWidth, newHeight) / getRenderScaleMultiplier();

// The ceil gives an extra pixel to the screen's width and height, in case the GUI scale doesn't
// divide evenly into width or height, so that none of the game screen is uncovered.
Expand Down Expand Up @@ -1192,12 +1194,14 @@ ItemInstance* Minecraft::getSelectedItem()
if (m_pGameMode->isSurvivalType())
return pInst;

if (pInst->m_itemID == 0)
// Create new "unlimited" ItemInstance for Creative mode

if (pInst->isNull())
return nullptr;

m_CurrItemInstance.m_itemID = pInst->m_itemID;
m_CurrItemInstance.m_amount = 999;
m_CurrItemInstance.m_auxValue = pInst->m_auxValue;
m_CurrItemInstance.m_count = 999;
m_CurrItemInstance.setAuxValue(pInst->getAuxValue());

return &m_CurrItemInstance;
}
Expand Down Expand Up @@ -1290,4 +1294,4 @@ void Minecraft::locateMultiplayer()
m_pRakNetInstance->pingForHosts(C_DEFAULT_PORT);
m_pNetEventCallback = new ClientSideNetworkHandler(this, m_pRakNetInstance);
#endif
}
}
10 changes: 7 additions & 3 deletions source/client/app/Minecraft.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,20 @@ class Minecraft : public App
LevelStorageSource* getLevelSource();
ItemInstance* getSelectedItem();
Options* getOptions() const { return m_options; }

static void setGuiScaleMultiplier(float f);

private:
void _reloadInput();
void _levelGenerated();
GameMode* createGameMode(GameType gameType, Level& level);

private:
// Value provided by the OS
static float _renderScaleMultiplier;
public:
static float getRenderScaleMultiplier() { return _renderScaleMultiplier; }
static void setRenderScaleMultiplier(float value) { _renderScaleMultiplier = value; }

public:
static float guiScaleMultiplier;
static int width, height;
static bool useAmbientOcclusion;
static const char* progressMessages[];
Expand Down
23 changes: 17 additions & 6 deletions source/client/gui/Gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,13 +417,24 @@ void Gui::renderSlot(int slot, int x, int y, float f)
Inventory* pInv = m_pMinecraft->m_pLocalPlayer->m_pInventory;

ItemInstance* pInst = pInv->getQuickSlotItem(slot);
if (!pInst)
if (pInst == nullptr || pInst->m_itemID <= 0)
return;

if (!pInst->m_itemID)
return;

ItemRenderer::renderGuiItem(m_pMinecraft->m_pFont, m_pMinecraft->m_pTextures, pInst, x, y, true);
float var6 = ((float)pInst->m_popTime) - f;
if (var6 > 0.0f)
{
glPushMatrix();
float var7 = 1.0f + var6 / 5.0f;
glTranslatef(x + 8, y + 12, 0.0f);
glScalef(1.0f / var7, (var7 + 1.0f) / 2.0f, 1.0f);
glTranslatef(-(x + 8), -(y + 12), 0.0f);
}

ItemRenderer::renderGuiItem(m_pMinecraft->m_pFont, m_pMinecraft->m_pTextures, pInst, x, y, true);
if (var6 > 0.0f)
glPopMatrix();

//ItemRenderer::renderGuiItemDecorations(m_pMinecraft->m_pFont, m_pMinecraft->m_pTextures, pInst, x, y);
}

void Gui::renderSlotOverlay(int slot, int x, int y, float f)
Expand Down Expand Up @@ -592,4 +603,4 @@ RectangleArea Gui::getRectangleArea(bool b)
Minecraft::height - 24.0f / InvGuiScale,
centerX + hotbarWidthHalf,
Minecraft::height);
}
}
25 changes: 9 additions & 16 deletions source/client/model/Cube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,17 @@ Cube::Cube(ModelPart* a2, int a3, int a4, float x, float y, float z, int d, int
m_faces[0] = PolygonQuad(&m_verts[5], &m_verts[1], &m_verts[2], &m_verts[6], m + f + d, n + f, m + f + d + f, n + f + e); // x2 face
m_faces[1] = PolygonQuad(&m_verts[0], &m_verts[4], &m_verts[7], &m_verts[3], m, n + f, m + f, n + f + e); // x1 face
m_faces[2] = PolygonQuad(&m_verts[5], &m_verts[4], &m_verts[0], &m_verts[1], m + f, n, m + f + d, n + f); // up face
m_faces[3] = PolygonQuad(&m_verts[7], &m_verts[6], &m_verts[2], &m_verts[3], m + f + d, n, m + f + d + d, n + f); // down face*
m_faces[3] = PolygonQuad(&m_verts[2], &m_verts[3], &m_verts[7], &m_verts[6], m + f + d, n, m + f + d + d, n + f); // down face*
m_faces[4] = PolygonQuad(&m_verts[1], &m_verts[0], &m_verts[3], &m_verts[2], m + f, n + f, m + f + d, n + f + e); // z1 face
m_faces[5] = PolygonQuad(&m_verts[4], &m_verts[5], &m_verts[6], &m_verts[7], m + f + d + f, n + f, m + f + d + f + d, n + f + e); // z2 face

#ifdef ENH_ENTITY_SHADING && 0
// Applies shading that is identical to that of the in-hand block. This doesn't look any different.
// - Brent
#define SHADE_FACE(face, shade) m_faces[face].setColor(shade, shade, shade)
SHADE_FACE(0, 0.8f); // south
SHADE_FACE(1, 0.8f); // north
SHADE_FACE(2, 0.5f); // up
//SHADE_FACE(3, 1.0f); // down
SHADE_FACE(4, 0.6f); // east
SHADE_FACE(5, 0.6f); // west
#endif

// *N.B. The original game specifies the vertex ordering as 2, 3, 7, 6, but that renders the back side of the cow upside down.
// This might not be proper form for the face, but we're disabling culling anyway so who cares.

// *N.B. The original game specifies the vertex ordering as 2, 3, 7, 6, but that renders the back side of the cow upside down.
// This might not be proper form for the face, but we're disabling culling anyway so who cares.

// Despite the updated vertex ordering, the textures I have are causing the cow's back side
// to be rendered upside down. Perhaps it's a texture issue, not a vertex ordering issue.
// Reverting to b1.2_02 defaults for now, as it corrects the problem on my end.
// - Brent

if (a2->m_bMirror)
{
Expand Down
2 changes: 1 addition & 1 deletion source/client/model/ModelPart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void ModelPart::draw()
{
// We are not using drawArrayVTC here since that would use the color that's compiled initially into the ModelPart
// and would therefore not allow for on-the-fly coloring.
drawArrayVTN(this->m_buffer, 36 * m_pCubes.size(), sizeof(Tesselator::Vertex));
drawArrayVTN(this->m_buffer, 36 * (int)m_pCubes.size(), sizeof(Tesselator::Vertex));
}

void ModelPart::drawSlow(float scale)
Expand Down
4 changes: 2 additions & 2 deletions source/client/options/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Options::Option

void Options::_initDefaultValues()
{
field_238 = 2;
m_difficulty = 2;
field_244 = 1.0f;
m_bDontRenderGui = false;
field_248 = 1.0f;
Expand Down Expand Up @@ -441,4 +441,4 @@ void Options::loadControls()
#endif
#undef KM
}
}
}
2 changes: 1 addition & 1 deletion source/client/options/Options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class Options
bool m_bAmbientOcclusion;
uint8_t field_19; // use Mouse as input for breaking
std::string field_1C;
int field_238;
int m_difficulty;
bool m_bDontRenderGui;
bool m_bThirdPerson;
uint8_t field_23E;
Expand Down
4 changes: 2 additions & 2 deletions source/client/renderer/GameRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ void GameRenderer::bobView(float f)
return;

Player* player = (Player*)m_pMinecraft->m_pMobPersp;
float f1 = Mth::Lerp(player->field_B9C, player->field_BA0, f);
float f2 = Mth::Lerp(player->field_118, player->field_11C, f);
float f1 = Mth::Lerp(player->m_oBob, player->m_bob, f);
float f2 = Mth::Lerp(player->m_oTilt, player->m_tilt, f);
// @NOTE: Multiplying by M_PI inside of the paren makes it stuttery for some reason? Anyways it works now :)
float f3 = -(player->m_walkDist + (player->m_walkDist - player->field_90) * f) * float(M_PI);
float f4 = Mth::sin(f3);
Expand Down
Loading