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);
|
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.
|
// grab the metadata object via reflection. Object is live.
|
||||||
Map<String, String> metadata = ProfileTextureUtil.getMetadata(texture);
|
Map<String, String> metadata = ProfileTextureUtil.getMetadata(texture);
|
||||||
boolean wasNull = metadata == null;
|
boolean wasNull = metadata == null;
|
||||||
|
@ -265,7 +265,7 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
|
||||||
metadata = new HashMap<>();
|
metadata = new HashMap<>();
|
||||||
}
|
}
|
||||||
for (ISkinParser parser : skinParsers) {
|
for (ISkinParser parser : skinParsers) {
|
||||||
parser.parse(type, resource, metadata);
|
parser.parse(profile, type, resource, metadata);
|
||||||
}
|
}
|
||||||
if (wasNull && !metadata.isEmpty()) {
|
if (wasNull && !metadata.isEmpty()) {
|
||||||
ProfileTextureUtil.setMetadata(texture, metadata);
|
ProfileTextureUtil.setMetadata(texture, metadata);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.voxelmodpack.hdskins;
|
package com.voxelmodpack.hdskins;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
@ -15,9 +16,10 @@ public interface ISkinParser {
|
||||||
* Parses the texture for metadata. Any discovered data should be put into
|
* Parses the texture for metadata. Any discovered data should be put into
|
||||||
* the metadata Map parameter.
|
* the metadata Map parameter.
|
||||||
*
|
*
|
||||||
|
* @param profile The profile whose skin is being parsed.
|
||||||
* @param type The texture type
|
* @param type The texture type
|
||||||
* @param resource The texture location
|
* @param resource The texture location
|
||||||
* @param metadata The metadata previously parsed
|
* @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())
|
CompletableFuture.runAsync(Runnables.doNothing())
|
||||||
.thenAcceptAsync((v) -> {
|
.thenAcceptAsync((v) -> {
|
||||||
// schedule parsing next tick, texture may not be uploaded at this point
|
// 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
|
// re-set the skin-type because vanilla has already set it
|
||||||
String model = profileTexture.getMetadata("model");
|
String model = profileTexture.getMetadata("model");
|
||||||
|
|
|
@ -74,7 +74,7 @@ public abstract class MixinNetworkPlayerInfo implements INetworkPlayerInfo {
|
||||||
CompletableFuture.runAsync(Runnables.doNothing())
|
CompletableFuture.runAsync(Runnables.doNothing())
|
||||||
// schedule parsing next tick
|
// schedule parsing next tick
|
||||||
.thenAcceptAsync((v) -> {
|
.thenAcceptAsync((v) -> {
|
||||||
HDSkinManager.INSTANCE.parseSkin(typeIn, location, profileTexture);
|
HDSkinManager.INSTANCE.parseSkin(gameProfile, typeIn, location, profileTexture);
|
||||||
}, Minecraft.getMinecraft()::addScheduledTask);
|
}, Minecraft.getMinecraft()::addScheduledTask);
|
||||||
customTextures.put(type, location);
|
customTextures.put(type, location);
|
||||||
customProfiles.put(type, profileTexture);
|
customProfiles.put(type, profileTexture);
|
||||||
|
|
|
@ -68,7 +68,9 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
|
||||||
ResourceLocation skin = player.getLocationSkin();
|
ResourceLocation skin = player.getLocationSkin();
|
||||||
UUID uuid = player.getGameProfile().getId();
|
UUID uuid = player.getGameProfile().getId();
|
||||||
|
|
||||||
if (skin == null) return getDefaultPony(uuid);
|
if (Pony.getBufferedImage(skin) == null) {
|
||||||
|
return getDefaultPony(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
return getPony(skin, uuid);
|
return getPony(skin, uuid);
|
||||||
}
|
}
|
||||||
|
@ -78,7 +80,9 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
|
||||||
ResourceLocation skin = playerInfo.getLocationSkin();
|
ResourceLocation skin = playerInfo.getLocationSkin();
|
||||||
UUID uuid = playerInfo.getGameProfile().getId();
|
UUID uuid = playerInfo.getGameProfile().getId();
|
||||||
|
|
||||||
if (skin == null) return getDefaultPony(uuid);
|
if (Pony.getBufferedImage(skin) == null) {
|
||||||
|
return getDefaultPony(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
return getPony(skin, uuid);
|
return getPony(skin, uuid);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.minelittlepony;
|
package com.minelittlepony;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
import com.voxelmodpack.hdskins.ISkinParser;
|
import com.voxelmodpack.hdskins.ISkinParser;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
@ -9,13 +10,14 @@ import java.util.Map;
|
||||||
public class PonySkinParser implements ISkinParser {
|
public class PonySkinParser implements ISkinParser {
|
||||||
|
|
||||||
@Override
|
@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) {
|
if (type == MinecraftProfileTexture.Type.SKIN) {
|
||||||
boolean slim = "slim".equals(metadata.get("model"));
|
boolean slim = "slim".equals(metadata.get("model"));
|
||||||
// TODO use proper model metadata system
|
// TODO use proper model metadata system
|
||||||
|
|
||||||
metadata.put("model", MineLittlePony.getInstance().getManager()
|
metadata.put("model", MineLittlePony.getInstance().getManager()
|
||||||
.getPony(resource)
|
.getPony(resource, profile.getId())
|
||||||
.getRace(false)
|
.getRace(false)
|
||||||
.getModel()
|
.getModel()
|
||||||
.getId(slim));
|
.getId(slim));
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class RenderPonyModel extends RenderPlayerModel<EntityPonyModel> implemen
|
||||||
renderingAsHuman = true;
|
renderingAsHuman = true;
|
||||||
|
|
||||||
ResourceLocation loc = getEntityTexture(playermodel);
|
ResourceLocation loc = getEntityTexture(playermodel);
|
||||||
if (loc == null) {
|
if (loc == null || Pony.getBufferedImage(loc) == null) {
|
||||||
return super.getEntityModel(playermodel);
|
return super.getEntityModel(playermodel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.minelittlepony.pony.data;
|
package com.minelittlepony.pony.data;
|
||||||
|
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
import com.minelittlepony.MineLittlePony;
|
import com.minelittlepony.MineLittlePony;
|
||||||
import com.voxelmodpack.hdskins.IBufferedTexture;
|
import com.voxelmodpack.hdskins.IBufferedTexture;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
@ -42,9 +43,11 @@ public class Pony {
|
||||||
|
|
||||||
private IPonyData checkSkin(ResourceLocation resource) {
|
private IPonyData checkSkin(ResourceLocation resource) {
|
||||||
IPonyData data = checkPonyMeta(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);
|
return this.checkSkin(skinImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +77,8 @@ public class Pony {
|
||||||
MineLittlePony.logger.debug("Obtained skin from resource location {}", resource);
|
MineLittlePony.logger.debug("Obtained skin from resource location {}", resource);
|
||||||
|
|
||||||
return skinImage;
|
return skinImage;
|
||||||
} catch (IOException ignored) { }
|
} catch (IOException ignored) {
|
||||||
|
}
|
||||||
|
|
||||||
ITextureObject texture = Minecraft.getMinecraft().getTextureManager().getTexture(resource);
|
ITextureObject texture = Minecraft.getMinecraft().getTextureManager().getTexture(resource);
|
||||||
|
|
||||||
|
@ -85,8 +89,7 @@ public class Pony {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IPonyData checkSkin(@Nullable BufferedImage bufferedimage) {
|
private IPonyData checkSkin(BufferedImage bufferedimage) {
|
||||||
if (bufferedimage == null) return new PonyData();
|
|
||||||
MineLittlePony.logger.debug("\tStart skin check for pony #{} with image {}.", ponyId, bufferedimage);
|
MineLittlePony.logger.debug("\tStart skin check for pony #{} with image {}.", ponyId, bufferedimage);
|
||||||
return PonyData.parse(bufferedimage);
|
return PonyData.parse(bufferedimage);
|
||||||
}
|
}
|
||||||
|
@ -101,13 +104,14 @@ public class Pony {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFullySubmerged(EntityLivingBase entity) {
|
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) {
|
protected Vec3d getVisualEyePosition(EntityLivingBase entity) {
|
||||||
PonySize size = entity.isChild() ? PonySize.FOAL : metadata.getSize();
|
PonySize size = entity.isChild() ? PonySize.FOAL : metadata.getSize();
|
||||||
|
|
||||||
return new Vec3d(entity.posX, entity.posY + (double)entity.getEyeHeight() * size.getScaleFactor(), entity.posZ);
|
return new Vec3d(entity.posX, entity.posY + (double) entity.getEyeHeight() * size.getScaleFactor(), entity.posZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWearingHeadgear(EntityLivingBase entity) {
|
public boolean isWearingHeadgear(EntityLivingBase entity) {
|
||||||
|
@ -119,7 +123,7 @@ public class Pony {
|
||||||
|
|
||||||
Item item = stack.getItem();
|
Item item = stack.getItem();
|
||||||
|
|
||||||
return !(item instanceof ItemArmor) || ((ItemArmor)item).getEquipmentSlot() != EntityEquipmentSlot.HEAD;
|
return !(item instanceof ItemArmor) || ((ItemArmor) item).getEquipmentSlot() != EntityEquipmentSlot.HEAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PonyRace getRace(boolean ignorePony) {
|
public PonyRace getRace(boolean ignorePony) {
|
||||||
|
|
|
@ -18,6 +18,8 @@ import net.minecraft.util.ResourceLocation;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import static com.mojang.authlib.minecraft.MinecraftProfileTexture.*;
|
||||||
|
|
||||||
public class PlayerSkullRenderer extends PonySkull {
|
public class PlayerSkullRenderer extends PonySkull {
|
||||||
|
|
||||||
private final ModelDeadMau5Ears deadMau5 = new ModelDeadMau5Ears();
|
private final ModelDeadMau5Ears deadMau5 = new ModelDeadMau5Ears();
|
||||||
|
@ -41,20 +43,23 @@ public class PlayerSkullRenderer extends PonySkull {
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
deadMau5.setVisible("deadmau5".equals(profile.getName()));
|
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) {
|
if (skin != null && Pony.getBufferedImage(skin) != null) {
|
||||||
return skin;
|
return skin;
|
||||||
}
|
}
|
||||||
|
|
||||||
Minecraft minecraft = Minecraft.getMinecraft();
|
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)) {
|
if (map.containsKey(Type.SKIN)) {
|
||||||
return minecraft.getSkinManager().loadSkin(map.get(MinecraftProfileTexture.Type.SKIN), MinecraftProfileTexture.Type.SKIN);
|
ResourceLocation loc = minecraft.getSkinManager().loadSkin(map.get(Type.SKIN), Type.SKIN);
|
||||||
} else {
|
if (Pony.getBufferedImage(loc) != null) {
|
||||||
return DefaultPlayerSkin.getDefaultSkin(EntityPlayer.getUUID(profile));
|
return loc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return DefaultPlayerSkin.getDefaultSkin(EntityPlayer.getUUID(profile));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return DefaultPlayerSkin.getDefaultSkinLegacy();
|
return DefaultPlayerSkin.getDefaultSkinLegacy();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue