Search in sources :

Example 6 with IRectangle3D

use of riskyken.armourersWorkshop.api.common.IRectangle3D in project Armourers-Workshop by RiskyKen.

the class ArmourerWorldHelper method getNumberOfCubesInPart.

private static int getNumberOfCubesInPart(World world, int x, int y, int z, ISkinPartType skinPart) {
    IRectangle3D buildSpace = skinPart.getBuildingSpace();
    IPoint3D offset = skinPart.getOffset();
    int cubeCount = 0;
    for (int ix = 0; ix < buildSpace.getWidth(); ix++) {
        for (int iy = 0; iy < buildSpace.getHeight(); iy++) {
            for (int iz = 0; iz < buildSpace.getDepth(); iz++) {
                int xTar = x + ix + -offset.getX() + buildSpace.getX();
                int yTar = y + iy + -offset.getY();
                int zTar = z + iz + offset.getZ() + buildSpace.getZ();
                if (world.blockExists(xTar, yTar, zTar)) {
                    Block block = world.getBlock(xTar, yTar, zTar);
                    if (CubeRegistry.INSTANCE.isBuildingBlock(block)) {
                        cubeCount++;
                    }
                }
            }
        }
    }
    return cubeCount;
}
Also used : IPoint3D(riskyken.armourersWorkshop.api.common.IPoint3D) IRectangle3D(riskyken.armourersWorkshop.api.common.IRectangle3D) Block(net.minecraft.block.Block) SkinBlock(riskyken.armourersWorkshop.common.skin.type.block.SkinBlock)

Example 7 with IRectangle3D

use of riskyken.armourersWorkshop.api.common.IRectangle3D in project Armourers-Workshop by RiskyKen.

the class ArmourerWorldHelper method clearMarkersForSkinPart.

private static int clearMarkersForSkinPart(World world, int x, int y, int z, ISkinPartType skinPart) {
    IRectangle3D buildSpace = skinPart.getBuildingSpace();
    IPoint3D offset = skinPart.getOffset();
    int blockCount = 0;
    for (int ix = 0; ix < buildSpace.getWidth(); ix++) {
        for (int iy = 0; iy < buildSpace.getHeight(); iy++) {
            for (int iz = 0; iz < buildSpace.getDepth(); iz++) {
                int xTar = x + ix + -offset.getX() + buildSpace.getX();
                int yTar = y + iy + -offset.getY();
                int zTar = z + iz + offset.getZ() + buildSpace.getZ();
                if (world.blockExists(xTar, yTar, zTar)) {
                    Block block = world.getBlock(xTar, yTar, zTar);
                    if (CubeRegistry.INSTANCE.isBuildingBlock(block)) {
                        if (world.getBlockMetadata(xTar, yTar, zTar) != 0) {
                            world.setBlockMetadataWithNotify(xTar, yTar, zTar, 0, 2);
                            blockCount++;
                        }
                    }
                }
            }
        }
    }
    return blockCount;
}
Also used : IPoint3D(riskyken.armourersWorkshop.api.common.IPoint3D) IRectangle3D(riskyken.armourersWorkshop.api.common.IRectangle3D) Block(net.minecraft.block.Block) SkinBlock(riskyken.armourersWorkshop.common.skin.type.block.SkinBlock)

Example 8 with IRectangle3D

use of riskyken.armourersWorkshop.api.common.IRectangle3D 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 9 with IRectangle3D

use of riskyken.armourersWorkshop.api.common.IRectangle3D 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 10 with IRectangle3D

use of riskyken.armourersWorkshop.api.common.IRectangle3D 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

IRectangle3D (riskyken.armourersWorkshop.api.common.IRectangle3D)12 IPoint3D (riskyken.armourersWorkshop.api.common.IPoint3D)9 Block (net.minecraft.block.Block)5 SkinBlock (riskyken.armourersWorkshop.common.skin.type.block.SkinBlock)5 ISkinPartType (riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType)4 ArrayList (java.util.ArrayList)2 Rectangle3D (riskyken.armourersWorkshop.api.common.skin.Rectangle3D)2 CubeMarkerData (riskyken.armourersWorkshop.common.skin.cubes.CubeMarkerData)2 SkinCubeData (riskyken.armourersWorkshop.common.skin.data.SkinCubeData)2 SkinPart (riskyken.armourersWorkshop.common.skin.data.SkinPart)2 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 TileEntity (net.minecraft.tileentity.TileEntity)1 ICubeColour (riskyken.armourersWorkshop.api.common.skin.cubes.ICubeColour)1 ISkinPart (riskyken.armourersWorkshop.api.common.skin.data.ISkinPart)1 ISkinPartTypeTextured (riskyken.armourersWorkshop.api.common.skin.type.ISkinPartTypeTextured)1 IRenderBuffer (riskyken.armourersWorkshop.client.render.IRenderBuffer)1 BlockLocation (riskyken.armourersWorkshop.common.blocks.BlockLocation)1 MiniCube (riskyken.armourersWorkshop.common.data.MiniCube)1 SkinSaveException (riskyken.armourersWorkshop.common.exception.SkinSaveException)1 CubeColour (riskyken.armourersWorkshop.common.skin.cubes.CubeColour)1