Не рендерится скин

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
52
Лучшие ответы
0
Реакции
1
Здраст,столкнулся с проблемой,не рендерит скин,сразу скажу что код не весь мой,попросили поправить
Java:
public class RenderTab
{
    public HashMap skins;
    boolean start;
    
    public RenderTab() {
        this.skins = new HashMap();
        this.start = false;
    }
    
    @Mod.EventHandler
    public void init(final FMLInitializationEvent event) {
        MinecraftForge.EVENT_BUS.register((Object)this);
    }
    
    @SubscribeEvent(priority = EventPriority.HIGHEST)
    public void eventHandler(final RenderGameOverlayEvent.Pre event) {
        if (event.type == RenderGameOverlayEvent.ElementType.PLAYER_LIST) {
            event.setCanceled(true);
            this.renderList(event.resolution.getScaledWidth(), event.resolution.getScaledHeight());
        }
    }
    
    public void renderList(final int width, final int height) {
        final List players = Minecraft.getMinecraft().thePlayer.sendQueue.playerInfoList;
        final int count = players.size();
        final int maxcols = width / 50 - 1;
        int var20;
        if (count >= maxcols) {
            var20 = maxcols;
        }
        else {
            var20 = count;
        }
        int x = width / 2 - 42 * var20 / 2;
        final int xmax = width / 2 + 42 * var20 / 2;
        int id = 0;
        int y = 10;
        int c = 0;
        GL11.glPushMatrix();
        GL11.glScalef(0.5f, 0.5f, 0.5f);
        for (int i = 0; i < count; ++i) {
            if (id < 45) {
                final GuiPlayerInfo pl = (GuiPlayerInfo) players.get(i);
                final String name = pl.name;
                ResourceLocation skin;
                if (this.skins.containsKey(name)) {
                    skin = (ResourceLocation) this.skins.get(name);
                }
                else {
                    skin = new ResourceLocation("patchskins/" + StringUtils.stripControlCodes(name));
                    final TextureManager var21 = Minecraft.getMinecraft().getTextureManager();
                    final ITextureObject var22 = var21.getTexture(skin);
                    if (var22 == null) {
                        final ImageData var23 = new ImageData(String.format("http://swiftycraft.ru/lk/upload/skins/%s.png", StringUtils.stripControlCodes(name)), AbstractClientPlayer.locationStevePng, (IImageBuffer)new ImageBufferDownload());
                        var21.loadTexture(skin, (ITextureObject)var23);
                    }
                    this.skins.put(name, skin);
                }
                skin(skin, x * 2 + 15, y * 2, 50, 50);
                String display = name;
                display = ((display.length() > 11) ? new String(display.substring(0, 11)) : display);
                Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(display, x * 2 + 15 + 26 - Minecraft.getMinecraft().fontRenderer.getStringWidth(display) / 2, y * 2 + 55, -1);
                ++c;
                x += 42;
                ++id;
                if (c == var20) {
                    x = width / 2 - 42 * var20 / 2;
                    y += 36;
                    c = 0;
                }
            }
        }
        GL11.glPopMatrix();
        GL11.glDisable(32826);
    }
    
    public static void skin(final ResourceLocation skin, final int x, final int y, final int w, final int h) {
        Minecraft.getMinecraft().getTextureManager().bindTexture(skin);
        GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
        final Tessellator tessellator = Tessellator.instance;
        tessellator.startDrawingQuads();
        tessellator.addVertexWithUV((double)x, (double)(y + h), 0.0, 0.125, 0.5);
        tessellator.addVertexWithUV((double)(x + w), (double)(y + h), 0.0, 0.25, 0.5);
        tessellator.addVertexWithUV((double)(x + w), (double)y, 0.0, 0.25, 0.25);
        tessellator.addVertexWithUV((double)x, (double)y, 0.0, 0.125, 0.25);
        tessellator.draw();
    }
}
 
Сообщения
52
Лучшие ответы
0
Реакции
1
*Вставил не тот код
Java:
package ru.mryarik666.skins;

import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.client.renderer.IImageBuffer;
import net.minecraft.client.renderer.ThreadDownloadImageData;
import net.minecraft.client.renderer.ImageBufferDownload;
import java.io.File;
import net.minecraft.util.StringUtils;
import net.minecraftforge.client.event.RenderHandEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.entity.player.EntityPlayer;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraftforge.client.event.RenderPlayerEvent;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import net.minecraft.client.Minecraft;
import java.util.HashMap;
import net.minecraft.util.ResourceLocation;
import cpw.mods.fml.common.Mod;

public class RenderSkin
{
    private static ResourceLocation res;
    public HashMap renderedSkins;
    public HashMap renderedCape;
    Minecraft mc;
    
    public RenderSkin() {
        this.renderedSkins = new HashMap();
        this.renderedCape = new HashMap();
    }
    
    @Mod.EventHandler
    public void load(final FMLInitializationEvent event) {
        this.mc = Minecraft.getMinecraft();
        MinecraftForge.EVENT_BUS.register((Object)this);
    }
    
    @SubscribeEvent
    public void onRenderPlayer(final RenderPlayerEvent.Pre event) {
        final EntityPlayer entity = event.entityPlayer;
        final String name = entity.getDisplayName();
        if (!this.renderedSkins.containsKey(name)) {
            final ResourceLocation skin = getSkin(name);
            ((AbstractClientPlayer)entity).func_152121_a(MinecraftProfileTexture.Type.SKIN, skin);
            this.renderedSkins.put(name, skin);
        }
        else {
            ((AbstractClientPlayer)entity).func_152121_a(MinecraftProfileTexture.Type.SKIN, (ResourceLocation)this.renderedSkins.get(name));
        }
        if (!this.renderedCape.containsKey(name)) {
            final ResourceLocation cape = getCloak(name);
            ((AbstractClientPlayer)entity).func_152121_a(MinecraftProfileTexture.Type.CAPE, cape);
            this.renderedCape.put(name, cape);
        }
        else {
            ((AbstractClientPlayer)entity).func_152121_a(MinecraftProfileTexture.Type.CAPE, (ResourceLocation)this.renderedCape.get(name));
        }
    }
    
    @SubscribeEvent
    public void onRenderPlayer(final RenderHandEvent event) {
        event.setCanceled(true);
        final EntityPlayer entity = (EntityPlayer)this.mc.thePlayer;
        final String name = entity.getDisplayName();
        if (!this.renderedSkins.containsKey(name)) {
            final ResourceLocation skin = getSkin(name);
            ((AbstractClientPlayer)entity).func_152121_a(MinecraftProfileTexture.Type.SKIN, skin);
            this.renderedSkins.put(name, skin);
        }
        else {
            ((AbstractClientPlayer)entity).func_152121_a(MinecraftProfileTexture.Type.SKIN, (ResourceLocation)this.renderedSkins.get(name));
        }
        event.setCanceled(false);
    }
    
    public static ResourceLocation getSkin(final String name) {
        final ResourceLocation skin = new ResourceLocation("patchskins/" + StringUtils.stripControlCodes(name));
        final TextureManager var2 = Minecraft.getMinecraft().getTextureManager();
        final ITextureObject var3 = var2.getTexture(skin);
        if (var3 == null) {
            final ThreadDownloadImageData var4 = new ThreadDownloadImageData((File)null, String.format("http://swiftycraft.ru/lk/upload/skins/%s.png", StringUtils.stripControlCodes(name)), AbstractClientPlayer.locationStevePng, (IImageBuffer)new ImageBufferDownload());
            var2.loadTexture(skin, (ITextureObject)var4);
        }
        return skin;
    }
    
    public static ResourceLocation getCloak(final String name) {
        final ResourceLocation cloak = new ResourceLocation("patchcloaks/" + StringUtils.stripControlCodes(name));
        final TextureManager var2 = Minecraft.getMinecraft().getTextureManager();
        final ITextureObject var3 = var2.getTexture(cloak);
        if (var3 == null) {
            final ThreadDownloadImageData var4 = new ThreadDownloadImageData((File)null, String.format("http://swiftycraft.ru/lk/upload/cloaks/%s.png", StringUtils.stripControlCodes(name)), RenderSkin.res, (IImageBuffer)new ImageBufferDownload());
            var2.loadTexture(cloak, (ITextureObject)var4);
        }
        return cloak;
    }
    
    static {
        RenderSkin.res = new ResourceLocation("menu", "textures/gui/1corona.png");
    }
}
 

Doc

Сообщения
2,659
Лучшие ответы
160
Реакции
397
Сообщения
52
Лучшие ответы
0
Реакции
1
я и не говорил что он мой,попросили подправить
 
Статус
В этой теме нельзя размещать новые ответы.
Сверху