mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 16:24:23 +01:00
Fix PonyLevel.PONIES not working correctly.
This commit is contained in:
parent
fd113f1b90
commit
91f741fa08
9 changed files with 41 additions and 24 deletions
|
@ -257,7 +257,7 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
|
|||
clearListeners.removeIf(this::onSkinCacheCleared);
|
||||
}
|
||||
|
||||
public void parseSkin(Type type, ResourceLocation resource, MinecraftProfileTexture texture) {
|
||||
public void parseSkin(GameProfile profile, Type type, ResourceLocation resource, MinecraftProfileTexture texture) {
|
||||
// grab the metadata object via reflection. Object is live.
|
||||
Map<String, String> metadata = ProfileTextureUtil.getMetadata(texture);
|
||||
boolean wasNull = metadata == null;
|
||||
|
@ -265,7 +265,7 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
|
|||
metadata = new HashMap<>();
|
||||
}
|
||||
for (ISkinParser parser : skinParsers) {
|
||||
parser.parse(type, resource, metadata);
|
||||
parser.parse(profile, type, resource, metadata);
|
||||
}
|
||||
if (wasNull && !metadata.isEmpty()) {
|
||||
ProfileTextureUtil.setMetadata(texture, metadata);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.voxelmodpack.hdskins;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
|
@ -15,9 +16,10 @@ public interface ISkinParser {
|
|||
* Parses the texture for metadata. Any discovered data should be put into
|
||||
* the metadata Map parameter.
|
||||
*
|
||||
* @param profile The profile whose skin is being parsed.
|
||||
* @param type The texture type
|
||||
* @param resource The texture location
|
||||
* @param metadata The metadata previously parsed
|
||||
*/
|
||||
void parse(Type type, ResourceLocation resource, Map<String, String> metadata);
|
||||
void parse(GameProfile profile, Type type, ResourceLocation resource, Map<String, String> metadata);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public abstract class MixinNetworkPlayerInfo$1 implements SkinManager.SkinAvaila
|
|||
CompletableFuture.runAsync(Runnables.doNothing())
|
||||
.thenAcceptAsync((v) -> {
|
||||
// schedule parsing next tick, texture may not be uploaded at this point
|
||||
HDSkinManager.INSTANCE.parseSkin(typeIn, location, profileTexture);
|
||||
HDSkinManager.INSTANCE.parseSkin(player.getGameProfile(), typeIn, location, profileTexture);
|
||||
|
||||
// re-set the skin-type because vanilla has already set it
|
||||
String model = profileTexture.getMetadata("model");
|
||||
|
|
|
@ -74,7 +74,7 @@ public abstract class MixinNetworkPlayerInfo implements INetworkPlayerInfo {
|
|||
CompletableFuture.runAsync(Runnables.doNothing())
|
||||
// schedule parsing next tick
|
||||
.thenAcceptAsync((v) -> {
|
||||
HDSkinManager.INSTANCE.parseSkin(typeIn, location, profileTexture);
|
||||
HDSkinManager.INSTANCE.parseSkin(gameProfile, typeIn, location, profileTexture);
|
||||
}, Minecraft.getMinecraft()::addScheduledTask);
|
||||
customTextures.put(type, location);
|
||||
customProfiles.put(type, profileTexture);
|
||||
|
|
|
@ -68,7 +68,9 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
|
|||
ResourceLocation skin = player.getLocationSkin();
|
||||
UUID uuid = player.getGameProfile().getId();
|
||||
|
||||
if (skin == null) return getDefaultPony(uuid);
|
||||
if (Pony.getBufferedImage(skin) == null) {
|
||||
return getDefaultPony(uuid);
|
||||
}
|
||||
|
||||
return getPony(skin, uuid);
|
||||
}
|
||||
|
@ -78,7 +80,9 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
|
|||
ResourceLocation skin = playerInfo.getLocationSkin();
|
||||
UUID uuid = playerInfo.getGameProfile().getId();
|
||||
|
||||
if (skin == null) return getDefaultPony(uuid);
|
||||
if (Pony.getBufferedImage(skin) == null) {
|
||||
return getDefaultPony(uuid);
|
||||
}
|
||||
|
||||
return getPony(skin, uuid);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.minelittlepony;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.voxelmodpack.hdskins.ISkinParser;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
@ -9,13 +10,14 @@ import java.util.Map;
|
|||
public class PonySkinParser implements ISkinParser {
|
||||
|
||||
@Override
|
||||
public void parse(MinecraftProfileTexture.Type type, ResourceLocation resource, Map<String, String> metadata) {
|
||||
public void parse(GameProfile profile, MinecraftProfileTexture.Type type, ResourceLocation resource,
|
||||
Map<String, String> metadata) {
|
||||
if (type == MinecraftProfileTexture.Type.SKIN) {
|
||||
boolean slim = "slim".equals(metadata.get("model"));
|
||||
// TODO use proper model metadata system
|
||||
|
||||
metadata.put("model", MineLittlePony.getInstance().getManager()
|
||||
.getPony(resource)
|
||||
.getPony(resource, profile.getId())
|
||||
.getRace(false)
|
||||
.getModel()
|
||||
.getId(slim));
|
||||
|
|
|
@ -64,7 +64,7 @@ public class RenderPonyModel extends RenderPlayerModel<EntityPonyModel> implemen
|
|||
renderingAsHuman = true;
|
||||
|
||||
ResourceLocation loc = getEntityTexture(playermodel);
|
||||
if (loc == null) {
|
||||
if (loc == null || Pony.getBufferedImage(loc) == null) {
|
||||
return super.getEntityModel(playermodel);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.minelittlepony.pony.data;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.minelittlepony.MineLittlePony;
|
||||
import com.voxelmodpack.hdskins.IBufferedTexture;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -42,9 +43,11 @@ public class Pony {
|
|||
|
||||
private IPonyData checkSkin(ResourceLocation resource) {
|
||||
IPonyData data = checkPonyMeta(resource);
|
||||
if (data != null) return data;
|
||||
if (data != null) {
|
||||
return data;
|
||||
}
|
||||
|
||||
BufferedImage skinImage = getBufferedImage(resource);
|
||||
BufferedImage skinImage = Preconditions.checkNotNull(getBufferedImage(resource), "bufferedImage: " + resource);
|
||||
return this.checkSkin(skinImage);
|
||||
}
|
||||
|
||||
|
@ -74,7 +77,8 @@ public class Pony {
|
|||
MineLittlePony.logger.debug("Obtained skin from resource location {}", resource);
|
||||
|
||||
return skinImage;
|
||||
} catch (IOException ignored) { }
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
|
||||
ITextureObject texture = Minecraft.getMinecraft().getTextureManager().getTexture(resource);
|
||||
|
||||
|
@ -85,8 +89,7 @@ public class Pony {
|
|||
return null;
|
||||
}
|
||||
|
||||
private IPonyData checkSkin(@Nullable BufferedImage bufferedimage) {
|
||||
if (bufferedimage == null) return new PonyData();
|
||||
private IPonyData checkSkin(BufferedImage bufferedimage) {
|
||||
MineLittlePony.logger.debug("\tStart skin check for pony #{} with image {}.", ponyId, bufferedimage);
|
||||
return PonyData.parse(bufferedimage);
|
||||
}
|
||||
|
@ -101,7 +104,8 @@ public class Pony {
|
|||
}
|
||||
|
||||
public boolean isFullySubmerged(EntityLivingBase entity) {
|
||||
return entity.isInWater() && entity.getEntityWorld().getBlockState(new BlockPos(getVisualEyePosition(entity))).getMaterial() == Material.WATER;
|
||||
return entity.isInWater()
|
||||
&& entity.getEntityWorld().getBlockState(new BlockPos(getVisualEyePosition(entity))).getMaterial() == Material.WATER;
|
||||
}
|
||||
|
||||
protected Vec3d getVisualEyePosition(EntityLivingBase entity) {
|
||||
|
|
|
@ -18,6 +18,8 @@ import net.minecraft.util.ResourceLocation;
|
|||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.mojang.authlib.minecraft.MinecraftProfileTexture.*;
|
||||
|
||||
public class PlayerSkullRenderer extends PonySkull {
|
||||
|
||||
private final ModelDeadMau5Ears deadMau5 = new ModelDeadMau5Ears();
|
||||
|
@ -41,20 +43,23 @@ public class PlayerSkullRenderer extends PonySkull {
|
|||
if (profile != null) {
|
||||
deadMau5.setVisible("deadmau5".equals(profile.getName()));
|
||||
|
||||
ResourceLocation skin = HDSkinManager.INSTANCE.getTextures(profile).get(MinecraftProfileTexture.Type.SKIN);
|
||||
ResourceLocation skin = HDSkinManager.INSTANCE.getTextures(profile).get(Type.SKIN);
|
||||
if (skin != null && Pony.getBufferedImage(skin) != null) {
|
||||
return skin;
|
||||
}
|
||||
|
||||
Minecraft minecraft = Minecraft.getMinecraft();
|
||||
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = minecraft.getSkinManager().loadSkinFromCache(profile);
|
||||
Map<Type, MinecraftProfileTexture> map = minecraft.getSkinManager().loadSkinFromCache(profile);
|
||||
|
||||
if (map.containsKey(MinecraftProfileTexture.Type.SKIN)) {
|
||||
return minecraft.getSkinManager().loadSkin(map.get(MinecraftProfileTexture.Type.SKIN), MinecraftProfileTexture.Type.SKIN);
|
||||
} else {
|
||||
return DefaultPlayerSkin.getDefaultSkin(EntityPlayer.getUUID(profile));
|
||||
if (map.containsKey(Type.SKIN)) {
|
||||
ResourceLocation loc = minecraft.getSkinManager().loadSkin(map.get(Type.SKIN), Type.SKIN);
|
||||
if (Pony.getBufferedImage(loc) != null) {
|
||||
return loc;
|
||||
}
|
||||
}
|
||||
return DefaultPlayerSkin.getDefaultSkin(EntityPlayer.getUUID(profile));
|
||||
|
||||
}
|
||||
|
||||
return DefaultPlayerSkin.getDefaultSkinLegacy();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue