diff --git a/Minecraft.Client/Common/UI/UIScene.cpp b/Minecraft.Client/Common/UI/UIScene.cpp index 3f204414f..d01585cb8 100644 --- a/Minecraft.Client/Common/UI/UIScene.cpp +++ b/Minecraft.Client/Common/UI/UIScene.cpp @@ -1331,11 +1331,17 @@ bool UIScene::hasRegisteredSubstitutionTexture(const wstring &textureName) void UIScene::_handleFocusChange(F64 controlId, F64 childId) { - m_iFocusControl = (int)controlId; - m_iFocusChild = (int)childId; + int newControl = (int)controlId; + int newChild = (int)childId; - handleFocusChange(controlId, childId); - ui.PlayUISFX(eSFX_Focus); + if (newControl != m_iFocusControl || newChild != m_iFocusChild) + { + m_iFocusControl = newControl; + m_iFocusChild = newChild; + + handleFocusChange(controlId, childId); + ui.PlayUISFX(eSFX_Focus); + } } void UIScene::_handleInitFocus(F64 controlId, F64 childId) diff --git a/Minecraft.Client/EntityRenderDispatcher.cpp b/Minecraft.Client/EntityRenderDispatcher.cpp index 5bb98eadb..57fdcc477 100644 --- a/Minecraft.Client/EntityRenderDispatcher.cpp +++ b/Minecraft.Client/EntityRenderDispatcher.cpp @@ -234,6 +234,7 @@ void EntityRenderDispatcher::prepare(Level *level, Textures *textures, Font *fon if (pl->ThirdPersonView() == 2) { playerRotY += 180; + playerRotX = -playerRotX; } xPlayer = player->xOld + (player->x - player->xOld) * a; diff --git a/Minecraft.Client/Gui.cpp b/Minecraft.Client/Gui.cpp index f9810a365..8a3e84db0 100644 --- a/Minecraft.Client/Gui.cpp +++ b/Minecraft.Client/Gui.cpp @@ -895,14 +895,14 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) int zBlockPos = Mth::floor(minecraft->player->z); // Chunk player is in - int xChunkPos = minecraft->player->xChunk; - int yChunkPos = minecraft->player->yChunk; - int zChunkPos = minecraft->player->zChunk; + int xChunkPos = xBlockPos >> 4; + int yChunkPos = yBlockPos >> 4; + int zChunkPos = zBlockPos >> 4; // Players offset within the chunk - int xChunkOffset = xBlockPos - xChunkPos * 16; - int yChunkOffset = yBlockPos - yChunkPos * 16; - int zChunkOffset = zBlockPos - zChunkPos * 16; + int xChunkOffset = xBlockPos & 15; + int yChunkOffset = yBlockPos & 15; + int zChunkOffset = zBlockPos & 15; // Format the position like java with limited decumal places WCHAR posString[44]; // Allows upto 7 digit positions (+-9_999_999) @@ -951,18 +951,20 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) if (minecraft->level != NULL && minecraft->level->hasChunkAt(xBlockPos, fmod(yBlockPos, 256), zBlockPos)) { LevelChunk *chunkAt = minecraft->level->getChunkAt(xBlockPos, zBlockPos); + if (chunkAt != NULL) + { + int skyLight = chunkAt->getBrightness(LightLayer::Sky, xChunkOffset, yChunkOffset, zChunkOffset); + int blockLight = chunkAt->getBrightness(LightLayer::Block, xChunkOffset, yChunkOffset, zChunkOffset); + int maxLight = fmax(skyLight, blockLight); + lines.push_back(L"Light: " + std::to_wstring(maxLight) + L" (" + std::to_wstring(skyLight) + L" sky, " + std::to_wstring(blockLight) + L" block)"); - int skyLight = chunkAt->getBrightness(LightLayer::Sky, xChunkOffset, yChunkOffset, zChunkOffset); - int blockLight = chunkAt->getBrightness(LightLayer::Block, xChunkOffset, yChunkOffset, zChunkOffset); - int maxLight = fmax(skyLight, blockLight); - lines.push_back(L"Light: " + std::to_wstring(maxLight) + L" (" + std::to_wstring(skyLight) + L" sky, " + std::to_wstring(blockLight) + L" block)"); + lines.push_back(L"CH S: " + std::to_wstring(chunkAt->getHeightmap(xChunkOffset, zChunkOffset))); - lines.push_back(L"CH S: " + std::to_wstring(chunkAt->getHeightmap(xChunkOffset, zChunkOffset))); + Biome *biome = chunkAt->getBiome(xChunkOffset, zChunkOffset, minecraft->level->getBiomeSource()); + lines.push_back(L"Biome: " + biome->m_name + L" (" + std::to_wstring(biome->id) + L")"); - Biome *biome = chunkAt->getBiome(xChunkOffset, zChunkOffset, minecraft->level->getBiomeSource()); - lines.push_back(L"Biome: " + biome->m_name + L" (" + std::to_wstring(biome->id) + L")"); - - lines.push_back(L"Difficulty: " + std::to_wstring(minecraft->level->difficulty) + L" (Day " + std::to_wstring(minecraft->level->getGameTime() / Level::TICKS_PER_DAY) + L")"); + lines.push_back(L"Difficulty: " + std::to_wstring(minecraft->level->difficulty) + L" (Day " + std::to_wstring(minecraft->level->getGameTime() / Level::TICKS_PER_DAY) + L")"); + } } diff --git a/Minecraft.Client/ItemInHandRenderer.cpp b/Minecraft.Client/ItemInHandRenderer.cpp index 782537051..f9e635893 100644 --- a/Minecraft.Client/ItemInHandRenderer.cpp +++ b/Minecraft.Client/ItemInHandRenderer.cpp @@ -930,6 +930,14 @@ void ItemInHandRenderer::tick() } +void ItemInHandRenderer::reset() +{ + selectedItem = nullptr; + lastSlot = -1; + height = 0.0f; + oHeight = 0.0f; +} + void ItemInHandRenderer::itemPlaced() { height = 0; diff --git a/Minecraft.Client/ItemInHandRenderer.h b/Minecraft.Client/ItemInHandRenderer.h index b5d840a26..0c0ac307b 100644 --- a/Minecraft.Client/ItemInHandRenderer.h +++ b/Minecraft.Client/ItemInHandRenderer.h @@ -41,6 +41,7 @@ private: int lastSlot; public: void tick(); + void reset(); void itemPlaced(); void itemUsed(); }; diff --git a/Minecraft.Client/Minecraft.cpp b/Minecraft.Client/Minecraft.cpp index 623a1459b..2be178c54 100644 --- a/Minecraft.Client/Minecraft.cpp +++ b/Minecraft.Client/Minecraft.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include "Minecraft.h" +#include "Common/UI/UIScene.h" #include "GameMode.h" #include "Timer.h" #include "ProgressRenderer.h" @@ -9,6 +10,7 @@ #include "User.h" #include "Textures.h" #include "GameRenderer.h" +#include "ItemInHandRenderer.h" #include "HumanoidModel.h" #include "Options.h" #include "TexturePackRepository.h" @@ -216,6 +218,7 @@ Minecraft::Minecraft(Component *mouseComponent, Canvas *parent, MinecraftApplet m_pendingLocalConnections[i] = NULL; m_connectionFailed[i] = false; localgameModes[i]=NULL; + localitemInHandRenderers[i] = NULL; } animateTickLevel = NULL; // 4J added @@ -1484,10 +1487,23 @@ void Minecraft::run_middle() { localplayers[i]->ullButtonsPressed|=1LL<isDirectEditBlocking(); if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_INVENTORY)) { - if(ui.IsSceneInStack(i, eUIScene_InventoryMenu)) + if(isClosableByEitherKey && !isEditing) { ui.CloseUIScenes(i); } @@ -1502,7 +1518,7 @@ void Minecraft::run_middle() if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_CRAFTING) || g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_CRAFTING_ALT)) { - if(ui.IsSceneInStack(i, eUIScene_Crafting2x2Menu) || ui.IsSceneInStack(i, eUIScene_Crafting3x3Menu) || ui.IsSceneInStack(i, eUIScene_CreativeMenu)) + if((ui.IsSceneInStack(i, eUIScene_Crafting2x2Menu) || ui.IsSceneInStack(i, eUIScene_Crafting3x3Menu) || ui.IsSceneInStack(i, eUIScene_CreativeMenu) || isClosableByEitherKey) && !isEditing) { ui.CloseUIScenes(i); } @@ -4311,6 +4327,17 @@ void Minecraft::setLevel(MultiPlayerLevel *level, int message /*=-1*/, shared_pt // 4J - stop update thread from processing this level, which blocks until it is safe to move on - will be re-enabled if we set the level to be non-NULL gameRenderer->DisableUpdateThread(); + if (level == NULL || player == NULL) + { + for (int i = 0; i < XUSER_MAX_COUNT; ++i) + { + if (localitemInHandRenderers[i] != NULL) + { + localitemInHandRenderers[i]->reset(); + } + } + } + for(unsigned int i = 0; i < levels.length; ++i) { // 4J We only need to save out in multiplayer is we are setting the level to NULL diff --git a/Minecraft.World/Arrow.cpp b/Minecraft.World/Arrow.cpp index ab942aac6..f7253ca6f 100644 --- a/Minecraft.World/Arrow.cpp +++ b/Minecraft.World/Arrow.cpp @@ -303,16 +303,20 @@ void Arrow::tick() damageSource = DamageSource::arrow(dynamic_pointer_cast(shared_from_this()), owner); } + if(!res->entity->isInvulnerable()) + { + if (isOnFire() && res->entity->GetType() != eTYPE_ENDERMAN) + { + res->entity->setOnFire(5); + } + } + if(res->entity->hurt(damageSource, dmg)) { // Firx for #67839 - Customer Encountered: Bows enchanted with "Flame" still set things on fire if pvp/attack animals is turned off // 4J Stu - We should not set the entity on fire unless we can cause some damage (this doesn't necessarily mean that the arrow hit lowered their health) // set targets on fire first because we want cooked // pork/chicken/steak - if (isOnFire() && res->entity->GetType() != eTYPE_ENDERMAN) - { - res->entity->setOnFire(5); - } if (res->entity->instanceof(eTYPE_LIVINGENTITY)) {