mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 08:14:23 +01:00
Properly implement steve/alex models
This commit is contained in:
parent
d3759af4f3
commit
2cfe7e138a
35 changed files with 111 additions and 68 deletions
|
@ -5,7 +5,6 @@ import java.util.function.Function;
|
|||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.minelittlepony.client.model.IPonyModel;
|
||||
import com.minelittlepony.client.model.PlayerModelKey;
|
||||
import com.minelittlepony.client.model.entity.race.PlayerModels;
|
||||
import com.minelittlepony.client.render.LevitatingItemRenderer;
|
||||
import com.minelittlepony.client.render.entity.MobRenderers;
|
||||
|
@ -60,11 +59,10 @@ public class PonyRenderManager {
|
|||
}
|
||||
|
||||
private void addPlayerSkin(EntityRenderDispatcher manager, boolean slimArms, PlayerModels playerModel) {
|
||||
|
||||
PlayerModelKey<?, ?>.Key key = playerModel.getModelKey().getKey(slimArms);
|
||||
String id = playerModel.getId(slimArms);
|
||||
|
||||
Mson.getInstance().getEntityRendererRegistry().registerPlayerRenderer(id, key.getFactory());
|
||||
Mson.getInstance().getEntityRendererRegistry().registerPlayerRenderer(
|
||||
playerModel.getId(slimArms),
|
||||
playerModel.getModelKey().getRendererFactory(slimArms)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -74,7 +74,7 @@ public final class ModelType {
|
|||
@SuppressWarnings("unchecked")
|
||||
static <E extends LivingEntity, T extends Model & MsonModel> PlayerModelKey<E, T> registerPlayer(String name, Race race, Function<Boolean, T> constructor, PlayerModelKey.RendererFactory rendererFactory) {
|
||||
return (PlayerModelKey<E, T>)PLAYER_MODELS.computeIfAbsent(race, r -> {
|
||||
return new PlayerModelKey<>(new Identifier("minelittlepony", "races/" + name), constructor, rendererFactory);
|
||||
return new PlayerModelKey<>(name, constructor, rendererFactory);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -12,63 +12,35 @@ import com.minelittlepony.mson.api.Mson;
|
|||
import com.minelittlepony.mson.api.MsonModel;
|
||||
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class PlayerModelKey<T extends LivingEntity, M extends Model & MsonModel> {
|
||||
|
||||
private final ModelKey<M> key;
|
||||
|
||||
private boolean slim;
|
||||
|
||||
private final Key steveKey;
|
||||
private final Key alexKey;
|
||||
private final ModelKey<M> steveKey;
|
||||
private final ModelKey<M> alexKey;
|
||||
|
||||
private final RendererFactory rendererFactory;
|
||||
|
||||
PlayerModelKey(Identifier id, Function<Boolean, M> factory, RendererFactory rendererFactory) {
|
||||
this.key = Mson.getInstance().registerModel(id, () -> factory.apply(slim));
|
||||
PlayerModelKey(String name, Function<Boolean, M> modelFactory, RendererFactory rendererFactory) {
|
||||
this.rendererFactory = rendererFactory;
|
||||
|
||||
steveKey = new Key(false);
|
||||
alexKey = new Key(true);
|
||||
steveKey = Mson.getInstance().registerModel(new Identifier("minelittlepony", "races/steve/" + name), () -> modelFactory.apply(false));
|
||||
alexKey = Mson.getInstance().registerModel(new Identifier("minelittlepony", "races/alex/" + name), () -> modelFactory.apply(true));
|
||||
}
|
||||
|
||||
public Key getKey(boolean slimArms) {
|
||||
public ModelKey<M> getKey(boolean slimArms) {
|
||||
return slimArms ? alexKey : steveKey;
|
||||
}
|
||||
|
||||
public class Key implements ModelKey<M> {
|
||||
|
||||
final boolean slim;
|
||||
|
||||
public Key(boolean slim) {
|
||||
this.slim = slim;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getId() {
|
||||
return key.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public M createModel() {
|
||||
PlayerModelKey.this.slim = this.slim;
|
||||
return key.createModel();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Function<EntityRenderDispatcher, PlayerEntityRenderer> getFactory() {
|
||||
return d -> rendererFactory.create(d, slim, (ModelKey<? extends ClientPonyModel<AbstractClientPlayerEntity>>)this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V extends M> V createModel(Supplier<V> supplier) {
|
||||
PlayerModelKey.this.slim = this.slim;
|
||||
return key.createModel(supplier);
|
||||
}
|
||||
public Function<EntityRenderDispatcher, PlayerEntityRenderer> getRendererFactory(boolean slimArms) {
|
||||
return d -> rendererFactory.create(d, slimArms, (ModelKey<? extends ClientPonyModel<AbstractClientPlayerEntity>>)getKey(slimArms));
|
||||
}
|
||||
|
||||
public interface RendererFactory {
|
||||
PlayerEntityRenderer create(EntityRenderDispatcher dispatcher, boolean slim, ModelKey<? extends ClientPonyModel<AbstractClientPlayerEntity>> key);
|
||||
PlayerEntityRenderer create(
|
||||
EntityRenderDispatcher dispatcher,
|
||||
boolean slim,
|
||||
ModelKey<? extends ClientPonyModel<AbstractClientPlayerEntity>> key
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"parent": "minelittlepony:races/sea_pony"
|
||||
"parent": "minelittlepony:races/steve/sea_pony"
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"parent": "minelittlepony:races/alicorn"
|
||||
"parent": "minelittlepony:races/steve/alicorn"
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"parent": "minelittlepony:races/changeling"
|
||||
"parent": "minelittlepony:races/steve/changeling"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"parent": "minelittlepony:races/steve/alicorn",
|
||||
"locals": {
|
||||
"arm_width": 3,
|
||||
"arm_rotation_x": 2,
|
||||
"arm_rotation_y": 8.5
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"parent": "minelittlepony:races/steve/bat_pony",
|
||||
"locals": {
|
||||
"arm_width": 3,
|
||||
"arm_rotation_x": 2,
|
||||
"arm_rotation_y": 8.5
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"parent": "minelittlepony:races/steve/alicorn",
|
||||
"locals": {
|
||||
"arm_width": 3,
|
||||
"arm_rotation_x": 2,
|
||||
"arm_rotation_y": 8.5
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"parent": "minelittlepony:races/steve/earth_pony",
|
||||
"locals": {
|
||||
"arm_width": 3,
|
||||
"arm_rotation_x": 2,
|
||||
"arm_rotation_y": 8.5
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "minelittlepony:races/alex/pegasus"
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "minelittlepony:races/alex/pegasus"
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "minelittlepony:races/alex/unicorn"
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"parent": "minelittlepony:races/steve/pegasus",
|
||||
"locals": {
|
||||
"arm_width": 3,
|
||||
"arm_rotation_x": 2,
|
||||
"arm_rotation_y": 8.5
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"parent": "minelittlepony:races/steve/sea_pony",
|
||||
"locals": {
|
||||
"arm_width": 3,
|
||||
"arm_rotation_x": 2,
|
||||
"arm_rotation_y": 8.5
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"parent": "minelittlepony:race/steve/unicorn",
|
||||
"locals": {
|
||||
"arm_width": 3,
|
||||
"arm_rotation_x": 2,
|
||||
"arm_rotation_y": 8.5
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"parent": "minelittlepony:races/steve/zebra",
|
||||
"locals": {
|
||||
"arm_width": 3,
|
||||
"arm_rotation_x": 2,
|
||||
"arm_rotation_y": 8.5
|
||||
}
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"parent": "minelittlepony:races/pegasus"
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"parent": "minelittlepony:races/pegasus"
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"parent": "minelittlepony:races/unicorn"
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"parent": "minelittlepony:races/unicorn",
|
||||
"parent": "minelittlepony:races/steve/unicorn",
|
||||
"wings": {
|
||||
"type": "mson:slot",
|
||||
"name": "wings",
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"parent": "minelittlepony:races/alicorn",
|
||||
"parent": "minelittlepony:races/steve/alicorn",
|
||||
"wings": {
|
||||
"type": "mson:slot",
|
||||
"name": "wings",
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "minelittlepony:races/steve/pegasus"
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "minelittlepony:races/steve/pegasus"
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "minelittlepony:races/steve/unicorn"
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"parent": "minelittlepony:races/alicorn",
|
||||
"parent": "minelittlepony:races/steve/alicorn",
|
||||
"left_fin": {
|
||||
"type": "mson:planar",
|
||||
"texture": {"u": 56, "v": 16},
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"parent": "minelittlepony:races/alicorn",
|
||||
"parent": "minelittlepony:races/steve/alicorn",
|
||||
"locals": {
|
||||
"arm_width": 2,
|
||||
"arm_depth": 2
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"parent": "minelittlepony:races/alicorn",
|
||||
"parent": "minelittlepony:races/steve/alicorn",
|
||||
"head": {
|
||||
"offset": [ 0, -1, -2 ],
|
||||
"center": [ 0, 0, -2 ],
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"parent": "minelittlepony:races/alicorn"
|
||||
"parent": "minelittlepony:races/steve/alicorn"
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"parent": "minelittlepony:races/alicorn"
|
||||
"parent": "minelittlepony:races/steve/alicorn"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue