Skip to content

Commit aef57e7

Browse files
authored
Merge pull request #614 from misode/mcdoc
2 parents 55f961c + 1abc28f commit aef57e7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+5953
-4276
lines changed

package-lock.json

Lines changed: 1768 additions & 466 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,37 @@
99
"dev": "vite",
1010
"build": "tsc && vite build",
1111
"preview": "vite preview",
12-
"lint": "eslint . --ext .ts,.tsx"
12+
"lint": "eslint . --ext .ts,.tsx",
13+
"postinstall": "patch-package"
1314
},
1415
"keywords": [],
1516
"author": "Misode",
1617
"license": "MIT",
1718
"dependencies": {
1819
"@giscus/react": "^2.2.3",
19-
"@mcschema/core": "^0.13.0",
20-
"@mcschema/java-1.15": "^0.2.13",
21-
"@mcschema/java-1.16": "^0.6.20",
22-
"@mcschema/java-1.17": "^0.2.40",
23-
"@mcschema/java-1.18": "^0.3.16",
24-
"@mcschema/java-1.18.2": "^0.1.26",
25-
"@mcschema/java-1.19": "^0.1.54",
26-
"@mcschema/java-1.19.3": "^0.0.17",
27-
"@mcschema/java-1.19.4": "^0.1.21",
28-
"@mcschema/java-1.20": "^0.0.24",
29-
"@mcschema/java-1.20.2": "^0.0.15",
30-
"@mcschema/java-1.20.3": "^0.0.16",
31-
"@mcschema/java-1.20.5": "^0.0.42",
32-
"@mcschema/java-1.21": "^0.0.27",
33-
"@mcschema/java-1.21.2": "^0.0.16",
34-
"@mcschema/java-1.21.4": "^0.0.15",
35-
"@mcschema/locales": "^0.1.104",
20+
"@spyglassmc/core": "^0.4.15",
21+
"@spyglassmc/java-edition": "^0.3.19",
22+
"@spyglassmc/json": "^0.3.17",
23+
"@spyglassmc/locales": "^0.3.9",
24+
"@spyglassmc/mcdoc": "^0.3.18",
25+
"@spyglassmc/nbt": "^0.3.18",
3626
"@zip.js/zip.js": "^2.4.5",
3727
"brace": "^0.11.1",
3828
"buffer": "^6.0.3",
39-
"comment-json": "^4.1.1",
29+
"deepslate": "^0.22.3",
4030
"deepslate-1.18": "npm:[email protected]",
4131
"deepslate-1.18.2": "npm:[email protected]",
4232
"deepslate-1.20.4": "npm:[email protected]",
43-
"deepslate": "^0.22.3",
4433
"diff": "^7.0.0",
4534
"highlight.js": "^11.5.1",
4635
"howler": "^2.2.3",
4736
"js-yaml": "^3.14.1",
4837
"lz-string": "^1.4.4",
4938
"marked": "^4.0.10",
5039
"rfdc": "^1.3.0",
51-
"sourcemapped-stacktrace": "^1.1.11"
40+
"sourcemapped-stacktrace": "^1.1.11",
41+
"spark-md5": "^3.0.2",
42+
"vscode-languageserver-textdocument": "^1.0.12"
5243
},
5344
"devDependencies": {
5445
"@preact/preset-vite": "^2.4.0",
@@ -61,10 +52,12 @@
6152
"@types/lz-string": "^1.3.34",
6253
"@types/marked": "^4.0.1",
6354
"@types/seedrandom": "^2.4.28",
55+
"@types/spark-md5": "^3.0.5",
6456
"@typescript-eslint/eslint-plugin": "^5.28.0",
6557
"@typescript-eslint/parser": "^5.28.0",
6658
"autoprefixer": "^10.4.16",
6759
"eslint": "^8.17.0",
60+
"patch-package": "^8.0.0",
6861
"postcss": "^8.4.31",
6962
"preact": "^10.8.0",
7063
"preact-router": "^3.2.1",
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
diff --git a/node_modules/@spyglassmc/mcdoc/lib/runtime/checker/index.js b/node_modules/@spyglassmc/mcdoc/lib/runtime/checker/index.js
2+
index 2d51735..70ac4a0 100644
3+
--- a/node_modules/@spyglassmc/mcdoc/lib/runtime/checker/index.js
4+
+++ b/node_modules/@spyglassmc/mcdoc/lib/runtime/checker/index.js
5+
@@ -545,9 +545,9 @@ function simplifyReference(typeDef, context) {
6+
context.ctx.logger.warn(`Tried to access unknown reference ${typeDef.path}`);
7+
return { typeDef: { kind: 'union', members: [] } };
8+
}
9+
- if (data.simplifiedTypeDef) {
10+
- return { typeDef: data.simplifiedTypeDef };
11+
- }
12+
+ // if (data.simplifiedTypeDef) {
13+
+ // return { typeDef: data.simplifiedTypeDef };
14+
+ // }
15+
const simplifiedResult = simplify(data.typeDef, context);
16+
if (typeDef.attributes?.length) {
17+
simplifiedResult.typeDef = {
18+
@@ -555,16 +555,16 @@ function simplifyReference(typeDef, context) {
19+
attributes: [...typeDef.attributes, ...simplifiedResult.typeDef.attributes ?? []],
20+
};
21+
}
22+
- if (!simplifiedResult.dynamicData) {
23+
- symbol.amend({
24+
- data: {
25+
- data: {
26+
- ...data,
27+
- simplifiedTypeDef: simplifiedResult.typeDef,
28+
- },
29+
- },
30+
- });
31+
- }
32+
+ // if (!simplifiedResult.dynamicData) {
33+
+ // symbol.amend({
34+
+ // data: {
35+
+ // data: {
36+
+ // ...data,
37+
+ // simplifiedTypeDef: simplifiedResult.typeDef,
38+
+ // },
39+
+ // },
40+
+ // });
41+
+ // }
42+
return simplifiedResult;
43+
}
44+
function simplifyDispatcher(typeDef, context) {
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
use ::java::server::util::direction::Direction
2+
use ::java::server::util::block_state::BlockState
3+
use ::java::data::worldgen::biome::Precipitation
4+
use ::java::data::worldgen::processor_list::BlockMatch
5+
use ::java::data::worldgen::processor_list::BlockStateMatch
6+
use ::java::data::worldgen::processor_list::RandomBlockMatch
7+
use ::java::data::worldgen::processor_list::RandomBlockStateMatch
8+
use ::java::data::worldgen::processor_list::TagMatch
9+
10+
dispatch minecraft:resource[immersive_weathering:block_growth] to struct BlockGrowth {
11+
area_condition: AreaCondition,
12+
position_predicates?: [PositionTest],
13+
growth_chance: float @ 0..1,
14+
growth_for_face: [GrowthFace],
15+
owners: [#[id="block"] string],
16+
replacing_target: RuleTest,
17+
target_self?: boolean,
18+
destroy_target?: boolean,
19+
}
20+
21+
struct GrowthFace {
22+
direction?: Direction,
23+
weight?: int,
24+
growth: [struct {
25+
weight: int,
26+
data: BlockPair,
27+
}],
28+
}
29+
30+
struct BlockPair {
31+
block: BlockState,
32+
above_block?: BlockState,
33+
}
34+
35+
struct AreaCondition {
36+
type: ("generate_if_not_too_many" | "neighbor_based_generation"),
37+
...immersive_weathering:area_condition[[type]],
38+
}
39+
40+
dispatch immersive_weathering:area_condition[generate_if_not_too_many] to struct GenerateIfNotTooMany {
41+
radiusX: int,
42+
radiusY: int,
43+
radiusZ: int,
44+
requiredAmount: int,
45+
yOffset?: int,
46+
must_have?: RuleTest,
47+
must_not_have?: RuleTest,
48+
includes?: (#[id(registry="block",tags="allowed")] string | [#[id="block"] string]),
49+
}
50+
51+
dispatch immersive_weathering:area_condition[neighbor_based_generation] to struct NeighborBasedGeneration {
52+
must_have: RuleTest,
53+
must_not_have?: RuleTest,
54+
required_amount?: int,
55+
directions: [Direction],
56+
}
57+
58+
struct PositionTest {
59+
type: ("biome_match" | "day_test" | "nand" | "precipitation_test" | "temperature_range"),
60+
...immersive_weathering:position_test[[type]],
61+
}
62+
63+
dispatch immersive_weathering:position_test[biome_match] to struct BiomeMatch {
64+
biomes: (#[id(registry="worldgen/biome",tags="allowed")] string | [#[id="worldgen/biome"] string]),
65+
}
66+
67+
dispatch immersive_weathering:position_test[day_test] to struct DayTest {
68+
day: boolean,
69+
}
70+
71+
dispatch immersive_weathering:position_test[nand] to struct Nand {
72+
predicates: [PositionTest],
73+
}
74+
75+
dispatch immersive_weathering:position_test[precipitation_test] to struct PrecipitationTest {
76+
precipitation: Precipitation,
77+
}
78+
79+
dispatch immersive_weathering:position_test[temperature_range] to struct TemperatureRange {
80+
min: float,
81+
max: float,
82+
use_local_pos?: boolean,
83+
}
84+
85+
struct RuleTest {
86+
predicate_type: #[id] RuleTestType,
87+
...immersive_weathering:rule_test[[predicate_type]],
88+
}
89+
90+
enum(string) RuleTestType {
91+
#[starred] BlockSetMatch = "immersive_weathering:block_set_match",
92+
#[starred] FluidMatch = "immersive_weathering:fluid_match",
93+
#[starred] TreeLog = "immersive_weathering:tree_log",
94+
BlockMatch = "block_match",
95+
BlockStateMatch = "blockstate_match",
96+
RandomBlockMatch = "random_block_match",
97+
RandomBlockStateMatch = "random_blockstate_match",
98+
TagMatch = "tag_match",
99+
}
100+
101+
dispatch immersive_weathering:rule_test[block_match] to BlockMatch
102+
dispatch immersive_weathering:rule_test[blockstate_match] to BlockStateMatch
103+
dispatch immersive_weathering:rule_test[random_block_match] to RandomBlockMatch
104+
dispatch immersive_weathering:rule_test[random_blockstate_match] to RandomBlockStateMatch
105+
dispatch immersive_weathering:rule_test[tag_match] to TagMatch
106+
107+
dispatch immersive_weathering:rule_test[immersive_weathering:block_set_match] to struct BlockSetMatch {
108+
blocks: (#[id(registry="block",tags="allowed")] string | [#[id="block"] string]),
109+
probability?: float @ 0..1,
110+
}
111+
112+
dispatch immersive_weathering:rule_test[immersive_weathering:fluid_match] to struct FluidMatch {
113+
fluids: #[id="fluid"] string,
114+
}
115+
116+
dispatch immersive_weathering:rule_test[immersive_weathering:tree_log] to struct {}

0 commit comments

Comments
 (0)