Curios slots rendering !
This commit is contained in:
@@ -742,3 +742,33 @@ 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/>.
|
||||
```
|
||||
|
||||
# The Undergarden
|
||||
|
||||
The giant chestplate's textures (`textures/giant_chestplate.png` and `textures/giant_chestplate_worn.png`) are utherium
|
||||
armor's from [The Undergarden](https://github.com/quek04/undergarden) by quek, the 26.1 branch for NeoForge, which its
|
||||
`neoforge.mods.toml` declares as MIT licensed:
|
||||
|
||||
```
|
||||
MIT License
|
||||
|
||||
Copyright (c) quek
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
```
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"id": "bworld:giant_chestplate",
|
||||
"texture": "bworld:giant_chestplate",
|
||||
"max_stack": 1,
|
||||
"worn": { "model": "bworld:giant_chestplate", "texture": "bworld:giant_chestplate_worn" },
|
||||
"components": {
|
||||
"bworld:curio_modifiers": [
|
||||
{ "attribute": "bworld:max_health", "amount": 20, "operation": "add_value" }
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"format_version": "1.12.0",
|
||||
"minecraft:geometry": [
|
||||
{
|
||||
"description": {
|
||||
"identifier": "geometry.bworld.giant_chestplate",
|
||||
"texture_width": 64,
|
||||
"texture_height": 32
|
||||
},
|
||||
"bones": [
|
||||
{
|
||||
"name": "body",
|
||||
"pivot": [0, 24, 0],
|
||||
"cubes": [{ "origin": [-4, 12, -2], "size": [8, 12, 4], "uv": [16, 16], "inflate": 1 }]
|
||||
},
|
||||
{
|
||||
"name": "right_arm",
|
||||
"pivot": [-5, 22, 0],
|
||||
"cubes": [{ "origin": [-8, 12, -2], "size": [4, 12, 4], "uv": [40, 16], "inflate": 1 }]
|
||||
},
|
||||
{
|
||||
"name": "left_arm",
|
||||
"pivot": [5, 22, 0],
|
||||
"cubes": [{ "origin": [4, 12, -2], "size": [4, 12, 4], "uv": [40, 16], "inflate": 1 }]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
// 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";
|
||||
import type { AttributeModifier, Container, ItemStack, 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;
|
||||
@@ -43,16 +43,19 @@ export function register_curios(ctx: ServerContext) {
|
||||
// keeps what their curios give them up to date
|
||||
function watch(player: Player, curios: Container) {
|
||||
stop_watching.get(player.id)?.();
|
||||
stop_watching.set(player.id, curios.on_change(() => update_modifiers(player, curios)));
|
||||
update_modifiers(player, curios);
|
||||
stop_watching.set(player.id, curios.on_change(() => apply_worn(player, curios)));
|
||||
apply_worn(player, curios);
|
||||
}
|
||||
|
||||
function update_modifiers(player: Player, curios: Container) {
|
||||
// what they wear: its attribute modifiers, and its worn model on them for everyone to see
|
||||
function apply_worn(player: Player, curios: Container) {
|
||||
for (const { attribute, id } of applied.get(player.id) ?? []) player.remove_modifier(attribute, id);
|
||||
const now: { attribute: string; id: string }[] = [];
|
||||
const worn: ItemStack[] = [];
|
||||
for (const [index, slot] of SLOTS.entries()) {
|
||||
const item = curios.get(index);
|
||||
if (!item || !active.includes(slot)) continue;
|
||||
worn.push(item);
|
||||
for (const [i, { attribute, amount, operation }] of modifiers_of(item.id).entries()) {
|
||||
const id = `bworld:curio/${slot}/${i}`;
|
||||
player.add_modifier(attribute, { id, amount, operation });
|
||||
@@ -60,6 +63,7 @@ export function register_curios(ctx: ServerContext) {
|
||||
}
|
||||
}
|
||||
applied.set(player.id, now);
|
||||
player.set_worn("bworld:curios", worn);
|
||||
}
|
||||
|
||||
ctx.events.after.player_leave.subscribe(({ player }) => {
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
Reference in New Issue
Block a user