diff --git a/.gitignore b/.gitignore index f46095c4..014f3b98 100644 --- a/.gitignore +++ b/.gitignore @@ -161,6 +161,16 @@ xcuserdata/ /game/assets/misc/foliagecolor.png /game/assets/misc/grasscolor.png /game/assets/mob/char.png +/game/assets/mob/chicken.png +/game/assets/mob/cow.png +/game/assets/mob/creeper.png +/game/assets/mob/pig.png +/game/assets/mob/pigzombie.png +/game/assets/mob/sheep.png +/game/assets/mob/sheep_fur.png +/game/assets/mob/skeleton.png +/game/assets/mob/spider.png +/game/assets/mob/zombie.png /game/assets/particles.png /game/assets/terrain.png /game/assets/gui/buynow.png @@ -204,4 +214,3 @@ xcuserdata/ /game/assets/gui/feedback_fill.png /game/assets/gui/feedback_outer.png /game/assets/snow.png -/game/assets/mob/pig.png diff --git a/GameMods.hpp b/GameMods.hpp index d47fc363..031d09e5 100644 --- a/GameMods.hpp +++ b/GameMods.hpp @@ -3,16 +3,12 @@ // Here is a list of options that you can enable when building the project: // ORIGINAL_CODE - Unpatches all bugs and allows building for Xperia Play only. (TODO) -// #define ORIGINAL_CODE +//#define ORIGINAL_CODE #ifdef ORIGINAL_CODE #define DEMO #else -#if defined ANDROID || defined TARGET_OS_IPHONE -#define MOBILE -#endif - // TODO: Since this is the modded version, we don't need these anymore. Remove them // Mods @@ -22,9 +18,7 @@ //#define MOD_POPOUT_CONSOLE // Open a separate console aside from the game window. By default only the debugger can see our logs. Win32 Debug only. // Tests -//#define TEST_DROPPED_ITEMS // Allow dropped items to be dropped and collected. //#define TEST_SURVIVAL_MODE // Test survival mode. -#define TEST_TOUCH_SCREEN // Test touch screen controls. The mouse will simulate one touch finger. // Enhancements //#define ENH_ENTITY_SHADING // Allows shading of entities -- Currently we are abandoning this. Want to add normal support @@ -36,19 +30,17 @@ #define ENH_USE_JAVA_LIGHT_RAMP // Use Java Beta 1.3 light ramp instead of flawed PE one #define ENH_RUN_DAY_NIGHT_CYCLE // Allow the day/night cycle to run. #define ENH_USE_OWN_AO // Use own ambient occlusion engine - looks pretty much the same except it fixes the corners -#define ENH_ADD_OPTIONS_PAUSE // Add an 'options' button in the pause menu -#define ENH_EXTRA_ITEMS_IN_INV // Add extra items in a new 5th row in the inventory. +#define ENH_ADD_OPTIONS_PAUSE // Add an 'options' button in the pause menu= #define ENH_HIGHLIGHT_BY_HOVER // Highlight buttons by hovering them instead of the usual way. #define ENH_ALLOW_SAND_GRAVITY // Allow sand to fall. #define ENH_USE_GUI_SCALE_2 // Use a 2x GUI scale instead of 3x. Looks better on PC #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. + +// TODO: Implement this permanently? #define ENH_IMPROVED_SAVING // Improve world saving. The original Minecraft doesn't always really save for some reason // Toggle Demo Mode //#define DEMO -// Enable Debug Mode -//#define MC_DEBUG - #endif diff --git a/source/client/app/AppPlatform.cpp b/source/client/app/AppPlatform.cpp index 8258948a..917f1a00 100644 --- a/source/client/app/AppPlatform.cpp +++ b/source/client/app/AppPlatform.cpp @@ -107,6 +107,8 @@ Texture AppPlatform::loadTexture(const std::string&, bool bIsRequired) return Texture(0, 0, nullptr, 1, 0); } +#ifndef ORIGINAL_CODE + bool AppPlatform::isTouchscreen() { return true; @@ -222,6 +224,8 @@ SoundSystem* const AppPlatform::getSoundSystem() const return nullptr; } +#endif + std::string AppPlatform::getAssetPath(const std::string &path) const { std::string realPath = path; diff --git a/source/client/gui/Screen.cpp b/source/client/gui/Screen.cpp index 8b73b444..930ae1c4 100644 --- a/source/client/gui/Screen.cpp +++ b/source/client/gui/Screen.cpp @@ -79,19 +79,19 @@ void Screen::keyPressed(int key) if (m_buttonTabList.size()) { #ifndef ENH_HIGHLIGHT_BY_HOVER - if (m_pMinecraft->getOptions()->isKey(MENU_NEXT, key)) + if (m_pMinecraft->getOptions()->isKey(KM_MENU_NEXT, key)) { m_tabButtonIndex++; if (m_tabButtonIndex == int(m_buttonTabList.size())) m_tabButtonIndex = 0; } - if (m_pMinecraft->getOptions()->isKey(MENU_PREVIOUS, key)) + if (m_pMinecraft->getOptions()->isKey(KM_MENU_PREVIOUS, key)) { m_tabButtonIndex--; if (m_tabButtonIndex == -1) m_tabButtonIndex = int(m_buttonTabList.size() - 1); } - if (m_pMinecraft->getOptions()->isKey(MENU_OK, key)) + if (m_pMinecraft->getOptions()->isKey(KM_MENU_OK, key)) { if (m_buttonTabList[m_tabButtonIndex]->m_bEnabled) { diff --git a/source/client/gui/screens/PauseScreen.cpp b/source/client/gui/screens/PauseScreen.cpp index b06a550e..305d2ca3 100644 --- a/source/client/gui/screens/PauseScreen.cpp +++ b/source/client/gui/screens/PauseScreen.cpp @@ -84,8 +84,10 @@ void PauseScreen::init() #endif } +#ifdef ENH_ADD_OPTIONS_PAUSE //swap the options and quit buttons around (??) std::swap(m_btnOptions.m_yPos, m_btnQuit.m_yPos); +#endif for (int i = 0; i < int(m_buttons.size()); i++) m_buttonTabList.push_back(m_buttons[i]); diff --git a/source/client/model/Cube.cpp b/source/client/model/Cube.cpp index 92ef7f77..9f125cfc 100644 --- a/source/client/model/Cube.cpp +++ b/source/client/model/Cube.cpp @@ -51,6 +51,18 @@ Cube::Cube(ModelPart* a2, int a3, int a4, float x, float y, float z, int d, int 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. diff --git a/source/client/model/ModelPart.cpp b/source/client/model/ModelPart.cpp index 55d60c6a..212f2f33 100644 --- a/source/client/model/ModelPart.cpp +++ b/source/client/model/ModelPart.cpp @@ -173,38 +173,6 @@ void ModelPart::render(float scale) } } -void ModelPart::renderHorrible(float scale) -{ - if (field_49) - return; - - if (!field_48) - return; - - if (!m_bCompiled) - compile(scale); - - if (!hasDefaultRot()) - { - glPushMatrix(); - - translateRotTo(scale); - drawSlow(scale); - - glPopMatrix(); - } - else if (!hasDefaultPos()) - { - translatePosTo(scale); - drawSlow(scale); - translatePosTo(-scale); - } - else - { - drawSlow(scale); - } -} - void ModelPart::renderRollable(float scale) { if (field_49) diff --git a/source/client/model/ModelPart.hpp b/source/client/model/ModelPart.hpp index 95baa5f8..88e181df 100644 --- a/source/client/model/ModelPart.hpp +++ b/source/client/model/ModelPart.hpp @@ -30,7 +30,6 @@ class ModelPart void drawSlow(float scale); void mimic(ModelPart* pPart); void render(float scale); - void renderHorrible(float scale); void renderRollable(float scale); void setModel(Model* pModel); void setPos(float x, float y, float z); diff --git a/source/client/renderer/GameRenderer.cpp b/source/client/renderer/GameRenderer.cpp index 5ca1ae20..b8ecbfee 100644 --- a/source/client/renderer/GameRenderer.cpp +++ b/source/client/renderer/GameRenderer.cpp @@ -1052,7 +1052,7 @@ void GameRenderer::pick(float f) dist = mchr.m_hitPos.distanceTo(mobPos); if (m_pMinecraft->m_pGameMode->isCreativeType()) - dist = 32.0f; + dist = 7.0f; else if (dist > 3.0f) dist = 3.0f; diff --git a/source/client/renderer/Texture.hpp b/source/client/renderer/Texture.hpp index 25c3d10b..7db8a47c 100644 --- a/source/client/renderer/Texture.hpp +++ b/source/client/renderer/Texture.hpp @@ -16,7 +16,7 @@ struct Texture int m_width; int m_height; uint32_t* m_pixels; - uint8_t field_C; + bool m_hasAlpha; uint8_t field_D; Texture() @@ -24,14 +24,8 @@ struct Texture m_width = 0; m_height = 0; m_pixels = nullptr; - field_C = false; + m_hasAlpha = false; field_D = false; } - Texture(int width, int height, void* pixels, uint8_t a1, uint8_t a2) : m_width(width), m_height(height), m_pixels((uint32_t*)pixels), field_C(a1), field_D(a2) {} -}; - -struct GLTexture -{ - unsigned m_textureID; // GL texture ID - Texture m_textureData; + Texture(int width, int height, void* pixels, bool hasAlpha, uint8_t a2) : m_width(width), m_height(height), m_pixels((uint32_t*)pixels), m_hasAlpha(hasAlpha), field_D(a2) {} }; diff --git a/source/client/renderer/Textures.cpp b/source/client/renderer/Textures.cpp index f282ddba..dfdabb67 100644 --- a/source/client/renderer/Textures.cpp +++ b/source/client/renderer/Textures.cpp @@ -67,7 +67,7 @@ int Textures::assignTexture(const std::string& name, Texture& texture) GLuint internalFormat = GL_RGB; - if (texture.field_C) + if (texture.m_hasAlpha) internalFormat = GL_RGBA; glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, texture.m_width, texture.m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture.m_pixels); diff --git a/source/client/renderer/TileRenderer.cpp b/source/client/renderer/TileRenderer.cpp index c2cc7766..e5580a43 100644 --- a/source/client/renderer/TileRenderer.cpp +++ b/source/client/renderer/TileRenderer.cpp @@ -2388,19 +2388,20 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, int a3, #define SHADE_PREPARE 0 #define SHADE_IF_NEEDED(col) 0 #define SHADE_FIXUP_GRASS(col) 0 +#define SHADE_FIXUP_GRASS 0 #endif -void TileRenderer::renderTile(Tile* tile, int data RENDER_TILE_ARG_PATCH) +void TileRenderer::renderTile(Tile* tile, int data, float bright) { Tesselator& t = Tesselator::instance; -#ifdef ENH_SHADE_HELD_TILES - t.color(bright, bright, bright); -#else - t.color(255, 255, 255); +#ifndef ENH_SHADE_HELD_TILES + bright = 1.0f; // 255 #endif + t.color(bright, bright, bright); + int shape = tile->getRenderShape(); switch (shape) { diff --git a/source/client/renderer/TileRenderer.hpp b/source/client/renderer/TileRenderer.hpp index a92d2296..af0c3694 100644 --- a/source/client/renderer/TileRenderer.hpp +++ b/source/client/renderer/TileRenderer.hpp @@ -12,12 +12,6 @@ #include "client/renderer/Chunk.hpp" #include "client/renderer/Tesselator.hpp" -#ifndef ENH_SHADE_HELD_TILES -#define RENDER_TILE_ARG_PATCH -#else -#define RENDER_TILE_ARG_PATCH , float bright -#endif - class TileRenderer { private: @@ -26,7 +20,7 @@ class TileRenderer TileRenderer(); TileRenderer(LevelSource*); float getWaterHeight(int x, int y, int z, const Material*); - void renderTile(Tile*, int data RENDER_TILE_ARG_PATCH); + void renderTile(Tile*, int data, float bright = 1.0f); // TODO diff --git a/source/client/renderer/entity/EntityRenderDispatcher.cpp b/source/client/renderer/entity/EntityRenderDispatcher.cpp index 4838c1cc..22361237 100644 --- a/source/client/renderer/entity/EntityRenderDispatcher.cpp +++ b/source/client/renderer/entity/EntityRenderDispatcher.cpp @@ -47,7 +47,9 @@ EntityRenderDispatcher::EntityRenderDispatcher() : m_CameraRenderer.init(this); m_ItemRenderer.init(this); m_RocketRenderer.init(this); +#ifdef ENH_ALLOW_SAND_GRAVITY m_FallingTileRenderer.init(this); +#endif } float EntityRenderDispatcher::distanceToSqr(float x, float y, float z) @@ -94,9 +96,11 @@ EntityRenderer* EntityRenderDispatcher::getRenderer(int renderType) return &m_CreeperRenderer; case RENDER_ROCKET: return &m_RocketRenderer; +#ifdef ENH_ALLOW_SAND_GRAVITY // TODO case RENDER_FALLING_TILE: return &m_FallingTileRenderer; +#endif } return nullptr; diff --git a/source/client/renderer/entity/EntityRenderDispatcher.hpp b/source/client/renderer/entity/EntityRenderDispatcher.hpp index 81ba2102..35694414 100644 --- a/source/client/renderer/entity/EntityRenderDispatcher.hpp +++ b/source/client/renderer/entity/EntityRenderDispatcher.hpp @@ -71,7 +71,7 @@ class EntityRenderDispatcher Vec3 m_pos; Font* m_pFont; -#if defined(ENH_ALLOW_SAND_GRAVITY) +#ifdef ENH_ALLOW_SAND_GRAVITY FallingTileRenderer m_FallingTileRenderer; #endif diff --git a/source/client/renderer/entity/ItemRenderer.cpp b/source/client/renderer/entity/ItemRenderer.cpp index 51fc7d65..a7cf58e2 100644 --- a/source/client/renderer/entity/ItemRenderer.cpp +++ b/source/client/renderer/entity/ItemRenderer.cpp @@ -80,13 +80,7 @@ void ItemRenderer::render(Entity* pEntity, float x, float y, float z, float a, f 0.2f * (m_random.nextFloat() * 2.0f - 1.0f) / scale); } - #ifdef ENH_SHADE_HELD_TILES - # define PARM_HACK , pItemEntity->getBrightness(1.0f) - #else - # define PARM_HACK - #endif - tileRenderer->renderTile(Tile::tiles[itemID], pItemInstance->m_auxValue PARM_HACK); - #undef PARM_HACK + tileRenderer->renderTile(Tile::tiles[itemID], pItemInstance->m_auxValue, pItemEntity->getBrightness(1.0f)); glPopMatrix(); } } diff --git a/source/client/renderer/entity/TripodCameraRenderer.cpp b/source/client/renderer/entity/TripodCameraRenderer.cpp index df4a651d..cf6c3e06 100644 --- a/source/client/renderer/entity/TripodCameraRenderer.cpp +++ b/source/client/renderer/entity/TripodCameraRenderer.cpp @@ -64,7 +64,7 @@ void TripodCameraRenderer::render(Entity* entity, float x, float y, float z, flo glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // @TODO FIX: With ENH_ENTITY_SHADING on, the cube is fully opaque. glColor4f(0.5f, 0.5f, 0.5f, 0.5f); - m_modelPart.renderHorrible(0.0625f); + m_modelPart.render(0.0625f); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glDisable(GL_BLEND); glEnable(GL_TEXTURE_2D); diff --git a/source/common/Random.cpp b/source/common/Random.cpp index 79fe7e4c..cc6a3b97 100644 --- a/source/common/Random.cpp +++ b/source/common/Random.cpp @@ -18,7 +18,7 @@ Random::Random(TLong seed) { setSeed(seed); - nextNextGaussian = INFINITY; + nextNextGaussian = std::numeric_limits::max();; } void Random::setSeed(TLong seed) @@ -109,10 +109,10 @@ int Random::nextInt() float Random::nextGaussian() { - if (!isinf(nextNextGaussian)) + if (nextNextGaussian < std::numeric_limits::max()) { double backup = nextNextGaussian; - nextNextGaussian = INFINITY; + nextNextGaussian = std::numeric_limits::max(); return backup; } // See Knuth, ACP, Section 3.4.1 Algorithm C. diff --git a/source/world/entity/Entity.cpp b/source/world/entity/Entity.cpp index b7f1c862..9dca90f5 100644 --- a/source/world/entity/Entity.cpp +++ b/source/world/entity/Entity.cpp @@ -49,6 +49,7 @@ void Entity::_init() field_B8 = 0; field_BC = 300; field_C0 = 0; + field_C4 = 0; field_C8 = 0; // @NOTE: Render type? (eEntityRenderType) m_distanceFallen = 0.0f; field_D0 = 300; diff --git a/source/world/entity/ItemEntity.cpp b/source/world/entity/ItemEntity.cpp index 1da5e8b0..94ad0861 100644 --- a/source/world/entity/ItemEntity.cpp +++ b/source/world/entity/ItemEntity.cpp @@ -20,8 +20,12 @@ void ItemEntity::_init(ItemInstance* itemInstance) field_E8 = 2 * float(M_PI) * Mth::random(); setSize(0.25f, 0.25f); field_84 = field_8C * 0.5f; +#ifdef ORIGINAL_CODE + m_pItemInstance = itemInstance != nullptr ? itemInstance : new ItemInstance(); +#else m__itemInstance = itemInstance ? *itemInstance : ItemInstance(); m_pItemInstance = &m__itemInstance; +#endif } void ItemEntity::_init(ItemInstance* itemInstance, float x, float y, float z) diff --git a/source/world/entity/PathfinderMob.cpp b/source/world/entity/PathfinderMob.cpp index 75302470..3eb1564f 100644 --- a/source/world/entity/PathfinderMob.cpp +++ b/source/world/entity/PathfinderMob.cpp @@ -10,6 +10,7 @@ PathfinderMob::PathfinderMob(Level* pLevel) : Mob(pLevel) { + m_pAttackTarget = nullptr; field_BA0 = false; field_BA4 = 0; } diff --git a/source/world/gamemode/GameMode.cpp b/source/world/gamemode/GameMode.cpp index 70149036..c726603d 100644 --- a/source/world/gamemode/GameMode.cpp +++ b/source/world/gamemode/GameMode.cpp @@ -68,6 +68,15 @@ void GameMode::render(float f) float GameMode::getPickRange() { +/* + if ( *inputMode == 1 ) + return 5.7; + if ( *inputMode == 3 ) + return 5.6; + if ( !player || player->IsCreative() ) + return 12.0; + return 5.0; +*/ return 7.5f; } diff --git a/source/world/level/Dimension.cpp b/source/world/level/Dimension.cpp index 852a17a9..a6cdfd69 100644 --- a/source/world/level/Dimension.cpp +++ b/source/world/level/Dimension.cpp @@ -99,7 +99,7 @@ void Dimension::updateLightRamp() #else // @NOTE: Adjusted calculation causes full bright tiles to render at 80% brightness. // This was probably done so that highlighted tiles don't have their brightness blown up and the texture doesn't look weird. - m_rotY[i] = ((1.0f - ((i * -0.0625f) + 1.0f)) / ((((i * -0.0625f) + 1.0f) * 3.0f) + 1.0f)) * 0.95f + 0.05f; + field_10[i] = ((1.0f - ((i * -0.0625f) + 1.0f)) / ((((i * -0.0625f) + 1.0f) * 3.0f) + 1.0f)) * 0.95f + 0.05f; #endif } } diff --git a/source/world/tile/InvisibleTile.cpp b/source/world/tile/InvisibleTile.cpp index 3efa2efa..1ff4b320 100644 --- a/source/world/tile/InvisibleTile.cpp +++ b/source/world/tile/InvisibleTile.cpp @@ -20,3 +20,7 @@ int InvisibleTile::getRenderShape() return SHAPE_NONE; } +bool InvisibleTile::mayPick() +{ + return false; +} diff --git a/source/world/tile/InvisibleTile.hpp b/source/world/tile/InvisibleTile.hpp index f3c15b62..a5c9dcb7 100644 --- a/source/world/tile/InvisibleTile.hpp +++ b/source/world/tile/InvisibleTile.hpp @@ -15,4 +15,5 @@ class InvisibleTile : public Tile public: InvisibleTile(int ID, int texture, Material*); int getRenderShape() override; + bool mayPick() override; };