use of net.minecraft.client.renderer.ThreadDownloadImageData in project Armourers-Workshop by RiskyKen.
the class PlayerTextureDownloader method getDownloadImageSkin.
private ThreadDownloadImageData getDownloadImageSkin(ResourceLocation resourceLocation, String textureString, PlayerTexture playerTexture, TextureType textureType) {
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
Object object = texturemanager.getTexture(resourceLocation);
if (object == null) {
object = new ModThreadDownloadImageData((File) null, textureString, AbstractClientPlayer.locationStevePng, new ImageBufferDownload(), playerTexture);
texturemanager.loadTexture(resourceLocation, (ITextureObject) object);
}
return (ThreadDownloadImageData) object;
}
use of net.minecraft.client.renderer.ThreadDownloadImageData in project Armourers-Workshop by RiskyKen.
the class PlayerTextureDownloader method downloadTexture.
private void downloadTexture(String textureString, PlayerTexture playerTexture, TextureType textureType) {
ResourceLocation resourceLocation = null;
if (StringUtils.isNullOrEmpty(textureString)) {
return;
}
if (textureType == TextureType.URL) {
resourceLocation = new ResourceLocation("skins/" + StringUtils.stripControlCodes(textureString));
ThreadDownloadImageData imageData = getDownloadImageSkin(resourceLocation, textureString, playerTexture, textureType);
} else {
ModLogger.log("Setting wrong " + textureString);
// resourceLocation = new ResourceLocation(LibModInfo.ID.toLowerCase(), StringUtils.stripControlCodes(textureString));
}
}
use of net.minecraft.client.renderer.ThreadDownloadImageData in project Armourers-Workshop by RiskyKen.
the class SkinHelper method getBufferedImageSkin.
/*
* Based on @KitsuneKihira texture helper class.
* https://github.com/kihira/FoxLib/blob/2946cd6033d3039151064ceccfb8d38612d0af02/src/main/scala/kihira/foxlib/client/TextureHelper.scala#L28
*/
public static BufferedImage getBufferedImageSkin(AbstractClientPlayer player) {
BufferedImage bufferedImage = null;
ResourceLocation skinloc = AbstractClientPlayer.locationStevePng;
InputStream inputStream = null;
Minecraft mc = Minecraft.getMinecraft();
skinloc = player.getLocationSkin();
try {
ITextureObject skintex = mc.getTextureManager().getTexture(skinloc);
if (skintex instanceof ThreadDownloadImageData) {
ThreadDownloadImageData imageData = (ThreadDownloadImageData) skintex;
bufferedImage = ObfuscationReflectionHelper.getPrivateValue(ThreadDownloadImageData.class, imageData, "bufferedImage", "field_110560_d", "bpr.h");
} else {
inputStream = Minecraft.getMinecraft().getResourceManager().getResource(skinloc).getInputStream();
bufferedImage = ImageIO.read(inputStream);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
IOUtils.closeQuietly(inputStream);
}
return bufferedImage;
}
use of net.minecraft.client.renderer.ThreadDownloadImageData in project ArsMagica2 by Mithion.
the class CloakUtils method downloadCapeTexture.
private static ThreadDownloadImageData downloadCapeTexture(ResourceLocation resourceLocation, String uuid) {
ThreadDownloadImageData data = downloadedCloaks.get(uuid);
if (data == null) {
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
Object object = new ThreadDownloadImageData((File) null, AMCore.proxy.playerTracker.getCLF(uuid), null, null);
texturemanager.loadTexture(resourceLocation, (ITextureObject) object);
data = (ThreadDownloadImageData) object;
downloadedCloaks.put(uuid, data);
}
return data;
}
use of net.minecraft.client.renderer.ThreadDownloadImageData in project Hyperium by HyperiumClient.
the class MemoryHelper method worldEvent.
@InvokeEvent
public void worldEvent(WorldUnloadEvent event) {
try {
TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
Map<ResourceLocation, ITextureObject> mapTextureObjects = ((IMixinTextureManager) textureManager).getMapTextureObjects();
List<ResourceLocation> removes = new ArrayList<>();
mapTextureObjects.forEach((key, iTextureObject) -> {
if (iTextureObject instanceof ThreadDownloadImageData) {
IImageBuffer imageBuffer = ((IMixinThreadDownloadImageData) iTextureObject).getImageBuffer();
if (imageBuffer == null)
return;
Class<? extends IImageBuffer> aClass = imageBuffer.getClass();
// Optifine
if (aClass.getName().equalsIgnoreCase("CapeImageBuffer")) {
removes.add(key);
}
}
});
removes.forEach(this::deleteSkin);
// locations.forEach(this::deleteSkin);
int size = locations.size();
locations.clear();
int del = 0;
RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
try {
Method getSkinMap = renderManager.getClass().getMethod("getSkinMap");
Object invoke = getSkinMap.invoke(renderManager);
Map<String, RenderPlayer> skinMap = (Map<String, RenderPlayer>) invoke;
for (RenderPlayer value : skinMap.values()) {
ModelPlayer mainModel = value.getMainModel();
Class<?> superClass = mainModel.getClass().getSuperclass();
for (Field field : superClass.getDeclaredFields()) {
field.setAccessible(true);
try {
Object o = field.get(mainModel);
if (o != null) {
try {
Field entityIn = o.getClass().getSuperclass().getDeclaredField("entityIn");
entityIn.setAccessible(true);
Object o1 = entityIn.get(o);
if (o1 != null) {
entityIn.set(o, null);
del++;
}
} catch (IllegalAccessException | NoSuchFieldException ignored) {
}
try {
Field clientPlayer = o.getClass().getSuperclass().getDeclaredField("clientPlayer");
clientPlayer.setAccessible(true);
Object o1 = clientPlayer.get(o);
if (o1 != null) {
clientPlayer.set(o, null);
del++;
}
} catch (IllegalAccessException | NoSuchFieldException ignored) {
}
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
Hyperium.LOGGER.info("Deleted " + (removes.size() + size + del) + " cosmetic items / skins");
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations