Skip to content

Commit ccf3702

Browse files
committed
- better spash and lingering models
1 parent 0bf520f commit ccf3702

File tree

15 files changed

+199
-55
lines changed

15 files changed

+199
-55
lines changed

common/src/main/java/smartin/miapi/client/modelrework/BakedMiapiModel.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@ public void render(MatrixStack matrices, ItemStack stack, ModelTransformationMod
5252
model = model.getOverrides().apply(model, stack, MinecraftClient.getInstance().world, entity, light);
5353
}
5454
VertexConsumer consumer = modelholder.colorProvider.getConsumer(vertexConsumers);
55+
Color color = modelholder.colorProvider.getVertexColor();
5556

5657
int lightValue = transformationMode == ModelTransformationMode.GUI ? LightmapTextureManager.MAX_LIGHT_COORDINATE : LightmapTextureManager.MAX_SKY_LIGHT_COORDINATE;
5758
model.getQuads(null, direction, Random.create()).forEach(bakedQuad -> {
58-
consumer.quad(matrices.peek(), bakedQuad, 1, 1, 1, lightValue, overlay);
59+
consumer.quad(matrices.peek(), bakedQuad, color.redAsFloat(), color.greenAsFloat(), color.blueAsFloat(), lightValue, overlay);
5960
});
6061
immediate.draw();
6162
MinecraftClient.getInstance().world.getProfiler().pop();

common/src/main/java/smartin/miapi/modules/properties/material/MaterialInscribeProperty.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public static ItemStack inscribe(ItemStack raw, ItemStack materialStack) {
2525
materialStack = materialStack.copy();
2626
materialStack.setCount(1);
2727
compound.put(element.getAsString(), materialStack.writeNbt(new NbtCompound()));
28+
compound.copyFrom(materialStack.getOrCreateNbt());
2829
raw.setNbt(compound);
2930
}
3031
return raw;

common/src/main/java/smartin/miapi/modules/properties/render/colorproviders/ColorProvider.java

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package smartin.miapi.modules.properties.render.colorproviders;
22

3+
import com.redpxnda.nucleus.util.Color;
34
import net.minecraft.client.render.RenderLayers;
45
import net.minecraft.client.render.VertexConsumer;
56
import net.minecraft.client.render.VertexConsumerProvider;
67
import net.minecraft.item.ItemStack;
8+
import net.minecraft.potion.PotionUtil;
79
import smartin.miapi.modules.ItemModule;
810
import smartin.miapi.modules.properties.material.Material;
911
import smartin.miapi.modules.properties.material.MaterialProperty;
@@ -19,13 +21,17 @@ public interface ColorProvider {
1921
static void setup() {
2022
colorProviders.put("material", new MaterialColorProvider());
2123
colorProviders.put("model", new ModelColorProvider());
22-
24+
colorProviders.put("potion", new PotionColorProvider());
2325
}
2426

2527
static ColorProvider getProvider(String type, ItemStack itemStack, ItemModule.ModuleInstance moduleInstance) {
2628
return colorProviders.getOrDefault(type, colorProviders.get("material")).getInstance(itemStack, moduleInstance);
2729
}
2830

31+
default Color getVertexColor() {
32+
return Color.WHITE;
33+
}
34+
2935
VertexConsumer getConsumer(VertexConsumerProvider vertexConsumers);
3036

3137
ColorProvider getInstance(ItemStack stack, ItemModule.ModuleInstance instance);
@@ -75,4 +81,33 @@ public ColorProvider getInstance(ItemStack stack, ItemModule.ModuleInstance inst
7581
return new ModelColorProvider(stack);
7682
}
7783
}
84+
85+
class PotionColorProvider implements ColorProvider {
86+
Color potioncolor;
87+
ItemStack stack;
88+
89+
public PotionColorProvider() {
90+
91+
}
92+
93+
public PotionColorProvider(ItemStack stack) {
94+
potioncolor = new Color(PotionUtil.getColor(stack));
95+
this.stack = stack;
96+
}
97+
98+
@Override
99+
public Color getVertexColor() {
100+
return potioncolor;
101+
}
102+
103+
@Override
104+
public VertexConsumer getConsumer(VertexConsumerProvider vertexConsumers) {
105+
return vertexConsumers.getBuffer(RenderLayers.getItemLayer(stack, true));
106+
}
107+
108+
@Override
109+
public ColorProvider getInstance(ItemStack stack, ItemModule.ModuleInstance instance) {
110+
return new PotionColorProvider(stack);
111+
}
112+
}
78113
}

common/src/main/resources/assets/miapi/lang/en_us.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"config.miapi_server": "Server Config",
3+
"config.miapi_server.other": "Development",
4+
"config.miapi_server.enchants": "Enchantments",
25
"miapi.ui.craft.back": "Back",
36
"miapi.ui.back": "Back",
47
"miapi.ui.craft": "Craft",
@@ -194,7 +197,8 @@
194197
"miapi.material.custom.ender_pearl": "Ender Pearl ",
195198
"miapi.material.custom.gunpowder": "Gunpowder ",
196199
"miapi.material.custom.ice": "Ice ",
197-
"miapi.material.custom.potion": "Potion ",
200+
"miapi.material.custom.splash_potion": "Splash Potion ",
201+
"miapi.material.custom.lingering_potion": "Lingering Potion ",
198202
"miapi.material.custom.tnt": "TNT ",
199203

