Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vanilla entity models #646

Draft
wants to merge 26 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* This file is part of BlueMap, licensed under the MIT License (MIT).
*
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
* Copyright (c) contributors
*
* 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.
*/
package de.bluecolored.bluemap.core.map.hires.entity;

import de.bluecolored.bluemap.core.map.TextureGallery;
import de.bluecolored.bluemap.core.map.hires.RenderSettings;
import de.bluecolored.bluemap.core.map.hires.TileModelView;
import de.bluecolored.bluemap.core.resources.ResourcePath;
import de.bluecolored.bluemap.core.resources.pack.resourcepack.ResourcePack;
import de.bluecolored.bluemap.core.resources.pack.resourcepack.entitystate.Part;
import de.bluecolored.bluemap.core.resources.pack.resourcepack.model.Model;
import de.bluecolored.bluemap.core.util.Key;
import de.bluecolored.bluemap.core.world.Entity;
import de.bluecolored.bluemap.core.world.block.BlockNeighborhood;
import de.bluecolored.bluemap.core.world.mca.entity.Bee;

public class BeeRenderer extends ResourceModelRenderer {

private final ResourcePath<Model>
BEE_ADULT = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/bee/adult"),
BEE_BABY = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/bee/baby");

public BeeRenderer(ResourcePack resourcePack, TextureGallery textureGallery, RenderSettings renderSettings) {
super(resourcePack, textureGallery, renderSettings);
}

@Override
public void render(Entity entity, BlockNeighborhood block, Part part, TileModelView tileModel) {
if (!(entity instanceof Bee bee)) return;

// choose correct model
ResourcePath<Model> model;
if (bee.getAge() < 0) {
model = BEE_BABY;
} else {
model = BEE_ADULT;
}

// render chosen model
super.render(entity, block, model.getResource(resourcePack::getModel), TintColorProvider.NO_TINT, tileModel);

// apply part transform
if (part.isTransformed())
tileModel.transform(part.getTransformMatrix());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* This file is part of BlueMap, licensed under the MIT License (MIT).
*
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
* Copyright (c) contributors
*
* 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.
*/
package de.bluecolored.bluemap.core.map.hires.entity;

import de.bluecolored.bluemap.core.map.TextureGallery;
import de.bluecolored.bluemap.core.map.hires.RenderSettings;
import de.bluecolored.bluemap.core.map.hires.TileModelView;
import de.bluecolored.bluemap.core.resources.ResourcePath;
import de.bluecolored.bluemap.core.resources.pack.resourcepack.ResourcePack;
import de.bluecolored.bluemap.core.resources.pack.resourcepack.entitystate.Part;
import de.bluecolored.bluemap.core.resources.pack.resourcepack.model.Model;
import de.bluecolored.bluemap.core.util.Key;
import de.bluecolored.bluemap.core.world.Entity;
import de.bluecolored.bluemap.core.world.block.BlockNeighborhood;
import de.bluecolored.bluemap.core.world.mca.entity.Bee;
import de.bluecolored.bluemap.core.world.mca.entity.Cat;

public class CatRenderer extends ResourceModelRenderer {

private final ResourcePath<Model>
CAT_BLACK = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/cat/cat_black"),
CAT_ALL_BLACK = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/cat/cat_all_black"),
CAT_BRITISH_SHORTHAIR = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/cat/cat_british_shorthair"),
CAT_CALICO = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/cat/cat_calico"),
CAT_JELLIE = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/cat/cat_jellie"),
CAT_WHITE = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/cat/cat_white"),
CAT_PERSIAN = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/cat/cat_persian"),
CAT_RAGDOLL = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/cat/cat_ragdoll"),
CAT_RED = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/cat/cat_red"),
CAT_SIAMESE = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/cat/cat_siamese"),
CAT_TABBY = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/cat/cat_tabby");

public CatRenderer(ResourcePack resourcePack, TextureGallery textureGallery, RenderSettings renderSettings) {
super(resourcePack, textureGallery, renderSettings);
}

@Override
public void render(Entity entity, BlockNeighborhood block, Part part, TileModelView tileModel) {
if (!(entity instanceof Cat cat)) return;

// choose correct model
ResourcePath<Model> model;
model = switch (cat.getVariant()) {
case BLACK -> CAT_BLACK;
case ALL_BLACK -> CAT_ALL_BLACK;
case BRITISH_SHORTHAIR -> CAT_BRITISH_SHORTHAIR;
case CALICO -> CAT_CALICO;
case JELLIE -> CAT_JELLIE;
case WHITE -> CAT_WHITE;
case PERSIAN -> CAT_PERSIAN;
case RAGDOLL -> CAT_RAGDOLL;
case RED -> CAT_RED;
case SIAMESE -> CAT_SIAMESE;
case TABBY -> CAT_TABBY;
};

// render chosen model
super.render(entity, block, model.getResource(resourcePack::getModel), TintColorProvider.NO_TINT, tileModel);

// apply part transform
if (part.isTransformed())
tileModel.transform(part.getTransformMatrix());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* This file is part of BlueMap, licensed under the MIT License (MIT).
*
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
* Copyright (c) contributors
*
* 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.
*/
package de.bluecolored.bluemap.core.map.hires.entity;

import de.bluecolored.bluemap.core.map.TextureGallery;
import de.bluecolored.bluemap.core.map.hires.RenderSettings;
import de.bluecolored.bluemap.core.map.hires.TileModelView;
import de.bluecolored.bluemap.core.resources.ResourcePath;
import de.bluecolored.bluemap.core.resources.pack.resourcepack.ResourcePack;
import de.bluecolored.bluemap.core.resources.pack.resourcepack.entitystate.Part;
import de.bluecolored.bluemap.core.resources.pack.resourcepack.model.Model;
import de.bluecolored.bluemap.core.util.Key;
import de.bluecolored.bluemap.core.world.Entity;
import de.bluecolored.bluemap.core.world.block.BlockNeighborhood;
import de.bluecolored.bluemap.core.world.mca.entity.AgeEntity;

public class ChickenRenderer extends ResourceModelRenderer {

private final ResourcePath<Model>
CHICKEN_ADULT = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/chicken/adult"),
CHICKEN_BABY = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/chicken/baby");

public ChickenRenderer(ResourcePack resourcePack, TextureGallery textureGallery, RenderSettings renderSettings) {
super(resourcePack, textureGallery, renderSettings);
}

@Override
public void render(Entity entity, BlockNeighborhood block, Part part, TileModelView tileModel) {
if (!(entity instanceof AgeEntity chicken)) return;

// choose correct model
ResourcePath<Model> model;
if (chicken.getAge() < 0) {
model = CHICKEN_BABY;
} else {
model = CHICKEN_ADULT;
}

// render chosen model
super.render(entity, block, model.getResource(resourcePack::getModel), TintColorProvider.NO_TINT, tileModel);

// apply part transform
if (part.isTransformed())
tileModel.transform(part.getTransformMatrix());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@

import de.bluecolored.bluemap.core.map.TextureGallery;
import de.bluecolored.bluemap.core.map.hires.RenderSettings;
import de.bluecolored.bluemap.core.map.hires.block.LiquidModelRenderer;
import de.bluecolored.bluemap.core.resources.pack.resourcepack.ResourcePack;
import de.bluecolored.bluemap.core.util.Key;
import de.bluecolored.bluemap.core.util.Keyed;
import de.bluecolored.bluemap.core.util.Registry;
import de.bluecolored.bluemap.core.world.BlockState;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

Expand All @@ -40,9 +38,26 @@ public interface EntityRendererType extends Keyed, EntityRendererFactory {
EntityRendererType DEFAULT = new Impl(Key.bluemap("default"), ResourceModelRenderer::new);
EntityRendererType MISSING = new Impl(Key.bluemap("missing"), MissingModelRenderer::new);

EntityRendererType LLAMA = new Impl(Key.minecraft("llama"), LlamaRenderer::new);
EntityRendererType BEE = new Impl(Key.minecraft("bee"), BeeRenderer::new);
EntityRendererType CAT = new Impl(Key.minecraft("cat"), CatRenderer::new);
EntityRendererType OCELOT = new Impl(Key.minecraft("ocelot"), OcelotRenderer::new);
EntityRendererType CHICKEN = new Impl(Key.minecraft("chicken"), ChickenRenderer::new);
EntityRendererType FOX = new Impl(Key.minecraft("fox"), FoxRenderer::new);
EntityRendererType PIG = new Impl(Key.minecraft("pig"), PigRenderer::new);
EntityRendererType TROPICAL_FISH = new Impl(Key.minecraft("tropical_fish"), TropicalFishRenderer::new);

Registry<EntityRendererType> REGISTRY = new Registry<>(
DEFAULT,
MISSING
MISSING,
LLAMA,
BEE,
CAT,
OCELOT,
CHICKEN,
FOX,
PIG,
TROPICAL_FISH
);

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* This file is part of BlueMap, licensed under the MIT License (MIT).
*
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
* Copyright (c) contributors
*
* 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.
*/
package de.bluecolored.bluemap.core.map.hires.entity;

import de.bluecolored.bluemap.core.map.TextureGallery;
import de.bluecolored.bluemap.core.map.hires.RenderSettings;
import de.bluecolored.bluemap.core.map.hires.TileModelView;
import de.bluecolored.bluemap.core.resources.ResourcePath;
import de.bluecolored.bluemap.core.resources.pack.resourcepack.ResourcePack;
import de.bluecolored.bluemap.core.resources.pack.resourcepack.entitystate.Part;
import de.bluecolored.bluemap.core.resources.pack.resourcepack.model.Model;
import de.bluecolored.bluemap.core.util.Key;
import de.bluecolored.bluemap.core.world.Entity;
import de.bluecolored.bluemap.core.world.block.BlockNeighborhood;
import de.bluecolored.bluemap.core.world.mca.entity.Fox;

public class FoxRenderer extends ResourceModelRenderer {

private final ResourcePath<Model>
FOX_ADULT_RED = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/fox/adult"),
FOX_ADULT_SNOW = new ResourcePath<>(Key.MINECRAFT_NAMESPACE, "entity/fox/adult_snow");

public FoxRenderer(ResourcePack resourcePack, TextureGallery textureGallery, RenderSettings renderSettings) {
super(resourcePack, textureGallery, renderSettings);
}

@Override
public void render(Entity entity, BlockNeighborhood block, Part part, TileModelView tileModel) {
if (!(entity instanceof Fox fox)) return;

// choose correct model
ResourcePath<Model> model;
model = switch (fox.getType()) {
case RED -> FOX_ADULT_RED;
case SNOW -> FOX_ADULT_SNOW;
};

// render chosen model
super.render(entity, block, model.getResource(resourcePack::getModel), TintColorProvider.NO_TINT, tileModel);

// apply part transform
if (part.isTransformed())
tileModel.transform(part.getTransformMatrix());
}

}
Loading
Loading