Skip to content

Commit 631ae94

Browse files
committed
Merge branch 'feat/entity' of https://github.com/MiraculixxT/BlueMap into MiraculixxT-feat/entity
2 parents 72e60f7 + bd1cbe9 commit 631ae94

File tree

26 files changed

+872
-11
lines changed

26 files changed

+872
-11
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* This file is part of BlueMap, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package de.bluecolored.bluemap.core.map.hires.entity;
26+
27+
import de.bluecolored.bluemap.core.map.TextureGallery;
28+
import de.bluecolored.bluemap.core.map.hires.RenderSettings;
29+
import de.bluecolored.bluemap.core.map.hires.TileModelView;
30+
import de.bluecolored.bluemap.core.resources.ResourcePath;
31+
import de.bluecolored.bluemap.core.resources.pack.resourcepack.ResourcePack;
32+
import de.bluecolored.bluemap.core.resources.pack.resourcepack.entitystate.Part;
33+
import de.bluecolored.bluemap.core.resources.pack.resourcepack.model.Model;
34+
import de.bluecolored.bluemap.core.util.Key;
35+
import de.bluecolored.bluemap.core.world.Entity;
36+
import de.bluecolored.bluemap.core.world.block.BlockNeighborhood;
37+
import de.bluecolored.bluemap.core.world.mca.entity.Bee;
38+
39+
public class BeeRenderer extends ResourceModelRenderer {
40+
41+
private final ResourcePath<Model>
42+
BEE_ADULT = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/bee/adult"),
43+
BEE_BABY = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/bee/baby");
44+
45+
public BeeRenderer(ResourcePack resourcePack, TextureGallery textureGallery, RenderSettings renderSettings) {
46+
super(resourcePack, textureGallery, renderSettings);
47+
}
48+
49+
@Override
50+
public void render(Entity entity, BlockNeighborhood block, Part part, TileModelView tileModel) {
51+
if (!(entity instanceof Bee bee)) return;
52+
53+
// choose correct model
54+
ResourcePath<Model> model;
55+
if (bee.getAge() < 0) {
56+
model = BEE_BABY;
57+
} else {
58+
model = BEE_ADULT;
59+
}
60+
61+
// render chosen model
62+
super.render(entity, block, model.getResource(resourcePack::getModel), TintColorProvider.NO_TINT, tileModel);
63+
64+
// apply part transform
65+
if (part.isTransformed())
66+
tileModel.transform(part.getTransformMatrix());
67+
}
68+
69+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* This file is part of BlueMap, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package de.bluecolored.bluemap.core.map.hires.entity;
26+
27+
import de.bluecolored.bluemap.core.map.TextureGallery;
28+
import de.bluecolored.bluemap.core.map.hires.RenderSettings;
29+
import de.bluecolored.bluemap.core.map.hires.TileModelView;
30+
import de.bluecolored.bluemap.core.resources.ResourcePath;
31+
import de.bluecolored.bluemap.core.resources.pack.resourcepack.ResourcePack;
32+
import de.bluecolored.bluemap.core.resources.pack.resourcepack.entitystate.Part;
33+
import de.bluecolored.bluemap.core.resources.pack.resourcepack.model.Model;
34+
import de.bluecolored.bluemap.core.util.Key;
35+
import de.bluecolored.bluemap.core.world.Entity;
36+
import de.bluecolored.bluemap.core.world.block.BlockNeighborhood;
37+
import de.bluecolored.bluemap.core.world.mca.entity.Bee;
38+
import de.bluecolored.bluemap.core.world.mca.entity.Cat;
39+
40+
public class CatRenderer extends ResourceModelRenderer {
41+
42+
private final ResourcePath<Model>
43+
CAT_BLACK = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/cat/cat_black"),
44+
CAT_ALL_BLACK = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/cat/cat_all_black"),
45+
CAT_BRITISH_SHORTHAIR = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/cat/cat_british_shorthair"),
46+
CAT_CALICO = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/cat/cat_calico"),
47+
CAT_JELLIE = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/cat/cat_jellie"),
48+
CAT_WHITE = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/cat/cat_white"),
49+
CAT_PERSIAN = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/cat/cat_persian"),
50+
CAT_RAGDOLL = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/cat/cat_ragdoll"),
51+
CAT_RED = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/cat/cat_red"),
52+
CAT_SIAMESE = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/cat/cat_siamese"),
53+
CAT_TABBY = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/cat/cat_tabby");
54+
55+
public CatRenderer(ResourcePack resourcePack, TextureGallery textureGallery, RenderSettings renderSettings) {
56+
super(resourcePack, textureGallery, renderSettings);
57+
}
58+
59+
@Override
60+
public void render(Entity entity, BlockNeighborhood block, Part part, TileModelView tileModel) {
61+
if (!(entity instanceof Cat cat)) return;
62+
63+
// choose correct model
64+
ResourcePath<Model> model;
65+
model = switch (cat.getVariant()) {
66+
case BLACK -> CAT_BLACK;
67+
case ALL_BLACK -> CAT_ALL_BLACK;
68+
case BRITISH_SHORTHAIR -> CAT_BRITISH_SHORTHAIR;
69+
case CALICO -> CAT_CALICO;
70+
case JELLIE -> CAT_JELLIE;
71+
case WHITE -> CAT_WHITE;
72+
case PERSIAN -> CAT_PERSIAN;
73+
case RAGDOLL -> CAT_RAGDOLL;
74+
case RED -> CAT_RED;
75+
case SIAMESE -> CAT_SIAMESE;
76+
case TABBY -> CAT_TABBY;
77+
};
78+
79+
// render chosen model
80+
super.render(entity, block, model.getResource(resourcePack::getModel), TintColorProvider.NO_TINT, tileModel);
81+
82+
// apply part transform
83+
if (part.isTransformed())
84+
tileModel.transform(part.getTransformMatrix());
85+
}
86+
87+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* This file is part of BlueMap, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package de.bluecolored.bluemap.core.map.hires.entity;
26+
27+
import de.bluecolored.bluemap.core.map.TextureGallery;
28+
import de.bluecolored.bluemap.core.map.hires.RenderSettings;
29+
import de.bluecolored.bluemap.core.map.hires.TileModelView;
30+
import de.bluecolored.bluemap.core.resources.ResourcePath;
31+
import de.bluecolored.bluemap.core.resources.pack.resourcepack.ResourcePack;
32+
import de.bluecolored.bluemap.core.resources.pack.resourcepack.entitystate.Part;
33+
import de.bluecolored.bluemap.core.resources.pack.resourcepack.model.Model;
34+
import de.bluecolored.bluemap.core.util.Key;
35+
import de.bluecolored.bluemap.core.world.Entity;
36+
import de.bluecolored.bluemap.core.world.block.BlockNeighborhood;
37+
import de.bluecolored.bluemap.core.world.mca.entity.AgeEntity;
38+
39+
public class ChickenRenderer extends ResourceModelRenderer {
40+
41+
private final ResourcePath<Model>
42+
CHICKEN_ADULT = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/chicken/adult"),
43+
CHICKEN_BABY = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/chicken/baby");
44+
45+
public ChickenRenderer(ResourcePack resourcePack, TextureGallery textureGallery, RenderSettings renderSettings) {
46+
super(resourcePack, textureGallery, renderSettings);
47+
}
48+
49+
@Override
50+
public void render(Entity entity, BlockNeighborhood block, Part part, TileModelView tileModel) {
51+
if (!(entity instanceof AgeEntity chicken)) return;
52+
53+
// choose correct model
54+
ResourcePath<Model> model;
55+
if (chicken.getAge() < 0) {
56+
model = CHICKEN_BABY;
57+
} else {
58+
model = CHICKEN_ADULT;
59+
}
60+
61+
// render chosen model
62+
super.render(entity, block, model.getResource(resourcePack::getModel), TintColorProvider.NO_TINT, tileModel);
63+
64+
// apply part transform
65+
if (part.isTransformed())
66+
tileModel.transform(part.getTransformMatrix());
67+
}
68+
69+
}

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@
2626

2727
import de.bluecolored.bluemap.core.map.TextureGallery;
2828
import de.bluecolored.bluemap.core.map.hires.RenderSettings;
29-
import de.bluecolored.bluemap.core.map.hires.block.LiquidModelRenderer;
3029
import de.bluecolored.bluemap.core.resources.pack.resourcepack.ResourcePack;
3130
import de.bluecolored.bluemap.core.util.Key;
3231
import de.bluecolored.bluemap.core.util.Keyed;
3332
import de.bluecolored.bluemap.core.util.Registry;
34-
import de.bluecolored.bluemap.core.world.BlockState;
3533
import lombok.Getter;
3634
import lombok.RequiredArgsConstructor;
3735

@@ -41,11 +39,25 @@ public interface EntityRendererType extends Keyed, EntityRendererFactory {
4139
EntityRendererType MISSING = new Impl(Key.bluemap("missing"), MissingModelRenderer::new);
4240

4341
EntityRendererType LLAMA = new Impl(Key.minecraft("llama"), LlamaRenderer::new);
42+
EntityRendererType BEE = new Impl(Key.minecraft("bee"), BeeRenderer::new);
43+
EntityRendererType CAT = new Impl(Key.minecraft("cat"), CatRenderer::new);
44+
EntityRendererType OCELOT = new Impl(Key.minecraft("ocelot"), OcelotRenderer::new);
45+
EntityRendererType CHICKEN = new Impl(Key.minecraft("chicken"), ChickenRenderer::new);
46+
EntityRendererType FOX = new Impl(Key.minecraft("fox"), FoxRenderer::new);
47+
EntityRendererType PIG = new Impl(Key.minecraft("pig"), PigRenderer::new);
48+
EntityRendererType TROPICAL_FISH = new Impl(Key.minecraft("tropical_fish"), TropicalFishRenderer::new);
4449

4550
Registry<EntityRendererType> REGISTRY = new Registry<>(
4651
DEFAULT,
4752
MISSING,
48-
LLAMA
53+
LLAMA,
54+
BEE,
55+
CAT,
56+
OCELOT,
57+
CHICKEN,
58+
FOX,
59+
PIG,
60+
TROPICAL_FISH
4961
);
5062

5163
/**
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* This file is part of BlueMap, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package de.bluecolored.bluemap.core.map.hires.entity;
26+
27+
import de.bluecolored.bluemap.core.map.TextureGallery;
28+
import de.bluecolored.bluemap.core.map.hires.RenderSettings;
29+
import de.bluecolored.bluemap.core.map.hires.TileModelView;
30+
import de.bluecolored.bluemap.core.resources.ResourcePath;
31+
import de.bluecolored.bluemap.core.resources.pack.resourcepack.ResourcePack;
32+
import de.bluecolored.bluemap.core.resources.pack.resourcepack.entitystate.Part;
33+
import de.bluecolored.bluemap.core.resources.pack.resourcepack.model.Model;
34+
import de.bluecolored.bluemap.core.util.Key;
35+
import de.bluecolored.bluemap.core.world.Entity;
36+
import de.bluecolored.bluemap.core.world.block.BlockNeighborhood;
37+
import de.bluecolored.bluemap.core.world.mca.entity.Fox;
38+
39+
public class FoxRenderer extends ResourceModelRenderer {
40+
41+
private final ResourcePath<Model>
42+
FOX_ADULT_RED = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/fox/adult"),
43+
FOX_ADULT_SNOW = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/fox/adult_snow");
44+
45+
public FoxRenderer(ResourcePack resourcePack, TextureGallery textureGallery, RenderSettings renderSettings) {
46+
super(resourcePack, textureGallery, renderSettings);
47+
}
48+
49+
@Override
50+
public void render(Entity entity, BlockNeighborhood block, Part part, TileModelView tileModel) {
51+
if (!(entity instanceof Fox fox)) return;
52+
53+
// choose correct model
54+
ResourcePath<Model> model;
55+
model = switch (fox.getType()) {
56+
case RED -> FOX_ADULT_RED;
57+
case SNOW -> FOX_ADULT_SNOW;
58+
};
59+
60+
// render chosen model
61+
super.render(entity, block, model.getResource(resourcePack::getModel), TintColorProvider.NO_TINT, tileModel);
62+
63+
// apply part transform
64+
if (part.isTransformed())
65+
tileModel.transform(part.getTransformMatrix());
66+
}
67+
68+
}

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
/*
2+
* This file is part of BlueMap, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
125
package de.bluecolored.bluemap.core.map.hires.entity;
226

327
import de.bluecolored.bluemap.core.map.TextureGallery;

0 commit comments

Comments
 (0)