use of cc.hyperium.mixins.client.renderer.IMixinThreadDownloadImageData 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