Merge branch 'main' into feat/middle-click-grab-block

This commit is contained in:
Alezito2008 2026-03-08 16:22:07 -03:00 committed by GitHub
commit ed7890eec1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 74 additions and 25 deletions

View file

@ -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)

View file

@ -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;

View file

@ -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")");
}
}

View file

@ -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;

View file

@ -41,6 +41,7 @@ private:
int lastSlot;
public:
void tick();
void reset();
void itemPlaced();
void itemUsed();
};

View file

@ -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<<MINECRAFT_ACTION_PICK_ITEM;
}
bool isClosableByEitherKey = ui.IsSceneInStack(i, eUIScene_FurnaceMenu) ||
ui.IsSceneInStack(i, eUIScene_ContainerMenu) ||
ui.IsSceneInStack(i, eUIScene_DispenserMenu) ||
ui.IsSceneInStack(i, eUIScene_EnchantingMenu) ||
ui.IsSceneInStack(i, eUIScene_BrewingStandMenu) ||
ui.IsSceneInStack(i, eUIScene_TradingMenu) ||
ui.IsSceneInStack(i, eUIScene_AnvilMenu) ||
ui.IsSceneInStack(i, eUIScene_HopperMenu) ||
ui.IsSceneInStack(i, eUIScene_BeaconMenu) ||
ui.IsSceneInStack(i, eUIScene_InventoryMenu) ||
ui.IsSceneInStack(i, eUIScene_HorseMenu);
bool isEditing = ui.GetTopScene(i) && ui.GetTopScene(i)->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

View file

@ -303,16 +303,20 @@ void Arrow::tick()
damageSource = DamageSource::arrow(dynamic_pointer_cast<Arrow>(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))
{