cyclops-infobook-html 1.1.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/README.md +1 -2
- package/bin/generate-infobook-html.js +4 -4
- package/bin/generate-mod-metadata.js +19 -1
- package/index.d.ts +2 -1
- package/index.js +10 -1
- package/lib/infobook/FileWriter.js +1 -0
- package/lib/infobook/IItem.d.ts +0 -1
- package/lib/infobook/InfoBookInitializer.js +1 -0
- package/lib/infobook/appendix/InfoBookAppendixAd.js +1 -0
- package/lib/infobook/appendix/InfoBookAppendixHandlerAbstractRecipe.d.ts +27 -0
- package/lib/infobook/appendix/InfoBookAppendixHandlerAbstractRecipe.js +51 -0
- package/lib/infobook/appendix/InfoBookAppendixHandlerAdvancementRewards.js +2 -2
- package/lib/infobook/appendix/InfoBookAppendixHandlerCraftingRecipe.d.ts +9 -20
- package/lib/infobook/appendix/InfoBookAppendixHandlerCraftingRecipe.js +9 -59
- package/lib/infobook/appendix/InfoBookAppendixHandlerImage.js +1 -0
- package/lib/infobook/appendix/InfoBookAppendixHandlerKeybinding.js +1 -0
- package/lib/infobook/appendix/InfoBookAppendixHandlerSmeltingRecipe.d.ts +18 -0
- package/lib/infobook/appendix/InfoBookAppendixHandlerSmeltingRecipe.js +25 -0
- package/lib/infobook/appendix/InfoBookAppendixTagIndex.js +3 -2
- package/lib/modloader/ModLoader.js +26 -9
- package/lib/parse/XmlInfoBookParser.js +1 -0
- package/lib/resource/ResourceHandler.d.ts +5 -11
- package/lib/resource/ResourceHandler.js +14 -25
- package/lib/resource/ResourceLoader.js +9 -15
- package/lib/serialize/HtmlInfoBookSerializer.js +14 -18
- package/package.json +11 -11
- package/template/includes/footer.pug +1 -1
- package/lib/infobook/appendix/InfoBookAppendixHandlerFurnaceRecipe.d.ts +0 -18
- package/lib/infobook/appendix/InfoBookAppendixHandlerFurnaceRecipe.js +0 -41
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
|
|
4
|
+
<a name="v3.0.0"></a>
|
|
5
|
+
## [v3.0.0](https://github.com/CyclopsMC/infobook-html/compare/v2.0.0...v3.0.0) - 2022-03-10
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
* [Update to MC 1.18](https://github.com/CyclopsMC/infobook-html/commit/1fb77959593a2b84cb14e56406f0df20ad450e16)
|
|
9
|
+
|
|
10
|
+
<a name="v2.0.0"></a>
|
|
11
|
+
## [v2.0.0](https://github.com/CyclopsMC/infobook-html/compare/v1.1.2...v2.0.0) - 2021-02-03
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
* [Update to MC 1.16](https://github.com/CyclopsMC/infobook-html/commit/249b211cb524414db95e3600dcdf14d9304926db)
|
|
15
|
+
* [Also extract mod data](https://github.com/CyclopsMC/infobook-html/commit/c11023465f93c2018deaa10e14270102398dfb2a)
|
|
16
|
+
* [Update footer year](https://github.com/CyclopsMC/infobook-html/commit/c946bab5c16c293b8a6a01a1c7ee1eb9c28b0ad6)
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
* [Fix incorrect dumpregistries command](https://github.com/CyclopsMC/infobook-html/commit/90bf5675f8a71170e36e91d41c01d5ec94fab430)
|
|
20
|
+
* [Fix server start failing after install in a hacky way](https://github.com/CyclopsMC/infobook-html/commit/03319253969e45b76d98b7b918bbf493c5985693)
|
|
21
|
+
|
|
22
|
+
<a name="v1.1.2"></a>
|
|
23
|
+
## [v1.1.2](https://github.com/CyclopsMC/infobook-html/compare/v1.1.1...v1.1.2) - 2019-07-31
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
* [Fix some URLs ending with two slashes](https://github.com/CyclopsMC/infobook-html/commit/8bb6b5f2efaa5babdbb0365258a911e82121ec74)
|
|
27
|
+
|
|
4
28
|
<a name="v1.1.1"></a>
|
|
5
29
|
## [v1.1.1](https://github.com/CyclopsMC/infobook-html/compare/v1.1.0...v1.1.1) - 2019-07-31
|
|
6
30
|
|
package/README.md
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
[](https://travis-ci.org/CyclopsMC/infobook-html)
|
|
4
4
|
[](https://coveralls.io/github/CyclopsMC/infobook-html?branch=master)
|
|
5
5
|
[](https://www.npmjs.com/package/infobook-html)
|
|
6
|
-
[](https://greenkeeper.io/)
|
|
7
6
|
|
|
8
7
|
Output Cyclops infobooks as HTML.
|
|
9
8
|
|
|
@@ -146,4 +145,4 @@ Example: [Integrated Dynamics plugin](https://github.com/CyclopsMC/infobook-html
|
|
|
146
145
|
## License
|
|
147
146
|
This software is written by [Ruben Taelman](http://rubensworks.net/).
|
|
148
147
|
|
|
149
|
-
This code is released under the [MIT license](http://opensource.org/licenses/MIT).
|
|
148
|
+
This code is released under the [MIT license](http://opensource.org/licenses/MIT).
|
|
@@ -7,7 +7,7 @@ const minimist = require("minimist");
|
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const InfoBookAppendixHandlerAdvancementRewards_1 = require("../lib/infobook/appendix/InfoBookAppendixHandlerAdvancementRewards");
|
|
9
9
|
const InfoBookAppendixHandlerCraftingRecipe_1 = require("../lib/infobook/appendix/InfoBookAppendixHandlerCraftingRecipe");
|
|
10
|
-
const
|
|
10
|
+
const InfoBookAppendixHandlerSmeltingRecipe_1 = require("../lib/infobook/appendix/InfoBookAppendixHandlerSmeltingRecipe");
|
|
11
11
|
const InfoBookAppendixHandlerImage_1 = require("../lib/infobook/appendix/InfoBookAppendixHandlerImage");
|
|
12
12
|
const InfoBookAppendixHandlerKeybinding_1 = require("../lib/infobook/appendix/InfoBookAppendixHandlerKeybinding");
|
|
13
13
|
const InfoBookInitializer_1 = require("../lib/infobook/InfoBookInitializer");
|
|
@@ -57,8 +57,8 @@ function create() {
|
|
|
57
57
|
// Setup infobook loader
|
|
58
58
|
const infoBookInitializer = new InfoBookInitializer_1.InfoBookInitializer(config);
|
|
59
59
|
infoBookInitializer.registerAppendixHandler('advancement_rewards', new InfoBookAppendixHandlerAdvancementRewards_1.InfoBookAppendixHandlerAdvancementRewards(resourceLoader.getResourceHandler()));
|
|
60
|
-
infoBookInitializer.registerAppendixHandler('
|
|
61
|
-
infoBookInitializer.registerAppendixHandler('
|
|
60
|
+
infoBookInitializer.registerAppendixHandler('minecraft:crafting', new InfoBookAppendixHandlerCraftingRecipe_1.InfoBookAppendixHandlerCraftingRecipe(resourceLoader.getResourceHandler(), 'registries', config.recipeOverrides));
|
|
61
|
+
infoBookInitializer.registerAppendixHandler('minecraft:smelting', new InfoBookAppendixHandlerSmeltingRecipe_1.InfoBookAppendixHandlerSmeltingRecipe(resourceLoader.getResourceHandler(), 'registries', config.recipeOverrides));
|
|
62
62
|
infoBookInitializer.registerAppendixHandler('image', new InfoBookAppendixHandlerImage_1.InfoBookAppendixHandlerImage(resourceLoader.getResourceHandler()));
|
|
63
63
|
infoBookInitializer.registerAppendixHandler('keybinding', new InfoBookAppendixHandlerKeybinding_1.InfoBookAppendixHandlerKeybinding(resourceLoader.getResourceHandler()));
|
|
64
64
|
// Load plugins
|
|
@@ -88,7 +88,7 @@ function create() {
|
|
|
88
88
|
path += '/';
|
|
89
89
|
}
|
|
90
90
|
const infoBookSerializer = new HtmlInfoBookSerializer_1.HtmlInfoBookSerializer();
|
|
91
|
-
yield infoBookSerializer.serialize(infoBook, Object.assign({}, config, { headSuffixGetters,
|
|
91
|
+
yield infoBookSerializer.serialize(infoBook, Object.assign(Object.assign({}, config), { headSuffixGetters,
|
|
92
92
|
mods,
|
|
93
93
|
path, resourceHandler: resourceLoader.getResourceHandler(), root: true }), assetsPaths);
|
|
94
94
|
});
|
|
@@ -44,7 +44,25 @@ function run(command, configPath) {
|
|
|
44
44
|
if (!modLoader.areModsInstalled()) {
|
|
45
45
|
yield modLoader.installMods();
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
// Multiple attempts for starting the server
|
|
48
|
+
// Needed because for some reason this can fail when happening right after Forge installation
|
|
49
|
+
let attempts = 0;
|
|
50
|
+
let lastError;
|
|
51
|
+
do {
|
|
52
|
+
try {
|
|
53
|
+
yield modLoader.startServer();
|
|
54
|
+
lastError = undefined;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
lastError = error;
|
|
59
|
+
process.stdout.write('Failed to start server, retrying after delay...\n');
|
|
60
|
+
yield new Promise((resolve) => setTimeout(resolve, 5000));
|
|
61
|
+
}
|
|
62
|
+
} while (attempts++ < 5);
|
|
63
|
+
if (lastError) {
|
|
64
|
+
throw lastError;
|
|
65
|
+
}
|
|
48
66
|
yield modLoader.copyRegistries(path_1.join(process.cwd(), 'registries'));
|
|
49
67
|
yield modLoader.extractMinecraftAssets();
|
|
50
68
|
yield modLoader.extractModsAssets();
|
package/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export * from "./lib/infobook/appendix/IInfoBookAppendixHandler";
|
|
2
2
|
export * from "./lib/infobook/appendix/InfoBookAppendixAd";
|
|
3
|
+
export * from "./lib/infobook/appendix/InfoBookAppendixHandlerAbstractRecipe";
|
|
3
4
|
export * from "./lib/infobook/appendix/InfoBookAppendixHandlerAdvancementRewards";
|
|
4
5
|
export * from "./lib/infobook/appendix/InfoBookAppendixHandlerCraftingRecipe";
|
|
5
|
-
export * from "./lib/infobook/appendix/
|
|
6
|
+
export * from "./lib/infobook/appendix/InfoBookAppendixHandlerSmeltingRecipe";
|
|
6
7
|
export * from "./lib/infobook/appendix/InfoBookAppendixHandlerImage";
|
|
7
8
|
export * from "./lib/infobook/appendix/InfoBookAppendixHandlerKeybinding";
|
|
8
9
|
export * from "./lib/infobook/appendix/InfoBookAppendixTagIndex";
|
package/index.js
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./lib/infobook/appendix/IInfoBookAppendixHandler"), exports);
|
|
4
5
|
tslib_1.__exportStar(require("./lib/infobook/appendix/InfoBookAppendixAd"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./lib/infobook/appendix/InfoBookAppendixHandlerAbstractRecipe"), exports);
|
|
5
7
|
tslib_1.__exportStar(require("./lib/infobook/appendix/InfoBookAppendixHandlerAdvancementRewards"), exports);
|
|
6
8
|
tslib_1.__exportStar(require("./lib/infobook/appendix/InfoBookAppendixHandlerCraftingRecipe"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./lib/infobook/appendix/
|
|
9
|
+
tslib_1.__exportStar(require("./lib/infobook/appendix/InfoBookAppendixHandlerSmeltingRecipe"), exports);
|
|
8
10
|
tslib_1.__exportStar(require("./lib/infobook/appendix/InfoBookAppendixHandlerImage"), exports);
|
|
9
11
|
tslib_1.__exportStar(require("./lib/infobook/appendix/InfoBookAppendixHandlerKeybinding"), exports);
|
|
10
12
|
tslib_1.__exportStar(require("./lib/infobook/appendix/InfoBookAppendixTagIndex"), exports);
|
|
11
13
|
tslib_1.__exportStar(require("./lib/infobook/FileWriter"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./lib/infobook/IFileWriter"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./lib/infobook/IFluid"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./lib/infobook/IInfoAppendix"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./lib/infobook/IInfoBook"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./lib/infobook/IInfobookPlugin"), exports);
|
|
19
|
+
tslib_1.__exportStar(require("./lib/infobook/IInfoSection"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./lib/infobook/IItem"), exports);
|
|
12
21
|
tslib_1.__exportStar(require("./lib/infobook/InfoBookInitializer"), exports);
|
|
13
22
|
tslib_1.__exportStar(require("./lib/modloader/ModLoader"), exports);
|
|
14
23
|
tslib_1.__exportStar(require("./lib/parse/XmlInfoBookParser"), exports);
|
package/lib/infobook/IItem.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InfoBookInitializer = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
5
|
const XmlInfoBookParser_1 = require("../parse/XmlInfoBookParser");
|
|
5
6
|
const InfoBookAppendixTagIndex_1 = require("./appendix/InfoBookAppendixTagIndex");
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ResourceHandler } from "../../resource/ResourceHandler";
|
|
2
|
+
import { HtmlInfoBookSerializer, ISerializeContext } from "../../serialize/HtmlInfoBookSerializer";
|
|
3
|
+
import { IFileWriter } from "../IFileWriter";
|
|
4
|
+
import { IInfoAppendix } from "../IInfoAppendix";
|
|
5
|
+
import { IInfoBookAppendixHandler } from "./IInfoBookAppendixHandler";
|
|
6
|
+
/**
|
|
7
|
+
* Handles abstract recipe appendices.
|
|
8
|
+
*/
|
|
9
|
+
export declare abstract class InfoBookAppendixHandlerAbstractRecipe<R extends IRecipe> implements IInfoBookAppendixHandler {
|
|
10
|
+
protected readonly id: string;
|
|
11
|
+
protected readonly resourceHandler: ResourceHandler;
|
|
12
|
+
protected readonly registry: IRecipeRegistryIndexed<R>;
|
|
13
|
+
constructor(id: string, resourceHandler: ResourceHandler, registriesPath: string, recipeOverrides: any);
|
|
14
|
+
static indexRegistry<R extends IRecipe>(registryRead: IRecipeRegistryRead<R>): IRecipeRegistryIndexed<R>;
|
|
15
|
+
createAppendix(data: any): IInfoAppendix;
|
|
16
|
+
protected abstract getRecipeNameUnlocalized(): string;
|
|
17
|
+
protected abstract serializeRecipe(recipe: R, context: ISerializeContext, fileWriter: IFileWriter, serializer: HtmlInfoBookSerializer): string;
|
|
18
|
+
}
|
|
19
|
+
export interface IRecipeRegistryRead<R extends IRecipe> {
|
|
20
|
+
recipes: [R];
|
|
21
|
+
}
|
|
22
|
+
export interface IRecipeRegistryIndexed<R extends IRecipe> {
|
|
23
|
+
[id: string]: R;
|
|
24
|
+
}
|
|
25
|
+
export interface IRecipe {
|
|
26
|
+
id: string;
|
|
27
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InfoBookAppendixHandlerAbstractRecipe = void 0;
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
/**
|
|
7
|
+
* Handles abstract recipe appendices.
|
|
8
|
+
*/
|
|
9
|
+
class InfoBookAppendixHandlerAbstractRecipe {
|
|
10
|
+
constructor(id, resourceHandler, registriesPath, recipeOverrides) {
|
|
11
|
+
this.id = id;
|
|
12
|
+
this.resourceHandler = resourceHandler;
|
|
13
|
+
this.registry = InfoBookAppendixHandlerAbstractRecipe.indexRegistry(JSON.parse(fs.readFileSync(path_1.join(registriesPath, id.replace(/:/g, '__') + '.json'), "utf8")));
|
|
14
|
+
if (recipeOverrides) {
|
|
15
|
+
this.registry = Object.assign(Object.assign({}, this.registry), (recipeOverrides[id] || {}));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
static indexRegistry(registryRead) {
|
|
19
|
+
const index = {};
|
|
20
|
+
for (const recipe of registryRead.recipes) {
|
|
21
|
+
index[recipe.id] = recipe;
|
|
22
|
+
}
|
|
23
|
+
return index;
|
|
24
|
+
}
|
|
25
|
+
createAppendix(data) {
|
|
26
|
+
const recipeId = data._;
|
|
27
|
+
let recipes = [];
|
|
28
|
+
if (recipeId.includes('*')) {
|
|
29
|
+
const recipeRegex = new RegExp(recipeId);
|
|
30
|
+
for (const [k, v] of Object.entries(this.registry)) {
|
|
31
|
+
if (recipeRegex.exec(k)) {
|
|
32
|
+
recipes.push(v);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else if (this.registry[recipeId]) {
|
|
37
|
+
recipes = [this.registry[recipeId]];
|
|
38
|
+
}
|
|
39
|
+
if (recipes.length === 0) {
|
|
40
|
+
throw new Error(`Could not find ${this.id} recipe for ${recipeId}`);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
getName: (context) => this.resourceHandler.getTranslation(this.getRecipeNameUnlocalized(), context.language),
|
|
44
|
+
toHtml: (context, fileWriter, serializer) => {
|
|
45
|
+
return recipes.map((recipe) => this.serializeRecipe(recipe, context, fileWriter, serializer)).join('<hr />');
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.InfoBookAppendixHandlerAbstractRecipe = InfoBookAppendixHandlerAbstractRecipe;
|
|
51
|
+
//# sourceMappingURL=InfoBookAppendixHandlerAbstractRecipe.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InfoBookAppendixHandlerAdvancementRewards = void 0;
|
|
3
4
|
const pug_1 = require("pug");
|
|
4
5
|
/**
|
|
5
6
|
* Handles advancement rewards appendices.
|
|
@@ -21,8 +22,7 @@ class InfoBookAppendixHandlerAdvancementRewards {
|
|
|
21
22
|
throw new Error(`Unknown achievement reward type '${rewardTag.$.type}'`);
|
|
22
23
|
}
|
|
23
24
|
const count = rewardTag.$.amount;
|
|
24
|
-
|
|
25
|
-
rewardsData.push({ item: rewardTag._, data: meta, count });
|
|
25
|
+
rewardsData.push({ item: rewardTag._, count });
|
|
26
26
|
}
|
|
27
27
|
return {
|
|
28
28
|
getName: (context) => this.resourceHandler.getTranslation('gui.advancements', context.language),
|
|
@@ -1,32 +1,21 @@
|
|
|
1
1
|
import { ResourceHandler } from "../../resource/ResourceHandler";
|
|
2
2
|
import { HtmlInfoBookSerializer, ISerializeContext } from "../../serialize/HtmlInfoBookSerializer";
|
|
3
3
|
import { IFileWriter } from "../IFileWriter";
|
|
4
|
-
import { IInfoAppendix } from "../IInfoAppendix";
|
|
5
4
|
import { IItem } from "../IItem";
|
|
6
|
-
import {
|
|
5
|
+
import { InfoBookAppendixHandlerAbstractRecipe, IRecipe } from "./InfoBookAppendixHandlerAbstractRecipe";
|
|
7
6
|
/**
|
|
8
7
|
* Handles crafting recipe appendices.
|
|
9
8
|
*/
|
|
10
|
-
export declare class InfoBookAppendixHandlerCraftingRecipe
|
|
11
|
-
private readonly resourceHandler;
|
|
12
|
-
private readonly registry;
|
|
13
|
-
private readonly registryTagged;
|
|
14
|
-
private readonly recipePredefineds;
|
|
9
|
+
export declare class InfoBookAppendixHandlerCraftingRecipe extends InfoBookAppendixHandlerAbstractRecipe<IRecipeCrafting> {
|
|
15
10
|
private readonly templateCraftingRecipe;
|
|
16
|
-
constructor(resourceHandler: ResourceHandler, registriesPath: string, recipeOverrides: any
|
|
17
|
-
|
|
18
|
-
protected serializeRecipe(recipe:
|
|
11
|
+
constructor(resourceHandler: ResourceHandler, registriesPath: string, recipeOverrides: any);
|
|
12
|
+
protected getRecipeNameUnlocalized(): string;
|
|
13
|
+
protected serializeRecipe(recipe: IRecipeCrafting, context: ISerializeContext, fileWriter: IFileWriter, serializer: HtmlInfoBookSerializer): string;
|
|
19
14
|
}
|
|
20
|
-
export interface
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
export interface IRecipe {
|
|
15
|
+
export interface IRecipeCrafting extends IRecipe {
|
|
16
|
+
id: string;
|
|
24
17
|
input: IItem[][];
|
|
25
18
|
output: IItem;
|
|
26
|
-
width
|
|
27
|
-
height
|
|
28
|
-
tags: string[];
|
|
29
|
-
}
|
|
30
|
-
export interface IRecipePredefineds {
|
|
31
|
-
[id: string]: IRecipe;
|
|
19
|
+
width?: number;
|
|
20
|
+
height?: number;
|
|
32
21
|
}
|
|
@@ -1,68 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const path_1 = require("path");
|
|
3
|
+
exports.InfoBookAppendixHandlerCraftingRecipe = void 0;
|
|
5
4
|
const pug_1 = require("pug");
|
|
5
|
+
const InfoBookAppendixHandlerAbstractRecipe_1 = require("./InfoBookAppendixHandlerAbstractRecipe");
|
|
6
6
|
/**
|
|
7
7
|
* Handles crafting recipe appendices.
|
|
8
8
|
*/
|
|
9
|
-
class InfoBookAppendixHandlerCraftingRecipe {
|
|
10
|
-
constructor(resourceHandler, registriesPath, recipeOverrides
|
|
11
|
-
|
|
12
|
-
this.registry = JSON.parse(fs.readFileSync(path_1.join(registriesPath, 'crafting_recipe.json'), "utf8"));
|
|
13
|
-
if (recipeOverrides) {
|
|
14
|
-
this.registry = Object.assign({}, this.registry, recipeOverrides);
|
|
15
|
-
}
|
|
16
|
-
this.recipePredefineds = recipePredefineds;
|
|
17
|
-
this.registryTagged = {};
|
|
18
|
-
for (const recipeId in this.registry) {
|
|
19
|
-
for (const recipe of this.registry[recipeId]) {
|
|
20
|
-
for (const tag of recipe.tags) {
|
|
21
|
-
let recipes = this.registryTagged[tag];
|
|
22
|
-
if (!recipes) {
|
|
23
|
-
recipes = this.registryTagged[tag] = [];
|
|
24
|
-
}
|
|
25
|
-
recipes.push(recipe);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
9
|
+
class InfoBookAppendixHandlerCraftingRecipe extends InfoBookAppendixHandlerAbstractRecipe_1.InfoBookAppendixHandlerAbstractRecipe {
|
|
10
|
+
constructor(resourceHandler, registriesPath, recipeOverrides) {
|
|
11
|
+
super('minecraft:crafting', resourceHandler, registriesPath, recipeOverrides);
|
|
29
12
|
this.templateCraftingRecipe = pug_1.compileFile(__dirname + '/../../../template/appendix/crafting_recipe.pug');
|
|
30
13
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// const meta = data.$.meta || 0;
|
|
34
|
-
// const count = data.$.count || 1;
|
|
35
|
-
const outputName = data._;
|
|
36
|
-
let recipes;
|
|
37
|
-
if (data.$.predefined) {
|
|
38
|
-
const predefined = this.recipePredefineds[outputName];
|
|
39
|
-
if (!predefined) {
|
|
40
|
-
throw new Error(`Could not find any predefined recipe for ${outputName}`);
|
|
41
|
-
}
|
|
42
|
-
recipes = [predefined];
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
recipes = this.registry[outputName];
|
|
46
|
-
if (!recipes) {
|
|
47
|
-
recipes = this.registryTagged['crafting_recipe:' + outputName];
|
|
48
|
-
index = -1;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
if (!recipes) {
|
|
52
|
-
throw new Error(`Could not find any recipe for ${outputName}`);
|
|
53
|
-
}
|
|
54
|
-
if (index > -1) {
|
|
55
|
-
if (index >= recipes.length) {
|
|
56
|
-
throw new Error(`Could not find recipe ${index} for ${outputName} that only has ${recipes.length} recipes.`);
|
|
57
|
-
}
|
|
58
|
-
recipes = [recipes[index]];
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
getName: (context) => this.resourceHandler.getTranslation('tile.workbench.name', context.language),
|
|
62
|
-
toHtml: (context, fileWriter, serializer) => {
|
|
63
|
-
return recipes.map((recipe) => this.serializeRecipe(recipe, context, fileWriter, serializer)).join('<hr />');
|
|
64
|
-
},
|
|
65
|
-
};
|
|
14
|
+
getRecipeNameUnlocalized() {
|
|
15
|
+
return 'block.minecraft.crafting_table';
|
|
66
16
|
}
|
|
67
17
|
serializeRecipe(recipe, context, fileWriter, serializer) {
|
|
68
18
|
// Prepare input array
|
|
@@ -83,7 +33,7 @@ class InfoBookAppendixHandlerCraftingRecipe {
|
|
|
83
33
|
items = [];
|
|
84
34
|
}
|
|
85
35
|
if (!items.length) {
|
|
86
|
-
items.push({ item: 'minecraft:air'
|
|
36
|
+
items.push({ item: 'minecraft:air' });
|
|
87
37
|
}
|
|
88
38
|
const outputIndex = y * 3 + x;
|
|
89
39
|
for (const item of items) {
|
|
@@ -92,7 +42,7 @@ class InfoBookAppendixHandlerCraftingRecipe {
|
|
|
92
42
|
}
|
|
93
43
|
}
|
|
94
44
|
const output = serializer.createItemDisplay(this.resourceHandler, context, fileWriter, recipe.output, true);
|
|
95
|
-
const appendixIcon = serializer.createItemDisplay(this.resourceHandler, context, fileWriter, { item: 'minecraft:crafting_table'
|
|
45
|
+
const appendixIcon = serializer.createItemDisplay(this.resourceHandler, context, fileWriter, { item: 'minecraft:crafting_table' }, false);
|
|
96
46
|
return this.templateCraftingRecipe({ inputs, output, appendixIcon });
|
|
97
47
|
}
|
|
98
48
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ResourceHandler } from "../../resource/ResourceHandler";
|
|
2
|
+
import { HtmlInfoBookSerializer, ISerializeContext } from "../../serialize/HtmlInfoBookSerializer";
|
|
3
|
+
import { IFileWriter } from "../IFileWriter";
|
|
4
|
+
import { IItem } from "../IItem";
|
|
5
|
+
import { InfoBookAppendixHandlerAbstractRecipe, IRecipe } from "./InfoBookAppendixHandlerAbstractRecipe";
|
|
6
|
+
/**
|
|
7
|
+
* Handles furnace recipe appendices.
|
|
8
|
+
*/
|
|
9
|
+
export declare class InfoBookAppendixHandlerSmeltingRecipe extends InfoBookAppendixHandlerAbstractRecipe<IRecipeSmelting> {
|
|
10
|
+
private readonly templateFurnaceRecipe;
|
|
11
|
+
constructor(resourceHandler: ResourceHandler, registriesPath: string, recipeOverrides: any);
|
|
12
|
+
protected getRecipeNameUnlocalized(): string;
|
|
13
|
+
protected serializeRecipe(recipe: IRecipeSmelting, context: ISerializeContext, fileWriter: IFileWriter, serializer: HtmlInfoBookSerializer): string;
|
|
14
|
+
}
|
|
15
|
+
export interface IRecipeSmelting extends IRecipe {
|
|
16
|
+
input: IItem[];
|
|
17
|
+
output: IItem;
|
|
18
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InfoBookAppendixHandlerSmeltingRecipe = void 0;
|
|
4
|
+
const pug_1 = require("pug");
|
|
5
|
+
const InfoBookAppendixHandlerAbstractRecipe_1 = require("./InfoBookAppendixHandlerAbstractRecipe");
|
|
6
|
+
/**
|
|
7
|
+
* Handles furnace recipe appendices.
|
|
8
|
+
*/
|
|
9
|
+
class InfoBookAppendixHandlerSmeltingRecipe extends InfoBookAppendixHandlerAbstractRecipe_1.InfoBookAppendixHandlerAbstractRecipe {
|
|
10
|
+
constructor(resourceHandler, registriesPath, recipeOverrides) {
|
|
11
|
+
super('minecraft:smelting', resourceHandler, registriesPath, recipeOverrides);
|
|
12
|
+
this.templateFurnaceRecipe = pug_1.compileFile(__dirname + '/../../../template/appendix/furnace_recipe.pug');
|
|
13
|
+
}
|
|
14
|
+
getRecipeNameUnlocalized() {
|
|
15
|
+
return 'block.minecraft.furnace';
|
|
16
|
+
}
|
|
17
|
+
serializeRecipe(recipe, context, fileWriter, serializer) {
|
|
18
|
+
const input = recipe.input.map((item) => serializer.createItemDisplay(this.resourceHandler, context, fileWriter, item, true));
|
|
19
|
+
const output = serializer.createItemDisplay(this.resourceHandler, context, fileWriter, recipe.output, true);
|
|
20
|
+
const appendixIcon = serializer.createItemDisplay(this.resourceHandler, context, fileWriter, { item: 'minecraft:furnace' }, false);
|
|
21
|
+
return this.templateFurnaceRecipe({ input, output, appendixIcon });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.InfoBookAppendixHandlerSmeltingRecipe = InfoBookAppendixHandlerSmeltingRecipe;
|
|
25
|
+
//# sourceMappingURL=InfoBookAppendixHandlerSmeltingRecipe.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InfoBookAppendixTagIndex = void 0;
|
|
3
4
|
const pug_1 = require("pug");
|
|
4
5
|
/**
|
|
5
6
|
* An appendix that lists all tags with links to them
|
|
@@ -15,13 +16,13 @@ class InfoBookAppendixTagIndex {
|
|
|
15
16
|
const url = context.sectionIndex.tags[tag];
|
|
16
17
|
// First try localizing as item, and if that fails, as fluid
|
|
17
18
|
let icon;
|
|
18
|
-
const item = { item: tag
|
|
19
|
+
const item = { item: tag };
|
|
19
20
|
let translationKey = this.resourceHandler.getItemTranslationKey(item);
|
|
20
21
|
if (translationKey) {
|
|
21
22
|
icon = serializer.createItemDisplay(this.resourceHandler, context, fileWriter, item, false);
|
|
22
23
|
}
|
|
23
24
|
else {
|
|
24
|
-
const fluid = { fluid: tag
|
|
25
|
+
const fluid = { fluid: tag };
|
|
25
26
|
translationKey = this.resourceHandler.getFluidTranslationKey(fluid);
|
|
26
27
|
icon = serializer.createFluidDisplay(this.resourceHandler, context, fileWriter, fluid, false);
|
|
27
28
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ModLoader = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
5
|
const child_process_1 = require("child_process");
|
|
5
6
|
const fs_1 = require("fs");
|
|
@@ -11,6 +12,7 @@ const path_1 = require("path");
|
|
|
11
12
|
const rimraf = require("rimraf");
|
|
12
13
|
const util_1 = require("util");
|
|
13
14
|
const yauzl_1 = require("yauzl");
|
|
15
|
+
const Path = require("path");
|
|
14
16
|
/**
|
|
15
17
|
* Takes care of installing Forge, installing mods, starting a Forge server, and fetching metadata.
|
|
16
18
|
*/
|
|
@@ -49,6 +51,9 @@ class ModLoader {
|
|
|
49
51
|
// Install Forge
|
|
50
52
|
process.stdout.write('Installing Forge...\n');
|
|
51
53
|
yield new Promise((resolve, reject) => child_process_1.exec(`cd ${this.path} && java -jar forge-installer.jar --installServer`).on('exit', resolve));
|
|
54
|
+
// Wait a bit, because otherwise some files don't exist yet (while they should...)
|
|
55
|
+
process.stdout.write('Wait a bit after Forge installation...\n');
|
|
56
|
+
yield new Promise((resolve) => setTimeout(resolve, 10000));
|
|
52
57
|
// Cleanup
|
|
53
58
|
process.stdout.write('Cleaning up...\n');
|
|
54
59
|
yield fs.promises.unlink(installerFile);
|
|
@@ -114,18 +119,25 @@ class ModLoader {
|
|
|
114
119
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
115
120
|
// Start the Forge server
|
|
116
121
|
process.stdout.write('Starting server...\n');
|
|
117
|
-
const proc = child_process_1.exec(`cd ${this.path} &&
|
|
122
|
+
const proc = child_process_1.exec(`cd ${this.path} && ./run.sh nogui`);
|
|
118
123
|
// Ignore stdout: proc.stdout.pipe(process.stdout);
|
|
119
124
|
proc.stderr.pipe(process.stderr);
|
|
120
125
|
const onDone = new Promise((resolve, reject) => {
|
|
121
|
-
proc.addListener('exit',
|
|
126
|
+
proc.addListener('exit', (code) => {
|
|
127
|
+
if (code === 0) {
|
|
128
|
+
resolve();
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
reject('Server closed with non-zero exit code');
|
|
132
|
+
}
|
|
133
|
+
});
|
|
122
134
|
proc.addListener('error', reject);
|
|
123
135
|
});
|
|
124
136
|
// Once the loading is complete, send our command and stop the server
|
|
125
137
|
proc.stdout.on('data', (line) => {
|
|
126
|
-
if (line.indexOf('[
|
|
138
|
+
if (line.indexOf('[Server thread/INFO]: Done') >= 0) {
|
|
127
139
|
process.stdout.write('Dumping registries...\n');
|
|
128
|
-
this.sendCommand(proc, '/
|
|
140
|
+
this.sendCommand(proc, '/cyclopscore dumpregistries');
|
|
129
141
|
this.sendCommand(proc, '/stop');
|
|
130
142
|
}
|
|
131
143
|
});
|
|
@@ -164,9 +176,14 @@ class ModLoader {
|
|
|
164
176
|
}
|
|
165
177
|
// Find Minecraft jar
|
|
166
178
|
let jar = null;
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
179
|
+
const subPath = Path.join(this.path, 'libraries', 'net', 'minecraft', 'server');
|
|
180
|
+
for (const dir of yield fs.promises.readdir(subPath)) {
|
|
181
|
+
if (dir.indexOf('-') > 0) {
|
|
182
|
+
for (const file of yield fs.promises.readdir(Path.join(subPath, dir))) {
|
|
183
|
+
if (file.startsWith('server') && file.endsWith('extra.jar')) {
|
|
184
|
+
jar = path_1.join(subPath, dir, file);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
170
187
|
}
|
|
171
188
|
}
|
|
172
189
|
// Error if no jar was found
|
|
@@ -221,8 +238,8 @@ class ModLoader {
|
|
|
221
238
|
}
|
|
222
239
|
else {
|
|
223
240
|
// File
|
|
224
|
-
if (entry.fileName.startsWith('assets/')) {
|
|
225
|
-
const targetFile = path_1.join(this.path, 'mod_assets', entry.fileName.substring(7, entry.fileName.length));
|
|
241
|
+
if (entry.fileName.startsWith('assets/') || entry.fileName.startsWith('data/')) {
|
|
242
|
+
const targetFile = path_1.join(this.path, 'mod_assets', entry.fileName.substring(entry.fileName.startsWith('assets/') ? 7 : 5, entry.fileName.length));
|
|
226
243
|
const targetDir = path_1.dirname(targetFile);
|
|
227
244
|
this.ensureDirExists(targetDir).then(() => {
|
|
228
245
|
zipFile.openReadStream(entry, (e, readStream) => {
|
|
@@ -26,20 +26,18 @@ export declare class ResourceHandler {
|
|
|
26
26
|
* Add an entry to a {@llink IItemKeyedRegistry}.
|
|
27
27
|
* @param {string} namespace The namespace.
|
|
28
28
|
* @param {string} path The path.
|
|
29
|
-
* @param {number} meta The meta.
|
|
30
29
|
* @param {string} nbt The NBT. (empty string represents no NBT)
|
|
31
30
|
* @param {string} value The value.
|
|
32
31
|
*/
|
|
33
|
-
protected static addItemKeyedRegistryEntry(registry: IItemKeyedRegistry, namespace: string, path: string,
|
|
32
|
+
protected static addItemKeyedRegistryEntry(registry: IItemKeyedRegistry, namespace: string, path: string, nbt: string, value: string): void;
|
|
34
33
|
/**
|
|
35
34
|
* Get an value from a {@llink IItemKeyedRegistry}.
|
|
36
35
|
* @param {string} namespace The namespace.
|
|
37
36
|
* @param {string} path The path.
|
|
38
|
-
* @param {number} meta The meta.
|
|
39
37
|
* @param {string} nbt The NBT. (empty string represents no NBT)
|
|
40
38
|
* @return The value.
|
|
41
39
|
*/
|
|
42
|
-
protected static getItemKeyedRegistryEntry(registry: IItemKeyedRegistry, namespace: string, path: string,
|
|
40
|
+
protected static getItemKeyedRegistryEntry(registry: IItemKeyedRegistry, namespace: string, path: string, nbt?: string): string;
|
|
43
41
|
/**
|
|
44
42
|
* @returns {string[]} All available language keys.
|
|
45
43
|
*/
|
|
@@ -75,19 +73,17 @@ export declare class ResourceHandler {
|
|
|
75
73
|
* Add an item icon file.
|
|
76
74
|
* @param {string} namespace The icon namespace.
|
|
77
75
|
* @param {string} path The icon path.
|
|
78
|
-
* @param {number} meta The icon meta.
|
|
79
76
|
* @param {string} nbt The icon NBT. (empty string represents no NBT)
|
|
80
77
|
* @param {string} file The icon file path.
|
|
81
78
|
*/
|
|
82
|
-
addItemIcon(namespace: string, path: string,
|
|
79
|
+
addItemIcon(namespace: string, path: string, nbt: string, file: string): void;
|
|
83
80
|
/**
|
|
84
81
|
* Get an item icon file.
|
|
85
82
|
* @param {string} itemId The icon namespace:path.
|
|
86
|
-
* @param {number} meta The icon meta.
|
|
87
83
|
* @param {string} nbt The icon NBT. (empty string represents no NBT)
|
|
88
84
|
* @return The icon file path or null.
|
|
89
85
|
*/
|
|
90
|
-
getItemIconFile(itemId: string,
|
|
86
|
+
getItemIconFile(itemId: string, nbt?: string): string;
|
|
91
87
|
/**
|
|
92
88
|
* Add a fluid icon file.
|
|
93
89
|
* @param {string} fluidName The fluid name.
|
|
@@ -152,9 +148,7 @@ export declare class ResourceHandler {
|
|
|
152
148
|
export interface IItemKeyedRegistry {
|
|
153
149
|
[namespace: string]: {
|
|
154
150
|
[path: string]: {
|
|
155
|
-
[
|
|
156
|
-
[nbt: string]: string;
|
|
157
|
-
};
|
|
151
|
+
[nbt: string]: string;
|
|
158
152
|
};
|
|
159
153
|
};
|
|
160
154
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResourceHandler = void 0;
|
|
3
4
|
const path_1 = require("path");
|
|
4
5
|
/**
|
|
5
6
|
* Allows Minecraft resources to be used.
|
|
@@ -30,22 +31,17 @@ class ResourceHandler {
|
|
|
30
31
|
* Add an entry to a {@llink IItemKeyedRegistry}.
|
|
31
32
|
* @param {string} namespace The namespace.
|
|
32
33
|
* @param {string} path The path.
|
|
33
|
-
* @param {number} meta The meta.
|
|
34
34
|
* @param {string} nbt The NBT. (empty string represents no NBT)
|
|
35
35
|
* @param {string} value The value.
|
|
36
36
|
*/
|
|
37
|
-
static addItemKeyedRegistryEntry(registry, namespace, path,
|
|
37
|
+
static addItemKeyedRegistryEntry(registry, namespace, path, nbt, value) {
|
|
38
38
|
let paths = registry[namespace];
|
|
39
39
|
if (!paths) {
|
|
40
40
|
paths = registry[namespace] = {};
|
|
41
41
|
}
|
|
42
|
-
let
|
|
43
|
-
if (!metas) {
|
|
44
|
-
metas = paths[path] = {};
|
|
45
|
-
}
|
|
46
|
-
let nbts = metas[meta];
|
|
42
|
+
let nbts = paths[path];
|
|
47
43
|
if (!nbts) {
|
|
48
|
-
nbts =
|
|
44
|
+
nbts = paths[path] = {};
|
|
49
45
|
}
|
|
50
46
|
nbts[nbt] = value;
|
|
51
47
|
}
|
|
@@ -53,20 +49,15 @@ class ResourceHandler {
|
|
|
53
49
|
* Get an value from a {@llink IItemKeyedRegistry}.
|
|
54
50
|
* @param {string} namespace The namespace.
|
|
55
51
|
* @param {string} path The path.
|
|
56
|
-
* @param {number} meta The meta.
|
|
57
52
|
* @param {string} nbt The NBT. (empty string represents no NBT)
|
|
58
53
|
* @return The value.
|
|
59
54
|
*/
|
|
60
|
-
static getItemKeyedRegistryEntry(registry, namespace, path,
|
|
55
|
+
static getItemKeyedRegistryEntry(registry, namespace, path, nbt = '') {
|
|
61
56
|
const paths = registry[namespace];
|
|
62
57
|
if (!paths) {
|
|
63
58
|
return null;
|
|
64
59
|
}
|
|
65
|
-
const
|
|
66
|
-
if (!metas) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
const nbts = metas[meta];
|
|
60
|
+
const nbts = paths[path];
|
|
70
61
|
if (!nbts) {
|
|
71
62
|
return null;
|
|
72
63
|
}
|
|
@@ -149,23 +140,21 @@ class ResourceHandler {
|
|
|
149
140
|
* Add an item icon file.
|
|
150
141
|
* @param {string} namespace The icon namespace.
|
|
151
142
|
* @param {string} path The icon path.
|
|
152
|
-
* @param {number} meta The icon meta.
|
|
153
143
|
* @param {string} nbt The icon NBT. (empty string represents no NBT)
|
|
154
144
|
* @param {string} file The icon file path.
|
|
155
145
|
*/
|
|
156
|
-
addItemIcon(namespace, path,
|
|
157
|
-
ResourceHandler.addItemKeyedRegistryEntry(this.iconsItem, namespace, path,
|
|
146
|
+
addItemIcon(namespace, path, nbt, file) {
|
|
147
|
+
ResourceHandler.addItemKeyedRegistryEntry(this.iconsItem, namespace, path, nbt, file);
|
|
158
148
|
}
|
|
159
149
|
/**
|
|
160
150
|
* Get an item icon file.
|
|
161
151
|
* @param {string} itemId The icon namespace:path.
|
|
162
|
-
* @param {number} meta The icon meta.
|
|
163
152
|
* @param {string} nbt The icon NBT. (empty string represents no NBT)
|
|
164
153
|
* @return The icon file path or null.
|
|
165
154
|
*/
|
|
166
|
-
getItemIconFile(itemId,
|
|
155
|
+
getItemIconFile(itemId, nbt = '') {
|
|
167
156
|
const { namespace, path } = ResourceHandler.splitItemId(itemId);
|
|
168
|
-
return ResourceHandler.getItemKeyedRegistryEntry(this.iconsItem, namespace, path,
|
|
157
|
+
return ResourceHandler.getItemKeyedRegistryEntry(this.iconsItem, namespace, path, nbt);
|
|
169
158
|
}
|
|
170
159
|
/**
|
|
171
160
|
* Add a fluid icon file.
|
|
@@ -181,7 +170,7 @@ class ResourceHandler {
|
|
|
181
170
|
* @return The icon file path or null.
|
|
182
171
|
*/
|
|
183
172
|
getFluidIconFile(fluidName) {
|
|
184
|
-
return this.iconsFluid[fluidName];
|
|
173
|
+
return this.iconsFluid[fluidName.replace(':', '__')];
|
|
185
174
|
}
|
|
186
175
|
/**
|
|
187
176
|
* Add an item translation key.
|
|
@@ -190,7 +179,7 @@ class ResourceHandler {
|
|
|
190
179
|
*/
|
|
191
180
|
addItemTranslationKey(item, translationKey) {
|
|
192
181
|
const { namespace, path } = ResourceHandler.splitItemId(item.item);
|
|
193
|
-
ResourceHandler.addItemKeyedRegistryEntry(this.itemTranslationKeys, namespace, path, item.
|
|
182
|
+
ResourceHandler.addItemKeyedRegistryEntry(this.itemTranslationKeys, namespace, path, item.nbt, translationKey);
|
|
194
183
|
}
|
|
195
184
|
/**
|
|
196
185
|
* Get an item translation key.
|
|
@@ -199,7 +188,7 @@ class ResourceHandler {
|
|
|
199
188
|
*/
|
|
200
189
|
getItemTranslationKey(item) {
|
|
201
190
|
const { namespace, path } = ResourceHandler.splitItemId(item.item);
|
|
202
|
-
return ResourceHandler.getItemKeyedRegistryEntry(this.itemTranslationKeys, namespace, path, item.
|
|
191
|
+
return ResourceHandler.getItemKeyedRegistryEntry(this.itemTranslationKeys, namespace, path, item.nbt);
|
|
203
192
|
}
|
|
204
193
|
/**
|
|
205
194
|
* Add an fluid translation key.
|
|
@@ -264,9 +253,9 @@ class ResourceHandler {
|
|
|
264
253
|
return keybinding;
|
|
265
254
|
}
|
|
266
255
|
}
|
|
256
|
+
exports.ResourceHandler = ResourceHandler;
|
|
267
257
|
ResourceHandler.TRANSLATION_DEFAULTS = {
|
|
268
258
|
'fluid.tile.lava': 'Lava',
|
|
269
259
|
'fluid.tile.water': 'Water',
|
|
270
260
|
};
|
|
271
|
-
exports.ResourceHandler = ResourceHandler;
|
|
272
261
|
//# sourceMappingURL=ResourceHandler.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResourceLoader = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
5
|
const fs_1 = require("fs");
|
|
5
6
|
const path_1 = require("path");
|
|
@@ -33,14 +34,16 @@ class ResourceLoader {
|
|
|
33
34
|
else {
|
|
34
35
|
const split = iconName.split("__");
|
|
35
36
|
const namespace = split[0];
|
|
36
|
-
|
|
37
|
-
const meta = parseInt(split[2], 10);
|
|
37
|
+
let path = split[1];
|
|
38
38
|
let nbt = '';
|
|
39
|
-
if (split.length >
|
|
40
|
-
nbt = split.slice(
|
|
39
|
+
if (split.length > 2) {
|
|
40
|
+
nbt = split.slice(2, split.length).join(":");
|
|
41
41
|
nbt = nbt.substr(0, nbt.length - 4);
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
else {
|
|
44
|
+
path = path.substr(0, path.length - 4);
|
|
45
|
+
}
|
|
46
|
+
this.resourceHandler.addItemIcon(namespace, path, nbt, iconFile);
|
|
44
47
|
}
|
|
45
48
|
}
|
|
46
49
|
});
|
|
@@ -158,16 +161,7 @@ class ResourceLoader {
|
|
|
158
161
|
*/
|
|
159
162
|
loadAssetsLangFile(modid, language, fullFilePath) {
|
|
160
163
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
161
|
-
const translations =
|
|
162
|
-
const lines = (yield fs_1.promises.readFile(fullFilePath)).toString('utf8').split('\n');
|
|
163
|
-
for (const line of lines) {
|
|
164
|
-
if (line.length > 0 && line[0] !== '#') {
|
|
165
|
-
const separatorIndex = line.indexOf('=');
|
|
166
|
-
const key = line.substr(0, separatorIndex);
|
|
167
|
-
const value = line.substr(separatorIndex + 1);
|
|
168
|
-
translations[key] = value;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
164
|
+
const translations = JSON.parse((yield fs_1.promises.readFile(fullFilePath)).toString('utf8'));
|
|
171
165
|
this.resourceHandler.addTranslations(language, translations);
|
|
172
166
|
});
|
|
173
167
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HtmlInfoBookSerializer = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
5
|
const fs_1 = require("fs");
|
|
5
6
|
const mkdirp = require("mkdirp");
|
|
@@ -21,7 +22,7 @@ class HtmlInfoBookSerializer {
|
|
|
21
22
|
}
|
|
22
23
|
serialize(infobook, context, assetsPaths) {
|
|
23
24
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
context = Object.assign({}, context, { basePath: context.path, breadcrumbs: [] });
|
|
25
|
+
context = Object.assign(Object.assign({}, context), { basePath: context.path, breadcrumbs: [] });
|
|
25
26
|
this.fileWriter = new FileWriter_1.FileWriter(context);
|
|
26
27
|
yield this.ensureDirExists(context.path);
|
|
27
28
|
yield this.ensureDirExists(path_1.join(context.path, 'assets'));
|
|
@@ -50,7 +51,7 @@ class HtmlInfoBookSerializer {
|
|
|
50
51
|
urlIndex: {},
|
|
51
52
|
};
|
|
52
53
|
let pageIndex = 0;
|
|
53
|
-
yield this.serializeSection(infobook.rootSection, Object.assign({}, contextRoot, { language, path: langPath }), ({ index, section, sectionTitle, fileUrl, breadcrumbs }) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
yield this.serializeSection(infobook.rootSection, Object.assign(Object.assign({}, contextRoot), { language, path: langPath }), ({ index, section, sectionTitle, fileUrl, breadcrumbs }) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
54
55
|
if (!index) {
|
|
55
56
|
sectionIndex.urlIndex[fileUrl] = pageIndex++;
|
|
56
57
|
const name = breadcrumbs.slice(1).map((b) => b.name).join(' / ');
|
|
@@ -68,7 +69,7 @@ class HtmlInfoBookSerializer {
|
|
|
68
69
|
}
|
|
69
70
|
serializeSectionFiles(infobook, contextRoot, language, langPath, sectionIndex) {
|
|
70
71
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
yield this.serializeSection(infobook.rootSection, Object.assign({}, contextRoot, { language, path: langPath, sectionIndex }), ({ index, breadcrumbs, context, section, sectionTitle, subSectionDatas, filePath, fileUrl }) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
yield this.serializeSection(infobook.rootSection, Object.assign(Object.assign({}, contextRoot), { language, path: langPath, sectionIndex }), ({ index, breadcrumbs, context, section, sectionTitle, subSectionDatas, filePath, fileUrl }) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
72
73
|
// Create links to this page in other languages
|
|
73
74
|
const languages = [];
|
|
74
75
|
for (const name of contextRoot.resourceHandler.getLanguages()) {
|
|
@@ -79,7 +80,7 @@ class HtmlInfoBookSerializer {
|
|
|
79
80
|
}
|
|
80
81
|
if (index) {
|
|
81
82
|
// Create index file
|
|
82
|
-
const fileContents = this.templateIndex(Object.assign({}, context, { breadcrumbs, headSuffix: context.headSuffixGetters.map((g) => g(context)).join(''), languages,
|
|
83
|
+
const fileContents = this.templateIndex(Object.assign(Object.assign({}, context), { breadcrumbs, headSuffix: context.headSuffixGetters.map((g) => g(context)).join(''), languages,
|
|
83
84
|
sectionTitle,
|
|
84
85
|
subSectionDatas }));
|
|
85
86
|
yield fs_1.promises.writeFile(filePath, fileContents);
|
|
@@ -97,7 +98,7 @@ class HtmlInfoBookSerializer {
|
|
|
97
98
|
appendices.unshift(new InfoBookAppendixAd_1.InfoBookAppendixAd());
|
|
98
99
|
}
|
|
99
100
|
// Create leaf file
|
|
100
|
-
const fileContents = this.templateSection(Object.assign({}, context, { breadcrumbs, headSuffix: context.headSuffixGetters.map((g) => g(context)).join(''), languages,
|
|
101
|
+
const fileContents = this.templateSection(Object.assign(Object.assign({}, context), { breadcrumbs, headSuffix: context.headSuffixGetters.map((g) => g(context)).join(''), languages,
|
|
101
102
|
nextPage,
|
|
102
103
|
previousPage, sectionAppendices: appendices
|
|
103
104
|
.filter((appendix) => appendix) // TODO: rm
|
|
@@ -128,7 +129,7 @@ class HtmlInfoBookSerializer {
|
|
|
128
129
|
// Go in a subfolder when we are handling a different mod
|
|
129
130
|
if (section.modId !== context.modId) {
|
|
130
131
|
yield this.ensureDirExists(path_1.join(context.path, section.modId));
|
|
131
|
-
context = Object.assign({}, context, { modId: section.modId, path: path_1.join(context.path, section.modId) });
|
|
132
|
+
context = Object.assign(Object.assign({}, context), { modId: section.modId, path: path_1.join(context.path, section.modId) });
|
|
132
133
|
}
|
|
133
134
|
if (section.subSections && section.subSections.length > 0) {
|
|
134
135
|
// Navigation section
|
|
@@ -140,9 +141,9 @@ class HtmlInfoBookSerializer {
|
|
|
140
141
|
url: fileUrl,
|
|
141
142
|
}]);
|
|
142
143
|
for (const subSection of section.subSections) {
|
|
143
|
-
const subSectionData = yield this.serializeSection(subSection, Object.assign({}, context, { breadcrumbs: subBreadcrumbs, path: path_1.join(context.path, subSection.nameTranslationKey
|
|
144
|
+
const subSectionData = yield this.serializeSection(subSection, Object.assign(Object.assign({}, context), { breadcrumbs: subBreadcrumbs, path: path_1.join(context.path, subSection.nameTranslationKey
|
|
144
145
|
.substr(subSection.nameTranslationKey.lastIndexOf('.') + 1)), root: false }), onSection);
|
|
145
|
-
subSectionDatas.push(Object.assign({}, subSectionData, { url: this.filePathToUrl(subSectionData.filePath, context.basePath, context.baseUrl) }));
|
|
146
|
+
subSectionDatas.push(Object.assign(Object.assign({}, subSectionData), { url: this.filePathToUrl(subSectionData.filePath, context.basePath, context.baseUrl) }));
|
|
146
147
|
}
|
|
147
148
|
const filePath = path_1.join(context.path, 'index.html');
|
|
148
149
|
yield onSection({ index: true, breadcrumbs, context, sectionTitle, section, subSectionDatas, filePath, fileUrl });
|
|
@@ -176,7 +177,7 @@ class HtmlInfoBookSerializer {
|
|
|
176
177
|
if (item.item === 'minecraft:air') {
|
|
177
178
|
return slot ? '<div class="item item-slot"> </div>' : '<div class="item"> </div>';
|
|
178
179
|
}
|
|
179
|
-
const icon = resourceHandler.getItemIconFile(item.item, item.
|
|
180
|
+
const icon = resourceHandler.getItemIconFile(item.item, item.nbt);
|
|
180
181
|
if (!icon) {
|
|
181
182
|
throw new Error(`Could not find an icon for item ${JSON.stringify(item)}`);
|
|
182
183
|
}
|
|
@@ -186,7 +187,7 @@ class HtmlInfoBookSerializer {
|
|
|
186
187
|
throw new Error(`Could not find translation key for item ${JSON.stringify(item)}`);
|
|
187
188
|
}
|
|
188
189
|
const { link, linkTarget } = this.createResourceLink(resourceHandler, context, item.item, key);
|
|
189
|
-
return this.templateItem(Object.assign({}, context, { annotation, count: item.count || 1, icon: iconUrl, link,
|
|
190
|
+
return this.templateItem(Object.assign(Object.assign({}, context), { annotation, count: item.count || 1, icon: iconUrl, link,
|
|
190
191
|
linkTarget, name: resourceHandler.getTranslation(resourceHandler.getItemTranslationKey(item), context.language), slot }));
|
|
191
192
|
}
|
|
192
193
|
createFluidDisplay(resourceHandler, context, fileWriter, fluid, slot) {
|
|
@@ -200,16 +201,11 @@ class HtmlInfoBookSerializer {
|
|
|
200
201
|
throw new Error(`Could not find translation key for fluid ${JSON.stringify(fluid)}`);
|
|
201
202
|
}
|
|
202
203
|
const { link, linkTarget } = this.createResourceLink(resourceHandler, context, this.tagFluid(context, fluid.fluid), key);
|
|
203
|
-
return this.templateItem(Object.assign({}, context, { count: (fluid.amount || 1), icon: iconUrl, link,
|
|
204
|
+
return this.templateItem(Object.assign(Object.assign({}, context), { count: (fluid.amount || 1), icon: iconUrl, link,
|
|
204
205
|
linkTarget, name: resourceHandler.getTranslation(resourceHandler.getFluidTranslationKey(fluid), context.language), slot }));
|
|
205
206
|
}
|
|
206
207
|
tagFluid(context, fluidName) {
|
|
207
|
-
|
|
208
|
-
return 'minecraft:' + fluidName;
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
return context.modId + ':' + fluidName;
|
|
212
|
-
}
|
|
208
|
+
return fluidName;
|
|
213
209
|
}
|
|
214
210
|
getLanguagePath(language, path) {
|
|
215
211
|
path = path || '';
|
|
@@ -267,7 +263,7 @@ class HtmlInfoBookSerializer {
|
|
|
267
263
|
filePathToUrl(filePath, basePath, baseUrl) {
|
|
268
264
|
let url = filePath.replace(basePath, baseUrl);
|
|
269
265
|
const last = path_1.basename(url);
|
|
270
|
-
if (last.indexOf('.') < 0) {
|
|
266
|
+
if (!url.endsWith('/') && last.indexOf('.') < 0) {
|
|
271
267
|
url = url + '/';
|
|
272
268
|
}
|
|
273
269
|
return url;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cyclops-infobook-html",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Output Cyclops infobooks as HTML",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": "git@github.com:CyclopsMC/infobook-html.git",
|
|
@@ -50,16 +50,16 @@
|
|
|
50
50
|
"testEnvironment": "node"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@types/jest": "^
|
|
53
|
+
"@types/jest": "^26.0.0",
|
|
54
54
|
"@types/minimist": "^1.2.0",
|
|
55
55
|
"coveralls": "^3.0.3",
|
|
56
|
-
"jest": "^
|
|
56
|
+
"jest": "^26.0.0",
|
|
57
57
|
"manual-git-changelog": "^1.0.1",
|
|
58
58
|
"pre-commit": "^1.2.2",
|
|
59
|
-
"ts-jest": "^
|
|
60
|
-
"tslint": "^
|
|
59
|
+
"ts-jest": "^26.0.0",
|
|
60
|
+
"tslint": "^6.0.0",
|
|
61
61
|
"tslint-eslint-rules": "^5.4.0",
|
|
62
|
-
"typescript": "^
|
|
62
|
+
"typescript": "^4.0.0"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"test": "jest ${1}",
|
|
@@ -75,19 +75,19 @@
|
|
|
75
75
|
"dependencies": {
|
|
76
76
|
"@types/mkdirp": "^0.5.2",
|
|
77
77
|
"@types/ncp": "^2.0.1",
|
|
78
|
-
"@types/node": "^
|
|
78
|
+
"@types/node": "^13.1.0",
|
|
79
79
|
"@types/node-fetch": "^2.5.0",
|
|
80
80
|
"@types/pug": "^2.0.4",
|
|
81
|
-
"@types/rimraf": "^
|
|
81
|
+
"@types/rimraf": "^3.0.0",
|
|
82
82
|
"@types/xml2js": "^0.4.4",
|
|
83
83
|
"@types/yauzl": "^2.9.1",
|
|
84
84
|
"minimist": "^1.2.0",
|
|
85
85
|
"mkdirp": "^0.5.1",
|
|
86
|
-
"mvn-artifact-download": "^
|
|
86
|
+
"mvn-artifact-download": "^5.0.0",
|
|
87
87
|
"ncp": "^2.0.0",
|
|
88
88
|
"node-fetch": "^2.6.0",
|
|
89
|
-
"pug": "^
|
|
90
|
-
"rimraf": "^
|
|
89
|
+
"pug": "^3.0.0",
|
|
90
|
+
"rimraf": "^3.0.0",
|
|
91
91
|
"xml2js": "^0.4.19",
|
|
92
92
|
"yauzl": "^2.10.0"
|
|
93
93
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
footer
|
|
2
2
|
p Generated with <a href="https://github.com/CyclopsMC/infobook-html" target="blank">cyclops-infobook-html</a>.
|
|
3
|
-
p <a href="https://www.rubensworks.net/">Ruben Taelman</a> © 2019
|
|
3
|
+
p <a href="https://www.rubensworks.net/">Ruben Taelman</a> © 2019-now
|
|
4
4
|
script(src="/assets/main.js")
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ResourceHandler } from "../../resource/ResourceHandler";
|
|
2
|
-
import { IInfoAppendix } from "../IInfoAppendix";
|
|
3
|
-
import { IItem } from "../IItem";
|
|
4
|
-
import { IInfoBookAppendixHandler } from "./IInfoBookAppendixHandler";
|
|
5
|
-
/**
|
|
6
|
-
* Handles furnace recipe appendices.
|
|
7
|
-
*/
|
|
8
|
-
export declare class InfoBookAppendixHandlerFurnaceRecipe implements IInfoBookAppendixHandler {
|
|
9
|
-
private readonly resourceHandler;
|
|
10
|
-
private readonly registry;
|
|
11
|
-
private readonly templateFurnaceRecipe;
|
|
12
|
-
constructor(resourceHandler: ResourceHandler, registriesPath: string);
|
|
13
|
-
createAppendix(data: any): IInfoAppendix;
|
|
14
|
-
}
|
|
15
|
-
export interface IRecipeFurnace {
|
|
16
|
-
input: IItem[];
|
|
17
|
-
output: IItem;
|
|
18
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const pug_1 = require("pug");
|
|
6
|
-
/**
|
|
7
|
-
* Handles furnace recipe appendices.
|
|
8
|
-
*/
|
|
9
|
-
class InfoBookAppendixHandlerFurnaceRecipe {
|
|
10
|
-
constructor(resourceHandler, registriesPath) {
|
|
11
|
-
this.resourceHandler = resourceHandler;
|
|
12
|
-
this.registry = JSON.parse(fs.readFileSync(path_1.join(registriesPath, 'furnace_recipe.json'), "utf8")).elements;
|
|
13
|
-
this.templateFurnaceRecipe = pug_1.compileFile(__dirname + '/../../../template/appendix/furnace_recipe.pug');
|
|
14
|
-
}
|
|
15
|
-
createAppendix(data) {
|
|
16
|
-
// const meta = data.$.meta || 0;
|
|
17
|
-
// const count = data.$.count || 1;
|
|
18
|
-
const outputName = data._;
|
|
19
|
-
let recipe;
|
|
20
|
-
for (const recipeIt of this.registry) {
|
|
21
|
-
if (recipeIt.output.item === outputName) {
|
|
22
|
-
recipe = recipeIt;
|
|
23
|
-
break;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (!recipe) {
|
|
27
|
-
throw new Error(`Could not find any recipe for ${outputName}`);
|
|
28
|
-
}
|
|
29
|
-
return {
|
|
30
|
-
getName: (context) => this.resourceHandler.getTranslation('tile.furnace.name', context.language),
|
|
31
|
-
toHtml: (context, fileWriter, serializer) => {
|
|
32
|
-
const input = recipe.input.map((item) => serializer.createItemDisplay(this.resourceHandler, context, fileWriter, item, true));
|
|
33
|
-
const output = serializer.createItemDisplay(this.resourceHandler, context, fileWriter, recipe.output, true);
|
|
34
|
-
const appendixIcon = serializer.createItemDisplay(this.resourceHandler, context, fileWriter, { item: 'minecraft:furnace', data: 0 }, false);
|
|
35
|
-
return this.templateFurnaceRecipe({ input, output, appendixIcon });
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.InfoBookAppendixHandlerFurnaceRecipe = InfoBookAppendixHandlerFurnaceRecipe;
|
|
41
|
-
//# sourceMappingURL=InfoBookAppendixHandlerFurnaceRecipe.js.map
|