converting block states to a bitfield

This commit is contained in:
MihailRis
2024-05-31 11:13:36 +03:00
parent 5dd06b233e
commit 6d933ac263
17 changed files with 197 additions and 164 deletions
+6 -5
View File
@@ -364,7 +364,7 @@ void PlayerController::updateInteraction(){
if (vox != nullptr) {
player->selectedVoxel = *vox;
selectedBlockId = vox->id;
selectedBlockRotation = vox->rotation();
selectedBlockRotation = vox->state.rotation;
player->selectedBlockPosition = iend;
selectedPointPosition = end;
selectedBlockNormal = norm;
@@ -373,7 +373,8 @@ void PlayerController::updateInteraction(){
int z = iend.z;
Block* def = indices->getBlockDef(item->rt.placingBlock);
uint8_t states = determine_rotation(def, norm, camera->dir);
blockstate state {};
state.rotation = determine_rotation(def, norm, camera->dir);
if (lclick && !input.shift && item->rt.funcsset.on_block_break_by) {
if (scripting::on_item_break_block(player.get(), item, x, y, z))
@@ -410,13 +411,13 @@ void PlayerController::updateInteraction(){
z = (iend.z)+(norm.z);
} else {
if (def->rotations.name == "pipe") {
states = BLOCK_DIR_UP;
state.rotation = BLOCK_DIR_UP;
}
}
vox = chunks->get(x, y, z);
blockid_t chosenBlock = def->rt.id;
if (vox && (target = indices->getBlockDef(vox->id))->replaceable) {
if (!level->physics->isBlockInside(x,y,z,def,states, player->hitbox.get())
if (!level->physics->isBlockInside(x,y,z,def,state, player->hitbox.get())
|| !def->obstacle){
if (def->grounded && !chunks->isSolidBlock(x, y-1, z)) {
chosenBlock = 0;
@@ -426,7 +427,7 @@ void PlayerController::updateInteraction(){
glm::ivec3(x, y, z), def,
BlockInteraction::placing
);
chunks->set(x, y, z, chosenBlock, states);
chunks->set(x, y, z, chosenBlock, state);
lighting->onBlockSet(x,y,z, chosenBlock);
if (def->rt.funcsset.onplaced) {
scripting::on_block_placed(player.get(), def, x, y, z);