Merge branch 'main' into headless-mode
This commit is contained in:
commit
3d7a9fd225
@ -74,7 +74,7 @@ function table.deep_copy(t)
|
||||
end
|
||||
end
|
||||
|
||||
return copied
|
||||
return setmetatable(copied, getmetatable(t))
|
||||
end
|
||||
|
||||
function table.count_pairs(t)
|
||||
|
||||
@ -220,11 +220,11 @@ void ContentLoader::loadBlock(
|
||||
}
|
||||
|
||||
// block model
|
||||
std::string modelTypeName;
|
||||
std::string modelTypeName = to_string(def.model);
|
||||
root.at("model").get(modelTypeName);
|
||||
root.at("model-name").get(def.modelName);
|
||||
if (auto model = BlockModel_from(modelTypeName)) {
|
||||
if (*model == BlockModel::custom) {
|
||||
if (*model == BlockModel::custom && def.customModelRaw == nullptr) {
|
||||
if (root.has("model-primitives")) {
|
||||
def.customModelRaw = root["model-primitives"];
|
||||
} else if (def.modelName.empty()) {
|
||||
@ -246,7 +246,7 @@ void ContentLoader::loadBlock(
|
||||
root.at("material").get(def.material);
|
||||
|
||||
// rotation profile
|
||||
std::string profile = "none";
|
||||
std::string profile = def.rotations.name;
|
||||
root.at("rotation").get(profile);
|
||||
|
||||
def.rotatable = profile != "none";
|
||||
@ -285,8 +285,6 @@ void ContentLoader::loadBlock(
|
||||
);
|
||||
aabb.b += aabb.a;
|
||||
def.hitboxes = {aabb};
|
||||
} else {
|
||||
def.hitboxes = {AABB()};
|
||||
}
|
||||
|
||||
// block light emission [r, g, b] where r,g,b in range [0..15]
|
||||
|
||||
@ -47,6 +47,7 @@
|
||||
#include "window/Window.hpp"
|
||||
#include "world/Level.hpp"
|
||||
#include "world/World.hpp"
|
||||
#include "debug/Logger.hpp"
|
||||
|
||||
#include <assert.h>
|
||||
#include <memory>
|
||||
@ -56,6 +57,8 @@
|
||||
|
||||
using namespace gui;
|
||||
|
||||
static debug::Logger logger("hud");
|
||||
|
||||
bool Hud::showGeneratorMinimap = false;
|
||||
|
||||
// implemented in debug_panel.cpp
|
||||
@ -489,7 +492,32 @@ void Hud::openPermanent(UiDocument* doc) {
|
||||
add(HudElement(hud_element_mode::permanent, doc, doc->getRoot(), false));
|
||||
}
|
||||
|
||||
void Hud::dropExchangeSlot() {
|
||||
auto slotView = std::dynamic_pointer_cast<SlotView>(
|
||||
gui->get(SlotView::EXCHANGE_SLOT_NAME)
|
||||
);
|
||||
if (slotView == nullptr) {
|
||||
return;
|
||||
}
|
||||
ItemStack& stack = slotView->getStack();
|
||||
|
||||
auto indices = frontend.getLevel().content->getIndices();
|
||||
if (auto invView = std::dynamic_pointer_cast<InventoryView>(blockUI)) {
|
||||
invView->getInventory()->move(stack, indices);
|
||||
}
|
||||
if (stack.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
player->getInventory()->move(stack, indices);
|
||||
if (!stack.isEmpty()) {
|
||||
logger.warning() << "discard item [" << stack.getItemId() << ":"
|
||||
<< stack.getCount();
|
||||
stack.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void Hud::closeInventory() {
|
||||
dropExchangeSlot();
|
||||
gui->remove(SlotView::EXCHANGE_SLOT_NAME);
|
||||
exchangeSlot = nullptr;
|
||||
exchangeSlotInv = nullptr;
|
||||
|
||||
@ -128,6 +128,9 @@ class Hud : public util::ObjectsKeeper {
|
||||
void updateHotbarControl();
|
||||
void cleanup();
|
||||
|
||||
/// @brief Perform exchange slot removal when it's not empty.
|
||||
void dropExchangeSlot();
|
||||
|
||||
void showExchangeSlot();
|
||||
void updateWorldGenDebugVisualization();
|
||||
public:
|
||||
|
||||
@ -181,7 +181,7 @@ public:
|
||||
bool translucent = false;
|
||||
|
||||
/// @brief Set of block physical hitboxes
|
||||
std::vector<AABB> hitboxes;
|
||||
std::vector<AABB> hitboxes {AABB()};
|
||||
|
||||
/// @brief Set of available block rotations (coord-systems)
|
||||
BlockRotProfile rotations = BlockRotProfile::NONE;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user