Search in sources :

Example 11 with ISkinPartType

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

the class ArmourerWorldHelper method createBoundingBoxes.

public static void createBoundingBoxes(World world, int x, int y, int z, int parentX, int parentY, int parentZ, ISkinType skinType) {
    for (int i = 0; i < skinType.getSkinParts().size(); i++) {
        ISkinPartType skinPart = skinType.getSkinParts().get(i);
        createBoundingBoxesForSkinPart(world, x, y, z, parentX, parentY, parentZ, skinPart);
    }
}
Also used : ISkinPartType(riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType)

Example 12 with ISkinPartType

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

the class ArmourerWorldHelper method removeBoundingBoxes.

public static void removeBoundingBoxes(World world, int x, int y, int z, ISkinType skinType) {
    for (int i = 0; i < skinType.getSkinParts().size(); i++) {
        ISkinPartType skinPart = skinType.getSkinParts().get(i);
        removeBoundingBoxesForSkinPart(world, x, y, z, skinPart);
    }
}
Also used : ISkinPartType(riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType)

Example 13 with ISkinPartType

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

the class ArmourerWorldHelper method createBoundingBoxesForSkinPart.

private static void createBoundingBoxesForSkinPart(World world, int x, int y, int z, int parentX, int parentY, int parentZ, ISkinPartType skinPart) {
    IRectangle3D buildSpace = skinPart.getBuildingSpace();
    IRectangle3D guideSpace = skinPart.getGuideSpace();
    IPoint3D offset = skinPart.getOffset();
    if (guideSpace == null) {
        return;
    }
    for (int ix = 0; ix < guideSpace.getWidth(); ix++) {
        for (int iy = 0; iy < guideSpace.getHeight(); iy++) {
            for (int iz = 0; iz < guideSpace.getDepth(); iz++) {
                int xTar = x + ix + -offset.getX() + guideSpace.getX();
                int yTar = y + iy + -offset.getY() + guideSpace.getY() - buildSpace.getY();
                int zTar = z + iz + offset.getZ() + guideSpace.getZ();
                // TODO Set skinPart to left and right legs for skirt.
                ISkinPartType guidePart = skinPart;
                byte guideX = (byte) ix;
                byte guideY = (byte) iy;
                byte guideZ = (byte) iz;
                if (world.isAirBlock(xTar, yTar, zTar)) {
                    world.setBlock(xTar, yTar, zTar, ModBlocks.boundingBox);
                    TileEntity te = null;
                    te = world.getTileEntity(xTar, yTar, zTar);
                    if (te != null && te instanceof TileEntityBoundingBox) {
                        ((TileEntityBoundingBox) te).setParent(parentX, parentY, parentZ, guideX, guideY, guideZ, guidePart);
                    } else {
                        te = new TileEntityBoundingBox(parentX, parentY, parentZ, guideX, guideY, guideZ, guidePart);
                        world.setTileEntity(xTar, yTar, zTar, te);
                    }
                }
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ISkinPartType(riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType) IPoint3D(riskyken.armourersWorkshop.api.common.IPoint3D) IRectangle3D(riskyken.armourersWorkshop.api.common.IRectangle3D) TileEntityBoundingBox(riskyken.armourersWorkshop.common.tileentities.TileEntityBoundingBox)

Example 14 with ISkinPartType

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

the class ArmourerWorldHelper method loadSkinPartIntoWorld.

private static void loadSkinPartIntoWorld(World world, SkinPart partData, int xCoord, int yCoord, int zCoord, ForgeDirection direction, boolean mirror) {
    ISkinPartType skinPart = partData.getPartType();
    IRectangle3D buildSpace = skinPart.getBuildingSpace();
    IPoint3D offset = skinPart.getOffset();
    SkinCubeData cubeData = partData.getCubeData();
    for (int i = 0; i < cubeData.getCubeCount(); i++) {
        ICube blockData = cubeData.getCube(i);
        int meta = 0;
        for (int j = 0; j < partData.getMarkerBlocks().size(); j++) {
            CubeMarkerData cmd = partData.getMarkerBlocks().get(j);
            byte[] loc = cubeData.getCubeLocation(i);
            if (cmd.x == loc[0] & cmd.y == loc[1] & cmd.z == loc[2]) {
                meta = cmd.meta;
                break;
            }
        }
        int xOrigin = -offset.getX();
        int yOrigin = -offset.getY() + -buildSpace.getY();
        int zOrigin = offset.getZ();
        loadSkinBlockIntoWorld(world, xCoord, yCoord, zCoord, xOrigin, yOrigin, zOrigin, blockData, direction, meta, cubeData, i, mirror);
    }
}
Also used : ISkinPartType(riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType) SkinCubeData(riskyken.armourersWorkshop.common.skin.data.SkinCubeData) IPoint3D(riskyken.armourersWorkshop.api.common.IPoint3D) IRectangle3D(riskyken.armourersWorkshop.api.common.IRectangle3D) CubeMarkerData(riskyken.armourersWorkshop.common.skin.cubes.CubeMarkerData) ICube(riskyken.armourersWorkshop.common.skin.cubes.ICube)

Example 15 with ISkinPartType

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

the class Skin method getSkinBounds.

@SideOnly(Side.CLIENT)
public Rectangle3D getSkinBounds() {
    int x = 0;
    int y = 0;
    int z = 0;
    int width = 1;
    int height = 1;
    int depth = 1;
    for (int i = 0; i < getPartCount(); i++) {
        if (!(getSkinType() == SkinTypeRegistry.skinBow && i > 0)) {
            SkinPart skinPart = getParts().get(i);
            Rectangle3D bounds = skinPart.getPartBounds();
            width = Math.max(width, bounds.getWidth());
            height = Math.max(height, bounds.getHeight());
            depth = Math.max(depth, bounds.getDepth());
            x = bounds.getX();
            y = bounds.getY();
            z = bounds.getZ();
            if (hasPaintData()) {
                IRectangle3D skinRec = skinPart.getPartType().getGuideSpace();
                width = Math.max(width, skinRec.getWidth());
                height = Math.max(height, skinRec.getHeight());
                depth = Math.max(depth, skinRec.getDepth());
                x = Math.max(x, skinRec.getX());
                y = Math.max(y, skinRec.getY());
                z = Math.max(z, skinRec.getZ());
            }
        }
    }
    if (getPartCount() == 0) {
        for (int i = 0; i < getSkinType().getSkinParts().size(); i++) {
            ISkinPartType part = getSkinType().getSkinParts().get(i);
            IRectangle3D skinRec = part.getGuideSpace();
            width = Math.max(width, skinRec.getWidth());
            height = Math.max(height, skinRec.getHeight());
            depth = Math.max(depth, skinRec.getDepth());
            x = Math.min(x, skinRec.getX());
            y = Math.max(y, skinRec.getY());
            z = Math.min(z, skinRec.getZ());
        }
    }
    return new Rectangle3D(x, y, z, width, height, depth);
}
Also used : ISkinPartType(riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType) IRectangle3D(riskyken.armourersWorkshop.api.common.IRectangle3D) IRectangle3D(riskyken.armourersWorkshop.api.common.IRectangle3D) Rectangle3D(riskyken.armourersWorkshop.api.common.skin.Rectangle3D) ISkinPart(riskyken.armourersWorkshop.api.common.skin.data.ISkinPart) SideOnly(cpw.mods.fml.relauncher.SideOnly)

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