Search in sources :

Example 16 with SkinIdentifier

use of riskyken.armourersWorkshop.common.skin.data.SkinIdentifier in project Armourers-Workshop by RiskyKen.

the class GuiSkinLibrary method drawScreen.

@Override
public void drawScreen(int mouseX, int mouseY, float partialTickTime) {
    int oldMouseX = mouseX;
    int oldMouseY = mouseY;
    if (isDialogOpen()) {
        mouseX = mouseY = 0;
    }
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    super.drawScreen(mouseX, mouseY, partialTickTime);
    GL11.glPopAttrib();
    ILibraryManager libraryManager = ArmourersWorkshop.proxy.libraryManager;
    ArrayList<LibraryFile> files = libraryManager.getServerPublicFileList().getFileList();
    loadSaveButton.enabled = true;
    if (isLoading()) {
        loadSaveButton.displayString = GuiHelper.getLocalizedControlName(armourLibrary.getInventoryName(), "load");
        if (fileList.getSelectedListEntry() == null || ((GuiFileListItem) fileList.getSelectedListEntry()).getFile().directory) {
            loadSaveButton.displayString = "";
            loadSaveButton.enabled = false;
        }
    } else {
        loadSaveButton.displayString = GuiHelper.getLocalizedControlName(armourLibrary.getInventoryName(), "save");
    }
    if (!((Slot) inventorySlots.inventorySlots.get(36)).getHasStack() & !armourLibrary.isCreativeLibrary()) {
        loadSaveButton.displayString = "";
        loadSaveButton.enabled = false;
    }
    if (fileSwitchType == LibraryFileType.LOCAL) {
        files = libraryManager.getClientPublicFileList().getFileList();
        if (!mc.isIntegratedServerRunning()) {
            loadSaveButton.enabled = false;
            if (isLoading()) {
                loadSaveButton.enabled = ConfigHandler.allowClientsToUploadSkins;
            } else {
                loadSaveButton.enabled = ConfigHandler.allowClientsToDownloadSkins;
            }
        }
    } else {
        loadSaveButton.enabled = true;
    }
    if (fileSwitchType == LibraryFileType.SERVER_PRIVATE) {
        files = libraryManager.getServerPrivateFileList(mc.thePlayer).getFileList();
    }
    String typeFilter = dropDownList.getListSelectedItem().tag;
    ISkinType skinTypeFilter = SkinTypeRegistry.INSTANCE.getSkinTypeFromRegistryName(typeFilter);
    lastSkinType = skinTypeFilter;
    lastSearchText = searchTextbox.getText();
    IGuiListItem selectedItem = fileList.getSelectedListEntry();
    if (selectedItem != null) {
    // deleteButton.enabled = !((GuiFileListItem)selectedItem).getFile().readOnly;
    } else {
    // deleteButton.enabled = false;
    }
    fileList.setSelectedIndex(-1);
    fileList.clearList();
    if (!(currentFolder.equals("/") | currentFolder.equals(getPrivateRoot(player)))) {
        fileList.addListItem(new GuiFileListItem(new LibraryFile("../", "", null, true)));
        if (selectedItem != null && ((GuiFileListItem) selectedItem).getFile().fileName.equals("../")) {
            fileList.setSelectedIndex(0);
        }
    }
    if (files != null) {
        for (int i = 0; i < files.size(); i++) {
            LibraryFile file = files.get(i);
            if (skinTypeFilter == null | skinTypeFilter == file.skinType) {
                if (file.filePath.equals(currentFolder)) {
                    if (!searchTextbox.getText().equals("")) {
                        if (file.fileName.toLowerCase().contains(searchTextbox.getText().toLowerCase())) {
                            fileList.addListItem(new GuiFileListItem(file));
                            if (selectedItem != null && ((GuiFileListItem) selectedItem).getFile() == file) {
                                fileList.setSelectedIndex(fileList.getSize() - 1);
                            }
                        }
                    } else {
                        fileList.addListItem(new GuiFileListItem(file));
                        if (selectedItem != null && ((GuiFileListItem) selectedItem).getFile() == file) {
                            fileList.setSelectedIndex(fileList.getSize() - 1);
                        }
                    }
                }
            }
        }
    }
    scrollAmount = scrollbar.getValue();
    fileList.setScrollPercentage(scrollbar.getPercentageValue());
    for (int i = 0; i < buttonList.size(); i++) {
        GuiButton button = (GuiButton) buttonList.get(i);
        if (button instanceof GuiIconButton) {
            ((GuiIconButton) button).drawRollover(mc, mouseX, mouseY);
        }
    }
    if (showModelPreviews()) {
        GuiFileListItem item = (GuiFileListItem) fileList.getSelectedListEntry();
        if (item != null && !item.getFile().isDirectory()) {
            SkinIdentifier identifier = new SkinIdentifier(0, new LibraryFile(item.getFile().getFullName()), 0, null);
            Skin skin = ClientSkinCache.INSTANCE.getSkin(identifier, true);
            if (skin != null) {
                SkinPointer skinPointer = new SkinPointer(identifier);
                int listRight = this.width - INVENTORY_WIDTH - PADDING * 5;
                listRight = MathHelper.clamp_int(listRight, 0, 200);
                listRight += INVENTORY_WIDTH + PADDING * 2 + 10;
                int listTop = TITLE_HEIGHT + 14 + PADDING * 2;
                int xSize = (this.width - listRight - PADDING) / 2;
                int ySize = (this.height - listTop - PADDING) / 2;
                float x = listRight + xSize;
                float y = listTop + ySize;
                float scale = 1F;
                scale = 1 * Math.min(xSize, ySize);
                ScaledResolution scaledResolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
                int startX = listRight + PADDING;
                int startY = listTop + PADDING;
                int tarW = (int) (x + xSize);
                int tarH = (int) (y + ySize);
                drawRect(startX, startY, tarW, tarH, 0x77777777);
                if (scale > 8) {
                    GL11.glPushMatrix();
                    GL11.glTranslatef((float) x, (float) y, 500.0F);
                    GL11.glScalef(10, 10, -10);
                    GL11.glRotatef(30, 1, 0, 0);
                    GL11.glRotatef(45, 0, 1, 0);
                    float rotation = (float) ((double) System.currentTimeMillis() / 10 % 360);
                    GL11.glRotatef(rotation, 0.0F, 1.0F, 0.0F);
                    RenderHelper.enableStandardItemLighting();
                    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
                    GL11.glEnable(GL11.GL_NORMALIZE);
                    GL11.glEnable(GL11.GL_COLOR_MATERIAL);
                    ModRenderHelper.enableAlphaBlend();
                    SkinItemRenderHelper.renderSkinAsItem(skin, skinPointer, true, false, tarW - startX, tarH - startY);
                    GL11.glPopAttrib();
                    GL11.glPopMatrix();
                }
            }
        }
    }
    GL11.glColor4f(1, 1, 1, 1);
    if (isDialogOpen()) {
        this.dialog.draw(oldMouseX, oldMouseY, partialTickTime);
    }
}
Also used : IGuiListItem(riskyken.armourersWorkshop.client.gui.controls.IGuiListItem) ISkinType(riskyken.armourersWorkshop.api.common.skin.type.ISkinType) SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ILibraryManager(riskyken.armourersWorkshop.common.library.ILibraryManager) SkinIdentifier(riskyken.armourersWorkshop.common.skin.data.SkinIdentifier) ScaledResolution(net.minecraft.client.gui.ScaledResolution) GuiFileListItem(riskyken.armourersWorkshop.client.gui.controls.GuiFileListItem) GuiButton(net.minecraft.client.gui.GuiButton) GuiIconButton(riskyken.armourersWorkshop.client.gui.controls.GuiIconButton) Slot(net.minecraft.inventory.Slot) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) LibraryFile(riskyken.armourersWorkshop.common.library.LibraryFile)

