Skip to content

Commit b6d890e

Browse files
committed
Add lama renderer to choose lama-model based on variant and chest
1 parent 9947a77 commit b6d890e

File tree

6 files changed

+95
-3
lines changed

6 files changed

+95
-3
lines changed

core/src/main/java/de/bluecolored/bluemap/core/map/hires/entity/EntityRendererType.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@ public interface EntityRendererType extends Keyed, EntityRendererFactory {
4040
EntityRendererType DEFAULT = new Impl(Key.bluemap("default"), ResourceModelRenderer::new);
4141
EntityRendererType MISSING = new Impl(Key.bluemap("missing"), MissingModelRenderer::new);
4242

43+
EntityRendererType LLAMA = new Impl(Key.minecraft("llama"), LlamaRenderer::new);
44+
4345
Registry<EntityRendererType> REGISTRY = new Registry<>(
4446
DEFAULT,
45-
MISSING
47+
MISSING,
48+
LLAMA
4649
);
4750

4851
/**
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package de.bluecolored.bluemap.core.map.hires.entity;
2+
3+
import de.bluecolored.bluemap.core.map.TextureGallery;
4+
import de.bluecolored.bluemap.core.map.hires.RenderSettings;
5+
import de.bluecolored.bluemap.core.map.hires.TileModelView;
6+
import de.bluecolored.bluemap.core.resources.ResourcePath;
7+
import de.bluecolored.bluemap.core.resources.pack.resourcepack.ResourcePack;
8+
import de.bluecolored.bluemap.core.resources.pack.resourcepack.entitystate.Part;
9+
import de.bluecolored.bluemap.core.resources.pack.resourcepack.model.Model;
10+
import de.bluecolored.bluemap.core.util.Key;
11+
import de.bluecolored.bluemap.core.world.Entity;
12+
import de.bluecolored.bluemap.core.world.block.BlockNeighborhood;
13+
import de.bluecolored.bluemap.core.world.mca.entity.Llama;
14+
15+
public class LlamaRenderer extends ResourceModelRenderer {
16+
17+
private final ResourcePath<Model>
18+
LAMA_CREAMY = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/llama/llama_creamy"),
19+
LAMA_WHITE = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/llama/llama_white"),
20+
LAMA_BROWN = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/llama/llama_brown"),
21+
LAMA_GRAY = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/llama/llama_gray"),
22+
LAMA_CHEST_CREAMY = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/llama/llama_chest_creamy"),
23+
LAMA_CHEST_WHITE = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/llama/llama_chest_white"),
24+
LAMA_CHEST_BROWN = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/llama/llama_chest_brown"),
25+
LAMA_CHEST_GRAY = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/llama/llama_chest_gray");
26+
27+
public LlamaRenderer(ResourcePack resourcePack, TextureGallery textureGallery, RenderSettings renderSettings) {
28+
super(resourcePack, textureGallery, renderSettings);
29+
}
30+
31+
@Override
32+
public void render(Entity entity, BlockNeighborhood block, Part part, TileModelView tileModel) {
33+
if (!(entity instanceof Llama llama)) return;
34+
35+
// choose correct model
36+
ResourcePath<Model> model;
37+
if (llama.isWithChest()) {
38+
model = switch (llama.getVariant()) {
39+
case CREAMY -> LAMA_CHEST_CREAMY;
40+
case WHITE -> LAMA_CHEST_WHITE;
41+
case BROWN -> LAMA_CHEST_BROWN;
42+
case GRAY -> LAMA_CHEST_GRAY;
43+
};
44+
} else {
45+
model = switch (llama.getVariant()) {
46+
case CREAMY -> LAMA_CREAMY;
47+
case WHITE -> LAMA_WHITE;
48+
case BROWN -> LAMA_BROWN;
49+
case GRAY -> LAMA_GRAY;
50+
};
51+
}
52+
53+
// render chosen model
54+
super.render(entity, block, model.getResource(resourcePack::getModel), TintColorProvider.NO_TINT, tileModel);
55+
56+
// apply part transform
57+
if (part.isTransformed())
58+
tileModel.transform(part.getTransformMatrix());
59+
}
60+
61+
}

core/src/main/java/de/bluecolored/bluemap/core/world/mca/entity/EntityType.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@
3333

3434
public interface EntityType extends Keyed {
3535

36-
Registry<EntityType> REGISTRY = new Registry<>();
36+
EntityType LLAMA = new Impl(Key.minecraft("llama"), Llama.class);
37+
38+
Registry<EntityType> REGISTRY = new Registry<>(
39+
LLAMA
40+
);
3741

3842
Class<? extends Entity> getEntityClass();
3943

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package de.bluecolored.bluemap.core.world.mca.entity;
2+
3+
import de.bluecolored.bluenbt.NBTName;
4+
import lombok.EqualsAndHashCode;
5+
import lombok.Getter;
6+
import lombok.ToString;
7+
8+
@Getter
9+
@EqualsAndHashCode(callSuper = true)
10+
@ToString
11+
@SuppressWarnings("FieldMayBeFinal")
12+
public class Llama extends MCAEntity {
13+
14+
@NBTName("ChestedHorse") boolean withChest;
15+
@NBTName("Variant") Variant variant;
16+
17+
public enum Variant {
18+
CREAMY,
19+
WHITE,
20+
BROWN,
21+
GRAY
22+
}
23+
24+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"parts": [
3-
{ "model": "minecraft:entity/llama/llama_brown" }
3+
{ "renderer": "minecraft:llama" }
44
]
55
}

core/src/main/resourceExtensions/assets/minecraft/models/entity/llama/llama_chest_grays.json renamed to core/src/main/resourceExtensions/assets/minecraft/models/entity/llama/llama_chest_gray.json

File renamed without changes.

0 commit comments

Comments
 (0)