mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-22 04:27:59 +01:00
Simply and remove PlayerModels as it's not needed since the move to Mson. Should allow resource packs to override changeling, gryphon, hippo, and kirin models as they were hardcoded as aliases before.
This commit is contained in:
parent
f145c59726
commit
77680341d6
9 changed files with 45 additions and 135 deletions
|
@ -2,10 +2,10 @@ package com.minelittlepony.api.pony.meta;
|
|||
|
||||
import com.minelittlepony.api.pony.TriggerPixelType;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public enum Race implements TriggerPixelType<Race> {
|
||||
|
||||
HUMAN (0x000000, false, false),
|
||||
EARTH (0xf9b131, false, false),
|
||||
PEGASUS (0x88caf0, true, false),
|
||||
|
@ -13,10 +13,10 @@ public enum Race implements TriggerPixelType<Race> {
|
|||
ALICORN (0xfef9fc, true, true),
|
||||
CHANGELING (0x282b29, true, true),
|
||||
ZEBRA (0xd0cccf, false, false),
|
||||
CHANGEDLING (0xcaed5a, CHANGELING),
|
||||
GRYPHON (0xae9145, PEGASUS),
|
||||
HIPPOGRIFF (0xd6ddac, PEGASUS),
|
||||
KIRIN (0xfa88af, UNICORN),
|
||||
CHANGEDLING (0xcaed5a, true, true),
|
||||
GRYPHON (0xae9145, true, false),
|
||||
HIPPOGRIFF (0xd6ddac, true, false),
|
||||
KIRIN (0xfa88af, false, true),
|
||||
BATPONY (0xeeeeee, true, false),
|
||||
SEAPONY (0x3655dd, false, true);
|
||||
|
||||
|
@ -25,26 +25,13 @@ public enum Race implements TriggerPixelType<Race> {
|
|||
|
||||
private int triggerPixel;
|
||||
|
||||
private final Race original;
|
||||
public static final List<Race> REGISTRY = Arrays.asList(values());
|
||||
|
||||
Race(int triggerPixel, boolean wings, boolean horn) {
|
||||
this.triggerPixel = triggerPixel;
|
||||
|
||||
this.wings = wings;
|
||||
this.horn = horn;
|
||||
|
||||
original = this;
|
||||
}
|
||||
|
||||
Race(int triggerPixel, Race cloneOf) {
|
||||
cloneOf = cloneOf.getAlias();
|
||||
|
||||
this.triggerPixel = triggerPixel;
|
||||
|
||||
this.wings = cloneOf.wings;
|
||||
this.horn = cloneOf.horn;
|
||||
|
||||
original = cloneOf;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,31 +56,12 @@ public enum Race implements TriggerPixelType<Race> {
|
|||
return this == HUMAN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the original race that this one is an alias for, if one exists.
|
||||
* Otherwise returns this race.
|
||||
*/
|
||||
@NotNull
|
||||
public Race getAlias() {
|
||||
return original;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this race is a virtual one.
|
||||
*/
|
||||
public boolean isVirtual() {
|
||||
return getAlias() != this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if both races resolve to the same value.
|
||||
*/
|
||||
public boolean isEquivalentTo(Race other) {
|
||||
return getAlias() == other.getAlias();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorCode() {
|
||||
return triggerPixel;
|
||||
}
|
||||
|
||||
public String getModelId(boolean isSlim) {
|
||||
return isSlim ? "slim" + name().toLowerCase() : name().toLowerCase();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import com.minelittlepony.api.model.ModelAttributes;
|
|||
import com.minelittlepony.api.pony.IPonyManager;
|
||||
import com.minelittlepony.client.IPreviewModel;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.model.entity.race.PlayerModels;
|
||||
import com.minelittlepony.client.pony.Pony;
|
||||
import com.minelittlepony.hdskins.client.dummy.DummyPlayer;
|
||||
import com.minelittlepony.hdskins.client.dummy.TextureProxy;
|
||||
|
@ -38,9 +37,9 @@ class DummyPony extends DummyPlayer implements IPreviewModel, ModelAttributes.Sw
|
|||
if (getTextures().getSkinType() == MineLPHDSkins.seaponySkinType) {
|
||||
return getTextures().usesThinSkin() ? "slimseapony" : "seapony";
|
||||
}
|
||||
return PlayerModels.forRace(MineLittlePony.getInstance().getManager()
|
||||
return MineLittlePony.getInstance().getManager()
|
||||
.getPony(this)
|
||||
.getRace(true))
|
||||
.getId(super.getModel().contains("slim"));
|
||||
.getRace(true)
|
||||
.getModelId(super.getModel().contains("slim"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
|||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
/**
|
||||
* Skin uploading GUI. Usually displayed over the main menu.
|
||||
*/
|
||||
|
@ -48,6 +50,15 @@ class GuiSkinsMineLP extends GuiSkins {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
|
||||
if (modifiers == (GLFW.GLFW_MOD_ALT | GLFW.GLFW_MOD_CONTROL) && keyCode == GLFW.GLFW_KEY_R) {
|
||||
client.reloadResources();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.keyPressed(keyCode, scanCode, modifiers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerPreview createPreviewer() {
|
||||
return new PonyPreview();
|
||||
|
|
|
@ -59,7 +59,7 @@ public class MineLPHDSkins extends SkinsProxy implements ClientModInitializer {
|
|||
parent instanceof GuiSkins ? parent : GuiSkins.create(screen, HDSkins.getInstance().getSkinServerList())
|
||||
))
|
||||
.getStyle()
|
||||
.setText("minelp.options.skins.hdskins.open");;
|
||||
.setText("minelp.options.skins.hdskins.open");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.minelittlepony.client.mixin;
|
|||
|
||||
import com.minelittlepony.api.pony.IPonyManager;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.model.entity.race.PlayerModels;
|
||||
import com.minelittlepony.settings.PonyLevel;
|
||||
|
||||
import net.minecraft.client.util.DefaultSkinHelper;
|
||||
|
@ -40,10 +39,10 @@ abstract class MixinDefaultPlayerSkin {
|
|||
private static void skinType(UUID uuid, CallbackInfoReturnable<String> cir) {
|
||||
if (MineLittlePony.getInstance().getConfig().ponyLevel.get() == PonyLevel.PONIES) {
|
||||
|
||||
cir.setReturnValue(PlayerModels.forRace(MineLittlePony.getInstance().getManager()
|
||||
cir.setReturnValue(MineLittlePony.getInstance().getManager()
|
||||
.getPony(IPonyManager.getDefaultSkin(uuid), uuid)
|
||||
.getRace(false))
|
||||
.getId(IPonyManager.isSlimSkin(uuid)));
|
||||
.getRace(false)
|
||||
.getModelId(IPonyManager.isSlimSkin(uuid)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.minelittlepony.client.mixin;
|
|||
|
||||
import com.minelittlepony.client.IPreviewModel;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.model.entity.race.PlayerModels;
|
||||
|
||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
|
@ -22,9 +21,9 @@ abstract class MixinEntityRenderDispatcher {
|
|||
if (player instanceof IPreviewModel) {
|
||||
return player.getModel();
|
||||
}
|
||||
return PlayerModels.forRace(MineLittlePony.getInstance().getManager()
|
||||
return MineLittlePony.getInstance().getManager()
|
||||
.getPony(player)
|
||||
.getRace(false))
|
||||
.getId(player.getModel().contains("slim"));
|
||||
.getRace(false)
|
||||
.getModelId(player.getModel().contains("slim"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
package com.minelittlepony.client.model.entity.race;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.minelittlepony.api.pony.meta.Race;
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.PlayerModelKey;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public enum PlayerModels {
|
||||
/**
|
||||
* The default non-pony model. This is typically handled my the vanilla renderer.
|
||||
*/
|
||||
DEFAULT("default", "slim", Race.HUMAN),
|
||||
EARTHPONY(Race.EARTH),
|
||||
PEGASUS(Race.PEGASUS),
|
||||
BATPONY(Race.BATPONY),
|
||||
UNICORN(Race.UNICORN),
|
||||
ALICORN(Race.ALICORN),
|
||||
CHANGELING(Race.CHANGELING),
|
||||
ZEBRA(Race.ZEBRA),
|
||||
SEAPONY(Race.SEAPONY);
|
||||
|
||||
public static final List<PlayerModels> registry = Arrays.asList(values());
|
||||
private static final Map<Race, PlayerModels> raceModelsMap = Maps.newEnumMap(Race.class);
|
||||
|
||||
static {
|
||||
for (PlayerModels i : values()) {
|
||||
raceModelsMap.put(i.race, i);
|
||||
}
|
||||
}
|
||||
|
||||
private final String normal;
|
||||
private final String slim;
|
||||
|
||||
private final Race race;
|
||||
|
||||
PlayerModels(Race race) {
|
||||
normal = name().toLowerCase();
|
||||
slim = "slim" + normal;
|
||||
|
||||
this.race = race;
|
||||
}
|
||||
|
||||
PlayerModels(String normalKey, String slimKey, Race race) {
|
||||
normal = normalKey;
|
||||
slim = slimKey;
|
||||
|
||||
this.race = race;
|
||||
}
|
||||
|
||||
public PlayerModelKey<?, ?> getModelKey() {
|
||||
return ModelType.getPlayerModel(race);
|
||||
}
|
||||
|
||||
public String getId(boolean isSlim) {
|
||||
return isSlim ? slim : normal;
|
||||
}
|
||||
|
||||
public static PlayerModels forRace(Race race) {
|
||||
return raceModelsMap.getOrDefault(race.getAlias(), DEFAULT);
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@ import com.minelittlepony.api.model.BodyPart;
|
|||
import com.minelittlepony.api.model.IModel;
|
||||
import com.minelittlepony.api.model.IPegasus;
|
||||
import com.minelittlepony.api.model.PonyModelConstants;
|
||||
import com.minelittlepony.api.pony.meta.Race;
|
||||
import com.minelittlepony.api.pony.meta.Wearable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -101,9 +100,6 @@ public class SaddleBags extends AbstractGear implements PonyModelConstants {
|
|||
|
||||
@Override
|
||||
public <T extends Entity> Identifier getTexture(T entity, Context<T, ?> context) {
|
||||
if (context.getEntityModel() != null && context.getEntityModel().getMetadata().getRace().isEquivalentTo(Race.CHANGELING)) {
|
||||
return TEXTURE;
|
||||
}
|
||||
return context.getDefaultTexture(entity, Wearable.SADDLE_BAGS);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,10 @@ package com.minelittlepony.client.render;
|
|||
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.minelittlepony.api.pony.meta.Race;
|
||||
import com.minelittlepony.client.mixin.MixinEntityRenderers;
|
||||
import com.minelittlepony.client.model.IPonyModel;
|
||||
import com.minelittlepony.client.model.entity.race.PlayerModels;
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
@ -40,21 +41,23 @@ public class PonyRenderDispatcher {
|
|||
* Registers all new player skin types. (currently only pony and slimpony).
|
||||
*/
|
||||
public void initialise(EntityRenderDispatcher manager) {
|
||||
PlayerModels.registry.forEach(i -> registerPlayerSkin(manager, i));
|
||||
Race.REGISTRY.forEach(r -> {
|
||||
if (!r.isHuman()) {
|
||||
registerPlayerSkin(manager, r);
|
||||
}
|
||||
});
|
||||
MobRenderers.REGISTRY.values().forEach(i -> i.apply(this));
|
||||
}
|
||||
|
||||
private void registerPlayerSkin(EntityRenderDispatcher manager, PlayerModels playerModel) {
|
||||
if (playerModel != PlayerModels.DEFAULT) {
|
||||
addPlayerSkin(manager, false, playerModel);
|
||||
addPlayerSkin(manager, true, playerModel);
|
||||
}
|
||||
private void registerPlayerSkin(EntityRenderDispatcher manager, Race race) {
|
||||
addPlayerSkin(manager, false, race);
|
||||
addPlayerSkin(manager, true, race);
|
||||
}
|
||||
|
||||
private void addPlayerSkin(EntityRenderDispatcher manager, boolean slimArms, PlayerModels playerModel) {
|
||||
private void addPlayerSkin(EntityRenderDispatcher manager, boolean slimArms, Race race) {
|
||||
Mson.getInstance().getEntityRendererRegistry().registerPlayerRenderer(
|
||||
playerModel.getId(slimArms),
|
||||
playerModel.getModelKey().getRendererFactory(slimArms)
|
||||
race.getModelId(slimArms),
|
||||
ModelType.getPlayerModel(race).getRendererFactory(slimArms)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue