Tint soup item contents with the blended recipe color

This commit is contained in:
2026-09-06 11:45:41 +03:00
parent 1f08010db6
commit 2687e4d47c
13 changed files with 209 additions and 35 deletions
@@ -2,11 +2,13 @@ package online.astradev.soups;
import io.papermc.paper.datacomponent.DataComponentTypes;
import io.papermc.paper.datacomponent.item.Consumable;
import io.papermc.paper.datacomponent.item.CustomModelData;
import io.papermc.paper.datacomponent.item.FoodProperties;
import io.papermc.paper.datacomponent.item.UseRemainder;
import io.papermc.paper.datacomponent.item.consumable.ConsumeEffect;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextDecoration;
@@ -366,6 +368,25 @@ public final class Ingredients {
item.setItemMeta(meta);
changed = true;
}
int rgb = meta.getPersistentDataContainer().getOrDefault(
new NamespacedKey("astrasoups", "soup_color"),
PersistentDataType.INTEGER, 0xB77A36);
Key model = Key.key("astradev_soups", "combined_soup");
if (!Objects.equals(item.getData(DataComponentTypes.ITEM_MODEL), model)) {
item.setData(DataComponentTypes.ITEM_MODEL, model);
changed = true;
}
CustomModelData data = item.getData(DataComponentTypes.CUSTOM_MODEL_DATA);
Color tint = Color.fromRGB(rgb & 0xFFFFFF);
if (data == null || data.colors().isEmpty() || !data.colors().getFirst().equals(tint)) {
var builder = CustomModelData.customModelData().addColor(tint);
if (data != null) {
builder.addFloats(data.floats()).addFlags(data.flags()).addStrings(data.strings());
builder.addColors(data.colors().stream().skip(1).toList());
}
item.setData(DataComponentTypes.CUSTOM_MODEL_DATA, builder.build());
changed = true;
}
}
return changed;
}
@@ -0,0 +1,13 @@
{
"model": {
"type": "minecraft:composite",
"models": [
{ "type": "minecraft:model", "model": "minecraft:item/bowl" },
{
"type": "minecraft:model",
"model": "astradev_soups:item/soup_liquid",
"tints": [{ "type": "minecraft:custom_model_data", "index": 0, "default": 12024374 }]
}
]
}
}
@@ -0,0 +1,37 @@
{
"gui_light": "front",
"textures": {
"white": "minecraft:item/bone_meal",
"particle": "minecraft:item/bowl"
},
"display": {
"ground": { "translation": [0, 2, 0], "scale": [0.5, 0.5, 0.5] },
"head": { "rotation": [0, 180, 0], "translation": [0, 13, 7] },
"thirdperson_righthand": { "translation": [0, 3, 1], "scale": [0.55, 0.55, 0.55] },
"firstperson_righthand": { "rotation": [0, -90, 25], "translation": [1.13, 3.2, 1.13], "scale": [0.68, 0.68, 0.68] },
"fixed": { "rotation": [0, 180, 0] }
},
"elements": [
{
"from": [5, 9, 7.49], "to": [11, 10, 8.51], "shade": false,
"faces": {
"north": { "uv": [4.4, 3.4, 4.6, 3.6], "texture": "#white", "tintindex": 0 },
"south": { "uv": [4.4, 3.4, 4.6, 3.6], "texture": "#white", "tintindex": 0 }
}
},
{
"from": [3, 8, 7.49], "to": [13, 9, 8.51], "shade": false,
"faces": {
"north": { "uv": [4.4, 3.4, 4.6, 3.6], "texture": "#white", "tintindex": 0 },
"south": { "uv": [4.4, 3.4, 4.6, 3.6], "texture": "#white", "tintindex": 0 }
}
},
{
"from": [4, 7, 7.49], "to": [12, 8, 8.51], "shade": false,
"faces": {
"north": { "uv": [4.4, 3.4, 4.6, 3.6], "texture": "#white", "tintindex": 0 },
"south": { "uv": [4.4, 3.4, 4.6, 3.6], "texture": "#white", "tintindex": 0 }
}
}
]
}
+3
View File
@@ -0,0 +1,3 @@
schema=1
plugin=AstraSoups
folder=astradev_soups
+1 -1
View File
@@ -4,7 +4,7 @@ main: online.astradev.soups.AstraSoupsPlugin
api-version: '26.2'
description: Four-ingredient cauldron soups with food and potion properties
author: AstraDev
softdepend: [ItemsAdder]
depend: [AstraPacks, ItemsAdder]
commands:
soups:
description: Комбинированные супы