Skip to content

Commit e71fd55

Browse files
committed
test: fix custom structure test
1 parent c1281d5 commit e71fd55

15 files changed

+805
-35
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ on:
22
pull_request:
33
push:
44
paths:
5-
- '**.cpp'
6-
- '**.h'
5+
- 'src/more_dimensions/**.cpp'
6+
- 'src/more_dimensions/**.h'
77
workflow_dispatch:
88

99
jobs:

.github/workflows/test_build.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
on:
2+
push:
3+
paths:
4+
- 'src/test/**.cpp'
5+
- 'src/test/**.h'
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
runs-on: windows-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- uses: xmake-io/github-action-setup-xmake@v1
15+
16+
- uses: actions/cache@v4
17+
with:
18+
path: |
19+
~/AppData/Local/.xmake
20+
key: xmake-${{ hashFiles('xmake.lua') }}
21+
restore-keys: |
22+
xmake-
23+
24+
- run: |
25+
xmake repo -u
26+
27+
- run: |
28+
xmake f --tests=y -a x64 -m release -p windows -v -y
29+
30+
- run: |
31+
xmake -v -w -y
32+
33+
- uses: actions/upload-artifact@v4
34+
with:
35+
name: more-dimensions-test-windows-x64-${{ github.sha }}
36+
path: |
37+
bin/

src/test/TestCustomDimension.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "test/generator/flat-gen-village/FlatVillageDimension.h"
2-
// #include "test/generator/generator-custom-structure/dimension/CustomStructureDimension.h"
2+
#include "test/generator/generator-custom-structure/dimension/CustomStructureDimension.h"
33
#include "test/generator/generator-terrain/NxnBorderTerrainDimension.h"
44

55
#include "ll/api/event/EventBus.h"
@@ -42,9 +42,9 @@ static bool reg = [] {
4242
more_dimensions::CustomDimensionManager::getInstance()
4343
.addDimension<nxn_border_terrain::NxnBorderTerrainDimension>("testFlatTerrain", 5);
4444

45-
// // flat type custom structure dimension test
46-
// more_dimensions::CustomDimensionManager::getInstance()
47-
// .addDimension<custom_structure_dimension::CustomStructureDimension>("testCustomStructure");
45+
// flat type custom structure dimension test
46+
more_dimensions::CustomDimensionManager::getInstance()
47+
.addDimension<custom_structure_dimension::CustomStructureDimension>("testCustomStructure");
4848
});
4949
return true;
5050
}();