Example 17 with SkinIdentifier

use of riskyken.armourersWorkshop.common.skin.data.SkinIdentifier in project Armourers-Workshop by RiskyKen.

the class GuiSkinLibrary method dialogResult.

@Override
public void dialogResult(AbstractGuiDialog dialog, DialogResult result) {
    if (result == DialogResult.OK) {
        if (dialog instanceof GuiDialogNewFolder) {
            GuiDialogNewFolder newFolderDialog = (GuiDialogNewFolder) dialog;
            if (fileSwitchType == LibraryFileType.LOCAL) {
                File dir = new File(SkinIOUtils.getSkinLibraryDirectory(), currentFolder);
                dir = new File(dir, newFolderDialog.getFolderName());
                if (!dir.exists()) {
                    dir.mkdir();
                }
                reloadLocalLibrary();
                ModLogger.log(String.format("making folder call %s in %s", newFolderDialog.getFolderName(), currentFolder));
                ModLogger.log("full path: " + dir.getAbsolutePath());
            } else {
                MessageClientGuiSkinLibraryCommand message = new MessageClientGuiSkinLibraryCommand();
                message.newFolder(new LibraryFile(newFolderDialog.getFolderName(), currentFolder, null, true), fileSwitchType == LibraryFileType.SERVER_PUBLIC);
                PacketHandler.networkWrapper.sendToServer(message);
            }
        }
        if (dialog instanceof GuiDialogDelete) {
            GuiDialogDelete deleteDialog = (GuiDialogDelete) dialog;
            boolean isFolder = deleteDialog.isFolder();
            String name = deleteDialog.getFileName();
            if (fileSwitchType == LibraryFileType.LOCAL) {
                File dir = new File(SkinIOUtils.getSkinLibraryDirectory(), currentFolder);
                if (deleteDialog.isFolder()) {
                    dir = new File(dir, name + "/");
                } else {
                    dir = new File(dir, name + SkinIOUtils.SKIN_FILE_EXTENSION);
                }
                if (dir.isDirectory() == isFolder) {
                    if (dir.exists()) {
                        if (isFolder) {
                            try {
                                FileUtils.deleteDirectory(dir);
                                reloadLocalLibrary();
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                        } else {
                            LibraryFile libraryFile = new LibraryFile(currentFolder + deleteDialog.getFileName());
                            ClientSkinCache.INSTANCE.markSkinAsDirty(new SkinIdentifier(0, libraryFile, 0, null));
                            dir.delete();
                            reloadLocalLibrary();
                        }
                    }
                }
            } else {
                MessageClientGuiSkinLibraryCommand message = new MessageClientGuiSkinLibraryCommand();
                message.delete(new LibraryFile(deleteDialog.getFileName(), currentFolder, null, isFolder), fileSwitchType == LibraryFileType.SERVER_PUBLIC);
                PacketHandler.networkWrapper.sendToServer(message);
            // ClientSkinCache.INSTANCE.clearIdForFileName(currentFolder + deleteDialog.getName());
            }
        }
        if (dialog instanceof GuiDialogOverwrite) {
            GuiDialogOverwrite overwriteDialog = (GuiDialogOverwrite) dialog;
            MessageClientGuiLoadSaveArmour message;
            boolean clientLoad = false;
            boolean publicList = true;
            if (fileSwitchType == LibraryFileType.LOCAL && !mc.isIntegratedServerRunning()) {
                // Is playing on a server.
                clientLoad = true;
            }
            if (fileSwitchType == LibraryFileType.SERVER_PRIVATE) {
                publicList = false;
            }
            if (clientLoad) {
                message = new MessageClientGuiLoadSaveArmour(overwriteDialog.getFileName(), currentFolder, LibraryPacketType.CLIENT_SAVE, false, trackFile);
                PacketHandler.networkWrapper.sendToServer(message);
            } else {
                message = new MessageClientGuiLoadSaveArmour(overwriteDialog.getFileName(), currentFolder, LibraryPacketType.SERVER_SAVE, publicList, trackFile);
                PacketHandler.networkWrapper.sendToServer(message);
            }
            LibraryFile libraryFile = new LibraryFile(currentFolder + overwriteDialog.getFileName());
            ClientSkinCache.INSTANCE.markSkinAsDirty(new SkinIdentifier(0, libraryFile, 0, null));
        // reloadLocalLibrary();
        // TODO clear name lookup list on clients or just removed this one name
        }
    }
    super.dialogResult(dialog, result);
}
Also used : MessageClientGuiLoadSaveArmour(riskyken.armourersWorkshop.common.network.messages.client.MessageClientGuiLoadSaveArmour) MessageClientGuiSkinLibraryCommand(riskyken.armourersWorkshop.common.network.messages.client.MessageClientGuiSkinLibraryCommand) LibraryFile(riskyken.armourersWorkshop.common.library.LibraryFile) IOException(java.io.IOException) LibraryFile(riskyken.armourersWorkshop.common.library.LibraryFile) File(java.io.File) SkinIdentifier(riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)

Example 18 with SkinIdentifier

use of riskyken.armourersWorkshop.common.skin.data.SkinIdentifier in project Armourers-Workshop by RiskyKen.

the class GuiFileListItem method drawListItem.

@Override
public void drawListItem(FontRenderer fontRenderer, int x, int y, int mouseX, int mouseY, boolean selected, int width) {
    int iconOffset = 0;
    if (GuiSkinLibrary.showModelPreviews() | file.isDirectory()) {
        iconOffset = 10;
    }
    int fontColour = UtilColour.getMinecraftColor(8, ColourFamily.MINECRAFT);
    if (isHovering(fontRenderer, x, y, mouseX, mouseY, width)) {
        Gui.drawRect(x, y, x + width - 3, y + 12, 0xFFCCCCCC);
        fontColour = UtilColour.getMinecraftColor(15, ColourFamily.MINECRAFT);
    }
    if (selected) {
        Gui.drawRect(x, y, x + width - 3, y + 12, 0xFFFFFF88);
        fontColour = UtilColour.getMinecraftColor(15, ColourFamily.MINECRAFT);
    }
    if (!file.isDirectory()) {
        fontRenderer.drawString(file.fileName, x + 2 + iconOffset, y + 2, fontColour);
        if (GuiSkinLibrary.showModelPreviews() | file.isDirectory()) {
            IGuiListItem item = this;
            if (item != null) {
                SkinIdentifier identifier = new SkinIdentifier(0, new LibraryFile(file.getFullName()), 0, null);
                Skin skin = ClientSkinCache.INSTANCE.getSkin(identifier, true);
                if (skin != null) {
                    SkinPointer skinPointer = new SkinPointer(identifier);
                    float scale = 10F;
                    GL11.glPushMatrix();
                    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
                    GL11.glTranslatef((float) x + 5, (float) y + 6, 50.0F);
                    GL11.glScalef((float) (-scale), (float) scale, (float) scale);
                    GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
                    GL11.glRotatef(20.0F, 1.0F, 0.0F, 0.0F);
                    float rotation = (float) ((double) System.currentTimeMillis() / 10 % 360);
                    GL11.glRotatef(rotation, 0.0F, 1.0F, 0.0F);
                    RenderHelper.enableStandardItemLighting();
                    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                    GL11.glEnable(GL11.GL_NORMALIZE);
                    GL11.glEnable(GL11.GL_COLOR_MATERIAL);
                    ModRenderHelper.enableAlphaBlend();
                    // ItemStackRenderHelper.renderItemModelFromSkinPointer(skinPointer, true, false);
                    SkinItemRenderHelper.renderSkinAsItem(skin, skinPointer, true, false, 16, 16);
                    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                    GL11.glPopAttrib();
                    GL11.glPopMatrix();
                }
            }
        }
    } else {
        GL11.glColor4f(1, 1, 1, 1);
        Minecraft.getMinecraft().renderEngine.bindTexture(texture);
        if (file.fileName.equals("private")) {
            drawTexturedModalRect(x, y, 32, 0, 12, 12);
            fontRenderer.drawString(file.fileName, x + 2 + iconOffset, y + 2, 0xFF8888FF);
        } else {
            drawTexturedModalRect(x, y, 16, 0, 10, 10);
            fontRenderer.drawString(file.fileName, x + 2 + iconOffset, y + 2, 0xFF88FF88);
        }
        GL11.glColor4f(1, 1, 1, 1);
    }
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) LibraryFile(riskyken.armourersWorkshop.common.library.LibraryFile) SkinIdentifier(riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)

Example 19 with SkinIdentifier

use of riskyken.armourersWorkshop.common.skin.data.SkinIdentifier in project Armourers-Workshop by RiskyKen.

the class CommandGiveSkin method processCommand.

@Override
public void processCommand(ICommandSender commandSender, String[] currentCommand) {
    if (currentCommand.length < 3) {
        throw new WrongUsageException(getCommandUsage(commandSender), (Object) currentCommand);
    }
    String playerName = currentCommand[1];
    EntityPlayerMP player = getPlayer(commandSender, playerName);
    if (player == null) {
        return;
    }
    String skinName = currentCommand[2];
    if (!skinName.substring(0, 1).equals("\"")) {
        throw new WrongUsageException(getCommandUsage(commandSender), (Object) skinName);
    }
    int usedCommands = 2;
    if (!skinName.substring(skinName.length() - 1, skinName.length()).equals("\"")) {
        for (int i = 3; i < currentCommand.length; i++) {
            skinName += " " + currentCommand[i];
            if (skinName.substring(skinName.length() - 1, skinName.length()).equals("\"")) {
                usedCommands = i;
                break;
            }
        }
    }
    ModLogger.log("usedCommands used: " + usedCommands);
    ModLogger.log("total commands used: " + currentCommand.length);
    if (!skinName.substring(skinName.length() - 1, skinName.length()).equals("\"")) {
        throw new WrongUsageException(getCommandUsage(commandSender), (Object) skinName);
    }
    skinName = skinName.replace("\"", "");
    SkinDye skinDye = new SkinDye();
    for (int i = usedCommands + 1; i < currentCommand.length; i++) {
        String dyeCommand = currentCommand[i];
        ModLogger.log("Command dye: " + dyeCommand);
        if (!dyeCommand.contains("-")) {
            throw new WrongUsageException(getCommandUsage(commandSender), (Object) skinName);
        }
        String[] commandSplit = dyeCommand.split("-");
        if (commandSplit.length != 2) {
            throw new WrongUsageException(getCommandUsage(commandSender), (Object) skinName);
        }
        int dyeIndex = parseIntBounded(commandSender, commandSplit[0], 1, 8) - 1;
        String dye = commandSplit[1];
        if (dye.startsWith("#") && dye.length() == 7) {
            // dye = dye.substring(2, 8);
            if (isValidHex(dye)) {
                Color dyeColour = Color.decode(dye);
                int r = dyeColour.getRed();
                int g = dyeColour.getGreen();
                int b = dyeColour.getBlue();
                skinDye.addDye(dyeIndex, new byte[] { (byte) r, (byte) g, (byte) b, (byte) 255 });
            } else {
                throw new WrongUsageException("commands.armourers.invalidDyeFormat", (Object) dye);
            }
        } else if (dye.length() >= 5 & dye.contains(",")) {
            String[] dyeValues = dye.split(",");
            if (dyeValues.length != 3) {
                throw new WrongUsageException(getCommandUsage(commandSender), (Object) skinName);
            }
            int r = parseIntBounded(commandSender, dyeValues[0], 0, 255);
            int g = parseIntBounded(commandSender, dyeValues[1], 0, 255);
            int b = parseIntBounded(commandSender, dyeValues[2], 0, 255);
            skinDye.addDye(dyeIndex, new byte[] { (byte) r, (byte) g, (byte) b, (byte) 255 });
        } else {
            throw new WrongUsageException("commands.armourers.invalidDyeFormat", (Object) dye);
        }
    }
    LibraryFile libraryFile = new LibraryFile(skinName);
    Skin skin = SkinIOUtils.loadSkinFromLibraryFile(libraryFile);
    if (skin == null) {
        throw new WrongUsageException("commands.armourers.fileNotFound", (Object) skinName);
    }
    try {
        skin.lightHash();
    } catch (Exception e) {
        ModLogger.log(Level.ERROR, String.format("Unable to create ID for file %s.", libraryFile.toString()));
        return;
    }
    CommonSkinCache.INSTANCE.addEquipmentDataToCache(skin, libraryFile);
    SkinIdentifier skinIdentifier = new SkinIdentifier(0, libraryFile, 0, skin.getSkinType());
    ItemStack skinStack = SkinNBTHelper.makeEquipmentSkinStack(new SkinPointer(skinIdentifier, skinDye));
    EntityItem entityItem = player.dropPlayerItemWithRandomChoice(skinStack, false);
    entityItem.delayBeforeCanPickup = 0;
    entityItem.func_145797_a(player.getCommandSenderName());
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) SkinDye(riskyken.armourersWorkshop.common.skin.data.SkinDye) Color(java.awt.Color) WrongUsageException(net.minecraft.command.WrongUsageException) SkinIdentifier(riskyken.armourersWorkshop.common.skin.data.SkinIdentifier) WrongUsageException(net.minecraft.command.WrongUsageException) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) LibraryFile(riskyken.armourersWorkshop.common.library.LibraryFile) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Example 20 with SkinIdentifier

use of riskyken.armourersWorkshop.common.skin.data.SkinIdentifier in project Armourers-Workshop by RiskyKen.

the class CommandSetSkin method processCommand.

@Override
public void processCommand(ICommandSender commandSender, String[] currentCommand) {
    if (currentCommand.length < 3) {
        throw new WrongUsageException(getCommandUsage(commandSender), (Object) currentCommand);
    }
    String playerName = currentCommand[1];
    EntityPlayerMP player = getPlayer(commandSender, playerName);
    if (player == null) {
        return;
    }
    int slotNum = 0;
    slotNum = parseIntBounded(commandSender, currentCommand[2], 1, 8);
    String skinName = currentCommand[3];
    if (!skinName.substring(0, 1).equals("\"")) {
        throw new WrongUsageException(getCommandUsage(commandSender), (Object) skinName);
    }
    int usedCommands = 3;
    if (!skinName.substring(skinName.length() - 1, skinName.length()).equals("\"")) {
        for (int i = 3; i < currentCommand.length; i++) {
            skinName += " " + currentCommand[i];
            if (skinName.substring(skinName.length() - 1, skinName.length()).equals("\"")) {
                usedCommands = i;
                break;
            }
        }
    }
    ModLogger.log("usedCommands used: " + usedCommands);
    ModLogger.log("total commands used: " + currentCommand.length);
    if (!skinName.substring(skinName.length() - 1, skinName.length()).equals("\"")) {
        throw new WrongUsageException(getCommandUsage(commandSender), (Object) skinName);
    }
    skinName = skinName.replace("\"", "");
    SkinDye skinDye = new SkinDye();
    for (int i = usedCommands + 1; i < currentCommand.length; i++) {
        String dyeCommand = currentCommand[i];
        ModLogger.log("Command dye: " + dyeCommand);
        if (!dyeCommand.contains("-")) {
            throw new WrongUsageException(getCommandUsage(commandSender), (Object) skinName);
        }
        String[] commandSplit = dyeCommand.split("-");
        if (commandSplit.length != 2) {
            throw new WrongUsageException(getCommandUsage(commandSender), (Object) skinName);
        }
        int dyeIndex = parseIntBounded(commandSender, commandSplit[0], 1, 8) - 1;
        String dye = commandSplit[1];
        if (dye.startsWith("#") && dye.length() == 7) {
            // dye = dye.substring(2, 8);
            if (isValidHex(dye)) {
                Color dyeColour = Color.decode(dye);
                int r = dyeColour.getRed();
                int g = dyeColour.getGreen();
                int b = dyeColour.getBlue();
                skinDye.addDye(dyeIndex, new byte[] { (byte) r, (byte) g, (byte) b, (byte) 255 });
            } else {
                throw new WrongUsageException("commands.armourers.invalidDyeFormat", (Object) dye);
            }
        } else if (dye.length() >= 5 & dye.contains(",")) {
            String[] dyeValues = dye.split(",");
            if (dyeValues.length != 3) {
                throw new WrongUsageException(getCommandUsage(commandSender), (Object) skinName);
            }
            int r = parseIntBounded(commandSender, dyeValues[0], 0, 255);
            int g = parseIntBounded(commandSender, dyeValues[1], 0, 255);
            int b = parseIntBounded(commandSender, dyeValues[2], 0, 255);
            skinDye.addDye(dyeIndex, new byte[] { (byte) r, (byte) g, (byte) b, (byte) 255 });
        } else {
            throw new WrongUsageException("commands.armourers.invalidDyeFormat", (Object) dye);
        }
    }
    LibraryFile libraryFile = new LibraryFile(skinName);
    Skin skin = SkinIOUtils.loadSkinFromLibraryFile(libraryFile);
    if (skin == null) {
        throw new WrongUsageException("commands.armourers.fileNotFound", (Object) skinName);
    }
    try {
        skin.lightHash();
    } catch (Exception e) {
        ModLogger.log(Level.ERROR, String.format("Unable to create ID for file %s.", libraryFile.toString()));
        return;
    }
    CommonSkinCache.INSTANCE.addEquipmentDataToCache(skin, libraryFile);
    SkinIdentifier skinIdentifier = new SkinIdentifier(0, libraryFile, 0, skin.getSkinType());
    ItemStack skinStack = SkinNBTHelper.makeEquipmentSkinStack(new SkinPointer(skinIdentifier, skinDye));
    ExPropsPlayerSkinData.get(player).setEquipmentStack(skinStack, slotNum - 1);
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) SkinDye(riskyken.armourersWorkshop.common.skin.data.SkinDye) Color(java.awt.Color) WrongUsageException(net.minecraft.command.WrongUsageException) SkinIdentifier(riskyken.armourersWorkshop.common.skin.data.SkinIdentifier) WrongUsageException(net.minecraft.command.WrongUsageException) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) LibraryFile(riskyken.armourersWorkshop.common.library.LibraryFile) ItemStack(net.minecraft.item.ItemStack)

Aggregations

SkinIdentifier (riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)21 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)10 ItemStack (net.minecraft.item.ItemStack)8 LibraryFile (riskyken.armourersWorkshop.common.library.LibraryFile)8 SkinPointer (riskyken.armourersWorkshop.common.skin.data.SkinPointer)7 ISkinIdentifier (riskyken.armourersWorkshop.api.common.skin.data.ISkinIdentifier)6 ISkinType (riskyken.armourersWorkshop.api.common.skin.type.ISkinType)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 ILibraryFile (riskyken.armourersWorkshop.api.common.library.ILibraryFile)3 Color (java.awt.Color)2 WrongUsageException (net.minecraft.command.WrongUsageException)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 SkinDye (riskyken.armourersWorkshop.common.skin.data.SkinDye)2 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 GuiButton (net.minecraft.client.gui.GuiButton)1 ScaledResolution (net.minecraft.client.gui.ScaledResolution)1 EntityItem (net.minecraft.entity.item.EntityItem)1 Slot (net.minecraft.inventory.Slot)1