Seaponies cano now have a dedicated texture separate from the normal skin

This commit is contained in:
Sollace 2020-11-10 22:49:30 +02:00
parent 97f71ffa24
commit 728e2b1a39
8 changed files with 80 additions and 70 deletions

View file

@ -0,0 +1,5 @@
package com.minelittlepony.client;
public interface IPreviewModel {
}

View file

@ -1,8 +1,11 @@
package com.minelittlepony.client;
import com.minelittlepony.client.model.ClientPonyModel;
import com.minelittlepony.client.render.EquineRenderManager;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.texture.PlayerSkinProvider;
import net.minecraft.util.Identifier;
@ -25,4 +28,8 @@ public class SkinsProxy {
return skins.loadSkin(texture, MinecraftProfileTexture.Type.SKIN);
}
public Identifier getSeaponySkin(EquineRenderManager<AbstractClientPlayerEntity, ClientPonyModel<AbstractClientPlayerEntity>> manager, AbstractClientPlayerEntity player) {
return manager.getPony(player).getTexture();
}
}

View file

@ -1,29 +1,37 @@
package com.minelittlepony.client.hdskins;
import com.minelittlepony.client.IPreviewModel;
import com.minelittlepony.client.MineLittlePony;
import com.minelittlepony.client.model.entity.race.PlayerModels;
import com.minelittlepony.hdskins.client.dummy.DummyPlayer;
import com.minelittlepony.hdskins.client.dummy.TextureProxy;
import com.minelittlepony.hdskins.profile.SkinType;
import com.minelittlepony.hdskins.client.resources.LocalTexture;
import com.minelittlepony.model.IRotatedSwimmer;
/**
* Dummy model used for the skin uploading screen.
*/
class DummyPony extends DummyPlayer implements IRotatedSwimmer {
public boolean wet = false;
class DummyPony extends DummyPlayer implements IRotatedSwimmer, IPreviewModel {
public DummyPony(TextureProxy textures) {
super(textures);
}
public void setWet(boolean wet) {
this.wet = wet;
}
LocalTexture skin = getTextures().get(SkinType.SKIN);
@Override
public boolean isSubmergedInWater() {
return getTextures().getSkinType() == MineLPHDSkins.seaponySkinType || super.isSubmergedInWater();
}
if (wet != (skin.getId() == PonyPreview.NO_SKIN_SEAPONY)) {
skin.clearLocal();
@Override
public String getModel() {
if (getTextures().getSkinType() == MineLPHDSkins.seaponySkinType) {
return getTextures().usesThinSkin() ? "slimseapony" : "seapony";
}
return PlayerModels.forRace(MineLittlePony.getInstance().getManager()
.getPony(this)
.getRace(false))
.getId(super.getModel().contains("slim"));
}
}

View file

@ -2,18 +2,13 @@ package com.minelittlepony.client.hdskins;
import com.minelittlepony.api.pony.IPonyManager;
import com.minelittlepony.client.MineLittlePony;
import com.minelittlepony.common.client.gui.element.Cycler;
import com.minelittlepony.common.client.gui.style.Style;
import com.minelittlepony.hdskins.client.dummy.PlayerPreview;
import com.minelittlepony.hdskins.client.gui.GuiSkins;
import com.minelittlepony.hdskins.server.SkinServerList;
import com.minelittlepony.hdskins.profile.SkinType;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import net.minecraft.item.Items;
import net.minecraft.sound.SoundEvents;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
/**
@ -23,8 +18,6 @@ class GuiSkinsMineLP extends GuiSkins {
private IPonyManager ponyManager = MineLittlePony.getInstance().getManager();
private boolean isWet = false;
private static final String[] panoramas = new String[] {
"minelittlepony:textures/cubemap/sugarcubecorner",
"minelittlepony:textures/cubemap/quillsandsofas",
@ -40,19 +33,6 @@ class GuiSkinsMineLP extends GuiSkins {
return new PonyPreview();
}
@Override
public void init() {
super.init();
addButton(new Cycler(width - 25, 142, 20, 20))
.setStyles(
new Style().setIcon(new ItemStack(Items.BUCKET)).setTooltip("minelp.mode.dry", 0, 10),
new Style().setIcon(new ItemStack(Items.WATER_BUCKET)).setTooltip("minelp.mode.wet", 0, 10)
)
.onChange(this::setWet)
.setValue(isWet ? 1 : 0);
}
@Override
protected Identifier getBackground() {
int i = (int)Math.floor(Math.random() * panoramas.length);
@ -60,19 +40,6 @@ class GuiSkinsMineLP extends GuiSkins {
return new Identifier(panoramas[i]);
}
protected int setWet(int wet) {
playSound(SoundEvents.BLOCK_BREWING_STAND_BREW);
isWet = wet == 1;
previewer.getLocal().getTextures().release();;
if (previewer instanceof PonyPreview) {
((PonyPreview)previewer).setWet(isWet);
}
return wet;
}
@Override
public void onSetLocalSkin(SkinType type) {
super.onSetLocalSkin(type);

View file

@ -2,17 +2,25 @@ package com.minelittlepony.client.hdskins;
import com.minelittlepony.client.MineLittlePony;
import com.minelittlepony.client.SkinsProxy;
import com.minelittlepony.client.model.ClientPonyModel;
import com.minelittlepony.common.event.ClientReadyCallback;
import com.minelittlepony.hdskins.client.SkinCacheClearCallback;
import com.minelittlepony.hdskins.client.ducks.ClientPlayerInfo;
import com.minelittlepony.hdskins.client.dummy.DummyPlayer;
import com.minelittlepony.hdskins.client.gui.GuiSkins;
import com.minelittlepony.hdskins.client.resources.LocalTexture;
import com.minelittlepony.hdskins.mixin.client.MixinClientPlayer;
import com.minelittlepony.hdskins.profile.SkinType;
import com.mojang.authlib.GameProfile;
import net.fabricmc.api.ClientModInitializer;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.item.Items;
import net.minecraft.util.Identifier;
import com.minelittlepony.client.pony.PonyManager;
import com.minelittlepony.client.render.EquineRenderManager;
import com.minelittlepony.hdskins.client.HDSkins;
/**
@ -20,10 +28,15 @@ import com.minelittlepony.hdskins.client.HDSkins;
*/
public class MineLPHDSkins extends SkinsProxy implements ClientModInitializer {
static SkinType seaponySkinType;
@Override
public void onInitializeClient() {
SkinsProxy.instance = this;
seaponySkinType = SkinType.register(new Identifier("minelp", "seapony"), Items.COD_BUCKET.getDefaultStack());
ClientReadyCallback.EVENT.register(client -> {
// Clear ponies when skins are cleared
PonyManager ponyManager = (PonyManager) MineLittlePony.getInstance().getManager();
@ -34,6 +47,23 @@ public class MineLPHDSkins extends SkinsProxy implements ClientModInitializer {
});
}
@Override
public Identifier getSeaponySkin(EquineRenderManager<AbstractClientPlayerEntity, ClientPonyModel<AbstractClientPlayerEntity>> manager, AbstractClientPlayerEntity player) {
if (player instanceof DummyPlayer) {
LocalTexture tex = ((DummyPlayer)player).getTextures().get(seaponySkinType);
Identifier id = tex.getId();
return id == null ? tex.getDefault() : id;
} else {
ClientPlayerInfo info = (ClientPlayerInfo)((MixinClientPlayer)player).getBackingClientData();
Identifier tex = info.getSkins().getSkin(seaponySkinType);
if (tex != null) {
return tex;
}
}
return super.getSeaponySkin(manager, player);
}
@Override
public Identifier getSkinTexture(GameProfile profile) {

View file

@ -2,9 +2,6 @@ package com.minelittlepony.client.hdskins;
import net.minecraft.util.Identifier;
import com.minelittlepony.api.pony.IPony;
import com.minelittlepony.api.pony.meta.Race;
import com.minelittlepony.client.MineLittlePony;
import com.minelittlepony.hdskins.client.dummy.DummyPlayer;
import com.minelittlepony.hdskins.client.dummy.PlayerPreview;
import com.minelittlepony.hdskins.profile.SkinType;
@ -26,9 +23,10 @@ class PonyPreview extends PlayerPreview {
@Override
public Identifier getBlankSteveSkin(SkinType type) {
if (type == SkinType.SKIN) {
// Initialization order means this method might be called before class members have been initialized.
// This is something that needs to be fixed in HDSkins
return localPony != null && localPony.wet ? NO_SKIN_SEAPONY : NO_SKIN_STEVE_PONY;
return NO_SKIN_STEVE_PONY;
}
if (type == MineLPHDSkins.seaponySkinType) {
return NO_SKIN_SEAPONY;
}
return super.getBlankSteveSkin(type);
}
@ -36,38 +34,22 @@ class PonyPreview extends PlayerPreview {
@Override
public Identifier getBlankAlexSkin(SkinType type) {
if (type == SkinType.SKIN) {
return localPony != null && localPony.wet ? NO_SKIN_SEAPONY : NO_SKIN_ALEX_PONY;
return NO_SKIN_ALEX_PONY;
}
if (type == MineLPHDSkins.seaponySkinType) {
return NO_SKIN_SEAPONY;
}
return getBlankSteveSkin(type);
}
protected DummyPlayer ponify(DummyPlayer human, DummyPlayer pony) {
Identifier loc = human.getTextures().get(SkinType.SKIN).getId();
if (loc == null) {
return pony;
}
IPony thePony = MineLittlePony.getInstance().getManager().getPony(loc);
Race race = thePony.getRace(true);
if (race.isHuman()) {
return human;
}
return pony;
}
@Override
public DummyPlayer getRemote() {
return ponify(super.getRemote(), remotePony);
return remotePony;
}
@Override
public DummyPlayer getLocal() {
return ponify(super.getLocal(), localPony);
return localPony;
}
}

View file

@ -1,5 +1,6 @@
package com.minelittlepony.client.mixin;
import com.minelittlepony.client.IPreviewModel;
import com.minelittlepony.client.MineLittlePony;
import com.minelittlepony.client.model.entity.race.PlayerModels;
@ -18,6 +19,9 @@ abstract class MixinEntityRenderDispatcher {
value = "INVOKE",
target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;getModel()Ljava/lang/String;"))
private String getPlayerModel(AbstractClientPlayerEntity player, Entity entity) {
if (player instanceof IPreviewModel) {
return player.getModel();
}
return PlayerModels.forRace(MineLittlePony.getInstance().getManager()
.getPony(player)
.getRace(false))

View file

@ -2,6 +2,7 @@ package com.minelittlepony.client.render.entity;
import com.minelittlepony.api.pony.IPony;
import com.minelittlepony.api.pony.meta.Race;
import com.minelittlepony.client.SkinsProxy;
import com.minelittlepony.client.model.ClientPonyModel;
import com.minelittlepony.client.model.ModelType;
import com.minelittlepony.client.model.ModelWrapper;
@ -11,6 +12,7 @@ import com.minelittlepony.util.MathUtil;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.util.Identifier;
public class PlayerSeaponyRenderer extends PlayerPonyRenderer {
@ -24,6 +26,11 @@ public class PlayerSeaponyRenderer extends PlayerPonyRenderer {
seapony = this.manager.getModelWrapper();
}
@Override
public Identifier getTexture(AbstractClientPlayerEntity player) {
return SkinsProxy.instance.getSeaponySkin(manager, player);
}
@Override
public IPony getEntityPony(AbstractClientPlayerEntity player) {
IPony pony = super.getEntityPony(player);