-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- regex checking - Registries are now also a Resource
- Loading branch information
Showing
20 changed files
with
162 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
import { isIntInRange, isObject, safeValidateProperty } from "../util/typecheck.js" | ||
import { NamespacedId } from "../util/interfaces.js" | ||
import TexturedResource from "./TexturedResource.js" | ||
import YSON from "https://j0code.github.io/yson/YSON.js" | ||
|
||
export default class ItemDef extends TexturedResource { | ||
|
||
readonly maxItemStack: number | ||
|
||
constructor(namespace: string, idname: string, data: unknown) { | ||
super(namespace, idname) | ||
constructor(id: NamespacedId, data: unknown) { | ||
super(id) | ||
if (!isObject(data) || !safeValidateProperty(data, "maxItemStack", isIntInRange(1, 9999), 128)) { | ||
throw new Error(`Invalid itemdef for ${namespace}:${idname}: ${JSON.stringify(data)}`) | ||
throw new Error(`Invalid itemdef for ${id}: ${YSON.stringify(data)}`) | ||
} | ||
|
||
this.maxItemStack = data.maxItemStack as number || 128 | ||
} | ||
|
||
get assetsPath() { | ||
return `${this.namespace}/textures/item/${this.idname}.png` | ||
return `${this.id.namespace}/textures/item/${this.id.path}.png` | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,12 @@ | ||
import { type NamespacedId } from "../util/interfaces.js" | ||
import { NamespacedId } from "../util/interfaces.js" | ||
import ResourceLocation from "../util/ResourceLocation.js" | ||
|
||
export default class Resource { | ||
|
||
readonly namespace: string | ||
readonly idname: string | ||
readonly id: ResourceLocation | ||
|
||
constructor(namespace: string, idname: string) { | ||
this.namespace = namespace | ||
this.idname = idname | ||
} | ||
|
||
get id(): NamespacedId { | ||
return `${this.namespace}:${this.idname}` | ||
constructor(id: NamespacedId) { | ||
this.id = new ResourceLocation(id) | ||
} | ||
|
||
} |
Oops, something went wrong.