Search in sources :

Example 6 with IPoint3D

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

the class ArmourerWorldHelper method removeBoundingBoxesForSkinPart.

private static void removeBoundingBoxesForSkinPart(World world, int x, int y, int z, 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();
                if (world.blockExists(xTar, yTar, zTar)) {
                    if (world.getBlock(xTar, yTar, zTar) == ModBlocks.boundingBox) {
                        world.setBlockToAir(xTar, yTar, zTar);
                    }
                }
            }
        }
    }
}
Also used : IPoint3D(riskyken.armourersWorkshop.api.common.IPoint3D) IRectangle3D(riskyken.armourersWorkshop.api.common.IRectangle3D)

Example 7 with IPoint3D

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

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

the class SkinTextureHelper method getTextureLocationFromWorldBlock.

public static Point getTextureLocationFromWorldBlock(TileEntityBoundingBox te, int side) {
    ISkinPartTypeTextured skinPart = (ISkinPartTypeTextured) te.getSkinPart();
    Point textureLocation = skinPart.getTextureLocation();
    IPoint3D textureModelSize = skinPart.getTextureModelSize();
    ForgeDirection blockFace = ForgeDirection.getOrientation(side);
    byte blockX = te.getGuideX();
    byte blockY = te.getGuideY();
    byte blockZ = te.getGuideZ();
    int textureX = textureLocation.x;
    int textureY = textureLocation.y;
    int shiftX = 0;
    int shiftY = 0;
    if (skinPart.isTextureMirrored()) {
        if (blockFace == ForgeDirection.EAST | blockFace == ForgeDirection.WEST) {
            blockFace = blockFace.getOpposite();
        }
    }
    switch(blockFace) {
        case EAST:
            textureY += textureModelSize.getZ();
            shiftX = (byte) (-blockZ + textureModelSize.getZ() - 1);
            shiftY = (byte) (-blockY + textureModelSize.getY() - 1);
            break;
        case NORTH:
            textureX += textureModelSize.getZ();
            textureY += textureModelSize.getZ();
            shiftX = (byte) (-blockX + textureModelSize.getX() - 1);
            if (skinPart.isTextureMirrored()) {
                shiftX = (byte) (blockX);
            }
            shiftY = (byte) (-blockY + textureModelSize.getY() - 1);
            break;
        case WEST:
            textureX += textureModelSize.getZ() + textureModelSize.getX();
            textureY += textureModelSize.getZ();
            shiftX = blockZ;
            shiftY = (byte) (-blockY + textureModelSize.getY() - 1);
            break;
        case SOUTH:
            textureX += textureModelSize.getZ() + textureModelSize.getX() + textureModelSize.getZ();
            textureY += textureModelSize.getZ();
            shiftX = blockX;
            if (skinPart.isTextureMirrored()) {
                shiftX = (byte) (-blockX + textureModelSize.getX() - 1);
            }
            shiftY = (byte) (-blockY + textureModelSize.getY() - 1);
            break;
        case DOWN:
            textureX += textureModelSize.getZ() + textureModelSize.getX();
            shiftX = (byte) (-blockX + textureModelSize.getX() - 1);
            if (skinPart.isTextureMirrored()) {
                shiftX = blockX;
            }
            shiftY = (byte) (-blockZ + textureModelSize.getZ() - 1);
            break;
        case UP:
            textureX += textureModelSize.getZ();
            shiftX = (byte) (-blockX + textureModelSize.getX() - 1);
            if (skinPart.isTextureMirrored()) {
                shiftX = blockX;
            }
            shiftY = (byte) (-blockZ + textureModelSize.getZ() - 1);
            break;
        default:
            break;
    }
    textureX += shiftX;
    textureY += shiftY;
    return new Point(textureX, textureY);
}
Also used : IPoint3D(riskyken.armourersWorkshop.api.common.IPoint3D) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) ISkinPartTypeTextured(riskyken.armourersWorkshop.api.common.skin.type.ISkinPartTypeTextured) Point(java.awt.Point) Point(java.awt.Point)

Example 9 with IPoint3D

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

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

Aggregations

IPoint3D (riskyken.armourersWorkshop.api.common.IPoint3D)15 IRectangle3D (riskyken.armourersWorkshop.api.common.IRectangle3D)9 Block (net.minecraft.block.Block)5 ISkinPartType (riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType)5 SkinPart (riskyken.armourersWorkshop.common.skin.data.SkinPart)5 SkinBlock (riskyken.armourersWorkshop.common.skin.type.block.SkinBlock)5 ISkinPartTypeTextured (riskyken.armourersWorkshop.api.common.skin.type.ISkinPartTypeTextured)3 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)3 Point (java.awt.Point)2 ArrayList (java.util.ArrayList)2 CubeMarkerData (riskyken.armourersWorkshop.common.skin.cubes.CubeMarkerData)2 SkinCubeData (riskyken.armourersWorkshop.common.skin.data.SkinCubeData)2 TileEntity (net.minecraft.tileentity.TileEntity)1 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)1 Rectangle3D (riskyken.armourersWorkshop.api.common.skin.Rectangle3D)1 BlockLocation (riskyken.armourersWorkshop.common.blocks.BlockLocation)1 SkinSaveException (riskyken.armourersWorkshop.common.exception.SkinSaveException)1 PaintType (riskyken.armourersWorkshop.common.painting.PaintType)1 ICube (riskyken.armourersWorkshop.common.skin.cubes.ICube)1 TileEntityBoundingBox (riskyken.armourersWorkshop.common.tileentities.TileEntityBoundingBox)1