Search in sources :

Example 1 with ShieldUser

use of reborncore.shields.json.ShieldUser in project RebornCore by TechReborn.

the class RebornItemStackRenderer method renderByItem.

@Override
public void renderByItem(ItemStack itemStackIn) {
    if (itemStackIn.getItem() == Items.SHIELD) {
        boolean isCustom = !ItemNBTHelper.getBoolean(itemStackIn, "vanilla", false);
        if (isCustom) {
            ResourceLocation location = null;
            String str = ItemNBTHelper.getString(itemStackIn, "type", "vanilla");
            if (ShieldJsonLoader.shieldJsonFile == null || ShieldJsonLoader.shieldJsonFile.userList == null) {
                renderer.renderByItem(itemStackIn);
                return;
            }
            for (ShieldUser user : ShieldJsonLoader.shieldJsonFile.userList) {
                if (user.username.equalsIgnoreCase(str)) {
                    location = new ResourceLocation("LOOKUP:" + str);
                }
            }
            if (location == null) {
                renderer.renderByItem(itemStackIn);
                return;
            }
            ShieldTexture shieldTexture = ShieldTextureStore.getTexture(str);
            if (shieldTexture != null) {
                if (shieldTexture.getState() == DownloadState.DOWNLOADED) {
                    if (customTextureMap.containsKey(location.getResourcePath())) {
                        Minecraft.getMinecraft().getTextureManager().bindTexture(location);
                    } else {
                        AbstractTexture texture = shieldTexture.getTexture();
                        customTextureMap.put(location.getResourcePath(), texture);
                        final ResourceLocation resourceLocation = location;
                        THREAD_POOL.submit((Runnable) () -> Minecraft.getMinecraft().addScheduledTask((Runnable) () -> Minecraft.getMinecraft().getTextureManager().loadTexture(resourceLocation, texture)));
                        Minecraft.getMinecraft().getTextureManager().bindTexture(BannerTextures.SHIELD_BASE_TEXTURE);
                    }
                } else {
                    Minecraft.getMinecraft().getTextureManager().bindTexture(BannerTextures.SHIELD_BASE_TEXTURE);
                }
            } else {
                Minecraft.getMinecraft().getTextureManager().bindTexture(BannerTextures.SHIELD_BASE_TEXTURE);
            }
        } else {
            renderer.renderByItem(itemStackIn);
            return;
        }
        GlStateManager.pushMatrix();
        GlStateManager.scale(1.0F, -1.0F, -1.0F);
        modelShield.render();
        GlStateManager.popMatrix();
        return;
    }
    renderer.renderByItem(itemStackIn);
}
Also used : AbstractTexture(net.minecraft.client.renderer.texture.AbstractTexture) ShieldUser(reborncore.shields.json.ShieldUser) ResourceLocation(net.minecraft.util.ResourceLocation)

Example 2 with ShieldUser

use of reborncore.shields.json.ShieldUser in project RebornCore by TechReborn.

the class ShieldTextureStore method load.

public static void load() {
    ShieldJsonFile file = ShieldJsonLoader.shieldJsonFile;
    if (file != null) {
        for (ShieldUser user : file.userList) {
            boolean isCustomTexture = false;
            String name = user.username;
            if (!user.textureName.isEmpty()) {
                name = user.textureName;
                isCustomTexture = true;
            }
            if (isCustomTexture) {
                ShieldTexture texture;
                if (customTextures.containsKey(name)) {
                    texture = customTextures.get(name);
                } else {
                    texture = new ShieldTexture(RebornCore.WEB_URL + "reborncore/textures/" + name + ".png");
                    customTextures.put(name, texture);
                }
                textures.put(user.username, texture);
            } else {
                textures.put(user.username, new ShieldTexture(RebornCore.WEB_URL + "reborncore/textures/" + user.username + ".png"));
            }
        }
    }
}
Also used : ShieldJsonFile(reborncore.shields.json.ShieldJsonFile) ShieldUser(reborncore.shields.json.ShieldUser)

Aggregations

ShieldUser (reborncore.shields.json.ShieldUser)2 AbstractTexture (net.minecraft.client.renderer.texture.AbstractTexture)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 ShieldJsonFile (reborncore.shields.json.ShieldJsonFile)1