Skip to content

Commit

Permalink
Merge pull request #17 from TheMrZZ/develop
Browse files Browse the repository at this point in the history
 Fix recipes not being saved in the correct folder
  • Loading branch information
TheMrZZ authored Oct 4, 2020
2 parents 4a98c4a + 71e536a commit 171b2d7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sandstone",
"version": "0.4.2",
"version": "0.4.3",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
"license": "MIT",
Expand Down
6 changes: 3 additions & 3 deletions src/_internals/datapack/resourcesTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export type ResourceTypeMap = {
advancements: AdvancementResource
predicates: PredicateResource
loot_tables: LootTableResource
recipe: RecipeResource
recipes: RecipeResource
}

export type ResourceOnlyTypeMap = {
Expand All @@ -69,7 +69,7 @@ export type ResourceOnlyTypeMap = {
advancements: File<AdvancementProperties>
predicates: File<PredicateProperties>
loot_tables: File<LootTableProperties>
recipe: File<RecipeProperties>
recipes: File<RecipeProperties>
}

/**
Expand Down Expand Up @@ -103,7 +103,7 @@ export class ResourcesTree {
advancements: new Map(),
predicates: new Map(),
loot_tables: new Map(),
recipe: new Map(),
recipes: new Map(),
}

this.namespaces.set(name, namespaceResource)
Expand Down
4 changes: 2 additions & 2 deletions src/_internals/datapack/saveDatapack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ export function saveDatapack(resources: ResourcesTree, name: string, options: Sa
}

// Save recipe
for (const r of n.recipe.values()) {
for (const r of n.recipes.values()) {
saveResource(
dataPath, 'recipe', r, options,
dataPath, 'recipes', r, options,
(resource) => JSON.stringify(resource.recipe, null, 2),
(namespace, folders, fileName) => `Recipe ${namespace}:${[...folders, fileName].join('/')}`,
)
Expand Down
2 changes: 1 addition & 1 deletion src/_internals/resources/Recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class Recipe<P1 extends string, P2 extends string, P3 extends string> {

this.path = datapack.getResourcePath(name)

this.datapack.addResource(name, 'recipe', { recipe })
this.datapack.addResource(name, 'recipes', { recipe })
}

get name() {
Expand Down
15 changes: 2 additions & 13 deletions tests/test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
execute, gamerule, raw, say, tellraw,
execute, gamerule, give, raw, say, tellraw,
} from '../src/commands'
import {
mcfunction, Recipe, saveDatapack, _,
Expand All @@ -14,18 +14,7 @@ Recipe('test', {
})

mcfunction('cc', () => {
raw('mount', 'cc')
give(Selector('@s', { scores: { xx: [0, 1] } }), 'minecraft:blue_ice')
})

saveDatapack('My datapack', { verbose: true, world: 'Crea1_15' })

/*
Added Recipe, raw command, and updated README
@TheMrZZ TheMrZZ released this now
Added Recipe, a raw command that can be used to create custom commands, and updated README.
Github Releases will now automatically be published to NPM.
*/

0 comments on commit 171b2d7

Please sign in to comment.