Search in sources :

Example 1 with SkinBlock

use of riskyken.armourersWorkshop.common.skin.type.block.SkinBlock 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 2 with SkinBlock

use of riskyken.armourersWorkshop.common.skin.type.block.SkinBlock in project Armourers-Workshop by RiskyKen.

the class SkinTypeRegistry method registerSkins.

private void registerSkins() {
    skinHead = new SkinHead();
    skinChest = new SkinChest();
    skinLegs = new SkinLegs();
    skinSkirt = new SkinSkirt();
    skinFeet = new SkinFeet();
    skinSword = new SkinItem();
    skinBow = new SkinBow();
    skinArrow = new SkinArrow();
    skinBlock = new SkinBlock();
    skinWings = new SkinWings();
    registerSkin(skinHead);
    registerSkin(skinChest);
    registerSkin(skinLegs);
    // registerSkin(skinSkirt);
    registerSkin(skinFeet);
    registerSkin(skinSword);
    registerSkin(skinBow);
    // registerSkin(skinArrow);
    registerSkin(skinBlock);
    registerSkin(skinWings);
}
Also used : SkinSkirt(riskyken.armourersWorkshop.common.skin.type.legs.SkinSkirt) SkinFeet(riskyken.armourersWorkshop.common.skin.type.feet.SkinFeet) SkinHead(riskyken.armourersWorkshop.common.skin.type.head.SkinHead) SkinBlock(riskyken.armourersWorkshop.common.skin.type.block.SkinBlock) SkinChest(riskyken.armourersWorkshop.common.skin.type.chest.SkinChest) SkinArrow(riskyken.armourersWorkshop.common.skin.type.arrow.SkinArrow) SkinWings(riskyken.armourersWorkshop.common.skin.type.wings.SkinWings) SkinLegs(riskyken.armourersWorkshop.common.skin.type.legs.SkinLegs) SkinItem(riskyken.armourersWorkshop.common.skin.type.item.SkinItem) SkinBow(riskyken.armourersWorkshop.common.skin.type.bow.SkinBow)

Aggregations

SkinBlock (riskyken.armourersWorkshop.common.skin.type.block.SkinBlock)2 ArrayList (java.util.ArrayList)1 ISkinPartType (riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType)1 SkinSaveException (riskyken.armourersWorkshop.common.exception.SkinSaveException)1 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)1 SkinPart (riskyken.armourersWorkshop.common.skin.data.SkinPart)1 SkinArrow (riskyken.armourersWorkshop.common.skin.type.arrow.SkinArrow)1 SkinBow (riskyken.armourersWorkshop.common.skin.type.bow.SkinBow)1 SkinChest (riskyken.armourersWorkshop.common.skin.type.chest.SkinChest)1 SkinFeet (riskyken.armourersWorkshop.common.skin.type.feet.SkinFeet)1 SkinHead (riskyken.armourersWorkshop.common.skin.type.head.SkinHead)1 SkinItem (riskyken.armourersWorkshop.common.skin.type.item.SkinItem)1 SkinLegs (riskyken.armourersWorkshop.common.skin.type.legs.SkinLegs)1 SkinSkirt (riskyken.armourersWorkshop.common.skin.type.legs.SkinSkirt)1 SkinWings (riskyken.armourersWorkshop.common.skin.type.wings.SkinWings)1