200204
"block.miapi.modular_work_bench": "Modular Workbench",
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"parent": "item/generated",
3+
"textures": {
4+
"layer0": "miapi:item/arrow/head/custom/lingering_potion"
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"parent": "item/generated",
3+
"textures": {
4+
"layer0": "miapi:item/arrow/head/custom/splash_potion_overlay"
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"parent": "item/generated",
3+
"textures": {
4+
"layer0": "miapi:item/arrow/head/custom/potion"
5+
}
6+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"key": "lingering_potion",
3+
"translation": "miapi.material.custom.lingering_potion",
4+
"icon": "textures/item/potion.png",
5+
"items": [
6+
{
7+
"item": "minecraft:lingering_potion",
8+
"value": 1.0
9+
}
10+
]
11+
}

common/src/main/resources/data/miapi/materials/custom/potion.json

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"key": "splash_potion",
3+
"translation": "miapi.material.custom.splash_potion",
4+
"icon": "textures/item/potion.png",
5+
"items": [
6+
{
7+
"item": "minecraft:splash_potion",
8+
"value": 1.0
9+
}
10+
]
11+
}

common/src/main/resources/data/miapi/modules/arrow/head/arrow_custom_head.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"chorus_fruit",
3636
"tnt",
3737
"gunpowder",
38-
"potion",
38+
"splash_potion",
39+
"lingering_potion",
3940
"lightning_rod",
4041
"ice"
4142
],
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"arrow_head_custom": {
3+
"condition": {
4+
"type": "material",
5+
"material": "lingering_potion"
6+
},
7+
"properties": {
8+
"inscribe_on_craft": "POTION",
9+
"replace_projectile": "POTION",
10+
"texture": [
11+
{
12+
"path": "miapi:models/item/arrow/head/normal/lingering_potion.json",
13+
"color_provider": "model",
14+
"transform": {
15+
"rotation": {
16+
"x": 0.0,
17+
"y": 0.0,
18+
"z": 0.0
19+
},
20+
"translation": {
21+
"x": -0.01,
22+
"y": -0.01,
23+
"z": 0.0
24+
},
25+
"scale": {
26+
"x": 1.0,
27+
"y": 1.0,
28+
"z": 1.0
29+
}
30+
}
31+
},
32+
{
33+
"path": "miapi:models/item/arrow/head/normal/potion_overlay.json",
34+
"color_provider": "potion",
35+
"transform": {
36+
"rotation": {
37+
"x": 0.0,
38+
"y": 0.0,
39+
"z": 0.0
40+
},
41+
"translation": {
42+
"x": -0.01,
43+
"y": -0.01,
44+
"z": 0.0
45+
},
46+
"scale": {
47+
"x": 1.0,
48+
"y": 1.0,
49+
"z": 1.0
50+
}
51+
}
52+
}
53+
]
54+
}
55+
}
56+
}

common/src/main/resources/data/miapi/synergies/arrow/head/custom/potion.json

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"arrow_head_custom": {
3+
"condition": {
4+
"type": "material",
5+
"material": "splash_potion"
6+
},
7+
"properties": {
8+
"inscribe_on_craft": "POTION",
9+
"replace_projectile": "POTION",
10+
"texture": [
11+
{
12+
"path": "miapi:models/item/arrow/head/normal/splash_potion.json",
13+
"color_provider": "model",
14+
"transform": {
15+
"rotation": {
16+
"x": 0.0,
17+
"y": 0.0,
18+
"z": 0.0
19+
},
20+
"translation": {
21+
"x": -0.01,
22+
"y": -0.01,
23+
"z": 0.0
24+
},
25+
"scale": {
26+
"x": 1.0,
27+
"y": 1.0,
28+
"z": 1.0
29+
}
30+
}
31+
},
32+
{
33+
"path": "miapi:models/item/arrow/head/normal/potion_overlay.json",
34+
"color_provider": "potion",
35+
"transform": {
36+
"rotation": {
37+
"x": 0.0,
38+
"y": 0.0,
39+
"z": 0.0
40+
},
41+
"translation": {
42+
"x": -0.01,
43+
"y": -0.01,
44+
"z": 0.0
45+
},
46+
"scale": {
47+
"x": 1.0,
48+
"y": 1.0,
49+
"z": 1.0
50+
}
51+
}
52+
}
53+
]
54+
}
55+
}
56+
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx3G
33
minecraft_version=1.20.1
44

55
archives_base_name=miapi
6-
mod_version=0.6.3-SNAPSHOT
6+
mod_version=0.6.5-SNAPSHOT
77
maven_group=smartin
88

99
architectury_version=9.0.8

0 commit comments

Comments
 (0)