diff --git a/src/Entity.c b/src/Entity.c index dee0ab7d9..51701ce8a 100644 --- a/src/Entity.c +++ b/src/Entity.c @@ -939,13 +939,13 @@ static void LocalPlayer_DoRespawn(void) { /* Spawn player at highest solid position to match vanilla Minecraft classic */ /* Only when player can noclip, since this can let you 'clip' to above solid blocks */ - if (p->Hacks.CanNoclip && World_Contains(pos.X, pos.Y, pos.Z)) { + if (p->Hacks.CanNoclip) { AABB_Make(&bb, &spawn, &p->Base.Size); for (y = pos.Y; y <= World.Height; y++) { spawnY = Respawn_HighestSolidY(&bb); if (spawnY == RESPAWN_NOT_FOUND) { - block = World_GetPhysicsBlock(pos.X, y, pos.Z); + block = World_SafeGetBlock(pos.X, y, pos.Z); height = Blocks.Collide[block] == COLLIDE_SOLID ? Blocks.MaxBB[block].Y : 0.0f; spawn.Y = y + height + ENTITY_ADJUSTMENT; break; diff --git a/src/EntityComponents.c b/src/EntityComponents.c index e52449aa1..497a1576b 100644 --- a/src/EntityComponents.c +++ b/src/EntityComponents.c @@ -1256,7 +1256,7 @@ static cc_bool Sounds_CheckSolid(BlockID b) { static void SoundComp_GetSound(struct LocalPlayer* p) { struct AABB bounds; Vec3 pos; - IVec3 feetPos; + IVec3 coords; BlockID blockUnder; float maxY; cc_uint8 typeUnder, collideUnder; @@ -1269,11 +1269,11 @@ static void SoundComp_GetSound(struct LocalPlayer* p) { Entity_TouchesAny(&bounds, Sounds_CheckNonSolid); if (sounds_type != SOUND_NONE) return; - /* then check block standing on */ + /* then check block standing on (feet) */ pos = p->Interp.Next.Pos; pos.Y -= 0.01f; - IVec3_Floor(&feetPos, &pos); - blockUnder = World_SafeGetBlock_3I(feetPos); - maxY = feetPos.Y + Blocks.MaxBB[blockUnder].Y; + IVec3_Floor(&coords, &pos); + blockUnder = World_SafeGetBlock(coords.X, coords.Y, coords.Z); + maxY = coords.Y + Blocks.MaxBB[blockUnder].Y; typeUnder = Blocks.StepSounds[blockUnder]; collideUnder = Blocks.Collide[blockUnder]; diff --git a/src/EnvRenderer.c b/src/EnvRenderer.c index 58b298495..71e4ed3af 100644 --- a/src/EnvRenderer.c +++ b/src/EnvRenderer.c @@ -50,7 +50,7 @@ static void EnvRenderer_CalcFog(float* density, PackedCol* col) { IVec3_Floor(&coords, &Camera.CurrentPos); /* coords = floor(camera_pos); */ IVec3_ToVec3(&pos, &coords); /* pos = coords; */ - block = World_SafeGetBlock_3I(coords); + block = World_SafeGetBlock(coords.X, coords.Y, coords.Z); Vec3_Add(&blockBB.Min, &pos, &Blocks.MinBB[block]); Vec3_Add(&blockBB.Max, &pos, &Blocks.MaxBB[block]); diff --git a/src/Gui.c b/src/Gui.c index e017b7bc1..e2cb2e8ed 100644 --- a/src/Gui.c +++ b/src/Gui.c @@ -17,8 +17,8 @@ int Gui_Chatlines; cc_bool Gui_ClickableChat, Gui_TabAutocomplete, Gui_ShowFPS; GfxResourceID Gui_GuiTex, Gui_GuiClassicTex, Gui_IconsTex; -struct Screen* Gui_HUD; -struct Screen* Gui_Chat; +struct HUDScreen* Gui_HUD; +struct ChatScreen* Gui_Chat; struct Screen* Gui_Screens[GUI_MAX_SCREENS]; int Gui_ScreensCount; static cc_uint8 priorities[GUI_MAX_SCREENS]; @@ -173,7 +173,7 @@ void Gui_RefreshAll(void) { Gui_ContextRecreated(NULL); } -void Gui_RefreshHud(void) { Gui_Refresh(Gui_Chat); } +void Gui_RefreshChat(void) { Gui_Refresh(Gui_Chat); } void Gui_Refresh(struct Screen* s) { s->VTABLE->ContextLost(s); s->VTABLE->ContextRecreated(s); diff --git a/src/Gui.h b/src/Gui.h index b6f7ea7f5..6083f6f6d 100644 --- a/src/Gui.h +++ b/src/Gui.h @@ -106,8 +106,11 @@ enum GuiPriority { GUI_PRIORITY_LOADING = 5, }; -extern struct Screen* Gui_HUD; -extern struct Screen* Gui_Chat; +struct HUDScreen; +struct ChatScreen; +extern struct HUDScreen* Gui_HUD; +extern struct ChatScreen* Gui_Chat; + #define GUI_MAX_SCREENS 10 extern struct Screen* Gui_Screens[GUI_MAX_SCREENS]; extern int Gui_ScreensCount; @@ -140,7 +143,7 @@ struct Screen* Gui_GetBlocksWorld(void); struct Screen* Gui_GetClosable(void); void Gui_RefreshAll(void); -void Gui_RefreshHud(void); +void Gui_RefreshChat(void); void Gui_Refresh(struct Screen* s); void Gui_RenderGui(double delta); diff --git a/src/MapRenderer.c b/src/MapRenderer.c index 6666e18c4..df238acd5 100644 --- a/src/MapRenderer.c +++ b/src/MapRenderer.c @@ -88,7 +88,7 @@ static void MapRenderer_CheckWeather(double delta) { cc_bool outside; IVec3_Floor(&pos, &Camera.CurrentPos); - block = World_SafeGetBlock_3I(pos); + block = World_SafeGetBlock(pos.X, pos.Y, pos.Z); outside = pos.Y < 0 || !World_ContainsXZ(pos.X, pos.Z); inTranslucent = Blocks.Draw[block] == DRAW_TRANSLUCENT || (pos.Y < Env.EdgeHeight && outside); diff --git a/src/Menus.c b/src/Menus.c index 68db8420f..071bfd594 100644 --- a/src/Menus.c +++ b/src/Menus.c @@ -2483,7 +2483,7 @@ static void GuiOptionsScreen_SetShowFPS(const String* v) { Gui_ShowFPS = Menu_Se static void GuiOptionsScreen_SetScale(const String* v, float* target, const char* optKey) { *target = Menu_Float(v); Options_Set(optKey, v); - Gui_RefreshHud(); + Gui_RefreshChat(); } static void GuiOptionsScreen_GetHotbar(String* v) { String_AppendFloat(v, Game_RawHotbarScale, 1); } diff --git a/src/World.c b/src/World.c index 36a3d8e4e..3944b79c1 100644 --- a/src/World.c +++ b/src/World.c @@ -109,8 +109,8 @@ BlockID World_GetPhysicsBlock(int x, int y, int z) { return World_GetBlock(x, y, z); } -BlockID World_SafeGetBlock_3I(IVec3 p) { - return World_Contains(p.X, p.Y, p.Z) ? World_GetBlock(p.X, p.Y, p.Z) : BLOCK_AIR; +BlockID World_SafeGetBlock(int x, int y, int z) { + return World_Contains(x, y, z) ? World_GetBlock(x, y, z) : BLOCK_AIR; } @@ -250,7 +250,7 @@ float Respawn_HighestSolidY(struct AABB* bb) { for (z = minZ; z <= maxZ; z++) { v.Z = (float)z; for (x = minX; x <= maxX; x++) { v.X = (float)x; - block = World_GetPhysicsBlock(x, y, z); + block = World_SafeGetBlock(x, y, z); Vec3_Add(&blockBB.Min, &v, &Blocks.MinBB[block]); Vec3_Add(&blockBB.Max, &v, &Blocks.MaxBB[block]); diff --git a/src/World.h b/src/World.h index de2d8ebce..6907b62b5 100644 --- a/src/World.h +++ b/src/World.h @@ -74,7 +74,7 @@ BlockID World_GetPhysicsBlock(int x, int y, int z); void World_SetBlock(int x, int y, int z, BlockID block); /* If coordinates are outside the map, returns BLOCK_AIR. */ /* Otherwise returns the block at the given coordinates. */ -BlockID World_SafeGetBlock_3I(IVec3 p); +BlockID World_SafeGetBlock(int x, int y, int z); /* Whether the given coordinates lie inside the map. */ static CC_INLINE cc_bool World_Contains(int x, int y, int z) {