From ab5d9f3c8d56c190ae763305317507d00d0d7de3 Mon Sep 17 00:00:00 2001 From: daoge <3523206925@qq.com> Date: Sat, 28 Sep 2024 18:58:32 +0800 Subject: [PATCH] feat(devtools): add block shape data to DevTools * feat(devtools): add more block shapes' data * feat(devtools): add liquid clip shape * refactor: introduce isAABBValid() function * chores: remove unused collisionShapeForCamera * fix: correct the signature of shape-related methods in Block class --------- Co-authored-by: Vincent --- include/bedrock/world/level/block/block.h | 25 ++++++++++++ src/endstone_devtools/vanilla_data.cpp | 46 ++++++++++++++++++++++- 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/include/bedrock/world/level/block/block.h b/include/bedrock/world/level/block/block.h index 75f6b9605..3582f4937 100644 --- a/include/bedrock/world/level/block/block.h +++ b/include/bedrock/world/level/block/block.h @@ -129,6 +129,31 @@ class Block : public BlockComponentStorage { return out_aabb.min.x < out_aabb.max.x && out_aabb.min.y < out_aabb.max.y && out_aabb.min.z < out_aabb.max.z; } + bool getCollisionShapeForCamera(AABB &out_aabb, IConstBlockSource const ®ion, BlockPos const &pos) const + { + return legacy_block_->getCollisionShapeForCamera(out_aabb, *this, region, pos); + } + + const AABB &getOutline(IConstBlockSource const ®ion, BlockPos const &pos, AABB &buffer) const + { + return legacy_block_->getOutline(*this, region, pos, buffer); + } + + const AABB &getVisualShape(AABB &buffer) const + { + return legacy_block_->getVisualShape(*this, buffer); + } + + const AABB &getUIShape(AABB &buffer) const + { + return legacy_block_->getUIShape(*this, buffer); + } + + bool getLiquidClipShape(BlockSource ®ion, BlockPos const &pos, AABB &include_box) const + { + return legacy_block_->getLiquidClipVolume(*this, region, pos, include_box); + } + private: friend class ItemStackBase; diff --git a/src/endstone_devtools/vanilla_data.cpp b/src/endstone_devtools/vanilla_data.cpp index a25e4c787..d7ddde133 100644 --- a/src/endstone_devtools/vanilla_data.cpp +++ b/src/endstone_devtools/vanilla_data.cpp @@ -95,8 +95,16 @@ void dumpBlockData(VanillaData &data, ::Level &level) } block_legacy.forEachBlockPermutation([&](const ::Block &block) { - AABB collision_shape = {0}; + AABB collision_shape; + AABB outline_shape; + AABB visual_shape; + AABB ui_shape; + AABB liquid_clip_shape; block.getCollisionShape(collision_shape, region, {0, 0, 0}, nullptr); + outline_shape = block.getOutline(region, {0, 0, 0}, outline_shape); + visual_shape = block.getVisualShape(visual_shape); + ui_shape = block.getUIShape(ui_shape); + block.getLiquidClipShape(region, {0, 0, 0}, liquid_clip_shape); auto map_color = block.getLegacyBlock().getMapColor(region, {0, 10, 0}, block); data.block_states.push_back({ {"name", name}, @@ -121,6 +129,42 @@ void dumpBlockData(VanillaData &data, ::Level &level) round(collision_shape.max.y), round(collision_shape.max.z), }}, + {"outlineShape", + { + round(outline_shape.min.x), + round(outline_shape.min.y), + round(outline_shape.min.z), + round(outline_shape.max.x), + round(outline_shape.max.y), + round(outline_shape.max.z), + }}, + {"visualShape", + { + round(visual_shape.min.x), + round(visual_shape.min.y), + round(visual_shape.min.z), + round(visual_shape.max.x), + round(visual_shape.max.y), + round(visual_shape.max.z), + }}, + {"uiShape", + { + round(ui_shape.min.x), + round(ui_shape.min.y), + round(ui_shape.min.z), + round(ui_shape.max.x), + round(ui_shape.max.y), + round(ui_shape.max.z), + }}, + {"liquidClipShape", + { + round(liquid_clip_shape.min.x), + round(liquid_clip_shape.min.y), + round(liquid_clip_shape.min.z), + round(liquid_clip_shape.max.x), + round(liquid_clip_shape.max.y), + round(liquid_clip_shape.max.z), + }}, }); data.block_palette.add(block.getSerializationId().copy()); return true;