Skip to content

Commit 03587df

Browse files
committed
feat: adapt 1.21.80.3
1 parent 210fb8e commit 03587df

File tree

9 files changed

+229
-74
lines changed

9 files changed

+229
-74
lines changed

src/more_dimensions/core/dimension/MoreDimensionsPatch.h

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ __declspec(dllimport) bool pl_notice(void* target);
88
}
99
namespace {
1010
struct AddressAndReg {
11+
DWORD func_rva;
1112
DWORD func_rva_start;
1213
DWORD func_rva_end;
1314
const std::vector<BYTE> native_code;
@@ -16,45 +17,45 @@ struct AddressAndReg {
1617
// 0~26 VanillaDimensions::toSerializedInt
1718
// 27~39 VanillaDimensions::fromSerializedInt(int)
1819
std::vector<AddressAndReg> data = {
19-
{0x07BB92F, 0x07BB95A, {0x89, 0xC8} },
20-
{0x292609B, 0x29260BF, {0x89, 0xC3} },
21-
{0x1162597, 0x11625C0, {0x89, 0xC2} },
22-
{0x117148E, 0x11714B7, {0x89, 0xC2} },
23-
{0x11789E0, 0x1178A09, {0x89, 0xC2} },
24-
{0x11798C5, 0x11798EE, {0x89, 0xC2} },
25-
{0x127D792, 0x127D7BB, {0x89, 0xC3} },
26-
{0x129BBB3, 0x129BBD6, {0x89, 0xC3} },
27-
{0x12A9A9F, 0x12A9AC8, {0x89, 0xC2} },
28-
{0x12C29A4, 0x12C29CD, {0x89, 0xC2} },
29-
{0x1C17D7B, 0x1C17DA3, {0x41, 0x88, 0xC9} },
30-
{0x1C1803B, 0x1C1805E, {0x88, 0xC8} },
31-
{0x1FE4127, 0x1FE414F, {0x41, 0x88, 0xC9} },
32-
{0x29FC7E7, 0x29FC812, {0x89, 0xC3} },
33-
{0x2A596EC, 0x2A59717, {0x89, 0xC3} },
34-
{0x2A59B95, 0x2A59BC1, {0x89, 0xDF} },
35-
{0x2A5694F, 0x2A56975, {0x41, 0x89, 0xC6} },
36-
{0x2A71DC0, 0x2A71DE9, {0x89, 0xC3} },
37-
{0x2A71530, 0x2A7155B, {0x89, 0xD3} },
38-
{0x2D960E2, 0x2D96110, {0x41, 0x89, 0xC6} },
39-
{0x2D99030, 0x2D99054, {0x89, 0xC7} },
40-
{0x2DA043E, 0x2DA0461, {0x88, 0xD8} },
41-
{0x2CF8393, 0x2CF83B6, {0x89, 0xC3} },
42-
{0x33C3822, 0x33C3850, {0x41, 0x89, 0xC3} },
43-
{0x347BE35, 0x347BE59, {0x89, 0xCB} },
44-
{0x347CE8E, 0x347CEB3, {0x89, 0xDF} },
45-
{0x3616FAD, 0x3616FD5, {0x40, 0x88, 0xC7} },
46-
{0x29FF291, 0x29FF2C1, {0x41, 0x89, 0xC8} },
47-
{0x2A1679C, 0x2A167C8, {0x89, 0xC8} },
48-
{0x0C354B0, 0x0C35500, {0x89, 0x8E, 0x3C, 0x00, 0x00, 0x00}},
49-
{0x1252BF9, 0x1252C25, {0x89, 0xCB} },
50-
{0x127CF17, 0x127CF43, {0x89, 0xCF} },
51-
{0x17809E5, 0x1780A1D, {0x89, 0xC8} },
52-
{0x2A714A0, 0x2A71502, {0x89, 0xC8} },
53-
{0x2A57969, 0x2A579A3, {0x89, 0x8E, 0x30, 0x0B, 0x00, 0x00}},
54-
{0x2D959B1, 0x2D959DD, {0x89, 0xC8} },
55-
{0x2D9925E, 0x2D9928A, {0x89, 0xC8} },
56-
{0x3482FD4, 0x3483000, {0x89, 0xC8} },
57-
{0x3618CD8, 0x3618D07, {} }
20+
{0x08440f0, 0x08443cf, 0x08443fa, {0x89, 0xc8} },
21+
{0x262a500, 0x262a5f5, 0x262a617, {0x89, 0xc3} },
22+
{0x104de80, 0x104deb7, 0x104dee0, {0x89, 0xc2} },
23+
{0x10a4f60, 0x10a4fee, 0x10a5017, {0x89, 0xc2} },
24+
{0x1089720, 0x1089770, 0x1089799, {0x89, 0xc2} },
25+
{0x108a620, 0x108a655, 0x108a67e, {0x89, 0xc2} },
26+
{0x0d018e0, 0x0d01ed2, 0x0d01efb, {0x89, 0xc3} },
27+
{0x1062410, 0x10625e3, 0x1062606, {0x89, 0xc3} },
28+
{0x0d93460, 0x0d9347f, 0x0d934a8, {0x89, 0xc2} },
29+
{0x0d71150, 0x0d711a4, 0x0d711cd, {0x89, 0xc2} },
30+
{0x197e0f0, 0x197e4ab, 0x197e4d3, {0x41, 0x88, 0xc9} },
31+
{0x197e670, 0x197e76b, 0x197e78e, {0x88, 0xc8} },
32+
{0x171f790, 0x171fab7, 0x171fadf, {0x41, 0x88, 0xc9} },
33+
{0x25c0140, 0x25c09c7, 0x25c09f2, {0x89, 0xc3} },
34+
{0x2569f20, 0x256a388, 0x256a3b3, {0x89, 0xc3} },
35+
{0x2569f20, 0x256a834, 0x256a860, {0x89, 0xdf} },
36+
{0x2567090, 0x2567841, 0x2567867, {0x41, 0x89, 0xc6} },
37+
{0x2582d50, 0x2582e80, 0x2582ea9, {0x89, 0xc3} },
38+
{0x25825e0, 0x25825f0, 0x258261b, {0x89, 0xd3} },
39+
{0x2d2ca90, 0x2d2ccb2, 0x2d2cce0, {0x41, 0x89, 0xc6} },
40+
{0x2d2faf0, 0x2d2fc40, 0x2d2fc64, {0x89, 0xc7} },
41+
{0x2d3e700, 0x2d3e75e, 0x2d3e781, {0x88, 0xd8} },
42+
{0x2984bf0, 0x2984cb3, 0x2984cd6, {0x89, 0xc3} },
43+
{0x30e4420, 0x30e4432, 0x30e4460, {0x41, 0x89, 0xc3} },
44+
{0x31f7d10, 0x31f7e35, 0x31f7e59, {0x89, 0xcb} },
45+
{0x31f8e10, 0x31f8e8e, 0x31f8eb3, {0x89, 0xdf} },
46+
{0x336cb80, 0x336cccd, 0x336ccf5, {0x40, 0x88, 0xc7} },
47+
{0x25c22a0, 0x25c33dd, 0x25c340d, {0x41, 0x89, 0xc8} },
48+
{0x25e02f0, 0x25e04bc, 0x25e04e8, {0x89, 0xc8} },
49+
{0x0b92a60, 0x0b92d10, 0x0b92d60, {0x89, 0x8e, 0x3c, 0x0, 0x0, 0x0}},
50+
{0x0cbde50, 0x0cbdfc9, 0x0cbdff5, {0x89, 0xcb} },
51+
{0x0d013f0, 0x0d01657, 0x0d01683, {0x89, 0xcf} },
52+
{0x10fef90, 0x10ff015, 0x10ff04d, {0x89, 0xc8} },
53+
{0x25824e0, 0x2582560, 0x25825c2, {0x89, 0xc8} },
54+
{0x2a572d0, 0x25687a5, 0x25687ea, {0x89, 0x8e, 0xe0, 0xa, 0x0, 0x0}},
55+
{0x2d2c450, 0x2d2c5c1, 0x2d2c5ed, {0x89, 0xc8} },
56+
{0x2d2fcd0, 0x2d2fe6e, 0x2d2fe9a, {0x89, 0xc8} },
57+
{0x31ff0b0, 0x31ff164, 0x31ff190, {0x89, 0xc8} },
58+
{0x336e8e0, 0x336e998, 0x336e9c7, {} },
5859
};
5960

6061
bool PatchFunction(HMODULE hModule, DWORD faddress_start, DWORD faddress_end, const std::vector<BYTE>& native_code) {
@@ -128,10 +129,8 @@ void injectNaticeCode() {
128129
}
129130
for (auto& item : data) {
130131
PatchFunction(hModule, item.func_rva_start, item.func_rva_end, item.native_code);
131-
if(item.func_rva_start == 0x12A9A9F){
132-
void* funcp = (void*)((BYTE*)hModule + 0x12A9A80);
133-
pl_notice(funcp);
134-
}
132+
void* funcp = (void*)((BYTE*)hModule + item.func_rva);
133+
pl_notice(funcp);
135134
};
136135
};
137136

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

Lines changed: 85 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,17 @@
1414
#include "mc/world/level/levelgen/structure/registry/JigsawStructureRegistry.h"
1515
#include "mc/world/level/levelgen/structure/registry/StructurePools.h"
1616
#include "mc/world/level/levelgen/structure/structurepools/StructurePoolBlockPredicateAlwaysTrue.h"
17-
#include "test/mc/StructurePoolBlockPredicateBlockMatchRandom.h"
18-
#include "test/mc/StructurePoolBlockRule.h"
1917
#include "mc/world/level/levelgen/structure/structurepools/StructurePoolElement.h"
2018
#include "mc/world/level/levelgen/structure/structurepools/StructureTemplatePool.h"
2119
#include "mc/world/level/storage/Experiments.h"
20+
#include "test/mc/StructurePoolBlockPredicateBlockMatchRandom.h"
21+
#include "test/mc/StructurePoolBlockRule.h"
2222

23+
// #include "mc/world/level/storage/Experiments.h"
24+
// #include "test/mc/StructureTemplateRegistrationContext.h"
25+
// #include "test/mc/WeightedStructureTemplateRegistration.h"
26+
27+
// #include <initializer_list>
2328
#include <memory>
2429

2530
namespace custom_structure {
@@ -28,12 +33,12 @@ void CustomJigsawStructureBlockRules::initialize(JigsawStructureRegistry& regist
2833
auto& jigsawBlockRulesRegistry = registry.mJigsawBlockRulesRegistry;
2934

3035
// input_predicate block
31-
auto& stoneBricks = BlockTypeRegistry::getDefaultBlockState(VanillaBlockTypeIds::StoneBricks());
36+
auto& stoneBricks = BlockTypeRegistry::getDefaultBlockState(VanillaBlockTypeIds::StoneBricks());
3237

3338
// output_state blocks
34-
auto& mossyStoneBricks = BlockTypeRegistry::getDefaultBlockState(VanillaBlockTypeIds::MossyStoneBricks());
39+
auto& mossyStoneBricks = BlockTypeRegistry::getDefaultBlockState(VanillaBlockTypeIds::MossyStoneBricks());
3540
auto& crackedStoneBricks = BlockTypeRegistry::getDefaultBlockState(VanillaBlockTypeIds::CrackedStoneBricks());
36-
auto& cobblestone = BlockTypeRegistry::getDefaultBlockState(VanillaBlockTypeIds::Cobblestone());
41+
auto& cobblestone = BlockTypeRegistry::getDefaultBlockState(VanillaBlockTypeIds::Cobblestone());
3742

3843
// input_predicate
3944
std::unique_ptr<IStructurePoolBlockPredicate> sourceBlock_pro1 =
@@ -44,10 +49,16 @@ void CustomJigsawStructureBlockRules::initialize(JigsawStructureRegistry& regist
4449
std::unique_ptr<IStructurePoolBlockPredicate> targetBlock =
4550
std::make_unique<StructurePoolBlockPredicateAlwaysTrue>();
4651

47-
auto blockRule_1 =
48-
std::make_unique<StructurePoolBlockRule>(std::move(sourceBlock_pro1), std::move(targetBlock), &mossyStoneBricks);
49-
auto blockRule_2 =
50-
std::make_unique<StructurePoolBlockRule>(std::move(sourceBlock_pro1), std::move(targetBlock), &crackedStoneBricks);
52+
auto blockRule_1 = std::make_unique<StructurePoolBlockRule>(
53+
std::move(sourceBlock_pro1),
54+
std::move(targetBlock),
55+
&mossyStoneBricks
56+
);
57+
auto blockRule_2 = std::make_unique<StructurePoolBlockRule>(
58+
std::move(sourceBlock_pro1),
59+
std::move(targetBlock),
60+
&crackedStoneBricks
61+
);
5162
auto blockRule_3 =
5263
std::make_unique<StructurePoolBlockRule>(std::move(sourceBlock_pro2), std::move(targetBlock), &cobblestone);
5364

@@ -58,7 +69,7 @@ void CustomJigsawStructureBlockRules::initialize(JigsawStructureRegistry& regist
5869
ruleList->emplace_back(std::move(blockRule_2));
5970
ruleList->emplace_back(std::move(blockRule_3));
6071

61-
jigsawBlockRulesRegistry->registerBlockRules("mike:stone_brick_replacement_jig", std::move(ruleList));
72+
jigsawBlockRulesRegistry->registerBlockRules("mike:stone_brick_replacement", std::move(ruleList));
6273

6374
// br::worldgen::processors::BlockRules::Test block_test;
6475
// block_test.mData = br::worldgen::processors::BlockRules::RandomBlockMatch(stoneBricks.mLegacyBlock.get(), 0.2);
@@ -70,7 +81,6 @@ void CustomJigsawStructureBlockRules::initialize(JigsawStructureRegistry& regist
7081
// auto ruleList = br::worldgen::StructureProcessor::Rule({blockRule_1, blockRule_2, blockRule_3});
7182
// auto prot = br::worldgen::StructureProcessor::Protected(VanillaBlockTypeIds::RedstoneBlock());
7283
// jigsawBlockRulesRegistry->record("mike:stone_brick_replacement", {ruleList, prot});
73-
7484
}
7585

7686
void CustomJigsawStructureElements::initialize(
@@ -93,7 +103,7 @@ void CustomJigsawStructureElements::initialize(
93103
nullptr,
94104
nullptr,
95105
Projection::TerrainMatching,
96-
PostProcessSettings::All
106+
PostProcessSettings::Beard
97107
)
98108
);
99109
jigsawStructureElementRegistry->registerStructureElement(
@@ -105,7 +115,7 @@ void CustomJigsawStructureElements::initialize(
105115
nullptr,
106116
nullptr,
107117
Projection::TerrainMatching,
108-
PostProcessSettings::All
118+
PostProcessSettings::Beard
109119
)
110120
);
111121
jigsawStructureElementRegistry->registerStructureElement(
@@ -117,11 +127,11 @@ void CustomJigsawStructureElements::initialize(
117127
nullptr,
118128
nullptr,
119129
Projection::TerrainMatching,
120-
PostProcessSettings::All
130+
PostProcessSettings::Beard
121131
)
122132
);
123133

124-
//mike:ew7x4
134+
// mike:ew7x4
125135
jigsawStructureElementRegistry->registerStructureElement(
126136
"mike:ew7x4h",
127137
std::make_unique<StructurePoolElement>(
@@ -131,7 +141,7 @@ void CustomJigsawStructureElements::initialize(
131141
nullptr,
132142
nullptr,
133143
Projection::TerrainMatching,
134-
PostProcessSettings::All
144+
PostProcessSettings::Beard
135145
)
136146
);
137147
jigsawStructureElementRegistry->registerStructureElement(
@@ -143,11 +153,11 @@ void CustomJigsawStructureElements::initialize(
143153
nullptr,
144154
nullptr,
145155
Projection::TerrainMatching,
146-
PostProcessSettings::All
156+
PostProcessSettings::Beard
147157
)
148158
);
149159

150-
//mike:ns7x4
160+
// mike:ns7x4
151161
jigsawStructureElementRegistry->registerStructureElement(
152162
"mike:ns7x4h",
153163
std::make_unique<StructurePoolElement>(
@@ -157,7 +167,7 @@ void CustomJigsawStructureElements::initialize(
157167
nullptr,
158168
nullptr,
159169
Projection::TerrainMatching,
160-
PostProcessSettings::All
170+
PostProcessSettings::Beard
161171
)
162172
);
163173
jigsawStructureElementRegistry->registerStructureElement(
@@ -169,11 +179,11 @@ void CustomJigsawStructureElements::initialize(
169179
nullptr,
170180
nullptr,
171181
Projection::TerrainMatching,
172-
PostProcessSettings::All
182+
PostProcessSettings::Beard
173183
)
174184
);
175185

176-
//mike:ewcap
186+
// mike:ewcap
177187
jigsawStructureElementRegistry->registerStructureElement(
178188
"mike:ewcap",
179189
std::make_unique<StructurePoolElement>(
@@ -183,11 +193,11 @@ void CustomJigsawStructureElements::initialize(
183193
nullptr,
184194
nullptr,
185195
Projection::TerrainMatching,
186-
PostProcessSettings::All
196+
PostProcessSettings::Beard
187197
)
188198
);
189199

190-
//mike:nacap
200+
// mike:nacap
191201
jigsawStructureElementRegistry->registerStructureElement(
192202
"mike:nscap",
193203
std::make_unique<StructurePoolElement>(
@@ -197,20 +207,24 @@ void CustomJigsawStructureElements::initialize(
197207
nullptr,
198208
nullptr,
199209
Projection::TerrainMatching,
200-
PostProcessSettings::All
210+
PostProcessSettings::Beard
201211
)
202212
);
203213
}
204214

205215
void CustomJigsawStructure::initialize(
206216
Bedrock::NotNullNonOwnerPtr<::StructureManager> manager,
207217
FeatureRegistry& featureRegistry,
208-
JigsawStructureRegistry& registry
218+
JigsawStructureRegistry& registry,
219+
BaseGameVersion const& baseGameVersion,
220+
Experiments const& experiments
209221
) {
210222
CustomJigsawStructureBlockRules::initialize(registry);
211223
CustomJigsawStructureElements::initialize(manager, featureRegistry, registry);
212224
auto& jigsawStructureElementRegistry = registry.mJigsawElementRegistry;
213225

226+
// auto ruleList = registry.mJigsawBlockRulesRegistry->lookupByName("mike:stone_brick_replacement");
227+
214228
std::vector<std::pair<StructurePoolElement const*, int>> templates_5x5{
215229
{jigsawStructureElementRegistry->lookupByName("mike:5x5intb"), 4},
216230
{jigsawStructureElementRegistry->lookupByName("mike:5x5intc"), 1},
@@ -236,6 +250,45 @@ void CustomJigsawStructure::initialize(
236250
registry.registerPool(std::make_unique<StructureTemplatePool>("mike:ns7x4", "mike:nscap", templates_ns));
237251
registry.registerPool(std::make_unique<StructureTemplatePool>("mike:ewcap", "empty", templates_ewcap));
238252
registry.registerPool(std::make_unique<StructureTemplatePool>("mike:nscap", "empty", templates_nscap));
253+
254+
// StructureTemplateRegistrationContext
255+
// context{manager, jigsawStructureElementRegistry, featureRegistry, baseGameVersion, experiments};
256+
257+
// std::initializer_list<WeightedStructureTemplateRegistration> templates_5x5{
258+
// {StructurePoolElement::single("mike:5x5intb", ruleList, {}, {}), 4},
259+
// {StructurePoolElement::single("mike:5x5intc", ruleList, {}, {}), 1},
260+
// {StructurePoolElement::single("mike:5x5intk", ruleList, {}, {}), 1}
261+
// };
262+
// std::initializer_list<WeightedStructureTemplateRegistration> templates_ew{
263+
// {StructurePoolElement::single("mike:ew7x4h", ruleList, {}, {}), 4},
264+
// {StructurePoolElement::single("mike:ew7x4r", ruleList, {}, {}), 1}
265+
// };
266+
// std::initializer_list<WeightedStructureTemplateRegistration> templates_ns{
267+
// {StructurePoolElement::single("mike:ns7x4h", ruleList, {}, {}), 4},
268+
// {StructurePoolElement::single("mike:ns7x4r", ruleList, {}, {}), 1}
269+
// };
270+
// std::initializer_list<WeightedStructureTemplateRegistration> templates_ewcap{
271+
// {StructurePoolElement::single("mike:ewcap", ruleList, {}, {}), 4}
272+
// };
273+
// std::initializer_list<WeightedStructureTemplateRegistration> templates_nscap{
274+
// {StructurePoolElement::single("mike:nscap", ruleList, {}, {}), 4}
275+
// };
276+
277+
// registry.registerPool(
278+
// std::make_unique<StructureTemplatePool>(context, "mike:5x5int", "empty", Projection::Invalid, templates_5x5)
279+
// );
280+
// registry.registerPool(
281+
// std::make_unique<StructureTemplatePool>(context, "mike:ew7x4", "mike:ewcap", Projection::Invalid, templates_ew)
282+
// );
283+
// registry.registerPool(
284+
// std::make_unique<StructureTemplatePool>(context, "mike:ns7x4", "mike:nscap", Projection::Invalid, templates_ns)
285+
// );
286+
// registry.registerPool(
287+
// std::make_unique<StructureTemplatePool>(context, "mike:ewcap", "empty", Projection::Invalid, templates_ewcap)
288+
// );
289+
// registry.registerPool(
290+
// std::make_unique<StructureTemplatePool>(context, "mike:nscap", "empty", Projection::Invalid, templates_nscap)
291+
// );
239292
}
240293

241294
} // namespace custom_structure
@@ -252,7 +305,13 @@ LL_AUTO_TYPE_STATIC_HOOK(
252305
BaseGameVersion const& baseGameVersion,
253306
Experiments const& experiments
254307
) {
308+
custom_structure::CustomJigsawStructure::initialize(
309+
structureManager,
310+
featureRegistry,
311+
jigsawStructureRegistry,
312+
baseGameVersion,
313+
experiments
314+
);
255315
origin(structureManager, featureRegistry, jigsawStructureRegistry, baseGameVersion, experiments);
256-
custom_structure::CustomJigsawStructure::initialize(structureManager, featureRegistry, jigsawStructureRegistry);
257316
return;
258317
};

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ class FeatureRegistry;
88
class JigsawStructureRegistry;
99
class WorkerPool;
1010
class StructureManager;
11+
class BaseGameVersion;
12+
class Experiments;
1113

1214
namespace custom_structure {
1315

@@ -17,7 +19,9 @@ namespace CustomJigsawStructure {
1719
void initialize(
1820
Bedrock::NotNullNonOwnerPtr<::StructureManager> manager,
1921
FeatureRegistry& featureRegistry,
20-
JigsawStructureRegistry& registry
22+
JigsawStructureRegistry& registry,
23+
BaseGameVersion const& baseGameVersion,
24+
Experiments const& experiments
2125
);
2226

2327
} // namespace CustomJigsawStructure

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ bool CustomStructureFeature::getNearestGeneratedFeature(
2828
bool mustBeInNewChunks,
2929
::std::optional<::HashedString> const& biomeTag
3030
) {
31-
return false;
31+
return StructureFeature::findNearestFeaturePositionBySpacing(dimension, preliminarySurfaceLevel, *this, biomeTag, biomeSource, origin, pos, mMaxSpacing, mMinSpacing, 39281139, true, 0, mustBeInNewChunks);
3232
};
3333

3434
bool CustomStructureFeature::

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace custom_structure {
2323
int CustomStructurePiece::
2424
generateHeightAtPosition(BlockPos const&, Dimension& dim, BlockVolume&, std::unordered_map<ChunkPos, std::unique_ptr<std::vector<short>>>&)
2525
const {
26-
return dim.mSeaLevel + 2;
26+
return dim.mSeaLevel + 100;
2727
};
2828

2929
Block const* CustomStructurePiece::getSupportBlock(::BlockSource&, ::BlockPos const&, ::Block const&) const {

0 commit comments

Comments
 (0)