New default skins
|
@ -22,5 +22,5 @@ org.gradle.daemon=false
|
|||
# Dependencies
|
||||
modmenu_version=5.0.0-alpha.3
|
||||
kirin_version=1.13.0-beta.3
|
||||
hd_skins_version=6.7.0-beta.2
|
||||
hd_skins_version=6.7.0-beta.3
|
||||
mson_version=1.7.0-beta.1
|
||||
|
|
2
skins
|
@ -1 +1 @@
|
|||
Subproject commit 203739b11aa6ab379e59b65bf4b320ab3d04755a
|
||||
Subproject commit 33af729369727ca03bf3883eda578dd5b2ced219
|
|
@ -1,5 +1,6 @@
|
|||
package com.minelittlepony.api.model;
|
||||
|
||||
import com.minelittlepony.api.pony.meta.Wearable;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
|
||||
public interface IPegasus extends IModel {
|
||||
|
@ -12,6 +13,11 @@ public interface IPegasus extends IModel {
|
|||
&& (MineLittlePony.getInstance().getConfig().flappyElytras.get() || !getAttributes().isGliding);
|
||||
}
|
||||
|
||||
|
||||
default boolean isBurdened() {
|
||||
return isWearing(Wearable.SADDLE_BAGS_BOTH) || isWearing(Wearable.SADDLE_BAGS_LEFT) || isWearing(Wearable.SADDLE_BAGS_RIGHT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the wings of this pegasus/flying creature
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package com.minelittlepony.api.pony;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class DefaultPonySkinHelper {
|
||||
public static final Identifier STEVE = new Identifier("minelittlepony", "textures/entity/player/wide/steve_pony.png");
|
||||
|
||||
private static final Map<Identifier, Identifier> SKINS = new HashMap<>();
|
||||
|
||||
public static Identifier getPonySkin(Identifier original) {
|
||||
return SKINS.computeIfAbsent(original, DefaultPonySkinHelper::computePonySkin);
|
||||
}
|
||||
|
||||
private static Identifier computePonySkin(Identifier original) {
|
||||
return new Identifier("minelittlepony", original.getPath().replace(".png", "_pony.png"));
|
||||
}
|
||||
}
|
|
@ -14,10 +14,6 @@ import java.util.UUID;
|
|||
*
|
||||
*/
|
||||
public interface IPonyManager {
|
||||
|
||||
Identifier STEVE = new Identifier("minelittlepony", "textures/entity/steve_pony.png");
|
||||
Identifier ALEX = new Identifier("minelittlepony", "textures/entity/alex_pony.png");
|
||||
|
||||
/**
|
||||
* Gets a pony representation of the passed in entity.
|
||||
*
|
||||
|
@ -48,17 +44,10 @@ public interface IPonyManager {
|
|||
* Delegates to the background-ponies registry if no pony skins were available and client settings allows it.
|
||||
*
|
||||
* @param resource A texture resource
|
||||
* @param uuid id of a player or entity
|
||||
* @param uuid id of a player
|
||||
*/
|
||||
IPony getPony(Identifier resource, UUID uuid);
|
||||
|
||||
/**
|
||||
* Gets the default pony. Either STEVE/ALEX, or a background pony based on client settings.
|
||||
*
|
||||
* @param uuid id of a player or entity
|
||||
*/
|
||||
IPony getDefaultPony(UUID uuid);
|
||||
|
||||
/**
|
||||
* Gets a random background pony determined by the given uuid.
|
||||
*
|
||||
|
@ -73,16 +62,5 @@ public interface IPonyManager {
|
|||
*/
|
||||
void removePony(Identifier resource);
|
||||
|
||||
static Identifier getDefaultSkin(UUID uuid) {
|
||||
return isSlimSkin(uuid) ? ALEX : STEVE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given uuid is of a player would would use the ALEX skin type.
|
||||
*/
|
||||
static boolean isSlimSkin(UUID uuid) {
|
||||
return (uuid.hashCode() & 1) == 1;
|
||||
}
|
||||
|
||||
interface ForcedPony {}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ import com.minelittlepony.api.pony.TriggerPixelType;
|
|||
import com.minelittlepony.api.pony.TriggerPixelValue;
|
||||
import com.minelittlepony.common.util.Color;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Individual trigger pixels for a pony skin.
|
||||
*
|
||||
|
@ -27,6 +29,10 @@ public enum TriggerPixel {
|
|||
|
||||
TriggerPixelType<?> def;
|
||||
|
||||
private static final TriggerPixel[] VALUES = values();
|
||||
private static final int MAX_READ_X = Arrays.stream(VALUES).mapToInt(i -> i.x).max().getAsInt();
|
||||
private static final int MAX_READ_Y = Arrays.stream(VALUES).mapToInt(i -> i.y).max().getAsInt();
|
||||
|
||||
TriggerPixel(TriggerPixelType<?> def, Channel channel, int x, int y) {
|
||||
this.def = def;
|
||||
this.channel = channel;
|
||||
|
@ -81,6 +87,10 @@ public enum TriggerPixel {
|
|||
out[value.ordinal()] |= value != def;
|
||||
}
|
||||
|
||||
public static boolean isTriggerPixelCoord(int x, int y) {
|
||||
return x <= MAX_READ_X && y <= MAX_READ_Y;
|
||||
}
|
||||
|
||||
enum Channel {
|
||||
RAW (0xFFFFFFFF, 0),
|
||||
ALL (0x00FFFFFF, 0),
|
||||
|
|
|
@ -7,13 +7,15 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
public enum Wearable implements TriggerPixelType<Wearable> {
|
||||
NONE (0x00),
|
||||
CROWN (0x16),
|
||||
MUFFIN (0x32),
|
||||
HAT (0x64),
|
||||
ANTLERS (0x96),
|
||||
SADDLE_BAGS (0xC8),
|
||||
STETSON (0xFA);
|
||||
NONE (0x00),
|
||||
CROWN (0x16),
|
||||
MUFFIN (0x32),
|
||||
HAT (0x64),
|
||||
ANTLERS (0x96),
|
||||
SADDLE_BAGS_LEFT (0xC6),
|
||||
SADDLE_BAGS_RIGHT (0xC7),
|
||||
SADDLE_BAGS_BOTH (0xC8),
|
||||
STETSON (0xFA);
|
||||
|
||||
private int triggerValue;
|
||||
|
||||
|
@ -26,6 +28,10 @@ public enum Wearable implements TriggerPixelType<Wearable> {
|
|||
return triggerValue;
|
||||
}
|
||||
|
||||
public boolean isSaddlebags() {
|
||||
return this == SADDLE_BAGS_BOTH || this == SADDLE_BAGS_LEFT || this == SADDLE_BAGS_RIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChannelAdjustedColorCode() {
|
||||
return triggerValue == 0 ? 0 : Color.argbToHex(255, triggerValue, triggerValue, triggerValue);
|
||||
|
|
|
@ -42,7 +42,7 @@ public class SkinsProxy {
|
|||
}
|
||||
|
||||
public Identifier getSeaponySkin(EquineRenderManager<AbstractClientPlayerEntity, ClientPonyModel<AbstractClientPlayerEntity>> manager, AbstractClientPlayerEntity player) {
|
||||
return manager.getPony(player).texture();
|
||||
return manager.getTexture(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.minelittlepony.client.MineLittlePony;
|
|||
import com.minelittlepony.common.client.gui.dimension.Bounds;
|
||||
import com.minelittlepony.hdskins.client.dummy.*;
|
||||
import com.minelittlepony.hdskins.profile.SkinType;
|
||||
import com.minelittlepony.settings.PonyLevel;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -30,15 +31,17 @@ class PonyPreview extends PlayerPreview {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Identifier getBlankSkin(SkinType type, boolean slim) {
|
||||
if (type == SkinType.SKIN) {
|
||||
return slim ? NO_SKIN_ALEX_PONY : NO_SKIN_STEVE_PONY;
|
||||
public Identifier getDefaultSkin(SkinType type, boolean slim) {
|
||||
if (MineLittlePony.getInstance().getConfig().ponyLevel.get() == PonyLevel.PONIES) {
|
||||
if (type == SkinType.SKIN) {
|
||||
return slim ? NO_SKIN_ALEX_PONY : NO_SKIN_STEVE_PONY;
|
||||
}
|
||||
}
|
||||
if (type == MineLPHDSkins.seaponySkinType) {
|
||||
return NO_SKIN_SEAPONY;
|
||||
}
|
||||
|
||||
return super.getBlankSkin(type, slim);
|
||||
return super.getDefaultSkin(type, slim);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.minelittlepony.client.mixin;
|
||||
|
||||
import com.minelittlepony.api.pony.IPonyManager;
|
||||
import com.minelittlepony.api.pony.DefaultPonySkinHelper;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.settings.PonyLevel;
|
||||
|
||||
|
@ -14,35 +14,34 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||
import java.util.UUID;
|
||||
|
||||
@Mixin(DefaultSkinHelper.class)
|
||||
abstract class MixinDefaultPlayerSkin {
|
||||
abstract class MixinDefaultSkinHelper {
|
||||
@Inject(method = "getTexture()Lnet/minecraft/util/Identifier;",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true)
|
||||
private static void legacySkin(CallbackInfoReturnable<Identifier> cir) {
|
||||
private static void onGetTexture(CallbackInfoReturnable<Identifier> cir) {
|
||||
if (MineLittlePony.getInstance().getConfig().ponyLevel.get() == PonyLevel.PONIES) {
|
||||
cir.setReturnValue(IPonyManager.STEVE);
|
||||
cir.setReturnValue(DefaultPonySkinHelper.getPonySkin(cir.getReturnValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getTexture(Ljava/util/UUID;)Lnet/minecraft/util/Identifier;",
|
||||
at = @At("HEAD"),
|
||||
at = @At("RETURN"),
|
||||
cancellable = true)
|
||||
private static void defaultSkin(UUID uuid, CallbackInfoReturnable<Identifier> cir) {
|
||||
private static void onGetTexture(UUID uuid, CallbackInfoReturnable<Identifier> cir) {
|
||||
if (MineLittlePony.getInstance().getConfig().ponyLevel.get() == PonyLevel.PONIES) {
|
||||
cir.setReturnValue(IPonyManager.getDefaultSkin(uuid));
|
||||
cir.setReturnValue(DefaultPonySkinHelper.getPonySkin(cir.getReturnValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getModel(Ljava/util/UUID;)Ljava/lang/String;",
|
||||
at = @At("HEAD"),
|
||||
at = @At("RETURN"),
|
||||
cancellable = true)
|
||||
private static void skinType(UUID uuid, CallbackInfoReturnable<String> cir) {
|
||||
private static void onGetModel(UUID uuid, CallbackInfoReturnable<String> cir) {
|
||||
if (MineLittlePony.getInstance().getConfig().ponyLevel.get() == PonyLevel.PONIES) {
|
||||
|
||||
cir.setReturnValue(MineLittlePony.getInstance().getManager()
|
||||
.getPony(IPonyManager.getDefaultSkin(uuid), uuid)
|
||||
.getPony(DefaultSkinHelper.getTexture(uuid), uuid)
|
||||
.race()
|
||||
.getModelId(IPonyManager.isSlimSkin(uuid)));
|
||||
.getModelId("slim".equalsIgnoreCase(cir.getReturnValue())));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,7 +18,7 @@ import net.minecraft.world.World;
|
|||
import net.minecraft.client.render.item.ItemRenderer;
|
||||
|
||||
@Mixin(HeldItemRenderer.class)
|
||||
abstract class MixinFirstPersonRenderer {
|
||||
abstract class MixinHeldItemRenderer {
|
||||
private static final String LivingEntity = "Lnet/minecraft/entity/LivingEntity;";
|
||||
private static final String MatrixStack = "Lnet/minecraft/client/util/math/MatrixStack;";
|
||||
private static final String ItemStack = "Lnet/minecraft/item/ItemStack;";
|
|
@ -56,7 +56,7 @@ public final class ModelType {
|
|||
public static final ModelKey<PonyArmourModel<?>> ARMOUR_OUTER = register("armour_outer", PonyArmourModel::new);
|
||||
|
||||
public static final ModelKey<Stetson> STETSON = registerGear("stetson", Wearable.STETSON, Stetson::new);
|
||||
public static final ModelKey<SaddleBags> SADDLEBAGS = registerGear("saddlebags", Wearable.SADDLE_BAGS, SaddleBags::new);
|
||||
public static final ModelKey<SaddleBags> SADDLEBAGS = registerGear("saddlebags", Wearable.SADDLE_BAGS_BOTH, SaddleBags::new);
|
||||
public static final ModelKey<Crown> CROWN = registerGear("crown", Wearable.CROWN, Crown::new);
|
||||
public static final ModelKey<Muffin> MUFFIN = registerGear("muffin", Wearable.MUFFIN, Muffin::new);
|
||||
public static final ModelKey<WitchHat> WITCH_HAT = registerGear("witch_hat", Wearable.HAT, WitchHat::new);
|
||||
|
|
|
@ -60,6 +60,9 @@ public class SaddleBags extends AbstractGear implements PonyModelConstants {
|
|||
leftBag.roll = bodySwing;
|
||||
rightBag.roll = -bodySwing;
|
||||
|
||||
leftBag.visible = model.isWearing(Wearable.SADDLE_BAGS_BOTH) || model.isWearing(Wearable.SADDLE_BAGS_LEFT);
|
||||
rightBag.visible = model.isWearing(Wearable.SADDLE_BAGS_BOTH) || model.isWearing(Wearable.SADDLE_BAGS_RIGHT);
|
||||
|
||||
dropAmount = hangLow ? 0.15F : 0;
|
||||
dropAmount = model.getMetadata().getInterpolator(interpolatorId).interpolate("dropAmount", dropAmount, 3);
|
||||
}
|
||||
|
@ -73,16 +76,22 @@ public class SaddleBags extends AbstractGear implements PonyModelConstants {
|
|||
stack.push();
|
||||
stack.translate(0, dropAmount, 0);
|
||||
|
||||
if (!rightBag.visible || !leftBag.visible) {
|
||||
stack.translate(0, 0.3F, -0.3F);
|
||||
}
|
||||
|
||||
leftBag.render(stack, renderContext, overlayUv, lightUv, red, green, blue, alpha);
|
||||
rightBag.render(stack, renderContext, overlayUv, lightUv, red, green, blue, alpha);
|
||||
|
||||
stack.pop();
|
||||
strap.render(stack, renderContext, overlayUv, lightUv, red, green, blue, alpha);
|
||||
if (leftBag.visible && rightBag.visible) {
|
||||
strap.render(stack, renderContext, overlayUv, lightUv, red, green, blue, alpha);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRender(IModel model, Entity entity) {
|
||||
return model.isWearing(Wearable.SADDLE_BAGS);
|
||||
return model.isWearing(Wearable.SADDLE_BAGS_BOTH) || model.isWearing(Wearable.SADDLE_BAGS_LEFT) || model.isWearing(Wearable.SADDLE_BAGS_RIGHT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -92,6 +101,6 @@ public class SaddleBags extends AbstractGear implements PonyModelConstants {
|
|||
|
||||
@Override
|
||||
public <T extends Entity> Identifier getTexture(T entity, Context<T, ?> context) {
|
||||
return context.getDefaultTexture(entity, Wearable.SADDLE_BAGS);
|
||||
return context.getDefaultTexture(entity, Wearable.SADDLE_BAGS_BOTH);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class PegasusWings<T extends Model & IPegasus> implements IPart, MsonMode
|
|||
}
|
||||
|
||||
public Wing getRight() {
|
||||
return pegasus.isWearing(Wearable.SADDLE_BAGS) ? legacyWing : rightWing;
|
||||
return pegasus.isBurdened() ? legacyWing : rightWing;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -66,7 +66,7 @@ public class PegasusWings<T extends Model & IPegasus> implements IPart, MsonMode
|
|||
|
||||
if (pegasus.wingsAreOpen()) {
|
||||
flapAngle = pegasus.getWingRotationFactor(ticks);
|
||||
if (!pegasus.getAttributes().isCrouching && pegasus.isWearing(Wearable.SADDLE_BAGS)) {
|
||||
if (!pegasus.getAttributes().isCrouching && pegasus.isBurdened()) {
|
||||
flapAngle -= 1F;
|
||||
}
|
||||
} else {
|
||||
|
@ -118,7 +118,7 @@ public class PegasusWings<T extends Model & IPegasus> implements IPart, MsonMode
|
|||
if (pegasus.wingsAreOpen()) {
|
||||
extended.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
} else {
|
||||
boolean bags = pegasus.isWearing(Wearable.SADDLE_BAGS);
|
||||
boolean bags = pegasus.isWearing(Wearable.SADDLE_BAGS_BOTH);
|
||||
if (bags) {
|
||||
stack.push();
|
||||
stack.translate(0, 0, 0.198F);
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
package com.minelittlepony.client.pony;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.resource.ResourceManager;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import com.minelittlepony.api.pony.IPonyManager;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.util.MathUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* All currently loaded background ponies.
|
||||
*/
|
||||
class BackgroundPonyList {
|
||||
/**
|
||||
* All currently loaded background ponies.
|
||||
*/
|
||||
private final List<Identifier> backgroundPonyList = new ArrayList<>();
|
||||
|
||||
private final Identifier id;
|
||||
|
||||
public BackgroundPonyList(Identifier id) {
|
||||
this.id = id;
|
||||
reloadAll(MinecraftClient.getInstance().getResourceManager());
|
||||
}
|
||||
|
||||
public Identifier getId(UUID uuid) {
|
||||
if (backgroundPonyList.isEmpty() || isUser(uuid)) {
|
||||
return IPonyManager.getDefaultSkin(uuid);
|
||||
}
|
||||
|
||||
int bgi = MathUtil.mod(uuid.hashCode(), backgroundPonyList.size());
|
||||
|
||||
return backgroundPonyList.get(bgi);
|
||||
}
|
||||
|
||||
public void reloadAll(ResourceManager resourceManager) {
|
||||
backgroundPonyList.clear();
|
||||
backgroundPonyList.addAll(resourceManager.findResources(id.getPath(), path -> path.getPath().endsWith(".png")).keySet());
|
||||
MineLittlePony.logger.info("Detected {} ponies installed at {}.", backgroundPonyList.size(), id);
|
||||
}
|
||||
|
||||
static boolean isUser(UUID uuid) {
|
||||
return MinecraftClient.getInstance().player != null
|
||||
&& MinecraftClient.getInstance().player.getUuid().equals(uuid);
|
||||
}
|
||||
}
|
|
@ -57,7 +57,7 @@ class NativePonyData implements IPonyData {
|
|||
|
||||
@Override
|
||||
public Race getRace() {
|
||||
return race.getValue();
|
||||
return PonyConfig.getEffectiveRace(race.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -92,7 +92,7 @@ class NativePonyData implements IPonyData {
|
|||
|
||||
@Override
|
||||
public boolean hasHorn() {
|
||||
return getRace() != null && PonyConfig.getEffectiveRace(getRace()).hasHorn();
|
||||
return getRace().hasHorn();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -99,7 +99,7 @@ public class PonyData implements IPonyData {
|
|||
|
||||
@Override
|
||||
public Race getRace() {
|
||||
return race;
|
||||
return PonyConfig.getEffectiveRace(race);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -134,7 +134,7 @@ public class PonyData implements IPonyData {
|
|||
|
||||
@Override
|
||||
public boolean hasHorn() {
|
||||
return getRace() != null && PonyConfig.getEffectiveRace(getRace()).hasHorn();
|
||||
return getRace().hasHorn();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.google.common.cache.*;
|
|||
import com.minelittlepony.api.pony.IPony;
|
||||
import com.minelittlepony.api.pony.IPonyManager;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.render.IPonyRenderContext;
|
||||
import com.minelittlepony.client.render.PonyRenderDispatcher;
|
||||
import com.minelittlepony.client.render.blockentity.skull.PonySkullRenderer;
|
||||
import com.minelittlepony.settings.PonyConfig;
|
||||
|
@ -30,7 +29,6 @@ import java.util.concurrent.TimeUnit;
|
|||
*
|
||||
*/
|
||||
public class PonyManager implements IPonyManager, SimpleSynchronousResourceReloadListener {
|
||||
|
||||
private static final Identifier ID = new Identifier("minelittlepony", "background_ponies");
|
||||
public static final Identifier BACKGROUND_PONIES = new Identifier("minelittlepony", "textures/entity/pony");
|
||||
|
||||
|
@ -48,22 +46,6 @@ public class PonyManager implements IPonyManager, SimpleSynchronousResourceReloa
|
|||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<IPony> getPony(@Nullable Entity entity) {
|
||||
if (entity instanceof PlayerEntity player) {
|
||||
return Optional.of(getPony(player));
|
||||
}
|
||||
|
||||
if (entity instanceof LivingEntity living) {
|
||||
IPonyRenderContext<LivingEntity, ?> dispatcher = PonyRenderDispatcher.getInstance().getPonyRenderer(living);
|
||||
if (dispatcher != null) {
|
||||
return Optional.of(dispatcher.getEntityPony(living));
|
||||
}
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPony getPony(Identifier resource) {
|
||||
try {
|
||||
|
@ -74,16 +56,29 @@ public class PonyManager implements IPonyManager, SimpleSynchronousResourceReloa
|
|||
}
|
||||
|
||||
@Override
|
||||
public IPony getPony(PlayerEntity player) {
|
||||
if (player.getGameProfile() == null) {
|
||||
return getDefaultPony(player.getUuid());
|
||||
public Optional<IPony> getPony(@Nullable Entity entity) {
|
||||
if (entity instanceof PlayerEntity player) {
|
||||
return Optional.of(getPony(player));
|
||||
}
|
||||
|
||||
if (entity instanceof LivingEntity living) {
|
||||
return Optional.ofNullable(PonyRenderDispatcher.getInstance().getPonyRenderer(living)).map(d -> d.getEntityPony(living));
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPony getPony(PlayerEntity player) {
|
||||
Identifier skin = getSkin(player);
|
||||
UUID uuid = player.getGameProfile().getId();
|
||||
UUID uuid = player.getGameProfile() == null ? player.getUuid() : player.getGameProfile().getId();
|
||||
|
||||
if (skin == null) {
|
||||
return getDefaultPony(uuid);
|
||||
if (config.ponyLevel.get() == PonyLevel.PONIES) {
|
||||
return getBackgroundPony(uuid);
|
||||
}
|
||||
|
||||
return getAsDefaulted(getPony(DefaultSkinHelper.getTexture(uuid)));
|
||||
}
|
||||
|
||||
if (player instanceof IPonyManager.ForcedPony) {
|
||||
|
@ -93,15 +88,6 @@ public class PonyManager implements IPonyManager, SimpleSynchronousResourceReloa
|
|||
return getPony(skin, uuid);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Identifier getSkin(PlayerEntity player) {
|
||||
if (player instanceof AbstractClientPlayerEntity) {
|
||||
return ((AbstractClientPlayerEntity)player).getSkinTexture();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPony getPony(Identifier resource, UUID uuid) {
|
||||
IPony pony = getPony(resource);
|
||||
|
@ -113,6 +99,11 @@ public class PonyManager implements IPonyManager, SimpleSynchronousResourceReloa
|
|||
return pony;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPony getBackgroundPony(UUID uuid) {
|
||||
return getAsDefaulted(getPony(MineLittlePony.getInstance().getVariatedTextures().get(BACKGROUND_PONIES, uuid).orElse(DefaultSkinHelper.getTexture(uuid))));
|
||||
}
|
||||
|
||||
private IPony getAsDefaulted(IPony pony) {
|
||||
try {
|
||||
return defaultedPoniesCache.get(pony.texture(), () -> new Pony(pony.texture(), ((Pony)pony).memoizedData(), true));
|
||||
|
@ -121,18 +112,16 @@ public class PonyManager implements IPonyManager, SimpleSynchronousResourceReloa
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPony getDefaultPony(UUID uuid) {
|
||||
if (config.ponyLevel.get() != PonyLevel.PONIES) {
|
||||
return getAsDefaulted(getPony(DefaultSkinHelper.getTexture(uuid)));
|
||||
@Nullable
|
||||
private Identifier getSkin(PlayerEntity player) {
|
||||
if (player.getGameProfile() == null) {
|
||||
return null;
|
||||
}
|
||||
if (player instanceof AbstractClientPlayerEntity) {
|
||||
return ((AbstractClientPlayerEntity)player).getSkinTexture();
|
||||
}
|
||||
|
||||
return getBackgroundPony(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPony getBackgroundPony(UUID uuid) {
|
||||
return getAsDefaulted(getPony(MineLittlePony.getInstance().getVariatedTextures().get(BACKGROUND_PONIES, uuid)));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,18 +1,20 @@
|
|||
package com.minelittlepony.client.pony;
|
||||
|
||||
import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.resource.ResourceManager;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.util.MathUtil;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class VariatedTextureSupplier implements SimpleSynchronousResourceReloadListener {
|
||||
private static final Identifier ID = new Identifier("minelittlepony", "variated_textures");
|
||||
|
||||
private final Map<Identifier, BackgroundPonyList> entries = new HashMap<>();
|
||||
private final Map<Identifier, SkinList> entries = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void reload(ResourceManager manager) {
|
||||
|
@ -24,15 +26,46 @@ public class VariatedTextureSupplier implements SimpleSynchronousResourceReloadL
|
|||
return ID;
|
||||
}
|
||||
|
||||
private BackgroundPonyList get(Identifier id) {
|
||||
return entries.computeIfAbsent(id, BackgroundPonyList::new);
|
||||
private SkinList get(Identifier id) {
|
||||
return entries.computeIfAbsent(id, SkinList::new);
|
||||
}
|
||||
|
||||
public Identifier get(Identifier poolId, UUID seed) {
|
||||
public Optional<Identifier> get(Identifier poolId, UUID seed) {
|
||||
return get(poolId).getId(seed);
|
||||
}
|
||||
|
||||
public Identifier get(Identifier poolId, Entity entity) {
|
||||
public Optional<Identifier> get(Identifier poolId, Entity entity) {
|
||||
return get(poolId, entity.getUuid());
|
||||
}
|
||||
|
||||
private static class SkinList {
|
||||
private final List<Identifier> textures = new ArrayList<>();
|
||||
|
||||
private final Identifier id;
|
||||
|
||||
public SkinList(Identifier id) {
|
||||
this.id = id;
|
||||
reloadAll(MinecraftClient.getInstance().getResourceManager());
|
||||
}
|
||||
|
||||
public Optional<Identifier> getId(UUID uuid) {
|
||||
if (textures.isEmpty() || isUser(uuid)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
return Optional.ofNullable(textures.get(MathUtil.mod(uuid.hashCode(), textures.size())));
|
||||
}
|
||||
|
||||
public void reloadAll(ResourceManager resourceManager) {
|
||||
textures.clear();
|
||||
textures.addAll(resourceManager.findResources(id.getPath(), path -> path.getPath().endsWith(".png")).keySet());
|
||||
MineLittlePony.logger.info("Detected {} ponies installed at {}.", textures.size(), id);
|
||||
}
|
||||
|
||||
static boolean isUser(UUID uuid) {
|
||||
return MinecraftClient.getInstance().player != null
|
||||
&& MinecraftClient.getInstance().player.getUuid().equals(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -185,6 +185,10 @@ public class EquineRenderManager<T extends LivingEntity, M extends EntityModel<T
|
|||
return pony;
|
||||
}
|
||||
|
||||
public Identifier getTexture(T entity) {
|
||||
return getPony(entity).texture();
|
||||
}
|
||||
|
||||
public float getShadowScale() {
|
||||
return getModel().getSize().getShadowSize();
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import net.minecraft.entity.passive.AllayEntity;
|
|||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import com.minelittlepony.api.pony.DefaultPonySkinHelper;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.entity.BreezieModel;
|
||||
|
@ -24,7 +25,7 @@ public class AllayRenderer extends MobEntityRenderer<AllayEntity, BreezieModel<A
|
|||
|
||||
@Override
|
||||
public Identifier getTexture(AllayEntity allayEntity) {
|
||||
return MineLittlePony.getInstance().getVariatedTextures().get(BREEZIE_PONIES, allayEntity);
|
||||
return MineLittlePony.getInstance().getVariatedTextures().get(BREEZIE_PONIES, allayEntity).orElse(DefaultPonySkinHelper.STEVE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -178,7 +178,7 @@ public class PlayerPonyRenderer extends PlayerEntityRenderer implements IPonyRen
|
|||
|
||||
@Override
|
||||
public Identifier getTexture(AbstractClientPlayerEntity player) {
|
||||
return manager.getPony(player).texture();
|
||||
return manager.getTexture(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -198,7 +198,7 @@ public class PlayerPonyRenderer extends PlayerEntityRenderer implements IPonyRen
|
|||
|
||||
@Override
|
||||
public Identifier getDefaultTexture(AbstractClientPlayerEntity entity, Wearable wearable) {
|
||||
if (wearable == Wearable.SADDLE_BAGS) {
|
||||
if (wearable.isSaddlebags()) {
|
||||
if (getInternalRenderer().getModel().getMetadata().getRace() == Race.BATPONY) {
|
||||
return SaddleBags.TEXTURE;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.client.util.math.MatrixStack;
|
|||
import net.minecraft.entity.passive.StriderEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import com.minelittlepony.api.pony.DefaultPonySkinHelper;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
|
||||
|
@ -24,7 +25,7 @@ public class StriderRenderer extends MobEntityRenderer<StriderEntity, EntityMode
|
|||
|
||||
@Override
|
||||
public Identifier getTexture(StriderEntity entity) {
|
||||
return MineLittlePony.getInstance().getVariatedTextures().get(entity.isCold() ? COLD_DRAGON_PONIES : DRAGON_PONIES, entity);
|
||||
return MineLittlePony.getInstance().getVariatedTextures().get(entity.isCold() ? COLD_DRAGON_PONIES : DRAGON_PONIES, entity).orElse(DefaultPonySkinHelper.STEVE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,6 +5,7 @@ import net.minecraft.client.util.math.MatrixStack;
|
|||
import net.minecraft.entity.mob.VexEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import com.minelittlepony.api.pony.DefaultPonySkinHelper;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.entity.ParaspriteModel;
|
||||
|
@ -23,7 +24,7 @@ public class VexRenderer extends MobEntityRenderer<VexEntity, ParaspriteModel<Ve
|
|||
|
||||
@Override
|
||||
public Identifier getTexture(VexEntity entity) {
|
||||
return MineLittlePony.getInstance().getVariatedTextures().get(PARASPRITE_PONIES, entity);
|
||||
return MineLittlePony.getInstance().getVariatedTextures().get(PARASPRITE_PONIES, entity).orElse(DefaultPonySkinHelper.STEVE);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ abstract class AbstractNpcRenderer<T extends MobEntity & VillagerDataContainer>
|
|||
|
||||
boolean special = PonyTextures.isBestPony(entity);
|
||||
|
||||
if (wearable == Wearable.SADDLE_BAGS) {
|
||||
if (wearable.isSaddlebags()) {
|
||||
VillagerProfession profession = entity.getVillagerData().getProfession();
|
||||
return !special && profession != VillagerProfession.NONE && (
|
||||
profession == VillagerProfession.CARTOGRAPHER
|
||||
|
@ -75,7 +75,7 @@ abstract class AbstractNpcRenderer<T extends MobEntity & VillagerDataContainer>
|
|||
|
||||
@Override
|
||||
public Identifier getDefaultTexture(T villager, Wearable wearable) {
|
||||
if (wearable == Wearable.SADDLE_BAGS) {
|
||||
if (wearable.isSaddlebags()) {
|
||||
return clothing.createTexture(villager, "accessory");
|
||||
}
|
||||
return getTexture(villager);
|
||||
|
|
|
@ -99,7 +99,7 @@ public class PonyConfig extends Config {
|
|||
* Gets the actual race determined by the given pony level.
|
||||
* PonyLevel.HUMANS would force all races to be humans.
|
||||
* PonyLevel.BOTH is no change.
|
||||
* PonyLevel.PONIES (should) return a pony if this is a human. Don't be fooled, though. It doesn't.
|
||||
* PonyLevel.PONIES no change.
|
||||
*/
|
||||
public static Race getEffectiveRace(Race race) {
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
"pivot": [0, 13, -2],
|
||||
"rotate": [90, 0, 0],
|
||||
"cubes": [
|
||||
{"from": [4, 5, 2], "size": [2, 6, 2] },
|
||||
{"from": [4, 5, 4], "size": [2, 8, 2] },
|
||||
{"from": [4, 5, 6], "size": [2, 6, 2] }
|
||||
{"from": [4.1, 5, 1.999], "size": [2, 6, 2] },
|
||||
{"from": [4.1, 5, 4.001], "size": [2, 8, 2] },
|
||||
{"from": [4.1, 5, 6.002], "size": [2, 6, 2] }
|
||||
]
|
||||
},
|
||||
"extended": {
|
||||
|
@ -40,9 +40,9 @@
|
|||
"pivot": [0, 13, -2],
|
||||
"rotate": [90, 0, 0],
|
||||
"cubes": [
|
||||
{"from": [-6, 5, 2], "size": [2, 6, 2] },
|
||||
{"from": [-6, 5, 4], "size": [2, 8, 2] },
|
||||
{"from": [-6, 5, 6], "size": [2, 6, 2] }
|
||||
{"from": [-6.001, 5, 1.999], "size": [2, 6, 2] },
|
||||
{"from": [-6.001, 5, 4.001], "size": [2, 8, 2] },
|
||||
{"from": [-6.001, 5, 6.002], "size": [2, 6, 2] }
|
||||
]
|
||||
},
|
||||
"extended": {
|
||||
|
@ -70,9 +70,9 @@
|
|||
"pivot": [0, 13, -2],
|
||||
"rotate": [90, 0, 0],
|
||||
"cubes": [
|
||||
{"from": [-6, 5, 2], "size": [2, 6, 2] },
|
||||
{"from": [-6, 5, 4], "size": [2, 8, 2] },
|
||||
{"from": [-6, 5, 6], "size": [2, 6, 2] }
|
||||
{"from": [-6.001, 5, 1.999], "size": [2, 6, 2] },
|
||||
{"from": [-6.001, 5, 4.001], "size": [2, 8, 2] },
|
||||
{"from": [-6.001, 5, 6.002], "size": [2, 6, 2] }
|
||||
]
|
||||
},
|
||||
"extended": {
|
||||
|
|
Before Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 6.2 KiB |
After Width: | Height: | Size: 5.1 KiB |
After Width: | Height: | Size: 6.3 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 5.5 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 7.6 KiB |
After Width: | Height: | Size: 7 KiB |
After Width: | Height: | Size: 6 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 6.9 KiB |
After Width: | Height: | Size: 1.3 KiB |
|
@ -7,11 +7,11 @@
|
|||
"client": [
|
||||
"IResizeable",
|
||||
"MixinCamera",
|
||||
"MixinDefaultPlayerSkin",
|
||||
"MixinDefaultSkinHelper",
|
||||
"MixinEntityRenderDispatcher",
|
||||
"MixinEntityRenderers",
|
||||
"MixinSkullBlockEntityRenderer",
|
||||
"MixinFirstPersonRenderer",
|
||||
"MixinHeldItemRenderer",
|
||||
"MixinItemRenderer",
|
||||
"MixinTexturedRenderLayers",
|
||||
"MixinSpriteIdentifier",
|
||||
|
|