mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-26 14:27:59 +01:00
Reimplement Daring Doo (STEVE) / Night Guard (ALEX)
This commit is contained in:
parent
3dbedc3a5b
commit
d6c5e2bd0b
3 changed files with 28 additions and 29 deletions
|
@ -9,7 +9,9 @@ import com.minelittlepony.model.PMAPI;
|
|||
import com.minelittlepony.pony.data.Pony;
|
||||
import com.minelittlepony.pony.data.PonyLevel;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
|
@ -75,13 +77,16 @@ public class PonyManager implements IResourceManagerReloadListener {
|
|||
* @param player the player
|
||||
*/
|
||||
public Pony getPony(AbstractClientPlayer player) {
|
||||
Pony pony = getPony(player.getLocationSkin(), IPlayerInfo.getPlayerInfo(player).usesSlimArms());
|
||||
return getPony(IPlayerInfo.getPlayerInfo(player).unwrap());
|
||||
}
|
||||
|
||||
if (config.getPonyLevel() == PonyLevel.PONIES && pony.getMetadata().getRace().isHuman()) {
|
||||
return getBackgroundPony(player.getUniqueID());
|
||||
}
|
||||
public Pony getPony(NetworkPlayerInfo playerInfo) {
|
||||
ResourceLocation skin = playerInfo.getLocationSkin();
|
||||
UUID uuid = playerInfo.getGameProfile().getId();
|
||||
|
||||
return pony;
|
||||
if (skin == null) return getDefaultPony(uuid);
|
||||
|
||||
return getPony(skin, uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -118,14 +123,20 @@ public class PonyManager implements IResourceManagerReloadListener {
|
|||
}
|
||||
|
||||
private Pony getBackgroundPony(UUID uuid) {
|
||||
if (getNumberOfPonies() == 0) return getPony(getDefaultSkin(uuid), isSlimSkin(uuid));
|
||||
if (getNumberOfPonies() == 0 || isUser(uuid)) {
|
||||
return getPony(getDefaultSkin(uuid), isSlimSkin(uuid));
|
||||
}
|
||||
|
||||
int bgi = uuid.hashCode() % this.getNumberOfPonies();
|
||||
while (bgi < 0) bgi += this.getNumberOfPonies();
|
||||
int bgi = uuid.hashCode() % getNumberOfPonies();
|
||||
while (bgi < 0) bgi += getNumberOfPonies();
|
||||
|
||||
return getPony(backgroundPonyList.get(bgi), false);
|
||||
}
|
||||
|
||||
private boolean isUser(UUID uuid) {
|
||||
return Minecraft.getMinecraft().player != null && Minecraft.getMinecraft().player.getUniqueID().equals(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* De-registers a pony from the cache.
|
||||
*/
|
||||
|
@ -164,7 +175,7 @@ public class PonyManager implements IResourceManagerReloadListener {
|
|||
* Returns true if the given uuid is of a player would would use the ALEX skin type.
|
||||
*/
|
||||
public static boolean isSlimSkin(UUID uuid) {
|
||||
return (uuid.hashCode() & 1) == 1;
|
||||
return false;//(uuid.hashCode() & 1) == 1;
|
||||
}
|
||||
|
||||
private int getNumberOfPonies() {
|
||||
|
|
|
@ -1,16 +1,10 @@
|
|||
package com.minelittlepony.ducks;
|
||||
|
||||
import com.minelittlepony.pony.data.Pony;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
||||
|
||||
public interface IPlayerInfo {
|
||||
/**
|
||||
* Gets the pony associated with this player.
|
||||
*/
|
||||
Pony getPony();
|
||||
|
||||
/**
|
||||
* Returns true if the vanilla skin (the one returned by NetworkPlayerInfo.getSkinLocation) uses the ALEX model type.
|
||||
*/
|
||||
|
@ -22,4 +16,8 @@ public interface IPlayerInfo {
|
|||
public static IPlayerInfo getPlayerInfo(AbstractClientPlayer player) {
|
||||
return (IPlayerInfo)Minecraft.getMinecraft().getConnection().getPlayerInfo(player.getUniqueID());
|
||||
}
|
||||
|
||||
default NetworkPlayerInfo unwrap() {
|
||||
return (NetworkPlayerInfo)this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||
import com.minelittlepony.MineLittlePony;
|
||||
import com.minelittlepony.PonyManager;
|
||||
import com.minelittlepony.ducks.IPlayerInfo;
|
||||
import com.minelittlepony.pony.data.Pony;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
||||
|
@ -29,16 +28,7 @@ public abstract class MixinNetworkPlayerInfo implements IPlayerInfo {
|
|||
|
||||
@Inject(method = "getSkinType()Ljava/lang/String;", at = @At("RETURN"), cancellable = true)
|
||||
private void getSkinType(CallbackInfoReturnable<String> info) {
|
||||
info.setReturnValue(getPony().getRace(false).getModel().getId(usesSlimArms()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pony getPony() {
|
||||
ResourceLocation skin = getLocationSkin();
|
||||
if (skin == null) {
|
||||
return MineLittlePony.getInstance().getManager().getDefaultPony(getGameProfile().getId());
|
||||
}
|
||||
return MineLittlePony.getInstance().getManager().getPony(skin, getGameProfile().getId());
|
||||
info.setReturnValue(MineLittlePony.getInstance().getManager().getPony(unwrap()).getRace(false).getModel().getId(usesSlimArms()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue