Search in sources :

Example 6 with ISkinPartType

use of riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType in project Armourers-Workshop by RiskyKen.

the class EquipmentRenderHandler method renderSkin.

@Override
public boolean renderSkin(ISkinPointer skinPointer) {
    ISkinType skinType = skinPointer.getIdentifier().getSkinType();
    for (int i = 0; i < skinType.getSkinParts().size(); i++) {
        // TODO Offset each part when rendering.
        ISkinPartType skinPartType = skinType.getSkinParts().get(i);
        renderSkinPart(skinPointer, skinPartType);
    }
    return false;
}
Also used : ISkinType(riskyken.armourersWorkshop.api.common.skin.type.ISkinType) ISkinPartType(riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType)

Example 7 with ISkinPartType

use of riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType in project Armourers-Workshop by RiskyKen.

the class SkinPartSerializer method loadSkinPart.

public static SkinPart loadSkinPart(DataInputStream stream, int version) throws IOException, InvalidCubeTypeException {
    ISkinPartType skinPart = null;
    SkinCubeData cubeData = null;
    ArrayList<CubeMarkerData> markerBlocks = null;
    if (version < 6) {
        skinPart = SkinTypeRegistry.INSTANCE.getSkinPartFromLegacyId(stream.readByte());
        if (skinPart == null) {
            ModLogger.log(Level.ERROR, "Skin part was null");
            throw new IOException("Skin part was null");
        }
    } else {
        String regName = null;
        if (version > 12) {
            regName = StreamUtils.readString(stream, Charsets.US_ASCII);
        } else {
            regName = stream.readUTF();
        }
        if (regName.equals("armourers:skirt.base")) {
            regName = "armourers:legs.skirt";
        }
        if (regName.equals("armourers:bow.base")) {
            regName = "armourers:bow.frame1";
        }
        if (regName.equals("armourers:arrow.base")) {
            regName = "armourers:bow.arrow";
        }
        skinPart = SkinTypeRegistry.INSTANCE.getSkinPartFromRegistryName(regName);
        if (skinPart == null) {
            ModLogger.log(Level.ERROR, "Skin part was null - reg name: " + regName + " version: " + version);
            throw new IOException("Skin part was null - reg name: " + regName + " version: " + version);
        }
    }
    cubeData = new SkinCubeData();
    cubeData.readFromStream(stream, version, skinPart);
    markerBlocks = new ArrayList<CubeMarkerData>();
    if (version > 8) {
        int markerCount = stream.readInt();
        for (int i = 0; i < markerCount; i++) {
            markerBlocks.add(new CubeMarkerData(stream, version));
        }
    }
    return new SkinPart(cubeData, skinPart, markerBlocks);
}
Also used : ISkinPartType(riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType) SkinCubeData(riskyken.armourersWorkshop.common.skin.data.SkinCubeData) CubeMarkerData(riskyken.armourersWorkshop.common.skin.cubes.CubeMarkerData) IOException(java.io.IOException) SkinPart(riskyken.armourersWorkshop.common.skin.data.SkinPart)

Example 8 with ISkinPartType

use of riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType in project Armourers-Workshop by RiskyKen.

the class SkinTypeRegistry method registerSkin.

@Override
public boolean registerSkin(ISkinType skinType) {
    if (skinType == null) {
        ModLogger.log(Level.WARN, "A mod tried to register a null skin type.");
        return false;
    }
    if (skinType.getRegistryName() == null || skinType.getRegistryName().trim().isEmpty()) {
        ModLogger.log(Level.WARN, "A mod tried to register a skin type with an invalid registry name.");
        return false;
    }
    if (skinPartMap.containsKey(skinType.getRegistryName())) {
        ModLogger.log(Level.WARN, "A mod tried to register a skin type with a registry name that is in use.");
        return false;
    }
    if (skinType.getSkinParts() == null || skinType.getSkinParts().size() == 0) {
        ModLogger.log(Level.WARN, "A mod tried to register a skin type no skin type parts.");
        return false;
    }
    ModLogger.log(String.format("Registering skin: %s", skinType.getRegistryName()));
    skinTypeMap.put(skinType.getRegistryName(), skinType);
    ArrayList<ISkinPartType> skinParts = skinType.getSkinParts();
    for (int i = 0; i < skinParts.size(); i++) {
        ISkinPartType skinPart = skinParts.get(i);
        skinPartMap.put(skinPart.getRegistryName(), skinPart);
    }
    return true;
}
Also used : ISkinPartType(riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType)

Example 9 with ISkinPartType

use of riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType in project Armourers-Workshop by RiskyKen.

the class ArmourerWorldHelper method saveSkinFromWorld.

/**
 * Converts blocks in the world into a skin class.
 * @param world The world.
 * @param skinProps The skin properties for this skin.
 * @param skinType The type of skin to save.
 * @param paintData Paint data for this skin.
 * @param xCoord Armourers x location.
 * @param yCoord Armourers y location.
 * @param zCoord Armourers z location.
 * @param directionDirection the armourer is facing.
 * @return
 * @throws InvalidCubeTypeException
 * @throws SkinSaveException
 */
public static Skin saveSkinFromWorld(World world, SkinProperties skinProps, ISkinType skinType, int[] paintData, int xCoord, int yCoord, int zCoord, ForgeDirection direction) throws SkinSaveException {
    ArrayList<SkinPart> parts = new ArrayList<SkinPart>();
    if (skinType == SkinTypeRegistry.skinBlock) {
        ISkinPartType partType = ((SkinBlock) SkinTypeRegistry.skinBlock).partBase;
        if (SkinProperties.PROP_BLOCK_MULTIBLOCK.getValue(skinProps)) {
            partType = ((SkinBlock) SkinTypeRegistry.skinBlock).partMultiblock;
        }
        SkinPart skinPart = saveArmourPart(world, partType, xCoord, yCoord, zCoord, direction, true);
        if (skinPart != null) {
            parts.add(skinPart);
        }
    } else {
        for (int i = 0; i < skinType.getSkinParts().size(); i++) {
            ISkinPartType partType = skinType.getSkinParts().get(i);
            SkinPart skinPart = saveArmourPart(world, partType, xCoord, yCoord, zCoord, direction, true);
            if (skinPart != null) {
                parts.add(skinPart);
            }
        }
    }
    if (paintData != null) {
        paintData = paintData.clone();
    }
    Skin skin = new Skin(skinProps, skinType, paintData, parts);
    // Check if there are any blocks in the build guides.
    if (skin.getParts().size() == 0 && !skin.hasPaintData()) {
        throw new SkinSaveException("Nothing to save.", SkinSaveExceptionType.NO_DATA);
    }
    // Check if the skin has all needed parts.
    for (int i = 0; i < skinType.getSkinParts().size(); i++) {
        ISkinPartType partType = skinType.getSkinParts().get(i);
        if (partType.isPartRequired()) {
            boolean havePart = false;
            for (int j = 0; j < skin.getPartCount(); j++) {
                if (partType == skin.getParts().get(j).getPartType()) {
                    havePart = true;
                    break;
                }
            }
            if (!havePart) {
                throw new SkinSaveException("Skin is missing part " + partType.getPartName(), SkinSaveExceptionType.MISSING_PARTS);
            }
        }
    }
    // Check if the skin is not a seat and a bed.
    if (SkinProperties.PROP_BLOCK_BED.getValue(skinProps) & SkinProperties.PROP_BLOCK_SEAT.getValue(skinProps)) {
        throw new SkinSaveException("Skin can not be a bed and a seat.", SkinSaveExceptionType.BED_AND_SEAT);
    }
    // Check if multiblock is valid.
    if (skinType == SkinTypeRegistry.skinBlock & SkinProperties.PROP_BLOCK_MULTIBLOCK.getValue(skinProps)) {
        SkinPart testPart = saveArmourPart(world, ((SkinBlock) SkinTypeRegistry.skinBlock).partBase, xCoord, yCoord, zCoord, direction, true);
        if (testPart == null) {
            throw new SkinSaveException("Multiblock has no blocks in the yellow area.", SkinSaveExceptionType.INVALID_MULTIBLOCK);
        }
    }
    return skin;
}
Also used : ISkinPartType(riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType) SkinSaveException(riskyken.armourersWorkshop.common.exception.SkinSaveException) SkinBlock(riskyken.armourersWorkshop.common.skin.type.block.SkinBlock) ArrayList(java.util.ArrayList) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) SkinPart(riskyken.armourersWorkshop.common.skin.data.SkinPart)

Example 10 with ISkinPartType

use of riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType in project Armourers-Workshop by RiskyKen.

the class ArmourerWorldHelper method getListOfPaintableCubes.

public static ArrayList<BlockLocation> getListOfPaintableCubes(World world, int x, int y, int z, ISkinType skinType) {
    ArrayList<BlockLocation> blList = new ArrayList<BlockLocation>();
    for (int i = 0; i < skinType.getSkinParts().size(); i++) {
        ISkinPartType skinPart = skinType.getSkinParts().get(i);
        getBuildingCubesForPart(world, x, y, z, skinPart, blList);
    }
    return blList;
}
Also used : ISkinPartType(riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType) ArrayList(java.util.ArrayList) BlockLocation(riskyken.armourersWorkshop.common.blocks.BlockLocation)

Aggregations

ISkinPartType (riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType)18 IPoint3D (riskyken.armourersWorkshop.api.common.IPoint3D)5 IRectangle3D (riskyken.armourersWorkshop.api.common.IRectangle3D)4 ArrayList (java.util.ArrayList)3 SkinPart (riskyken.armourersWorkshop.common.skin.data.SkinPart)3 GuiButtonExt (cpw.mods.fml.client.config.GuiButtonExt)2 Rectangle3D (riskyken.armourersWorkshop.api.common.skin.Rectangle3D)2 ISkinType (riskyken.armourersWorkshop.api.common.skin.type.ISkinType)2 GuiCheckBox (riskyken.armourersWorkshop.client.gui.controls.GuiCheckBox)2 GuiDropDownList (riskyken.armourersWorkshop.client.gui.controls.GuiDropDownList)2 CubeMarkerData (riskyken.armourersWorkshop.common.skin.cubes.CubeMarkerData)2 SkinCubeData (riskyken.armourersWorkshop.common.skin.data.SkinCubeData)2 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 IOException (java.io.IOException)1 TileEntity (net.minecraft.tileentity.TileEntity)1 ISkinPart (riskyken.armourersWorkshop.api.common.skin.data.ISkinPart)1 ISkinPartTypeTextured (riskyken.armourersWorkshop.api.common.skin.type.ISkinPartTypeTextured)1 GuiDialogClear (riskyken.armourersWorkshop.client.gui.armourer.dialog.GuiDialogClear)1 GuiDialogCopy (riskyken.armourersWorkshop.client.gui.armourer.dialog.GuiDialogCopy)1 DropDownListItem (riskyken.armourersWorkshop.client.gui.controls.GuiDropDownList.DropDownListItem)1