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;
}
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;
}
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);
}
}
}
}
}
}
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);
}
}
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);
}
Aggregations