diff --git a/GameMods.hpp b/GameMods.hpp index 06e7fdc11..54d588e18 100644 --- a/GameMods.hpp +++ b/GameMods.hpp @@ -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 diff --git a/compat/PlatformDefinitions.h b/compat/PlatformDefinitions.h index 971535cde..eecd4246b 100644 --- a/compat/PlatformDefinitions.h +++ b/compat/PlatformDefinitions.h @@ -12,6 +12,54 @@ #include #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 diff --git a/platforms/ios/minecraftpeViewController.mm b/platforms/ios/minecraftpeViewController.mm index 45da8c634..c33c901b3 100644 --- a/platforms/ios/minecraftpeViewController.mm +++ b/platforms/ios/minecraftpeViewController.mm @@ -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); } diff --git a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj index 049a75418..fd769b36a 100644 --- a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj +++ b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj @@ -1939,8 +1939,6 @@ 84AA8B5D2B32F3B5003F5B82 /* Cow.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Cow.hpp; sourceTree = ""; }; 84AA8B5E2B32F3B5003F5B82 /* Creeper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Creeper.cpp; sourceTree = ""; }; 84AA8B5F2B32F3B5003F5B82 /* Creeper.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Creeper.hpp; sourceTree = ""; }; - 84AA8B602B32F3B5003F5B82 /* Entity.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Entity.cpp; sourceTree = ""; }; - 84AA8B622B32F3B5003F5B82 /* FallingTile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FallingTile.cpp; sourceTree = ""; }; 84AA8B6A2B32F3B5003F5B82 /* Monster.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Monster.cpp; sourceTree = ""; }; 84AA8B6B2B32F3B5003F5B82 /* Monster.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Monster.hpp; sourceTree = ""; }; 84AA8B6C2B32F3B5003F5B82 /* PathfinderMob.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PathfinderMob.cpp; sourceTree = ""; }; @@ -1948,8 +1946,6 @@ 84AA8B6E2B32F3B5003F5B82 /* Pig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Pig.cpp; sourceTree = ""; }; 84AA8B6F2B32F3B5003F5B82 /* Pig.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Pig.hpp; sourceTree = ""; }; 84AA8B702B32F3B5003F5B82 /* Player.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Player.cpp; sourceTree = ""; }; - 84AA8B722B32F3B5003F5B82 /* PrimedTnt.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrimedTnt.cpp; sourceTree = ""; }; - 84AA8B742B32F3B5003F5B82 /* TripodCamera.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TripodCamera.cpp; sourceTree = ""; }; 84AA8B762B32F3B5003F5B82 /* WaterAnimal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WaterAnimal.cpp; sourceTree = ""; }; 84AA8B772B32F3B5003F5B82 /* WaterAnimal.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = WaterAnimal.hpp; sourceTree = ""; }; 84AA8B992B32F3F3003F5B82 /* Chunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Chunk.cpp; sourceTree = ""; }; @@ -2039,14 +2035,12 @@ 84AA8C3F2B32F535003F5B82 /* CowModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CowModel.hpp; sourceTree = ""; }; 84AA8C402B32F535003F5B82 /* CreeperModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CreeperModel.cpp; sourceTree = ""; }; 84AA8C412B32F535003F5B82 /* CreeperModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CreeperModel.hpp; sourceTree = ""; }; - 84AA8C422B32F535003F5B82 /* Cube.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Cube.cpp; sourceTree = ""; }; 84AA8C442B32F535003F5B82 /* HumanoidModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HumanoidModel.cpp; sourceTree = ""; }; 84AA8C462B32F535003F5B82 /* Model.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Model.cpp; sourceTree = ""; }; 84AA8C482B32F535003F5B82 /* ModelPart.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ModelPart.cpp; sourceTree = ""; }; 84AA8C492B32F535003F5B82 /* ModelPart.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ModelPart.hpp; sourceTree = ""; }; 84AA8C4A2B32F535003F5B82 /* PigModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PigModel.cpp; sourceTree = ""; }; 84AA8C4B2B32F535003F5B82 /* PigModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = PigModel.hpp; sourceTree = ""; }; - 84AA8C4C2B32F535003F5B82 /* PolygonQuad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PolygonQuad.cpp; sourceTree = ""; }; 84AA8C4E2B32F535003F5B82 /* QuadrupedModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = QuadrupedModel.cpp; sourceTree = ""; }; 84AA8C4F2B32F535003F5B82 /* QuadrupedModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = QuadrupedModel.hpp; sourceTree = ""; }; 84AA8C502B32F535003F5B82 /* SheepFurModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SheepFurModel.cpp; sourceTree = ""; }; @@ -2417,40 +2411,38 @@ 840DD5BD2AC810620006A435 /* model */ = { isa = PBXGroup; children = ( - 84AA8C3C2B32F535003F5B82 /* ChickenModel.cpp */, 84AA8C3D2B32F535003F5B82 /* ChickenModel.hpp */, - 84AA8C3E2B32F535003F5B82 /* CowModel.cpp */, + 84AA8C3C2B32F535003F5B82 /* ChickenModel.cpp */, 84AA8C3F2B32F535003F5B82 /* CowModel.hpp */, - 84AA8C402B32F535003F5B82 /* CreeperModel.cpp */, + 84AA8C3E2B32F535003F5B82 /* CowModel.cpp */, 84AA8C412B32F535003F5B82 /* CreeperModel.hpp */, - 84AA8C422B32F535003F5B82 /* Cube.cpp */, + 84AA8C402B32F535003F5B82 /* CreeperModel.cpp */, + 840DD5BF2AC810620006A435 /* Cube.hpp */, + 840DD5BE2AC810620006A435 /* Cube.cpp */, + 840DD5C12AC810620006A435 /* HumanoidModel.hpp */, 84AA8C442B32F535003F5B82 /* HumanoidModel.cpp */, + 840DD5C02AC810620006A435 /* HumanoidModel.cpp */, + 840DD5C32AC810620006A435 /* Model.hpp */, 84AA8C462B32F535003F5B82 /* Model.cpp */, - 84AA8C482B32F535003F5B82 /* ModelPart.cpp */, + 840DD5C22AC810620006A435 /* Model.cpp */, 84AA8C492B32F535003F5B82 /* ModelPart.hpp */, - 84AA8C4A2B32F535003F5B82 /* PigModel.cpp */, + 84AA8C482B32F535003F5B82 /* ModelPart.cpp */, 84AA8C4B2B32F535003F5B82 /* PigModel.hpp */, - 84AA8C4C2B32F535003F5B82 /* PolygonQuad.cpp */, - 84AA8C4E2B32F535003F5B82 /* QuadrupedModel.cpp */, + 84AA8C4A2B32F535003F5B82 /* PigModel.cpp */, + 840DD5C52AC810620006A435 /* PolygonQuad.hpp */, + 840DD5C42AC810620006A435 /* PolygonQuad.cpp */, 84AA8C4F2B32F535003F5B82 /* QuadrupedModel.hpp */, - 84AA8C502B32F535003F5B82 /* SheepFurModel.cpp */, + 84AA8C4E2B32F535003F5B82 /* QuadrupedModel.cpp */, 84AA8C512B32F535003F5B82 /* SheepFurModel.hpp */, - 84AA8C522B32F535003F5B82 /* SheepModel.cpp */, + 84AA8C502B32F535003F5B82 /* SheepFurModel.cpp */, 84AA8C532B32F535003F5B82 /* SheepModel.hpp */, - 84AA8C542B32F535003F5B82 /* SkeletonModel.cpp */, + 84AA8C522B32F535003F5B82 /* SheepModel.cpp */, 84AA8C552B32F535003F5B82 /* SkeletonModel.hpp */, - 84AA8C562B32F535003F5B82 /* SpiderModel.cpp */, + 84AA8C542B32F535003F5B82 /* SkeletonModel.cpp */, 84AA8C572B32F535003F5B82 /* SpiderModel.hpp */, - 84AA8C582B32F535003F5B82 /* ZombieModel.cpp */, + 84AA8C562B32F535003F5B82 /* SpiderModel.cpp */, 84AA8C592B32F535003F5B82 /* ZombieModel.hpp */, - 840DD5BE2AC810620006A435 /* Cube.cpp */, - 840DD5BF2AC810620006A435 /* Cube.hpp */, - 840DD5C02AC810620006A435 /* HumanoidModel.cpp */, - 840DD5C12AC810620006A435 /* HumanoidModel.hpp */, - 840DD5C22AC810620006A435 /* Model.cpp */, - 840DD5C32AC810620006A435 /* Model.hpp */, - 840DD5C42AC810620006A435 /* PolygonQuad.cpp */, - 840DD5C52AC810620006A435 /* PolygonQuad.hpp */, + 84AA8C582B32F535003F5B82 /* ZombieModel.cpp */, ); path = model; sourceTree = ""; @@ -2660,59 +2652,55 @@ 840DD6572AC810620006A435 /* entity */ = { isa = PBXGroup; children = ( - 84AA8B582B32F3B5003F5B82 /* Animal.cpp */, 84AA8B592B32F3B5003F5B82 /* Animal.hpp */, - 84AA8B5A2B32F3B5003F5B82 /* Chicken.cpp */, + 84AA8B582B32F3B5003F5B82 /* Animal.cpp */, 84AA8B5B2B32F3B5003F5B82 /* Chicken.hpp */, - 84AA8B5C2B32F3B5003F5B82 /* Cow.cpp */, + 84AA8B5A2B32F3B5003F5B82 /* Chicken.cpp */, 84AA8B5D2B32F3B5003F5B82 /* Cow.hpp */, - 84AA8B5E2B32F3B5003F5B82 /* Creeper.cpp */, + 84AA8B5C2B32F3B5003F5B82 /* Cow.cpp */, 84AA8B5F2B32F3B5003F5B82 /* Creeper.hpp */, - 84AA8B602B32F3B5003F5B82 /* Entity.cpp */, - 8445E7952D769329008DC834 /* EntityCategories.cpp */, + 84AA8B5E2B32F3B5003F5B82 /* Creeper.cpp */, + 840DD6592AC810620006A435 /* Entity.hpp */, + 840DD6582AC810620006A435 /* Entity.cpp */, 8445E7962D769329008DC834 /* EntityCategories.hpp */, - 8445E7972D769329008DC834 /* EntityType.cpp */, + 8445E7952D769329008DC834 /* EntityCategories.cpp */, 8470AF282BE9B60900BCA54E /* EntityType.hpp */, - 8445E7982D769329008DC834 /* EntityTypeDescriptor.cpp */, + 8445E7972D769329008DC834 /* EntityType.cpp */, 8445E7992D769329008DC834 /* EntityTypeDescriptor.hpp */, - 84AA8B622B32F3B5003F5B82 /* FallingTile.cpp */, - 8445E79A2D769329008DC834 /* MobCategory.cpp */, + 8445E7982D769329008DC834 /* EntityTypeDescriptor.cpp */, + 840DD65B2AC810620006A435 /* FallingTile.hpp */, + 840DD65A2AC810620006A435 /* FallingTile.cpp */, + 840DD65D2AC810620006A435 /* ItemEntity.hpp */, + 840DD65C2AC810620006A435 /* ItemEntity.cpp */, + 840DD65F2AC810620006A435 /* LocalPlayer.hpp */, + 840DD65E2AC810620006A435 /* LocalPlayer.cpp */, + 840DD6612AC810620006A435 /* Mob.hpp */, + 840DD6602AC810620006A435 /* Mob.cpp */, 8445E79B2D769329008DC834 /* MobCategory.hpp */, - 8470AF292BE9B60A00BCA54E /* MobFactory.cpp */, + 8445E79A2D769329008DC834 /* MobCategory.cpp */, 8470AF2A2BE9B60A00BCA54E /* MobFactory.hpp */, - 84AA8B6A2B32F3B5003F5B82 /* Monster.cpp */, + 8470AF292BE9B60A00BCA54E /* MobFactory.cpp */, 84AA8B6B2B32F3B5003F5B82 /* Monster.hpp */, - 84AA8B6C2B32F3B5003F5B82 /* PathfinderMob.cpp */, + 84AA8B6A2B32F3B5003F5B82 /* Monster.cpp */, 84AA8B6D2B32F3B5003F5B82 /* PathfinderMob.hpp */, - 84AA8B6E2B32F3B5003F5B82 /* Pig.cpp */, + 84AA8B6C2B32F3B5003F5B82 /* PathfinderMob.cpp */, 84AA8B6F2B32F3B5003F5B82 /* Pig.hpp */, + 84AA8B6E2B32F3B5003F5B82 /* Pig.cpp */, + 840DD6632AC810620006A435 /* Player.hpp */, 84AA8B702B32F3B5003F5B82 /* Player.cpp */, - 84AA8B722B32F3B5003F5B82 /* PrimedTnt.cpp */, - 84E78C792B58B3E000D515EF /* Rocket.cpp */, + 840DD6622AC810620006A435 /* Player.cpp */, + 840DD6652AC810620006A435 /* PrimedTnt.hpp */, + 840DD6642AC810620006A435 /* PrimedTnt.cpp */, 84E78C7A2B58B3E000D515EF /* Rocket.hpp */, - 8445E79C2D769329008DC834 /* Sheep.cpp */, + 84E78C792B58B3E000D515EF /* Rocket.cpp */, 8445E79D2D769329008DC834 /* Sheep.hpp */, - 8445E79E2D769329008DC834 /* SynchedEntityData.cpp */, + 8445E79C2D769329008DC834 /* Sheep.cpp */, 8445E79F2D769329008DC834 /* SynchedEntityData.hpp */, - 84AA8B742B32F3B5003F5B82 /* TripodCamera.cpp */, - 84AA8B762B32F3B5003F5B82 /* WaterAnimal.cpp */, - 84AA8B772B32F3B5003F5B82 /* WaterAnimal.hpp */, - 840DD6582AC810620006A435 /* Entity.cpp */, - 840DD6592AC810620006A435 /* Entity.hpp */, - 840DD65A2AC810620006A435 /* FallingTile.cpp */, - 840DD65B2AC810620006A435 /* FallingTile.hpp */, - 840DD65C2AC810620006A435 /* ItemEntity.cpp */, - 840DD65D2AC810620006A435 /* ItemEntity.hpp */, - 840DD65E2AC810620006A435 /* LocalPlayer.cpp */, - 840DD65F2AC810620006A435 /* LocalPlayer.hpp */, - 840DD6602AC810620006A435 /* Mob.cpp */, - 840DD6612AC810620006A435 /* Mob.hpp */, - 840DD6622AC810620006A435 /* Player.cpp */, - 840DD6632AC810620006A435 /* Player.hpp */, - 840DD6642AC810620006A435 /* PrimedTnt.cpp */, - 840DD6652AC810620006A435 /* PrimedTnt.hpp */, - 840DD6662AC810620006A435 /* TripodCamera.cpp */, + 8445E79E2D769329008DC834 /* SynchedEntityData.cpp */, 840DD6672AC810620006A435 /* TripodCamera.hpp */, + 840DD6662AC810620006A435 /* TripodCamera.cpp */, + 84AA8B772B32F3B5003F5B82 /* WaterAnimal.hpp */, + 84AA8B762B32F3B5003F5B82 /* WaterAnimal.cpp */, ); path = entity; sourceTree = ""; @@ -2757,25 +2745,25 @@ 840DD67E2AC810620006A435 /* level */ = { isa = PBXGroup; children = ( - 840DD67F2AC810620006A435 /* Dimension.cpp */, 840DD6802AC810620006A435 /* Dimension.hpp */, - 840DD6812AC810620006A435 /* Explosion.cpp */, + 840DD67F2AC810620006A435 /* Dimension.cpp */, 840DD6822AC810620006A435 /* Explosion.hpp */, - 840DD6832AC810620006A435 /* Level.cpp */, + 840DD6812AC810620006A435 /* Explosion.cpp */, 840DD6842AC810620006A435 /* Level.hpp */, + 840DD6832AC810620006A435 /* Level.cpp */, 840DD6852AC810620006A435 /* levelgen */, - 840DD6AF2AC810620006A435 /* LevelListener.cpp */, 840DD6B02AC810620006A435 /* LevelListener.hpp */, - 840DD6B12AC810620006A435 /* Material.cpp */, + 840DD6AF2AC810620006A435 /* LevelListener.cpp */, 840DD6B22AC810620006A435 /* Material.hpp */, + 840DD6B12AC810620006A435 /* Material.cpp */, 84AA8B472B32F39A003F5B82 /* path */, - 840DD6B32AC810620006A435 /* Region.cpp */, 840DD6B42AC810620006A435 /* Region.hpp */, + 840DD6B32AC810620006A435 /* Region.cpp */, 840DD6B52AC810620006A435 /* storage */, - 840DD6CC2AC810620006A435 /* TickNextTickData.cpp */, 840DD6CD2AC810620006A435 /* TickNextTickData.hpp */, - 8477B3AA2C4DC3F6004E1AC5 /* TilePos.cpp */, + 840DD6CC2AC810620006A435 /* TickNextTickData.cpp */, 8477B3AB2C4DC3F6004E1AC5 /* TilePos.hpp */, + 8477B3AA2C4DC3F6004E1AC5 /* TilePos.cpp */, ); path = level; sourceTree = ""; @@ -3664,51 +3652,51 @@ 84AA8B982B32F3F3003F5B82 /* renderer */ = { isa = PBXGroup; children = ( - 84AA8B992B32F3F3003F5B82 /* Chunk.cpp */, 84AA8B9A2B32F3F3003F5B82 /* Chunk.hpp */, - 84AA8B9B2B32F3F3003F5B82 /* Culler.cpp */, + 84AA8B992B32F3F3003F5B82 /* Chunk.cpp */, 84AA8B9C2B32F3F3003F5B82 /* Culler.hpp */, - 84AA8B9D2B32F3F3003F5B82 /* DynamicTexture.cpp */, + 84AA8B9B2B32F3F3003F5B82 /* Culler.cpp */, 84AA8B9E2B32F3F3003F5B82 /* DynamicTexture.hpp */, + 84AA8B9D2B32F3F3003F5B82 /* DynamicTexture.cpp */, 84AA8B9F2B32F3F3003F5B82 /* entity */, 84AA8BC42B32F3F3003F5B82 /* FireTexture.cpp */, - 84AA8BC52B32F3F3003F5B82 /* FoliageColor.cpp */, 84AA8BC62B32F3F3003F5B82 /* FoliageColor.hpp */, - 84AA8BC72B32F3F3003F5B82 /* Font.cpp */, + 84AA8BC52B32F3F3003F5B82 /* FoliageColor.cpp */, 84AA8BC82B32F3F3003F5B82 /* Font.hpp */, - 84AA8BC92B32F3F3003F5B82 /* Frustum.cpp */, + 84AA8BC72B32F3F3003F5B82 /* Font.cpp */, 84AA8BCA2B32F3F3003F5B82 /* Frustum.hpp */, - 84AA8BCB2B32F3F3003F5B82 /* FrustumCuller.cpp */, + 84AA8BC92B32F3F3003F5B82 /* Frustum.cpp */, 84AA8BCC2B32F3F3003F5B82 /* FrustumCuller.hpp */, - 84AA8BCD2B32F3F3003F5B82 /* GameRenderer.cpp */, + 84AA8BCB2B32F3F3003F5B82 /* FrustumCuller.cpp */, 84AA8BCE2B32F3F3003F5B82 /* GameRenderer.hpp */, - 84AA8BCF2B32F3F3003F5B82 /* GrassColor.cpp */, + 84AA8BCD2B32F3F3003F5B82 /* GameRenderer.cpp */, 84AA8BD02B32F3F3003F5B82 /* GrassColor.hpp */, - 84AA8BD12B32F3F3003F5B82 /* ItemInHandRenderer.cpp */, + 84AA8BCF2B32F3F3003F5B82 /* GrassColor.cpp */, 84AA8BD22B32F3F3003F5B82 /* ItemInHandRenderer.hpp */, + 84AA8BD12B32F3F3003F5B82 /* ItemInHandRenderer.cpp */, 84AA8BD32B32F3F3003F5B82 /* LavaSideTexture.cpp */, 84AA8BD42B32F3F3003F5B82 /* LavaTexture.cpp */, - 84AA8BD52B32F3F3003F5B82 /* LevelRenderer.cpp */, 84AA8BD62B32F3F3003F5B82 /* LevelRenderer.hpp */, - 849488342C9284DA006DB706 /* Lighting.cpp */, + 84AA8BD52B32F3F3003F5B82 /* LevelRenderer.cpp */, 849488352C9284DA006DB706 /* Lighting.hpp */, - 84AA8BD72B32F3F3003F5B82 /* LightLayer.cpp */, + 849488342C9284DA006DB706 /* Lighting.cpp */, 84AA8BD82B32F3F3003F5B82 /* LightLayer.hpp */, - 84AA8BD92B32F3F3003F5B82 /* LightUpdate.cpp */, + 84AA8BD72B32F3F3003F5B82 /* LightLayer.cpp */, 84AA8BDA2B32F3F3003F5B82 /* LightUpdate.hpp */, - 84AA8BDB2B32F3F3003F5B82 /* PatchManager.cpp */, + 84AA8BD92B32F3F3003F5B82 /* LightUpdate.cpp */, 84AA8BDC2B32F3F3003F5B82 /* PatchManager.hpp */, - 84AA8BDD2B32F3F3003F5B82 /* RenderChunk.cpp */, + 84AA8BDB2B32F3F3003F5B82 /* PatchManager.cpp */, 84AA8BDE2B32F3F3003F5B82 /* RenderChunk.hpp */, - 84AA8BDF2B32F3F3003F5B82 /* RenderList.cpp */, + 84AA8BDD2B32F3F3003F5B82 /* RenderChunk.cpp */, 84AA8BE02B32F3F3003F5B82 /* RenderList.hpp */, - 84AA8BE12B32F3F3003F5B82 /* Tesselator.cpp */, + 84AA8BDF2B32F3F3003F5B82 /* RenderList.cpp */, 84AA8BE22B32F3F3003F5B82 /* Tesselator.hpp */, + 84AA8BE12B32F3F3003F5B82 /* Tesselator.cpp */, 84AA8BE32B32F3F3003F5B82 /* Texture.hpp */, - 84AA8BE42B32F3F3003F5B82 /* Textures.cpp */, 84AA8BE52B32F3F3003F5B82 /* Textures.hpp */, - 84AA8BE62B32F3F3003F5B82 /* TileRenderer.cpp */, + 84AA8BE42B32F3F3003F5B82 /* Textures.cpp */, 84AA8BE72B32F3F3003F5B82 /* TileRenderer.hpp */, + 84AA8BE62B32F3F3003F5B82 /* TileRenderer.cpp */, 84AA8BE82B32F3F3003F5B82 /* VertexPT.hpp */, 84AA8BE92B32F3F3003F5B82 /* WaterSideTexture.cpp */, 84AA8BEA2B32F3F3003F5B82 /* WaterTexture.cpp */, diff --git a/platforms/sdl/main.cpp b/platforms/sdl/main.cpp index 6643ffc74..c9f49d55b 100644 --- a/platforms/sdl/main.cpp +++ b/platforms/sdl/main.cpp @@ -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 diff --git a/source/client/app/Minecraft.cpp b/source/client/app/Minecraft.cpp index 0eeaa4bce..1d38364d9 100644 --- a/source/client/app/Minecraft.cpp +++ b/source/client/app/Minecraft.cpp @@ -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; @@ -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; @@ -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); } } @@ -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(); @@ -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. @@ -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; } @@ -1290,4 +1294,4 @@ void Minecraft::locateMultiplayer() m_pRakNetInstance->pingForHosts(C_DEFAULT_PORT); m_pNetEventCallback = new ClientSideNetworkHandler(this, m_pRakNetInstance); #endif -} \ No newline at end of file +} diff --git a/source/client/app/Minecraft.hpp b/source/client/app/Minecraft.hpp index 114a7dff4..f69d9284c 100644 --- a/source/client/app/Minecraft.hpp +++ b/source/client/app/Minecraft.hpp @@ -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[]; diff --git a/source/client/gui/Gui.cpp b/source/client/gui/Gui.cpp index baedc763e..148a270fa 100644 --- a/source/client/gui/Gui.cpp +++ b/source/client/gui/Gui.cpp @@ -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) @@ -592,4 +603,4 @@ RectangleArea Gui::getRectangleArea(bool b) Minecraft::height - 24.0f / InvGuiScale, centerX + hotbarWidthHalf, Minecraft::height); -} \ No newline at end of file +} diff --git a/source/client/model/Cube.cpp b/source/client/model/Cube.cpp index 507f5f71f..5fdef201e 100644 --- a/source/client/model/Cube.cpp +++ b/source/client/model/Cube.cpp @@ -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) { diff --git a/source/client/model/ModelPart.cpp b/source/client/model/ModelPart.cpp index 8ce0a8505..61b2744a0 100644 --- a/source/client/model/ModelPart.cpp +++ b/source/client/model/ModelPart.cpp @@ -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) diff --git a/source/client/options/Options.cpp b/source/client/options/Options.cpp index 602ede4a6..57a43ca1e 100644 --- a/source/client/options/Options.cpp +++ b/source/client/options/Options.cpp @@ -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; @@ -441,4 +441,4 @@ void Options::loadControls() #endif #undef KM } -} \ No newline at end of file +} diff --git a/source/client/options/Options.hpp b/source/client/options/Options.hpp index df806406c..6bb24c7db 100644 --- a/source/client/options/Options.hpp +++ b/source/client/options/Options.hpp @@ -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; diff --git a/source/client/renderer/GameRenderer.cpp b/source/client/renderer/GameRenderer.cpp index 5b87d47f0..e0a300cca 100644 --- a/source/client/renderer/GameRenderer.cpp +++ b/source/client/renderer/GameRenderer.cpp @@ -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); diff --git a/source/client/renderer/ItemInHandRenderer.cpp b/source/client/renderer/ItemInHandRenderer.cpp index aab4cae4d..0c9c0b0b5 100644 --- a/source/client/renderer/ItemInHandRenderer.cpp +++ b/source/client/renderer/ItemInHandRenderer.cpp @@ -41,125 +41,126 @@ void ItemInHandRenderer::itemUsed() void ItemInHandRenderer::renderItem(ItemInstance* inst) { #ifndef ORIGINAL_CODE - if (inst->m_itemID < 0) - return; + if (inst->isNull()) + return; #endif - - glPushMatrix(); + + glPushMatrix(); #ifdef ENH_SHADE_HELD_TILES - float bright = m_pMinecraft->m_pLocalPlayer->getBrightness(0.0f); + float bright = m_pMinecraft->m_pLocalPlayer->getBrightness(0.0f); #endif - - if (inst->m_itemID <= C_MAX_TILES && TileRenderer::canRender(Tile::tiles[inst->m_itemID]->getRenderShape())) - { - float red, grn, blu, alp = 1.0f; - - if (inst->m_itemID == Tile::leaves->m_ID) - { - red = 0.35f; - grn = 0.65f; - blu = 0.25f; - } - else - { - blu = grn = red = 1.0f; - } - - glColor4f(red, grn, blu, alp); - - m_pMinecraft->m_pTextures->loadAndBindTexture(C_TERRAIN_NAME); - + + if (inst->m_itemID <= C_MAX_TILES && TileRenderer::canRender(Tile::tiles[inst->m_itemID]->getRenderShape())) + { + float red, grn, blu, alp = 1.0f; + + if (inst->m_itemID == Tile::leaves->m_ID) + { + red = 0.35f; + grn = 0.65f; + blu = 0.25f; + } + else + { + blu = grn = red = 1.0f; + } + + glColor4f(red, grn, blu, alp); + + m_pMinecraft->m_pTextures->loadAndBindTexture(C_TERRAIN_NAME); + #ifdef ENH_SHADE_HELD_TILES # define ARGPATCH , bright #else # define ARGPATCH #endif - - m_tileRenderer.renderTile(Tile::tiles[inst->m_itemID], inst->getAuxValue() ARGPATCH); - + + m_tileRenderer.renderTile(Tile::tiles[inst->m_itemID], inst->getAuxValue() ARGPATCH); + #ifdef ARGPATCH # undef ARGPATCH #endif - - glPopMatrix(); - return; - } - - std::string toBind; - if (inst->m_itemID <= C_MAX_TILES) - toBind = C_TERRAIN_NAME; - else - toBind = "gui/items.png"; - m_pMinecraft->m_pTextures->loadAndBindTexture(toBind); - - constexpr float C_RATIO = 1.0f / 256.0f; - constexpr float C_RATIO_2 = 1.0f / 512.0f; - constexpr float C_ONE_PIXEL = 1.0f / 16.0f; - - int textureX = inst->getIcon() % 16 * 16; - int textureY = inst->getIcon() / 16 * 16; - - float texU_1 = C_RATIO * float(textureX + 0.0f); - float texU_2 = C_RATIO * float(textureX + 15.99f); - float texV_1 = C_RATIO * float(textureY + 0.0f); - float texV_2 = C_RATIO * float(textureY + 15.99f); - - Tesselator& t = Tesselator::instance; - glTranslatef(-0.0f, -0.3f, 0.0f); - glScalef(1.5f, 1.5f, 1.5f); - glRotatef(50.0f, 0.0f, 1.0f, 0.0f); - glRotatef(335.0f, 0.0f, 0.0f, 1.0f); - glTranslatef(-0.9375f, -0.0625f, 0.0f); - - t.begin(); - SHADE_IF_NEEDED(1.0f); - - t.normal(0.0f, 0.0f, 1.0f); - t.vertexUV(0.0f, 0.0f, 0.0f, texU_2, texV_2); - t.vertexUV(1.0f, 0.0f, 0.0f, texU_1, texV_2); - t.vertexUV(1.0f, 1.0f, 0.0f, texU_1, texV_1); - t.vertexUV(0.0f, 1.0f, 0.0f, texU_2, texV_1); - - t.normal(0.0f, 0.0f, -1.0f); - t.vertexUV(0.0f, 1.0f, -C_ONE_PIXEL, texU_2, texV_1); - t.vertexUV(1.0f, 1.0f, -C_ONE_PIXEL, texU_1, texV_1); - t.vertexUV(1.0f, 0.0f, -C_ONE_PIXEL, texU_1, texV_2); - t.vertexUV(0.0f, 0.0f, -C_ONE_PIXEL, texU_2, texV_2); - - SHADE_IF_NEEDED(0.8f); - t.normal(-1.0f, 0.0f, 0.0f); - for (int i = 0; i < 16; i++) - { - t.vertexUV(i * C_ONE_PIXEL, 0.0f, -C_ONE_PIXEL, Mth::Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_2); - t.vertexUV(i * C_ONE_PIXEL, 0.0f, 0.0f, Mth::Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_2); - t.vertexUV(i * C_ONE_PIXEL, 1.0f, 0.0f, Mth::Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_1); - t.vertexUV(i * C_ONE_PIXEL, 1.0f, -C_ONE_PIXEL, Mth::Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_1); - } - for (int i = 0; i < 16; i++) - { - t.vertexUV((i + 1) * C_ONE_PIXEL, 1.0f, -C_ONE_PIXEL, Mth::Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_1); - t.vertexUV((i + 1) * C_ONE_PIXEL, 1.0f, 0.0f, Mth::Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_1); - t.vertexUV((i + 1) * C_ONE_PIXEL, 0.0f, 0.0f, Mth::Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_2); - t.vertexUV((i + 1) * C_ONE_PIXEL, 0.0f, -C_ONE_PIXEL, Mth::Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_2); - } - - SHADE_IF_NEEDED(0.6f); - for (int i = 0; i < 16; i++) - { - t.vertexUV(0.0f, (i + 1) * C_ONE_PIXEL, 0.0f, texU_2, Mth::Lerp(texV_2, texV_1, i * C_ONE_PIXEL)); - t.vertexUV(1.0f, (i + 1) * C_ONE_PIXEL, 0.0f, texU_1, Mth::Lerp(texV_2, texV_1, i * C_ONE_PIXEL)); - t.vertexUV(1.0f, (i + 1) * C_ONE_PIXEL, -C_ONE_PIXEL, texU_1, Mth::Lerp(texV_2, texV_1, i * C_ONE_PIXEL)); - t.vertexUV(0.0f, (i + 1) * C_ONE_PIXEL, -C_ONE_PIXEL, texU_2, Mth::Lerp(texV_2, texV_1, i * C_ONE_PIXEL)); - } - for (int i = 0; i < 16; i++) - { - t.vertexUV(1.0f, i * C_ONE_PIXEL, 0.0f, texU_1, Mth::Lerp(texV_2, texV_1, i * C_ONE_PIXEL)); - t.vertexUV(0.0f, i * C_ONE_PIXEL, 0.0f, texU_2, Mth::Lerp(texV_2, texV_1, i * C_ONE_PIXEL)); - t.vertexUV(0.0f, i * C_ONE_PIXEL, -C_ONE_PIXEL, texU_2, Mth::Lerp(texV_2, texV_1, i * C_ONE_PIXEL)); - t.vertexUV(1.0f, i * C_ONE_PIXEL, -C_ONE_PIXEL, texU_1, Mth::Lerp(texV_2, texV_1, i * C_ONE_PIXEL)); - } - - t.draw(); + + } + else + { + std::string toBind; + if (inst->m_itemID <= C_MAX_TILES) + toBind = C_TERRAIN_NAME; + else + toBind = "gui/items.png"; + m_pMinecraft->m_pTextures->loadAndBindTexture(toBind); + + constexpr float C_RATIO = 1.0f / 256.0f; + constexpr float C_RATIO_2 = 1.0f / 512.0f; + constexpr float C_ONE_PIXEL = 1.0f / 16.0f; + + int textureX = inst->getIcon() % 16 * 16; + int textureY = inst->getIcon() / 16 * 16; + + float texU_1 = C_RATIO * float(textureX + 0.0f); + float texU_2 = C_RATIO * float(textureX + 15.99f); + float texV_1 = C_RATIO * float(textureY + 0.0f); + float texV_2 = C_RATIO * float(textureY + 15.99f); + + Tesselator& t = Tesselator::instance; + glTranslatef(-0.0f, -0.3f, 0.0f); + glScalef(1.5f, 1.5f, 1.5f); + glRotatef(50.0f, 0.0f, 1.0f, 0.0f); + glRotatef(335.0f, 0.0f, 0.0f, 1.0f); + glTranslatef(-0.9375f, -0.0625f, 0.0f); + + t.begin(); + SHADE_IF_NEEDED(1.0f); + + t.normal(0.0f, 0.0f, 1.0f); + t.vertexUV(0.0f, 0.0f, 0.0f, texU_2, texV_2); + t.vertexUV(1.0f, 0.0f, 0.0f, texU_1, texV_2); + t.vertexUV(1.0f, 1.0f, 0.0f, texU_1, texV_1); + t.vertexUV(0.0f, 1.0f, 0.0f, texU_2, texV_1); + + t.normal(0.0f, 0.0f, -1.0f); + t.vertexUV(0.0f, 1.0f, -C_ONE_PIXEL, texU_2, texV_1); + t.vertexUV(1.0f, 1.0f, -C_ONE_PIXEL, texU_1, texV_1); + t.vertexUV(1.0f, 0.0f, -C_ONE_PIXEL, texU_1, texV_2); + t.vertexUV(0.0f, 0.0f, -C_ONE_PIXEL, texU_2, texV_2); + + SHADE_IF_NEEDED(0.8f); + t.normal(-1.0f, 0.0f, 0.0f); + for (int i = 0; i < 16; i++) + { + t.vertexUV(i * C_ONE_PIXEL, 0.0f, -C_ONE_PIXEL, Mth::Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_2); + t.vertexUV(i * C_ONE_PIXEL, 0.0f, 0.0f, Mth::Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_2); + t.vertexUV(i * C_ONE_PIXEL, 1.0f, 0.0f, Mth::Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_1); + t.vertexUV(i * C_ONE_PIXEL, 1.0f, -C_ONE_PIXEL, Mth::Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_1); + } + for (int i = 0; i < 16; i++) + { + t.vertexUV((i + 1) * C_ONE_PIXEL, 1.0f, -C_ONE_PIXEL, Mth::Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_1); + t.vertexUV((i + 1) * C_ONE_PIXEL, 1.0f, 0.0f, Mth::Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_1); + t.vertexUV((i + 1) * C_ONE_PIXEL, 0.0f, 0.0f, Mth::Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_2); + t.vertexUV((i + 1) * C_ONE_PIXEL, 0.0f, -C_ONE_PIXEL, Mth::Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_2); + } + + SHADE_IF_NEEDED(0.6f); + for (int i = 0; i < 16; i++) + { + t.vertexUV(0.0f, (i + 1) * C_ONE_PIXEL, 0.0f, texU_2, Mth::Lerp(texV_2, texV_1, i * C_ONE_PIXEL)); + t.vertexUV(1.0f, (i + 1) * C_ONE_PIXEL, 0.0f, texU_1, Mth::Lerp(texV_2, texV_1, i * C_ONE_PIXEL)); + t.vertexUV(1.0f, (i + 1) * C_ONE_PIXEL, -C_ONE_PIXEL, texU_1, Mth::Lerp(texV_2, texV_1, i * C_ONE_PIXEL)); + t.vertexUV(0.0f, (i + 1) * C_ONE_PIXEL, -C_ONE_PIXEL, texU_2, Mth::Lerp(texV_2, texV_1, i * C_ONE_PIXEL)); + } + for (int i = 0; i < 16; i++) + { + t.vertexUV(1.0f, i * C_ONE_PIXEL, 0.0f, texU_1, Mth::Lerp(texV_2, texV_1, i * C_ONE_PIXEL)); + t.vertexUV(0.0f, i * C_ONE_PIXEL, 0.0f, texU_2, Mth::Lerp(texV_2, texV_1, i * C_ONE_PIXEL)); + t.vertexUV(0.0f, i * C_ONE_PIXEL, -C_ONE_PIXEL, texU_2, Mth::Lerp(texV_2, texV_1, i * C_ONE_PIXEL)); + t.vertexUV(1.0f, i * C_ONE_PIXEL, -C_ONE_PIXEL, texU_1, Mth::Lerp(texV_2, texV_1, i * C_ONE_PIXEL)); + } + + t.draw(); + } + glPopMatrix(); } @@ -171,7 +172,7 @@ void ItemInHandRenderer::render(float f) glPushMatrix(); glRotatef(pLP->m_rotPrev.y + (pLP->m_rot.y - pLP->m_rotPrev.y) * f, 1.0f, 0.0f, 0.0f); glRotatef(pLP->m_rotPrev.x + (pLP->m_rot.x - pLP->m_rotPrev.x) * f, 0.0f, 1.0f, 0.0f); - Lighting::turnOn(); + Lighting::turnOn(); // must be called before glPopMatrix() glPopMatrix(); if (m_pMinecraft->getOptions()->m_bDynamicHand && m_pMinecraft->m_pMobPersp == pLP) @@ -189,66 +190,58 @@ void ItemInHandRenderer::render(float f) /*if (pLP->m_fishing != null) { pItem = new ItemInstance(Item::stick); }*/ - - - if (pItem->m_itemID <= 0) + + glPushMatrix(); + + float swing2, swing3; + float fAnim = pLP->getAttackAnim(f); + constexpr float d = 0.8f; + + if (!pItem->isNull()) { - glPushMatrix(); - float fAnim = pLP->getAttackAnim(f); - - glTranslatef(-0.3f * Mth::sin(float(M_PI) * Mth::sqrt(fAnim)), 0.4f * Mth::sin(2.0f * float(M_PI) * Mth::sqrt(fAnim)), -0.4f * Mth::sin(float(M_PI) * fAnim)); - glTranslatef(0.64f, ((1.0f - h) * -0.6f) - 0.6f, -0.72f); - glRotatef(45.0f, 0.0f, 1.0f, 0.0f); - glEnable(GL_RESCALE_NORMAL); - - // @HUH: refetch - fAnim = pLP->getAttackAnim(f); + glTranslatef(-0.4f * Mth::sin(float(M_PI) * Mth::sqrt(fAnim)), 0.2f * Mth::sin(2.0f * float(M_PI) * Mth::sqrt(fAnim)), -0.2f * Mth::sin(float(M_PI) * fAnim)); + glTranslatef(0.7f * d, -0.65f * d - (1.0f - h) * 0.6f, -0.9f * d); + glRotatef(45.0f, 0.0f, 1.0f, 0.0f); + glEnable(GL_RESCALE_NORMAL); - glRotatef(Mth::sin(float(M_PI) * Mth::sqrt(fAnim)) * 70.0f, 0.0f, 1.0f, 0.0f); - glRotatef(Mth::sin(float(M_PI) * fAnim * fAnim) * -20.0f, 0.0f, 0.0f, 1.0f); + swing3 = Mth::sin(float(M_PI) * fAnim * fAnim); + swing2 = Mth::sin(float(M_PI) * Mth::sqrt(fAnim)); - m_pMinecraft->m_pTextures->loadAndBindTexture("mob/char.png"); - glTranslatef(-1.0f, 3.6f, 3.5f); - glRotatef(120.0f, 0.0f, 0.0f, 1.0f); - glRotatef(200.0f, 1.0f, 0.0f, 0.0f); - glRotatef(-135.0f, 0.0f, 1.0f, 0.0f); - glScalef(1.0f, 1.0f, 1.0f); - glTranslatef(5.6f, 0.0f, 0.0f); + glRotatef(swing3 * -20.0f, 0.0f, 1.0f, 0.0f); + glRotatef(swing2 * -20.0f, 0.0f, 0.0f, 1.0f); + glRotatef(swing2 * -80.0f, 1.0f, 0.0f, 0.0f); + glScalef(0.4f, 0.4f, 0.4f); - HumanoidMobRenderer* pRenderer = (HumanoidMobRenderer*)EntityRenderDispatcher::getInstance()->getRenderer(pLP); - glScalef(1.0f, 1.0f, 1.0f); - pRenderer->renderHand(); + if (pItem->getItem()->isMirroredArt()) + glRotatef(180.0f, 0.0f, 1.0f, 0.0f); - glPopMatrix(); + renderItem(pItem); } else { - glPushMatrix(); - float fAnim = pLP->getAttackAnim(f); - - glTranslatef(-0.4f * Mth::sin(float(M_PI) * Mth::sqrt(fAnim)), 0.2f * Mth::sin(2.0f * float(M_PI) * Mth::sqrt(fAnim)), -0.2f * Mth::sin(float(M_PI) * fAnim)); - glTranslatef(0.56f, ((1.0f - h) * -0.6f) - 0.52f, -0.72f); - glRotatef(45.0f, 0.0f, 1.0f, 0.0f); - glEnable(GL_RESCALE_NORMAL); - - // @HUH: refetch - fAnim = pLP->getAttackAnim(f); - - float sin1 = Mth::sin(float(M_PI) * Mth::sqrt(fAnim)); - float sin2 = Mth::sin(float(M_PI) * fAnim * fAnim); - - glRotatef(sin2 * -20.0f, 0.0f, 1.0f, 0.0f); - glRotatef(sin1 * -20.0f, 0.0f, 0.0f, 1.0f); - glRotatef(sin1 * -80.0f, 1.0f, 0.0f, 0.0f); - glScalef(0.4f, 0.4f, 0.4f); - - if (pItem->getItem()->isMirroredArt()) - glRotatef(180.0f, 0.0f, 1.0f, 0.0f); - - renderItem(pItem); - glPopMatrix(); + glTranslatef(-0.3f * Mth::sin(float(M_PI) * Mth::sqrt(fAnim)), 0.4f * Mth::sin(2.0f * float(M_PI) * Mth::sqrt(fAnim)), -0.4f * Mth::sin(float(M_PI) * fAnim)); + glTranslatef(0.8f * d, -0.75f * d - (1.0f - h) * 0.6f, -0.9f * d); + glRotatef(45.0f, 0.0f, 1.0f, 0.0f); + glEnable(GL_RESCALE_NORMAL); + + glRotatef(Mth::sin(float(M_PI) * Mth::sqrt(fAnim)) * 70.0f, 0.0f, 1.0f, 0.0f); + glRotatef(Mth::sin(float(M_PI) * fAnim * fAnim) * -20.0f, 0.0f, 0.0f, 1.0f); + + m_pMinecraft->m_pTextures->loadAndBindTexture("mob/char.png"); + glTranslatef(-1.0f, 3.6f, 3.5f); + glRotatef(120.0f, 0.0f, 0.0f, 1.0f); + glRotatef(200.0f, 1.0f, 0.0f, 0.0f); + glRotatef(-135.0f, 0.0f, 1.0f, 0.0f); + glScalef(1.0f, 1.0f, 1.0f); + glTranslatef(5.6f, 0.0f, 0.0f); + + HumanoidMobRenderer* pRenderer = (HumanoidMobRenderer*)EntityRenderDispatcher::getInstance()->getRenderer(pLP); + swing2 = 1.0f; + glScalef(swing2, swing2, swing2); + pRenderer->renderHand(); } + glPopMatrix(); glDisable(GL_RESCALE_NORMAL); Lighting::turnOff(); } diff --git a/source/client/renderer/LevelRenderer.cpp b/source/client/renderer/LevelRenderer.cpp index b3c5b937b..36e103f75 100644 --- a/source/client/renderer/LevelRenderer.cpp +++ b/source/client/renderer/LevelRenderer.cpp @@ -909,7 +909,7 @@ void LevelRenderer::renderHitOutline(Player* pPlayer, const HitResult& hr, int i float range[2]; glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, range); - float lineWidth = 2.0f; + float lineWidth = 2.0f * Minecraft::getRenderScaleMultiplier(); if (lineWidth > range[1]) lineWidth = range[1]; @@ -1297,20 +1297,22 @@ void LevelRenderer::renderAdvancedClouds(float alpha) { glDisable(GL_CULL_FACE); - float yOffs = Mth::Lerp(m_pMinecraft->m_pMobPersp->m_posPrev.y, m_pMinecraft->m_pMobPersp->m_pos.y, alpha); + float yOffs = //Mth::Lerp(m_pMinecraft->m_pMobPersp->m_posPrev.y, m_pMinecraft->m_pMobPersp->m_pos.y, alpha); + m_pMinecraft->m_pMobPersp->m_posPrev.y + (m_pMinecraft->m_pMobPersp->m_pos.y - m_pMinecraft->m_pMobPersp->m_posPrev.y) * alpha; Tesselator& t = Tesselator::instance; - float ss = 12.0f; - float h = 4.0f; + constexpr float ss = 12.0f; + constexpr float h = 4.0f; // @NOTE: Using Mth::Lerp will use incorrect logic float xo = (m_pMinecraft->m_pMobPersp->m_oPos.x + (m_pMinecraft->m_pMobPersp->m_oPos.x - m_pMinecraft->m_pMobPersp->m_oPos.x) * alpha + ((float(m_ticksSinceStart) + alpha) * 0.03f)) / ss; - float zo = (m_pMinecraft->m_pMobPersp->m_oPos.z + (m_pMinecraft->m_pMobPersp->m_oPos.z - m_pMinecraft->m_pMobPersp->m_oPos.z) * alpha) / ss + 0.33; + float zo = (m_pMinecraft->m_pMobPersp->m_oPos.z + (m_pMinecraft->m_pMobPersp->m_oPos.z - m_pMinecraft->m_pMobPersp->m_oPos.z) * alpha) / ss + 0.33f; - float yy = ((float)C_MAX_Y - yOffs) + 0.33f; + float yy = ((float)C_MAX_Y - yOffs) + 0.33f; // 108.0f on b1.2_02, see below + //float yy = 108.0f - yOffs + 0.33F; - int xOffs = Mth::floor(xo / 2048.0); - int zOffs = Mth::floor(zo / 2048.0); + int xOffs = Mth::floor(xo / 2048); + int zOffs = Mth::floor(zo / 2048); xo -= xOffs * 2048; zo -= zOffs * 2048; @@ -1323,20 +1325,26 @@ void LevelRenderer::renderAdvancedClouds(float alpha) float cr = cc.x; float cg = cc.y; float cb = cc.z; - + float uo; + float vo; + float scale; + if (m_pMinecraft->getOptions()->m_bAnaglyphs) { - float crr = (cr * 30.0f + cg * 59.0f + cb * 11.0f) / 100.0f; - float cgg = (cr * 30.0f + cg * 70.0f) / 100.0f; - float cbb = (cr * 30.0f + cb * 70.0f) / 100.0f; - cr = crr; - cg = cgg; - cb = cbb; + uo = (cr * 30.0F + cg * 59.0F + cb * 11.0F) / 100.0F; + vo = (cr * 30.0F + cg * 70.0F) / 100.0F; + scale = (cr * 30.0F + cb * 70.0F) / 100.0F; + cr = uo; + cg = vo; + cb = scale; } + + uo = (float)(xo * 0.0); + vo = (float)(zo * 0.0); - float uo = xo * 0.0f; - float vo = zo * 0.0f; - float scale = 1.0f / 256.0f; + //uo = xo * 0.0f; + //vo = zo * 0.0f; + scale = 1.0f / 256.0f; uo = Mth::floor(xo) * scale; vo = Mth::floor(zo) * scale; @@ -1344,9 +1352,9 @@ void LevelRenderer::renderAdvancedClouds(float alpha) float xoffs = xo - Mth::floor(xo); float zoffs = zo - Mth::floor(zo); - int D = 8; - int radius = 3; - float e = 1.0f / 1024.0f; + constexpr int D = 8; + constexpr int radius = 3; + constexpr float e = 1.0f / 1024.0f; glScalef(ss, 1.0f, ss); diff --git a/source/client/renderer/Lighting.cpp b/source/client/renderer/Lighting.cpp index f6628ad87..ccf769fee 100644 --- a/source/client/renderer/Lighting.cpp +++ b/source/client/renderer/Lighting.cpp @@ -4,7 +4,7 @@ #include "thirdparty/GL/GL.hpp" -float Lighting::lb[16] = {}; +float Lighting::lb[4] = {}; void Lighting::turnOff() { @@ -25,9 +25,7 @@ void Lighting::turnOn() glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); - float a = 0.4f; - float d = 0.6f; - float s = 0.0f; + constexpr float a = 0.4f, d = 0.6f, s = 0.0f; Vec3 l = Vec3(0.2f, 1.0f, -0.7f).normalize(); glLightfv(GL_LIGHT0, GL_POSITION, getBuffer(l.x, l.y, l.z, 0.0f)); diff --git a/source/client/renderer/Lighting.hpp b/source/client/renderer/Lighting.hpp index 6a5ae6d56..8480fa4af 100644 --- a/source/client/renderer/Lighting.hpp +++ b/source/client/renderer/Lighting.hpp @@ -5,7 +5,7 @@ class Lighting { private: - static float lb[16]; + static float lb[4]; public: static void turnOff(); diff --git a/source/client/renderer/Tesselator.cpp b/source/client/renderer/Tesselator.cpp index 906566f36..a6778c1b0 100644 --- a/source/client/renderer/Tesselator.cpp +++ b/source/client/renderer/Tesselator.cpp @@ -340,6 +340,14 @@ void Tesselator::vertex(float x, float y, float z) { pVert2->m_color = pVert1->m_color; } + + // Wasn't here in Java cuz I guess it's not needed? +/*#ifdef USE_GL_NORMAL_LIGHTING + if (m_bHasNormal) + { + pVert2->m_normal = pVert1->m_normal; + } +#endif*/ pVert2->m_x = pVert1->m_x; pVert2->m_y = pVert1->m_y; diff --git a/source/client/renderer/Tesselator.hpp b/source/client/renderer/Tesselator.hpp index 94d92260a..2a82c78a2 100644 --- a/source/client/renderer/Tesselator.hpp +++ b/source/client/renderer/Tesselator.hpp @@ -41,7 +41,7 @@ class Tesselator uint32_t m_color; #ifdef USE_GL_NORMAL_LIGHTING // the legend - int m_normal; + uint32_t m_normal; #endif }; @@ -101,7 +101,7 @@ class Tesselator float m_offsetY; float m_offsetZ; - int m_nextVtxNormal; // normalValue + uint32_t m_nextVtxNormal; // normalValue // State bool m_bTesselating; diff --git a/source/client/renderer/entity/ItemRenderer.cpp b/source/client/renderer/entity/ItemRenderer.cpp index 8c6086359..67ebd9c12 100644 --- a/source/client/renderer/entity/ItemRenderer.cpp +++ b/source/client/renderer/entity/ItemRenderer.cpp @@ -44,11 +44,11 @@ void ItemRenderer::render(Entity* pEntity, float x, float y, float z, float a, f const ItemInstance* pItemInstance = &(pItemEntity->m_itemInstance); int itemsToRender = 1; - if (pItemInstance->m_amount > 1) + if (pItemInstance->m_count > 1) itemsToRender = 2; - if (pItemInstance->m_amount > 5) + if (pItemInstance->m_count > 5) itemsToRender = 3; - if (pItemInstance->m_amount > 20) + if (pItemInstance->m_count > 20) itemsToRender = 4; glTranslatef(x, y + 0.1f + yOffset * 0.1f, z); @@ -80,7 +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); } - tileRenderer->renderTile(Tile::tiles[itemID], pItemInstance->m_auxValue, pItemEntity->getBrightness(1.0f)); + tileRenderer->renderTile(Tile::tiles[itemID], pItemInstance->getAuxValue(), pItemEntity->getBrightness(1.0f)); glPopMatrix(); } } @@ -159,11 +159,11 @@ void ItemRenderer::renderGuiItemOverlay(Font* font, Textures* textures, ItemInst if (!instance) return; - if (instance->m_amount == 1) + if (instance->m_count == 1) return; std::stringstream ss; - ss << instance->m_amount; + ss << instance->m_count; std::string amtstr = ss.str(); int width = font->width(amtstr), height = font->height(amtstr) + 8; @@ -240,7 +240,7 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures, ItemInstance* i if (Tile::tiles[itemID]->getRenderShape() != SHAPE_STAIRS) glRotatef(-90.0f, 0.0f, 1.0f, 0.0f); - tileRenderer->renderTile(Tile::tiles[itemID], instance->m_auxValue, 1.0f, true); + tileRenderer->renderTile(Tile::tiles[itemID], instance->getAuxValue(), 1.0f, true); #undef PARM_HACK glPopMatrix(); diff --git a/source/client/renderer/entity/MobRenderer.cpp b/source/client/renderer/entity/MobRenderer.cpp index ec6ea0ae5..1fbeead8c 100644 --- a/source/client/renderer/entity/MobRenderer.cpp +++ b/source/client/renderer/entity/MobRenderer.cpp @@ -38,7 +38,7 @@ float MobRenderer::getAttackAnim(Mob* mob, float f) float MobRenderer::getBob(Mob* mob, float f) { - return float(mob->field_B4) + f; + return float(mob->m_tickCount) + f; } float MobRenderer::getFlipDegrees(Mob* mob) diff --git a/source/common/Utils.cpp b/source/common/Utils.cpp index 34ba4ba26..e187e142a 100644 --- a/source/common/Utils.cpp +++ b/source/common/Utils.cpp @@ -37,7 +37,7 @@ int g_TimeSecondsOnInit = 0; -#if (!defined(USE_SDL) || defined(_WIN32)) && !defined(ANDROID) && !MC_TARGET_OS_MAC +#if (!defined(USE_SDL) || defined(_WIN32)) && !defined(ANDROID) && !MC_PLATFORM_MAC DIR* opendir(const char* name) { diff --git a/source/world/entity/Entity.cpp b/source/world/entity/Entity.cpp index d783fcf1c..4d08af3e8 100644 --- a/source/world/entity/Entity.cpp +++ b/source/world/entity/Entity.cpp @@ -23,7 +23,7 @@ void Entity::_init() field_24 = 0; field_28 = 0; field_30 = 1.0f; - field_34 = 0; + m_bBlocksBuilding = false; m_pLevel = nullptr; m_rot = Vec2::ZERO; m_rotPrev = Vec2::ZERO; @@ -44,11 +44,12 @@ void Entity::_init() field_A8 = 0.0f; m_bNoPhysics = false; field_B0 = 0.0f; - field_B4 = 0; + m_tickCount = 0; field_B8 = 0; m_airCapacity = TOTAL_AIR_SUPPLY; m_fireTicks = 0; - m_flameTime = 0; + m_flameTime = 1; + m_tickCount = 0; field_C8 = 0; // @NOTE: Render type? (eEntityRenderType) m_distanceFallen = 0.0f; m_airSupply = TOTAL_AIR_SUPPLY; @@ -614,7 +615,7 @@ void Entity::baseTick() field_90 = m_walkDist; m_oPos = m_pos; - field_B4++; + m_tickCount++; m_rotPrev = m_rot; if (isInWater()) { diff --git a/source/world/entity/Entity.hpp b/source/world/entity/Entity.hpp index 98bc459a1..520eae1af 100644 --- a/source/world/entity/Entity.hpp +++ b/source/world/entity/Entity.hpp @@ -176,12 +176,12 @@ class Entity bool m_bInAChunk; ChunkPos m_chunkPos; int m_chunkPosY; - int field_20; + int field_20; // unused Vec3? int field_24; int field_28; int m_EntityID; float field_30; - uint8_t field_34; + bool m_bBlocksBuilding; Level* m_pLevel; Vec3 m_oPos; // "o" in Java or "xo" ""yo" "zo" Vec3 m_vel; @@ -209,7 +209,7 @@ class Entity float field_A8; bool m_bNoPhysics; float field_B0; - int field_B4; + int m_tickCount; int field_B8; int m_airCapacity; int m_fireTicks; diff --git a/source/world/entity/FallingTile.cpp b/source/world/entity/FallingTile.cpp index b57310136..3718c5e91 100644 --- a/source/world/entity/FallingTile.cpp +++ b/source/world/entity/FallingTile.cpp @@ -18,7 +18,7 @@ FallingTile::FallingTile(Level* level, const Vec3& pos, int id) : Entity(level), field_E0(0) { m_id = id; - field_34 = 1; + m_bBlocksBuilding = false; setSize(0.98f, 0.98f); m_heightOffset = m_bbHeight * 0.5f; setPos(pos); diff --git a/source/world/entity/ItemEntity.cpp b/source/world/entity/ItemEntity.cpp index 655cca5d7..9dfa8b7cd 100644 --- a/source/world/entity/ItemEntity.cpp +++ b/source/world/entity/ItemEntity.cpp @@ -75,7 +75,7 @@ void ItemEntity::playerTouch(Player* player) m_pLevel->playSound(this, "random.pop", 0.3f, (((sharedRandom.nextFloat() - sharedRandom.nextFloat()) * 0.7f) + 1.0f) + (((sharedRandom.nextFloat() - sharedRandom.nextFloat()) * 0.7f) + 1.0f)); - if (m_itemInstance.m_amount <= 0) + if (m_itemInstance.m_count <= 0) remove(); } diff --git a/source/world/entity/Mob.cpp b/source/world/entity/Mob.cpp index bab62d664..55d791fc2 100644 --- a/source/world/entity/Mob.cpp +++ b/source/world/entity/Mob.cpp @@ -25,14 +25,14 @@ Mob::Mob(Level* pLevel) : Entity(pLevel) m_hurtDir = 0.0f; field_110 = 0; field_114 = 0; - field_118 = 0.0f; - field_11C = 0.0f; + m_oTilt = 0.0f; + m_tilt = 0.0f; field_120 = 0; field_124 = 0; field_128 = 0.0f; field_12C = 0.0f; field_130 = 0.0f; - field_AFC = 0; + m_noActionTime = 0; field_B00 = Vec2::ZERO; field_B08 = 0.0f; m_bJumping = 0; @@ -59,7 +59,7 @@ Mob::Mob(Level* pLevel) : Entity(pLevel) m_texture = "/mob/pig.png"; m_class = ""; - field_34 = 1; + m_bBlocksBuilding = true; field_E4 = (Mth::random() + 1.0f) * 0.01f; setPos(m_pos); @@ -257,7 +257,7 @@ void Mob::baseTick() m_airCapacity = m_airSupply; } - field_118 = field_11C; + m_oTilt = m_tilt; if (field_114 > 0) field_114--; if (m_hurtTime > 0) m_hurtTime--; @@ -306,7 +306,7 @@ bool Mob::hurt(Entity *pAttacker, int damage) if (m_pLevel->m_bIsMultiplayer) return false; - field_AFC = m_pLevel->m_bIsMultiplayer; + m_noActionTime = 0; if (m_health <= 0) return false; @@ -718,7 +718,7 @@ void Mob::jumpFromGround() void Mob::updateAi() { - field_AFC++; + m_noActionTime++; checkDespawn(); @@ -777,12 +777,12 @@ void Mob::checkDespawn(Mob* nearestMob) if (remWhenFar && distSqr > 9216.0f) remove(); - if (field_AFC <= 600) - field_AFC = 0; + if (m_noActionTime <= 600) + m_noActionTime = 0; else if (m_random.nextInt(800) == 0 && remWhenFar && distSqr >= 1024.0f) remove(); else - field_AFC = 0; + m_noActionTime = 0; } } @@ -831,4 +831,4 @@ void Mob::updateAttackAnim() } m_attackAnim = m_swingTime * 0.125f; -} \ No newline at end of file +} diff --git a/source/world/entity/Mob.hpp b/source/world/entity/Mob.hpp index d75eb88c1..63568fc1d 100644 --- a/source/world/entity/Mob.hpp +++ b/source/world/entity/Mob.hpp @@ -100,15 +100,15 @@ class Mob : public Entity float m_hurtDir; int field_110; int field_114; - float field_118; - float field_11C; + float m_oTilt; + float m_tilt; int field_120; int field_124; float field_128; float field_12C; float field_130; Random m_random; - int field_AFC; + int m_noActionTime; Vec2 field_B00; float field_B08; bool m_bJumping; diff --git a/source/world/entity/PathfinderMob.cpp b/source/world/entity/PathfinderMob.cpp index bb0e4e771..8a3213431 100644 --- a/source/world/entity/PathfinderMob.cpp +++ b/source/world/entity/PathfinderMob.cpp @@ -135,7 +135,7 @@ void PathfinderMob::updateAi() } else if (!m_bHoldGround && ((m_path.empty() && m_random.nextInt(180) == 0) || field_BA4 > 0 || m_random.nextInt(120) == 0)) { - if (field_AFC < 100) + if (m_noActionTime < 100) findRandomStrollLocation(); } diff --git a/source/world/entity/Player.cpp b/source/world/entity/Player.cpp index 3b5f6c16a..937b83b53 100644 --- a/source/world/entity/Player.cpp +++ b/source/world/entity/Player.cpp @@ -15,8 +15,8 @@ Player::Player(Level* pLevel, GameType playerGameType) : Mob(pLevel) m_pInventory = nullptr; field_B94 = 0; m_score = 0; - field_B9C = 0.0f; - field_BA0 = 0.0f; + m_oBob = 0.0f; + m_bob = 0.0f; m_name = ""; field_BC4 = 0; m_bHaveRespawnPos = false; @@ -59,8 +59,38 @@ bool Player::hurt(Entity* pEnt, int damage) { if (isCreative()) return false; - - return Mob::hurt(pEnt, damage); + + m_noActionTime = 0; + if (m_health <= 0) + { + return false; + } + + EntityTypeDescriptor entDesc = pEnt->getDescriptor(); + + if (entDesc.hasCategory(EntityCategories::MONSTER) || entDesc.hasCategory(EntityCategories::ABSTRACT_ARROW)) + { + switch (m_pLevel->m_difficulty) + { + case 0: + damage = 0; + break; + case 1: + damage = damage / 3 + 1; + break; + case 2: + // Don't modify damage + break; + case 3: + damage = damage * 3 / 2; + break; + default: + assert(!"Unknown difficulty value"); + break; + } + } + + return damage == 0 ? false : Mob::hurt(pEnt, damage); } void Player::awardKillScore(Entity* pKilled, int score) @@ -104,7 +134,18 @@ void Player::die(Entity* pCulprit) void Player::aiStep() { - field_B9C = field_BA0; + if (m_pLevel->m_difficulty == 0 && + m_health < 20 && + m_tickCount % 20 * 12 == 0) + { + heal(1); + } + +#ifdef ENH_GUI_ITEM_POP + m_pInventory->tick(); +#endif + m_oBob = m_bob; + //Mob::aiStep(); // called in Java, calling here results in 2x speed player movement float velLen = Mth::sqrt(m_vel.x * m_vel.x + m_vel.z * m_vel.z); float velYAtan = Mth::atan(m_vel.y * -0.2f), x1 = 0.0f; @@ -127,8 +168,8 @@ void Player::aiStep() if (m_health <= 0) velLen = 0.0f; - field_BA0 += (velLen - field_BA0) * 0.4f; - field_11C += (x1 - field_11C) * 0.8f; + m_bob += (velLen - m_bob) * 0.4f; + m_tilt += (x1 - m_tilt) * 0.8f; if (m_health <= 0) return; @@ -323,4 +364,4 @@ void Player::interact(Entity* pEnt) ItemInstance* Player::getSelectedItem() const { return m_pInventory->getSelected(); -} \ No newline at end of file +} diff --git a/source/world/entity/Player.hpp b/source/world/entity/Player.hpp index 08b27988a..eea58dbcc 100644 --- a/source/world/entity/Player.hpp +++ b/source/world/entity/Player.hpp @@ -85,8 +85,8 @@ class Player : public Mob Inventory* m_pInventory; uint8_t field_B94; int m_score; - float field_B9C; - float field_BA0; + float m_oBob; // field_B9C + float m_bob; std::string m_name; int field_BC4; RakNet::RakNetGUID m_guid; diff --git a/source/world/entity/PrimedTnt.cpp b/source/world/entity/PrimedTnt.cpp index 0c8571576..fc2321cab 100644 --- a/source/world/entity/PrimedTnt.cpp +++ b/source/world/entity/PrimedTnt.cpp @@ -13,7 +13,7 @@ void PrimedTnt::_init() { m_fuseTimer = 0; field_C8 = RENDER_TNT; - field_34 = 1; + m_bBlocksBuilding = true; setSize(0.98f, 0.98f); m_heightOffset = m_bbHeight * 0.5f; m_bMakeStepSound = false; diff --git a/source/world/entity/Rocket.cpp b/source/world/entity/Rocket.cpp index ae664fcce..b5b8ccad0 100644 --- a/source/world/entity/Rocket.cpp +++ b/source/world/entity/Rocket.cpp @@ -16,7 +16,7 @@ Rocket::Rocket(Level* level, const Vec3& pos) : Entity(level) field_B90 = 80; field_C8 = RENDER_ROCKET; - field_34 = 1; + m_bBlocksBuilding = true; setSize(0.1f, 1.0f); m_heightOffset = m_bbHeight * 0.5f - 0.25f; diff --git a/source/world/entity/TripodCamera.cpp b/source/world/entity/TripodCamera.cpp index b5f505e11..df00627d9 100644 --- a/source/world/entity/TripodCamera.cpp +++ b/source/world/entity/TripodCamera.cpp @@ -21,7 +21,7 @@ TripodCamera::TripodCamera(Level* level, Player* player, const Vec3& pos) : Mob( m_rotPrev = m_rot = player->m_rot; - field_34 = 1; + m_bBlocksBuilding = true; setSize(1.0f, 1.5f); m_heightOffset = m_bbHeight * 0.5f - 0.25f; diff --git a/source/world/gamemode/GameMode.cpp b/source/world/gamemode/GameMode.cpp index 096a83511..410e37fad 100644 --- a/source/world/gamemode/GameMode.cpp +++ b/source/world/gamemode/GameMode.cpp @@ -128,10 +128,10 @@ void GameMode::handleCloseInventory(int a, Player* player) bool GameMode::useItem(Player* player, Level* level, ItemInstance* instance) { - int oldAmount = instance->m_amount; + int oldCount = instance->m_count; if (instance == instance->use(level, player)) - return instance->m_amount != oldAmount; + return instance->m_count != oldCount; return true; } diff --git a/source/world/item/DoorItem.cpp b/source/world/item/DoorItem.cpp index 5962644ce..8ae01f733 100644 --- a/source/world/item/DoorItem.cpp +++ b/source/world/item/DoorItem.cpp @@ -68,6 +68,6 @@ bool DoorItem::useOn(ItemInstance* inst, Player* player, Level* level, const Til level->setData(pos.above(), faceDir); level->setTile(TilePos(pos.x, pos.y + 2, pos.z), pTile->m_ID); level->setData(TilePos(pos.x, pos.y + 2, pos.z), faceDir + 8); - inst->m_amount--; + inst->m_count--; return true; } diff --git a/source/world/item/Inventory.cpp b/source/world/item/Inventory.cpp index 5f3657c16..606bc88a9 100644 --- a/source/world/item/Inventory.cpp +++ b/source/world/item/Inventory.cpp @@ -127,12 +127,15 @@ void Inventory::clear() m_items.resize(C_NUM_SURVIVAL_SLOTS); } +// This code, and this function, don't exist in b1.2_02 +// "add" exists with these same arguments, which calls "addResource", +// but addResource's code is entirely different somehow. Did we write this from scratch? void Inventory::addItem(ItemInstance* pInst) { if (!m_bIsSurvival) { // Just get rid of the item. - pInst->m_amount = 0; + pInst->m_count = 0; return; } @@ -144,11 +147,11 @@ void Inventory::addItem(ItemInstance* pInst) int maxStackSize = m_items[i].getMaxStackSize(); bool bIsStackedByData = Item::items[pInst->m_itemID]->isStackedByData(); - if (bIsStackedByData && m_items[i].m_auxValue != pInst->m_auxValue) + if (bIsStackedByData && m_items[i].getAuxValue() != pInst->getAuxValue()) continue; // try to collate. - int combinedItemAmount = pInst->m_amount + m_items[i].m_amount; + int combinedItemAmount = pInst->m_count + m_items[i].m_count; int leftover = combinedItemAmount - maxStackSize; if (leftover < 0) @@ -156,16 +159,17 @@ void Inventory::addItem(ItemInstance* pInst) else combinedItemAmount = C_MAX_AMOUNT; - m_items[i].m_amount = combinedItemAmount; + m_items[i].m_count = combinedItemAmount; + m_items[i].m_popTime = 5; - pInst->m_amount = leftover; + pInst->m_count = leftover; if (!bIsStackedByData) - m_items[i].m_auxValue = 0; + m_items[i].setAuxValue(0); } // If there's nothing leftover: - if (!pInst->m_amount) + if (pInst->m_count <= 0) return; // try to add it to an empty slot @@ -175,20 +179,33 @@ void Inventory::addItem(ItemInstance* pInst) continue; m_items[i] = *pInst; - pInst->m_amount = 0; + m_items[i].m_popTime = 5; + pInst->m_count = 0; return; } } +// Doesn't exist in PE +void Inventory::tick() +{ + for (int i = 0; i < m_items.size(); i++) + { + if (!m_items[i].isNull() && m_items[i].m_popTime > 0) + { + m_items[i].m_popTime--; + } + } +} + void Inventory::addTestItem(int itemID, int amount, int auxValue) { ItemInstance inst(itemID, amount, auxValue); addItem(&inst); - if (inst.m_amount != 0) + if (inst.m_count != 0) { LOG_I("AddTestItem: Couldn't add all %d of %s, only gave %d", - amount, Item::items[itemID]->m_DescriptionID.c_str(), amount - inst.m_amount); + amount, Item::items[itemID]->m_DescriptionID.c_str(), amount - inst.m_count); } } @@ -197,7 +214,7 @@ ItemInstance* Inventory::getItem(int slotNo) if (slotNo < 0 || slotNo >= int(m_items.size())) return nullptr; - if (m_items[slotNo].m_amount <= 0) + if (m_items[slotNo].m_count <= 0) m_items[slotNo].m_itemID = 0; return &m_items[slotNo]; @@ -319,11 +336,11 @@ void Inventory::dropAll(bool butNotReally) for (int i = 0; i < getNumItems(); i++) { ItemInstance* item = &m_items[i]; - if (item->m_amount > 0) + if (item->m_count > 0) { if (!butNotReally) m_pPlayer->drop(item->copy(), true); - item->m_amount = 0; + item->m_count = 0; } } -} \ No newline at end of file +} diff --git a/source/world/item/Inventory.hpp b/source/world/item/Inventory.hpp index d5eb77841..acbd0b939 100644 --- a/source/world/item/Inventory.hpp +++ b/source/world/item/Inventory.hpp @@ -26,6 +26,7 @@ class Inventory void clear(); void addItem(ItemInstance* pInst); + void tick(); ItemInstance* getItem(int slotNo); ItemInstance* getQuickSlotItem(int slotNo); diff --git a/source/world/item/ItemInstance.cpp b/source/world/item/ItemInstance.cpp index c06ad4597..388369260 100644 --- a/source/world/item/ItemInstance.cpp +++ b/source/world/item/ItemInstance.cpp @@ -10,64 +10,54 @@ #include "ItemInstance.hpp" #include "world/tile/Tile.hpp" -void ItemInstance::init(int itemID, int amount, int auxValue) +void ItemInstance::_init(int itemID, int count, int auxValue) { m_itemID = itemID; - m_amount = amount; + m_count = count; m_auxValue = auxValue; - m_field_8 = 0; + m_popTime = 0; //@BUG? Not using the auxValue. This is problematic in the case of wool and dyes. } ItemInstance::ItemInstance() { - init(0, 0, 0); + _init(0, 0, 0); } ItemInstance::ItemInstance(Item* pItem) { - init(pItem->m_itemID, 1, 0); + _init(pItem->m_itemID, 1, 0); } ItemInstance::ItemInstance(Item* pItem, int amount) { - init(pItem->m_itemID, amount, 0); + _init(pItem->m_itemID, amount, 0); } ItemInstance::ItemInstance(Item* pItem, int amount, int auxValue) { - init(pItem->m_itemID, amount, auxValue); + _init(pItem->m_itemID, amount, auxValue); } ItemInstance::ItemInstance(Tile* pTile) { - init(pTile->m_ID, 1, 0); + _init(pTile->m_ID, 1, 0); } ItemInstance::ItemInstance(Tile* pTile, int amount) { - init(pTile->m_ID, amount, 0); + _init(pTile->m_ID, amount, 0); } ItemInstance::ItemInstance(Tile* pTile, int amount, int auxValue) { - init(pTile->m_ID, amount, auxValue); + _init(pTile->m_ID, amount, auxValue); } ItemInstance::ItemInstance(int itemID, int amount, int auxValue) { - init(itemID, amount, auxValue); -} - -int ItemInstance::getAuxValue() -{ - return m_auxValue; -} - -int ItemInstance::getDamageValue() -{ - return m_auxValue; + _init(itemID, amount, auxValue); } Item* ItemInstance::getItem() const @@ -77,7 +67,7 @@ Item* ItemInstance::getItem() const ItemInstance* ItemInstance::copy() { - return new ItemInstance(m_itemID, m_amount, m_auxValue); + return new ItemInstance(m_itemID, m_count, m_auxValue); } bool ItemInstance::canDestroySpecial(Tile* tile) @@ -118,9 +108,9 @@ void ItemInstance::hurt(int by) m_auxValue += by; if (m_auxValue > getMaxDamage()) { - m_amount--; - if (m_amount < 0) - m_amount = 0; + m_count--; + if (m_count < 0) + m_count = 0; m_auxValue = 0; } } @@ -163,7 +153,9 @@ bool ItemInstance::isStackedByData() bool ItemInstance::matches(ItemInstance* other) const { - return m_auxValue == other->m_auxValue && m_amount == other->m_amount && m_itemID == other->m_itemID; + return this->getAuxValue() == other->getAuxValue() && + this->m_count == other->m_count && + this->m_itemID == other->m_itemID; } bool ItemInstance::matches(ItemInstance* a1, ItemInstance* a2) @@ -187,10 +179,10 @@ void ItemInstance::mineBlock(const TilePos& pos, Facing::Name face) return getItem()->mineBlock(this, pos, face); } -ItemInstance ItemInstance::remove(int amt) +ItemInstance ItemInstance::remove(int count) { - m_amount -= amt; - return ItemInstance(m_itemID, amt, m_auxValue); + m_count -= count; + return ItemInstance(m_itemID, count, m_auxValue); } void ItemInstance::setDescriptionId(const std::string& str) @@ -205,7 +197,7 @@ void ItemInstance::snap(Player*) std::string ItemInstance::toString() { std::stringstream ss; - ss << m_amount << "x" << getItem()->getDescriptionId() << "@" << m_auxValue; + ss << m_count << "x" << getItem()->getDescriptionId() << "@" << m_auxValue; return ss.str(); } @@ -223,15 +215,15 @@ bool ItemInstance::useOn(Player* player, Level* level, const TilePos& pos, Facin bool ItemInstance::isNull() const { // 0.9.2 - //if (!m_field_10) - // return true; + if (m_itemID <= 0) // m_field_10, assuming this is m_itemID + return true; if (m_auxValue != 0) return false; - if (m_amount != 0) + if (m_count != 0) return false; - if (m_field_8 != 0) + if (m_popTime != 0) return false; return true; // isNull -} \ No newline at end of file +} diff --git a/source/world/item/ItemInstance.hpp b/source/world/item/ItemInstance.hpp index 35c24b834..5dab7e8b5 100644 --- a/source/world/item/ItemInstance.hpp +++ b/source/world/item/ItemInstance.hpp @@ -22,6 +22,9 @@ class Player; class ItemInstance { +private: + void _init(int itemID, int amount, int auxValue); + public: ItemInstance(); ItemInstance(Item*); @@ -32,10 +35,9 @@ class ItemInstance ItemInstance(Tile*, int amount, int auxValue); ItemInstance(int itemID, int amount, int auxValue); - void init(int itemID, int amount, int auxValue); - - int getAuxValue(); - int getDamageValue(); + int getAuxValue() const { return m_auxValue; } + void setAuxValue(int auxValue) { m_auxValue = auxValue; } // Technically doesn't exist in b1.2_02 + int getDamageValue() const { return m_auxValue; } bool canDestroySpecial(Tile*); std::string getDescriptionId(); @@ -69,9 +71,10 @@ class ItemInstance bool isNull() const; public: - int m_auxValue; - int m_amount; - int m_field_8; + int m_count; + int m_popTime; int m_itemID; +private: + int m_auxValue; }; diff --git a/source/world/item/RocketItem.cpp b/source/world/item/RocketItem.cpp index 2192e5b56..488bef601 100644 --- a/source/world/item/RocketItem.cpp +++ b/source/world/item/RocketItem.cpp @@ -35,6 +35,6 @@ bool RocketItem::useOn(ItemInstance* inst, Player* player, Level* level, const T level->addEntity(new Rocket(level, tp + 0.5f)); - inst->m_amount--; + inst->m_count--; return true; } diff --git a/source/world/item/TileItem.cpp b/source/world/item/TileItem.cpp index 189645790..5d16c7981 100644 --- a/source/world/item/TileItem.cpp +++ b/source/world/item/TileItem.cpp @@ -45,7 +45,7 @@ bool TileItem::useOn(ItemInstance* instance, Player* player, Level* level, const case Facing::EAST: tp.x++; break; } - if (!instance->m_amount) + if (!instance->m_count) return false; if (!level->mayPlace(m_tile, tp, false)) @@ -66,6 +66,6 @@ bool TileItem::useOn(ItemInstance* instance, Player* player, Level* level, const pTile->m_pSound->pitch * 0.8f ); - instance->m_amount--; + instance->m_count--; return true; } diff --git a/source/world/item/TilePlanterItem.cpp b/source/world/item/TilePlanterItem.cpp index 5d96d13ba..71e4bfe37 100644 --- a/source/world/item/TilePlanterItem.cpp +++ b/source/world/item/TilePlanterItem.cpp @@ -33,7 +33,7 @@ bool TilePlanterItem::useOn(ItemInstance* instance, Player* player, Level* level case Facing::EAST: tp.x++; break; } - if (!instance->m_amount) + if (!instance->m_count) return false; // why? @@ -46,6 +46,6 @@ bool TilePlanterItem::useOn(ItemInstance* instance, Player* player, Level* level Tile::tiles[m_tile]->setPlacedOnFace(level, tp, face); Tile::tiles[m_tile]->setPlacedBy(level, tp, player); - instance->m_amount--; + instance->m_count--; return true; } diff --git a/source/world/level/Level.cpp b/source/world/level/Level.cpp index 0d40725ab..2e21dc644 100644 --- a/source/world/level/Level.cpp +++ b/source/world/level/Level.cpp @@ -22,6 +22,7 @@ Level::Level(LevelStorage* pStor, const std::string& str, int32_t seed, int stor m_skyDarken = 0; field_30 = 0; m_pDimension = nullptr; + m_difficulty = 2; // Java has no actual default, it just always pulls from Options. Putting 2 here just so there's no chance of mobs getting despawned accidentally. m_bCalculatingInitialSpawn = false; m_pChunkSource = nullptr; m_pLevelStorage = pStor; @@ -1265,13 +1266,8 @@ bool Level::isUnobstructed(AABB* aabb) const for (std::vector::iterator it = entities.begin(); it != entities.end(); it++) { Entity* pEnt = *it; - if (pEnt->m_bRemoved) - continue; - - if (!pEnt->field_34) - continue; - - return false; + if (!pEnt->m_bRemoved && pEnt->m_bBlocksBuilding) + return false; } return true; diff --git a/source/world/level/Level.hpp b/source/world/level/Level.hpp index 10ecefb48..53c0babb1 100644 --- a/source/world/level/Level.hpp +++ b/source/world/level/Level.hpp @@ -191,6 +191,7 @@ class Level : public LevelSource int m_skyDarken; uint8_t field_30; Dimension* m_pDimension; + int m_difficulty; // @TODO: Difficulty enum Random m_random; bool m_bCalculatingInitialSpawn; std::vector m_levelListeners; diff --git a/thirdparty/GL/GL.hpp b/thirdparty/GL/GL.hpp index 4aa5e6878..bfe1cf645 100644 --- a/thirdparty/GL/GL.hpp +++ b/thirdparty/GL/GL.hpp @@ -22,7 +22,7 @@ #ifdef USE_GLES - #if MC_TARGET_OS_IOS + #if MC_PLATFORM_IOS #import #import diff --git a/thirdparty/raknet/RakNetSocket2_Windows_Linux.cpp b/thirdparty/raknet/RakNetSocket2_Windows_Linux.cpp index d4a6789ab..9c683f1cc 100644 --- a/thirdparty/raknet/RakNetSocket2_Windows_Linux.cpp +++ b/thirdparty/raknet/RakNetSocket2_Windows_Linux.cpp @@ -18,7 +18,7 @@ #if !defined(WINDOWS_STORE_RT) && !defined(__native_client__) -#if MC_TARGET_OS_IOS +#if MC_PLATFORM_IOS // Lifed from SLikeNet because *just* iOS 6 was bitching and moaning 25% of the time // iOS 6 SDK makes phones hate this for some reason @@ -107,7 +107,7 @@ void GetMyIP_Linux(SystemAddress addresses[MAXIMUM_NUMBER_OF_INTERNAL_IDS], cons } } -#else // !MC_TARGET_OS_IOS +#else // !MC_PLATFORM_IOS #if RAKNET_SUPPORT_IPV6==1 @@ -196,19 +196,19 @@ void GetMyIP_Windows_Linux_IPV4( SystemAddress addresses[MAXIMUM_NUMBER_OF_INTER #endif // RAKNET_SUPPORT_IPV6==1 -#endif // MC_TARGET_OS_IOS +#endif // MC_PLATFORM_IOS void GetMyIP_Windows_Linux( SystemAddress addresses[MAXIMUM_NUMBER_OF_INTERNAL_IDS] ) { #if RAKNET_SUPPORT_IPV6==1 - #if MC_TARGET_OS_IOS + #if MC_PLATFORM_IOS GetMyIP_Linux(addresses, true); #else GetMyIP_Windows_Linux_IPV4And6(addresses); #endif #else - #if MC_TARGET_OS_IOS + #if MC_PLATFORM_IOS GetMyIP_Linux(addresses, false); #else GetMyIP_Windows_Linux_IPV4(addresses); @@ -221,4 +221,4 @@ void GetMyIP_Windows_Linux( SystemAddress addresses[MAXIMUM_NUMBER_OF_INTERNAL_I #endif // file header -#endif // #ifdef RAKNET_SOCKET_2_INLINE_FUNCTIONS \ No newline at end of file +#endif // #ifdef RAKNET_SOCKET_2_INLINE_FUNCTIONS