src/test/generator/generator-custom-structure/CustomStructure.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@
1313
#include "mc/world/level/levelgen/structure/registry/JigsawStructureElementRegistry.h"
1414
#include "mc/world/level/levelgen/structure/registry/JigsawStructureRegistry.h"
1515
#include "mc/world/level/levelgen/structure/registry/StructurePools.h"
16-
#include "mc/world/level/levelgen/structure/structurepools/StructurePoolActorRule.h"
1716
#include "mc/world/level/levelgen/structure/structurepools/StructurePoolBlockPredicateAlwaysTrue.h"
18-
#include "mc/world/level/levelgen/structure/structurepools/StructurePoolBlockPredicateBlockMatchRandom.h"
19-
#include "mc/world/level/levelgen/structure/structurepools/StructurePoolBlockRule.h"
20-
#include "mc/world/level/levelgen/structure/structurepools/StructurePoolBlockTagRule.h"
17+
#include "test/mc/StructurePoolBlockPredicateBlockMatchRandom.h"
18+
#include "test/mc/StructurePoolBlockRule.h"
2119
#include "mc/world/level/levelgen/structure/structurepools/StructurePoolElement.h"
2220
#include "mc/world/level/levelgen/structure/structurepools/StructureTemplatePool.h"
2321
#include "mc/world/level/storage/Experiments.h"
@@ -55,10 +53,6 @@ void CustomJigsawStructureElements::initialize(
5553
auto& jigsawBlockRulesRegistry = jigsawRegistry.mUnk807a76.as<JigsawStructureBlockRulesRegistry>();
5654
auto& jigsawStructureElementRegistry = jigsawRegistry.mUnk8230cc.as<JigsawStructureElementRegistry>();
5755
auto ruleList = jigsawBlockRulesRegistry.lookupByName("custom:custom_structure_block_rule");
58-
std::vector<std::unique_ptr<StructurePoolBlockTagRule>> blockTag{};
59-
std::vector<std::unique_ptr<StructurePoolActorRule>> actorRule{};
60-
// blockTag.push_back(nullptr);
61-
// actorRule.push_back(nullptr);
6256

6357
// 每一个结构nbt文件都得这样注册进来,多个nbt结构文件的可以使用同一个Block Rule
6458
jigsawStructureElementRegistry.registerStructureElement(

src/test/generator/generator-custom-structure/structure/CustomStructurePiece.cpp

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
#include "mc/world/level/block/registry/BlockTypeRegistry.h"
77
#include "mc/world/level/dimension/Dimension.h"
88
#include "mc/world/level/levelgen/structure/BoundingBox.h"
9-
#include "mc/world/level/levelgen/structure/JigsawJunction.h"
10-
#include "mc/world/level/levelgen/structure/JigsawPlacement.h"
9+
#include "test/mc/JigsawJunction.h"
10+
#include "test/mc/JigsawPlacement.h"
1111
#include "mc/world/level/levelgen/structure/registry/JigsawStructureRegistry.h"
1212
#include "mc/world/level/levelgen/structure/structurepools/StructurePoolElement.h"
13-
#include "mc/world/level/levelgen/structure/structurepools/StructureTemplatePool.h"
14-
#include "mc/world/level/levelgen/structure/structurepools/alias/PoolAliasBinding.h"
13+
#include "test/mc/StructureTemplatePool.h"
14+
#include "test/mc/PoolAliasBinding.h"
1515
#include "mc/world/level/levelgen/v1/AdjustmentEffect.h"
1616

1717

@@ -45,15 +45,7 @@ CustomStructurePiece::CustomStructurePiece(
4545
::BoundingBox const& box,
4646
::BlockPos refPos
4747
)
48-
: PoolElementStructurePiece() {
49-
mUnkc93c20.as<StructurePoolElement&>() = element;
50-
mUnkea11e1.as<BlockPos>() = position;
51-
mUnk8a1f71.as<Rotation>() = rotation;
52-
mUnkd032f6.as<JigsawJunction>() = junction;
53-
mUnkcaf6a7.as<BlockPos>() = refPos;
54-
mUnk8c6046.as<BoundingBox>() = box;
55-
mUnk85df9a.as<int>() = genDepth;
56-
};
48+
: PoolElementStructurePiece(element, position, rotation, genDepth, junction, box, refPos) {};
5749

5850
void CustomStructurePiece::addPieces(
5951
BlockPos position,
@@ -77,10 +69,9 @@ void CustomStructurePiece::addPieces(
7769
};
7870
JigsawPlacement place(15, 80, pieces, lambda, random, pools, dimension);
7971

80-
auto index = random.nextInt(0, templates->mUnk305a7f.as<std::vector<StructurePoolElement const*>>().size() - 1);
81-
72+
auto index = random.nextInt(0, templates->mTemplates->size() - 1);
8273
place.addPieces(
83-
*templates->mUnk305a7f.as<std::vector<StructurePoolElement const*>>()[index],
74+
*templates->mTemplates->at(index),
8475
position,
8576
Rotation::Rotate90,
8677
"",
@@ -89,5 +80,3 @@ void CustomStructurePiece::addPieces(
8980
}
9081

9182
} // namespace custom_structure
92-
93-
PoolAliasBinding::PoolAliasLookup::PoolAliasLookup() = default;

src/test/generator/generator-custom-structure/structure/CustomStructurePiece.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include "mc/util/Rotation.h"
44
#include "mc/world/level/biome/components/vanilla/VanillaBiomeTypes.h"
5-
#include "mc/world/level/levelgen/structure/PoolElementStructurePiece.h"
5+
#include "test/mc/PoolElementStructurePiece.h"
66

77

88

src/test/mc/JigsawJunction.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#pragma once
2+
3+
#include "mc/_HeaderOutputPredefine.h"
4+
5+
#include "mc/world/level/BlockPos.h"
6+
#include "mc/world/level/levelgen/structure/Projection.h"
7+
8+
9+
struct JigsawJunction {
10+
public:
11+
// member variables
12+
// NOLINTBEGIN
13+
::ll::TypedStorage<4, 12, BlockPos> mSourceBlockPos;
14+
::ll::TypedStorage<4, 4, int> mDeltaSourceY;
15+
::ll::TypedStorage<4, 4, int> mDeltaTargetY;
16+
::ll::TypedStorage<1, 1, Projection> mSourceProjection;
17+
::ll::TypedStorage<1, 1, Projection> mTargetProjection;
18+
// NOLINTEND
19+
20+
public:
21+
// prevent constructor by default
22+
};

src/test/mc/JigsawPlacement.h

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#pragma once
2+
3+
#include "mc/_HeaderOutputPredefine.h"
4+
5+
// auto generated inclusion list
6+
#include "mc/util/Rotation.h"
7+
#include "test/mc/PoolAliasBinding.h"
8+
9+
// auto generated forward declare list
10+
// clang-format off
11+
class BlockPos;
12+
class BoundingBox;
13+
class Dimension;
14+
class JigsawBlockInfo;
15+
class JigsawStructureRegistry;
16+
class PoolElementStructurePiece;
17+
class Random;
18+
class StructurePiece;
19+
class StructurePoolElement;
20+
class StructureTemplatePool;
21+
struct JigsawJunction;
22+
// clang-format on
23+
24+
class JigsawPlacement {
25+
public:
26+
// member variables
27+
// NOLINTBEGIN
28+
::ll::UntypedStorage<4, 4> mUnkcc2c4f;
29+
::ll::UntypedStorage<4, 4> mUnk230fb5;
30+
::ll::UntypedStorage<8, 64> mUnk40c5ee;
31+
::ll::UntypedStorage<8, 8> mUnke0bb10;
32+
::ll::UntypedStorage<8, 8> mUnk3c1434;
33+
::ll::UntypedStorage<8, 8> mUnkfa3181;
34+
::ll::UntypedStorage<8, 8> mUnk2bf1da;
35+
::ll::UntypedStorage<8, 64> mUnk5862e9;
36+
::ll::UntypedStorage<8, 40> mUnkdd8234;
37+
::ll::UntypedStorage<8, 24> mUnkb1b40e;
38+
::ll::UntypedStorage<8, 24> mUnka60e45;
39+
::ll::UntypedStorage<8, 40> mUnk747941;
40+
// NOLINTEND
41+
42+
public:
43+
// prevent constructor by default
44+
JigsawPlacement& operator=(JigsawPlacement const&);
45+
JigsawPlacement(JigsawPlacement const&);
46+
JigsawPlacement();
47+
48+
public:
49+
// member functions
50+
// NOLINTBEGIN
51+
MCAPI JigsawPlacement(
52+
uint64 maxDepth,
53+
uint64 globalContextSize,
54+
::std::vector<::std::unique_ptr<::StructurePiece>>& pieceList,
55+
::std::function<::std::unique_ptr<
56+
::PoolElementStructurePiece>(::StructurePoolElement const&, ::BlockPos const&, ::Rotation const&, int, ::JigsawJunction&, ::BoundingBox const&, ::BlockPos const&)>
57+
factory,
58+
::Random& random,
59+
::JigsawStructureRegistry const& pools,
60+
::Dimension& dimension
61+
);
62+
63+
MCAPI void _addPiece(
64+
::PoolElementStructurePiece const& sourcePiece,
65+
::BlockPos const& position,
66+
::Rotation const& rotation,
67+
::BlockPos const& refPos,
68+
uint64 contextDepth,
69+
::PoolAliasBinding::PoolAliasLookup const& poolAliasLookup
70+
);
71+
72+
MCAPI ::BlockPos _findLocalAnchorOffset(
73+
::StructurePoolElement const& initialElement,
74+
::BlockPos const& pieceCornerPosition,
75+
::Rotation const& rotation,
76+
::std::string_view startAnchorName
77+
) const;
78+
79+
MCAPI bool _tryPlacingPiece(
80+
::PoolElementStructurePiece const& sourcePiece,
81+
::BoundingBox const& sourceBB,
82+
::JigsawBlockInfo const& sourceJigsaw,
83+
::BlockPos const& attachPos,
84+
::StructureTemplatePool const* targetPool,
85+
::BlockPos const& refPos,
86+
uint64 contextDepth,
87+
::PoolAliasBinding::PoolAliasLookup const& poolAliasLookup
88+
);
89+
90+
MCAPI void addPieces(
91+
::StructurePoolElement const& initialElement,
92+
::BlockPos const& startPosition,
93+
::Rotation const& rotation,
94+
::std::string_view startAnchorName,
95+
::PoolAliasBinding::PoolAliasLookup const& poolAliasLookup
96+
);
97+
98+
MCAPI ~JigsawPlacement();
99+
// NOLINTEND
100+
101+
public:
102+
// constructor thunks
103+
// NOLINTBEGIN
104+
MCAPI void* $ctor(
105+
uint64 maxDepth,
106+
uint64 globalContextSize,
107+
::std::vector<::std::unique_ptr<::StructurePiece>>& pieceList,
108+
::std::function<::std::unique_ptr<
109+
::PoolElementStructurePiece>(::StructurePoolElement const&, ::BlockPos const&, ::Rotation const&, int, ::JigsawJunction&, ::BoundingBox const&, ::BlockPos const&)>
110+
factory,
111+
::Random& random,
112+
::JigsawStructureRegistry const& pools,
113+
::Dimension& dimension
114+
);
115+
// NOLINTEND
116+
117+
public:
118+
// destructor thunk
119+
// NOLINTBEGIN
120+
MCAPI void $dtor();
121+
// NOLINTEND
122+
};

src/test/mc/PoolAliasBinding.h

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#pragma once
2+
3+
#include "mc/_HeaderOutputPredefine.h"
4+
5+
// auto generated inclusion list
6+
#include "mc/deps/core/math/SimpleWeightedEntry.h"
7+
8+
// auto generated forward declare list
9+
// clang-format off
10+
class BlockPos;
11+
class IRandom;
12+
// clang-format on
13+
14+
class PoolAliasBinding {
15+
public:
16+
// PoolAliasBinding inner types declare
17+
// clang-format off
18+
class PoolAliasLookup;
19+
// clang-format on
20+
21+
// PoolAliasBinding inner types define
22+
class PoolAliasLookup {
23+
public:
24+
// member variables
25+
// NOLINTBEGIN
26+
::ll::TypedStorage<8, 24, std::vector<std::pair<std::string,std::string >>> mLookupTable;
27+
// NOLINTEND
28+
29+
public:
30+
// prevent constructor by default
31+
32+
public:
33+
// member functions
34+
// NOLINTBEGIN
35+
MCAPI ~PoolAliasLookup();
36+
// NOLINTEND
37+
38+
public:
39+
// destructor thunk
40+
// NOLINTBEGIN
41+
MCFOLD void $dtor();
42+
// NOLINTEND
43+
};
44+
45+
public:
46+
// virtual functions
47+
// NOLINTBEGIN
48+
// vIndex: 0
49+
virtual void appendResolvedAliases(::IRandom&, ::PoolAliasBinding::PoolAliasLookup&) const = 0;
50+
51+
// vIndex: 1
52+
virtual void forAllTargets(::std::function<void(::std::string const&, ::std::string const&)> const&) const = 0;
53+
54+
// vIndex: 2
55+
virtual ~PoolAliasBinding() = default;
56+
// NOLINTEND
57+
58+
public:
59+
// static functions
60+
// NOLINTBEGIN
61+
MCAPI static ::std::shared_ptr<::PoolAliasBinding> direct(::std::string&& id, ::std::string&& target);
62+
63+
MCAPI static ::std::shared_ptr<::PoolAliasBinding>
64+
random(::std::string&& id, ::std::vector<::Core::SimpleWeightedEntry<::std::string>>&& targets);
65+
66+
MCAPI static ::PoolAliasBinding::PoolAliasLookup resolvePoolAliases(
67+
::std::vector<::std::shared_ptr<::PoolAliasBinding>> const& aliases,
68+
::BlockPos const& structureStartPosition,
69+
int64 levelSeed
70+
);
71+
// NOLINTEND
72+
73+
public:
74+
// destructor thunk
75+
// NOLINTBEGIN
76+
77+
// NOLINTEND
78+
79+
public:
80+
// virtual function thunks
81+
// NOLINTBEGIN
82+
83+
// NOLINTEND
84+
85+
public:
86+
// vftables
87+
// NOLINTBEGIN
88+
MCAPI static void** $vftable();
89+
// NOLINTEND
90+
};

0 commit comments

Comments
 (0)