add temporary test block

This commit is contained in:
MihailRis 2024-06-08 21:42:44 +03:00
parent c2aa4e3c26
commit ee47213dbb
8 changed files with 45 additions and 4 deletions

View File

@ -0,0 +1,15 @@
{
"material": "base:wood",
"texture-faces": [
"door_side",
"door_side",
"door_top",
"door_top",
"door",
"door"
],
"light-passing": true,
"sky-light-passing": true,
"size": [1, 2, 1],
"rotation": "pipe"
}

View File

@ -1,7 +1,4 @@
{ {
"items": [
"bazalt_breaker"
],
"blocks": [ "blocks": [
"dirt", "dirt",
"grass_block", "grass_block",
@ -25,6 +22,10 @@
"pane", "pane",
"pipe", "pipe",
"lightbulb", "lightbulb",
"torch" "torch",
"door"
],
"items": [
"bazalt_breaker"
] ]
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@ -31,6 +31,13 @@ static std::shared_ptr<Label> create_label(wstringsupplier supplier) {
return label; return label;
} }
template <size_t T>
inline std::wstring to_string(std::bitset<T> bs) {
std::wstringstream ss;
ss << bs;
return ss.str();
}
std::shared_ptr<UINode> create_debug_panel( std::shared_ptr<UINode> create_debug_panel(
Engine* engine, Engine* engine,
Level* level, Level* level,
@ -94,6 +101,18 @@ std::shared_ptr<UINode> create_debug_panel(
return std::wstring {L"name: void"}; return std::wstring {L"name: void"};
} }
})); }));
panel->add(create_label([=](){
auto* indices = level->content->getIndices();
if (auto def = indices->getBlockDef(player->selectedVoxel.id)) {
return L"light: " + to_string(std::bitset<16>(level->chunks->getLight(
player->actualSelectedBlockPosition.x,
player->actualSelectedBlockPosition.y,
player->actualSelectedBlockPosition.z
)));
} else {
return std::wstring {L"no light: -"};
}
}));
panel->add(create_label([=](){ panel->add(create_label([=](){
return L"seed: "+std::to_wstring(level->getWorld()->getSeed()); return L"seed: "+std::to_wstring(level->getWorld()->getSeed());
})); }));

View File

@ -368,6 +368,7 @@ void PlayerController::updateInteraction(){
player->selectedVoxel = *vox; player->selectedVoxel = *vox;
selectedBlockId = vox->id; selectedBlockId = vox->id;
selectedBlockRotation = vox->state.rotation; selectedBlockRotation = vox->state.rotation;
player->actualSelectedBlockPosition = iend;
if (selectedState.segment) { if (selectedState.segment) {
iend = chunks->seekOrigin( iend = chunks->seekOrigin(
iend, indices->getBlockDef(selectedBlockId), selectedState iend, indices->getBlockDef(selectedBlockId), selectedState
@ -410,6 +411,7 @@ void PlayerController::updateInteraction(){
} }
} }
if (def && rclick){ if (def && rclick){
iend = player->actualSelectedBlockPosition;
if (!input.shift && target->rt.funcsset.oninteract) { if (!input.shift && target->rt.funcsset.oninteract) {
if (scripting::on_block_interact(player.get(), target, x, y, z)) if (scripting::on_block_interact(player.get(), target, x, y, z))
return; return;
@ -420,6 +422,9 @@ void PlayerController::updateInteraction(){
z = (iend.z)+(norm.z); z = (iend.z)+(norm.z);
} else if (def->rotations.name == "pipe") { } else if (def->rotations.name == "pipe") {
state.rotation = BLOCK_DIR_UP; state.rotation = BLOCK_DIR_UP;
x = iend.x;
y = iend.y;
z = iend.z;
} }
vox = chunks->get(x, y, z); vox = chunks->get(x, y, z);
blockid_t chosenBlock = def->rt.id; blockid_t chosenBlock = def->rt.id;

View File

@ -47,6 +47,7 @@ public:
voxel selectedVoxel {0, {}}; voxel selectedVoxel {0, {}};
glm::vec3 cam {}; glm::vec3 cam {};
glm::ivec3 selectedBlockPosition {}; glm::ivec3 selectedBlockPosition {};
glm::ivec3 actualSelectedBlockPosition {};
Player(glm::vec3 position, float speed, std::shared_ptr<Inventory> inv); Player(glm::vec3 position, float speed, std::shared_ptr<Inventory> inv);
~Player(); ~Player();