-
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.
- Loading branch information
Showing
11 changed files
with
435 additions
and
327 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "vendor/treasure-disks"] | ||
path = vendor/treasure-disks | ||
url = https://github.com/cc-tweaked/treasure-disks.git |
Large diffs are not rendered by default.
Oops, something went wrong.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Version, type PackItem } from "."; | ||
|
||
import icon from "../assets/treasure.png"; | ||
|
||
export type TreasureDisk = { | ||
author: string, | ||
name: string, | ||
colour: number, | ||
files: Record<string, string>, | ||
} | ||
|
||
let diskCache: TreasureDisk[] | null = null; | ||
|
||
const treasure: PackItem = { | ||
name: "Treasure Disks", | ||
description: "Add all of ComputerCraft's old treasure disks.", | ||
icon, | ||
iconAlt: "A blue ComputerCraft floppy disk.", | ||
process: async output => { | ||
// We store the disks locally to avoid awaits on later actions, which allows the | ||
// render to be instant. | ||
const disks = diskCache ?? (diskCache = (await import("virtual:treasure-disks")).default); | ||
|
||
const pool = []; | ||
for (const { author, name, colour, files } of disks) { | ||
for (const [file, contents] of Object.entries(files)) { | ||
output.data("computercraft", `lua/treasure/${author}/${name}/${file}`, contents) | ||
} | ||
|
||
const title = `${name} by ${author}`; | ||
const path = `${author}/${name}`; | ||
|
||
pool.push({ | ||
type: "minecraft:item", | ||
name: "computercraft:treasure_disk", | ||
functions: [ | ||
output.version >= Version.MC_1_20_6 ? { | ||
function: "minecraft:set_components", | ||
components: { | ||
"computercraft:treasure_disk": { name: title, path }, | ||
"minecraft:dyed_color": { rgb: colour, show_in_tooltip: false } | ||
} | ||
} : { | ||
function: "minecraft:set_nbt", | ||
tag: JSON.stringify({ "Title": title, "SubPath": path, "Colour": colour }) | ||
} | ||
], | ||
}) | ||
} | ||
|
||
output.data("computercraft", output.version >= Version.MC_1_21 ? "loot_table/treasure_disk.json" : "loot_tables/treasure_disk.json", { | ||
pools: [{ | ||
name: "main", | ||
rolls: 1, | ||
entries: pool, | ||
}] | ||
}); | ||
}, | ||
}; | ||
|
||
export default treasure; |
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
Submodule treasure-disks
added at
60d1b0
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