Move curios into the main bworld mod

This commit is contained in:
2026-10-01 16:48:40 -03:00
parent 3dc7d2adee
commit a7835261e1
31 changed files with 170 additions and 159 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
"texture": "artifacts:feral_claws",
"max_stack": 1,
"components": {
"curios:attribute_modifiers": [
"bworld:curio_modifiers": [
{ "attribute": "bworld:attack_speed", "amount": 0.3, "operation": "add_multiplied_base" }
]
}
+1 -1
View File
@@ -5,7 +5,7 @@
"texture": "artifacts:power_glove",
"max_stack": 1,
"components": {
"curios:attribute_modifiers": [
"bworld:curio_modifiers": [
{ "attribute": "bworld:attack_damage", "amount": 4, "operation": "add_value" }
]
}
+1 -5
View File
@@ -2,7 +2,7 @@
"format_version": 1,
"id": "artifacts",
"name": "Artifacts",
"description": "A port of ochotonida's Artifacts: wearable items worn in Curios slots.",
"description": "A port of ochotonida's Artifacts: wearable items worn in the curios slots.",
"version": "0.1.0",
"authors": [
"ochotonida (original)",
@@ -13,10 +13,6 @@
{
"id": "bworld",
"version": "*"
},
{
"id": "curios",
"version": "*"
}
],
"credits": "CREDITS.md"
+23
View File
@@ -719,3 +719,26 @@ Textures by Hugh "XSSheep" Rutland (https://www.minecraftforum.net/members/XSShe
https://github.com/NovaWostra/Pixel-Perfection-Chorus-Eddit
license: [Creative Commons Attribution-Share Alike 4.0 International](http://creativecommons.org/licenses/by-sa/4.0/)
# Curios
The curios slots (`scripts/curios.ts`) are a port of [Curios](https://github.com/TheIllusiveC4/Curios) by C4. Their slot
textures (`textures/empty_*_slot.png`) and game design come from the original, version 17.0.0-beta.2 for NeoForge 26.3,
under the GNU Lesser General Public License, version 3 or later:
```
Copyright (C) 2018-2024 C4
Curios is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Curios is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Curios. If not, see <https://www.gnu.org/licenses/>.
```
+44
View File
@@ -5,3 +5,47 @@ item behavior from `scripts/server.ts`, the same way it loads any other mod.
Some of the base game is still built into the engine: recipe types, the inventory screen and crafting grid, the HUD,
`/give` and `/time`, mining rules, and terrain generation. See "The Engine and the Base Game" in `docs/modding_plan.md`.
## Curios
`scripts/curios.ts` is a port of [Curios](https://github.com/TheIllusiveC4/Curios): accessory slots, like rings,
necklaces and belts, for any mod's items. They're in 2 columns left of the player's inventory, there whenever it's open.
Shift clicking a curio in the inventory puts it in the first slot it fits.
Like the original, it adds no items, and a slot type only shows up once some mod puts an item in its tag.
### Making an Item a Curio
Add the item to the slot type's item tag. For a ring, `tags/items/bworld/curios/ring.json` in your mod:
```json
{ "format_version": 1, "tag": { "values": ["jewelry:gold_ring"] } }
```
| Tag | Slot |
| ------------------------- | ---------------------- |
| `#bworld:curios/curio` | Any slot, and its own. |
| `#bworld:curios/head` | Head |
| `#bworld:curios/necklace` | Necklace |
| `#bworld:curios/back` | Back |
| `#bworld:curios/body` | Body |
| `#bworld:curios/bracelet` | Bracelet |
| `#bworld:curios/hands` | Hands |
| `#bworld:curios/ring` | Ring |
| `#bworld:curios/belt` | Belt |
| `#bworld:curios/feet` | Feet |
| `#bworld:curios/charm` | Charm |
Every player has one slot of each type. Curios drop when the player dies, like the rest of what they carry.
### Attribute Modifiers
An item with the `bworld:curio_modifiers` component changes the wearer's
[attributes](../../docs/modding/entities/players.md#attributes) while it's in a curio slot, and says so in its tooltip.
The Power Glove from Artifacts:
```json
"components": {
"bworld:curio_modifiers": [{ "attribute": "bworld:attack_damage", "amount": 4, "operation": "add_value" }]
}
```
@@ -1,27 +1,25 @@
// curios: accessory slots, in 2 columns left of the player's inventory. each player's curios are a
// container of their own, and fall out when they die like the rest of what they carry. items with the
// curios:attribute_modifiers component change the wearer's attributes, like curios' attribute modifiers
import type { AttributeModifier, Container, Player, ServerContext } from "bworld/server";
import { active_slots, fits, SLOTS } from "./slots.ts";
// curios, from C4's Curios mod: accessory slots, in 2 columns left of the player's inventory. each player's curios are
// a container of their own, and fall out when they die like the rest of what they carry. items with the
// bworld:curio_modifiers component change the wearer's attributes, like curios' attribute modifiers
import type { AttributeModifier, Container, Player, ServerContext, TagApi } from "bworld/server";
// where the left column of slots goes, from the inventory screen's left edge. the panel around them ends just left of it
const COLUMNS_X = -45;
// curios:attribute_modifiers' params, a list of these
// bworld:curio_modifiers' params, a list of these
interface WornModifier {
attribute: string;
amount: number;
operation: AttributeModifier["operation"];
}
export function setup(ctx: ServerContext) {
export function register_curios(ctx: ServerContext) {
const active = active_slots(ctx.tags);
ctx.components.register_item<WornModifier[]>("curios:attribute_modifiers", {
ctx.components.register_item<WornModifier[]>("bworld:curio_modifiers", {
get_lore: (_item, modifiers) => ["When worn:", ...modifiers.map(describe)].join("\n"),
});
const modifiers_of = (id: string) =>
(ctx.items.components(id)["curios:attribute_modifiers"] ?? []) as WornModifier[];
const modifiers_of = (id: string) => (ctx.items.components(id)["bworld:curio_modifiers"] ?? []) as WornModifier[];
// the modifiers each online player's curios gave them, by player id, to take them off again
const applied = new Map<string, { attribute: string; id: string }[]>();
@@ -29,7 +27,7 @@ export function setup(ctx: ServerContext) {
// by player name, like the players themselves are saved. undefined until they first join with curios
function saved_curios(player: Player): Container | undefined {
const id = ctx.storage.get<Record<string, string>>("containers")?.[player.name];
const id = ctx.storage.get<Record<string, string>>("curios")?.[player.name];
return id ? ctx.containers.get(id) : undefined;
}
@@ -37,8 +35,8 @@ export function setup(ctx: ServerContext) {
const existing = saved_curios(player);
if (existing) return existing;
const container = ctx.containers.create(SLOTS.length);
const ids = ctx.storage.get<Record<string, string>>("containers") ?? {};
ctx.storage.set("containers", { ...ids, [player.name]: container.id });
const ids = ctx.storage.get<Record<string, string>>("curios") ?? {};
ctx.storage.set("curios", { ...ids, [player.name]: container.id });
watch(player, container);
return container;
}
@@ -57,7 +55,7 @@ export function setup(ctx: ServerContext) {
const item = curios.get(index);
if (!item || !active.includes(slot)) continue;
for (const [i, { attribute, amount, operation }] of modifiers_of(item.id).entries()) {
const id = `curios:${slot}/${i}`;
const id = `bworld:curio/${slot}/${i}`;
player.add_modifier(attribute, { id, amount, operation });
now.push({ attribute, id });
}
@@ -79,7 +77,8 @@ export function setup(ctx: ServerContext) {
ctx.menus.extend_player_menu((menu, player) => {
if (active.length === 0) return;
const curios = curios_of(player);
// what's in slot types no item goes in anymore, since the mod that added them was removed, goes back to them
// what's in slot types no item goes in anymore, since the mod that put items in them was removed, goes back
// to them
for (const [index, slot] of SLOTS.entries()) {
const item = curios.get(index);
if (item && !active.includes(slot)) {
@@ -92,7 +91,7 @@ export function setup(ctx: ServerContext) {
x: COLUMNS_X + (i % 2) * 18,
y: 7 + Math.floor(i / 2) * 18,
filter: (item) => fits(ctx.tags, slot, item.id),
icon: `curios:empty_${slot}_slot`,
icon: `bworld:empty_${slot}_slot`,
});
}
});
@@ -118,3 +117,30 @@ function describe({ attribute, amount, operation }: WornModifier): string {
const value = operation === "add_value" ? `${Math.abs(amount)}` : `${Math.round(Math.abs(amount) * 100)}%`;
return `${sign}${value} ${name}`;
}
// the slot types, in curios' order. every player has one of each, at its index here in their curios container, so
// slots keep their items when mods come and go
const SLOTS = [
"curio",
"head",
"necklace",
"back",
"body",
"bracelet",
"hands",
"ring",
"belt",
"feet",
"charm",
];
// like curios, a slot type is only there once some item goes in it: something is in its item tag, #bworld:curios/ring
// for rings
function active_slots(tags: TagApi): string[] {
return SLOTS.filter((slot) => tags.get("items", `bworld:curios/${slot}`).length > 0);
}
// curios' tag validator: an item goes in the slot types whose tag it's in, and #bworld:curios/curio items go in any
function fits(tags: TagApi, slot: string, id: string): boolean {
return tags.has("items", `bworld:curios/${slot}`, id) || tags.has("items", "bworld:curios/curio", id);
}
+2
View File
@@ -1,5 +1,6 @@
// the base game's block and item behavior, written against the same api as any other mod
import type { BlockRef, Container, EntityRef, Player, ServerContext } from "bworld/server";
import { register_curios } from "./curios.ts";
export function setup(ctx: ServerContext) {
register_hoeable(ctx);
@@ -8,6 +9,7 @@ export function setup(ctx: ServerContext) {
register_smithing_table(ctx);
register_farming(ctx);
register_fishing(ctx);
register_curios(ctx);
}
// right clicking with a type of tool turns the block into another, like any hoe on grass

Before

Width:  |  Height:  |  Size: 145 B

After

Width:  |  Height:  |  Size: 145 B

Before

Width:  |  Height:  |  Size: 144 B

After

Width:  |  Height:  |  Size: 144 B

Before

Width:  |  Height:  |  Size: 152 B

After

Width:  |  Height:  |  Size: 152 B

Before

Width:  |  Height:  |  Size: 157 B

After

Width:  |  Height:  |  Size: 157 B

Before

Width:  |  Height:  |  Size: 139 B

After

Width:  |  Height:  |  Size: 139 B

Before

Width:  |  Height:  |  Size: 140 B

After

Width:  |  Height:  |  Size: 140 B

Before

Width:  |  Height:  |  Size: 149 B

After

Width:  |  Height:  |  Size: 149 B

Before

Width:  |  Height:  |  Size: 158 B

After

Width:  |  Height:  |  Size: 158 B

Before

Width:  |  Height:  |  Size: 157 B

After

Width:  |  Height:  |  Size: 157 B

Before

Width:  |  Height:  |  Size: 152 B

After

Width:  |  Height:  |  Size: 152 B

Before

Width:  |  Height:  |  Size: 144 B

After

Width:  |  Height:  |  Size: 144 B

-21
View File
@@ -1,21 +0,0 @@
# Curios
A bworld port of [Curios](https://github.com/TheIllusiveC4/Curios) by C4. Its slot textures and game design come from
the original, version 17.0.0-beta.2 for NeoForge 26.3, under the GNU Lesser General Public License, version 3 or later:
```
Copyright (C) 2018-2024 C4
Curios is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Curios is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Curios. If not, see <https://www.gnu.org/licenses/>.
```
-46
View File
@@ -1,46 +0,0 @@
# Curios
A port of [Curios](https://github.com/TheIllusiveC4/Curios): accessory slots, like rings, necklaces and belts, for any
mod's items. They're in 2 columns left of the player's inventory, there whenever it's open. Shift clicking a curio in
the inventory puts it in the first slot it fits.
Like the original, Curios adds no items and no slots of its own. A slot type only shows up once some mod puts an item in
its tag.
## Making an Item a Curio
Add the item to the slot type's item tag. For a ring, `tags/items/curios/ring.json` in your mod:
```json
{ "format_version": 1, "tag": { "values": ["jewelry:gold_ring"] } }
```
| Tag | Slot |
| ------------------ | ---------------------- |
| `#curios:curio` | Any slot, and its own. |
| `#curios:head` | Head |
| `#curios:necklace` | Necklace |
| `#curios:back` | Back |
| `#curios:body` | Body |
| `#curios:bracelet` | Bracelet |
| `#curios:hands` | Hands |
| `#curios:ring` | Ring |
| `#curios:belt` | Belt |
| `#curios:feet` | Feet |
| `#curios:charm` | Charm |
Every player has one slot of each type. Curios drop when the player dies, like the rest of what they carry.
## Attribute Modifiers
An item with the `curios:attribute_modifiers` component changes the wearer's
[attributes](../../docs/modding/entities/players.md#attributes) while it's in a curio slot, and says so in its tooltip.
The Power Glove from Artifacts:
```json
"components": {
"curios:attribute_modifiers": [{ "attribute": "bworld:attack_damage", "amount": 4, "operation": "add_value" }]
}
```
Depend on `curios` to use it.
-16
View File
@@ -1,16 +0,0 @@
{
"format_version": 1,
"id": "curios",
"name": "Curios",
"description": "A port of C4's Curios: accessory slots like rings, necklaces and belts, for any mod's items.",
"version": "0.1.0",
"authors": [
"C4 (original)",
"paula (port)"
],
"game_version": ">=0.1.0",
"credits": "CREDITS.md",
"scripts": {
"server": "scripts/server.ts"
}
}
-29
View File
@@ -1,29 +0,0 @@
// curios' slot types
import type { TagApi } from "bworld/server";
// in curios' order. every player has one of each, at its index here in their curios container, so slots keep their
// items when mods come and go
export const SLOTS = [
"curio",
"head",
"necklace",
"back",
"body",
"bracelet",
"hands",
"ring",
"belt",
"feet",
"charm",
];
// like curios, a slot type is only there once some item goes in it: something is in its item tag, #curios:ring for
// rings
export function active_slots(tags: TagApi): string[] {
return SLOTS.filter((slot) => tags.get("items", `curios:${slot}`).length > 0);
}
// curios' tag validator: an item goes in the slot types whose tag it's in, and #curios:curio items go in any
export function fits(tags: TagApi, slot: string, id: string): boolean {
return tags.has("items", `curios:${slot}`, id) || tags.has("items", "curios:curio", id);
}