use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class ShapeCardItem method countBlocks.
public static int countBlocks(Shape shape, Coordinate dimension) {
final int[] cnt = { 0 };
Coordinate offset = new Coordinate(0, 128, 0);
Coordinate clamped = new Coordinate(Math.min(dimension.getX(), 512), Math.min(dimension.getY(), 256), Math.min(dimension.getZ(), 512));
composeShape(shape, null, new Coordinate(0, 0, 0), clamped, offset, new AbstractCollection<Coordinate>() {
@Override
public Iterator<Coordinate> iterator() {
return null;
}
@Override
public boolean add(Coordinate coordinate) {
cnt[0]++;
return true;
}
@Override
public int size() {
return 0;
}
}, MAXIMUM_COUNT + 1, false, null);
return cnt[0];
}
use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class ShapeCardItem method composeSphere.
private static void composeSphere(World worldObj, Coordinate thisCoord, Coordinate dimension, Coordinate offset, Collection<Coordinate> blocks, int maxSize, int side, boolean solid, boolean forquarry, ChunkCoordIntPair chunk) {
int xCoord = thisCoord.getX();
int yCoord = thisCoord.getY();
int zCoord = thisCoord.getZ();
int dx = dimension.getX();
int dy = dimension.getY();
int dz = dimension.getZ();
float centerx;
float centery;
float centerz;
if (SpaceProjectorConfiguration.oldSphereCylinderShape) {
centerx = xCoord + offset.getX() + 0.5f;
centery = yCoord + offset.getY() + 0.5f;
centerz = zCoord + offset.getZ() + 0.5f;
} else {
centerx = xCoord + offset.getX() + ((dx % 2 != 0) ? 0.0f : -.5f);
centery = yCoord + offset.getY() + ((dy % 2 != 0) ? 0.0f : -.5f);
centerz = zCoord + offset.getZ() + ((dz % 2 != 0) ? 0.0f : -.5f);
}
Coordinate tl = new Coordinate(xCoord - dx / 2 + offset.getX(), yCoord - dy / 2 + offset.getY(), zCoord - dz / 2 + offset.getZ());
float dx2;
float dy2;
float dz2;
int davg;
if (SpaceProjectorConfiguration.oldSphereCylinderShape) {
dx2 = dx == 0 ? .5f : (dx * dx) / 4.0f;
dy2 = dy == 0 ? .5f : (dy * dy) / 4.0f;
dz2 = dz == 0 ? .5f : (dz * dz) / 4.0f;
davg = (dx + dy + dz) / 3;
} else {
// float factor = 2.0f;
float factor = 1.8f;
dx2 = dx == 0 ? .5f : ((dx + factor) * (dx + factor)) / 4.0f;
dy2 = dy == 0 ? .5f : ((dy + factor) * (dy + factor)) / 4.0f;
dz2 = dz == 0 ? .5f : ((dz + factor) * (dz + factor)) / 4.0f;
davg = (int) ((dx + dy + dz + factor * 3) / 3);
}
for (int ox = 0; ox < dx; ox++) {
int x = tl.getX() + ox;
if (xInChunk(x, chunk)) {
for (int oz = 0; oz < dz; oz++) {
int z = tl.getZ() + oz;
if (zInChunk(z, chunk)) {
for (int oy = 0; oy < dy; oy++) {
int y = tl.getY() + oy;
if (y >= 0 && y < 255) {
if (side == 0 || (side == 1 && y >= yCoord + offset.getY()) || (side == -1 && y <= yCoord + offset.getY())) {
if (isInside3D(centerx, centery, centerz, x, y, z, dx2, dy2, dz2, davg) == 1) {
int cnt;
if (solid) {
cnt = 0;
} else {
cnt = isInside3D(centerx, centery, centerz, x - 1, y, z, dx2, dy2, dz2, davg);
cnt += isInside3D(centerx, centery, centerz, x + 1, y, z, dx2, dy2, dz2, davg);
cnt += isInside3D(centerx, centery, centerz, x, y - 1, z, dx2, dy2, dz2, davg);
cnt += isInside3D(centerx, centery, centerz, x, y + 1, z, dx2, dy2, dz2, davg);
cnt += isInside3D(centerx, centery, centerz, x, y, z - 1, dx2, dy2, dz2, davg);
cnt += isInside3D(centerx, centery, centerz, x, y, z + 1, dx2, dy2, dz2, davg);
}
if (cnt != 6) {
placeBlockIfPossible(worldObj, blocks, maxSize, x, y, z, forquarry);
}
}
}
}
}
}
}
}
}
}
use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class ShapeCardItem method getDimension.
public static Coordinate getDimension(ItemStack stack) {
NBTTagCompound tagCompound = stack.getTagCompound();
if (tagCompound == null) {
return new Coordinate(5, 5, 5);
}
if (!tagCompound.hasKey("dimX")) {
return new Coordinate(5, 5, 5);
}
int dimX = tagCompound.getInteger("dimX");
int dimY = tagCompound.getInteger("dimY");
int dimZ = tagCompound.getInteger("dimZ");
return new Coordinate(dimX, clampDimension(dimY, 256), dimZ);
}
use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class ShapeCardItem method getOffset.
public static Coordinate getOffset(ItemStack stack) {
NBTTagCompound tagCompound = stack.getTagCompound();
if (tagCompound == null) {
return new Coordinate(0, 0, 0);
}
int offsetX = tagCompound.getInteger("offsetX");
int offsetY = tagCompound.getInteger("offsetY");
int offsetZ = tagCompound.getInteger("offsetZ");
return new Coordinate(offsetX, offsetY, offsetZ);
}
use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class ShapeCardItem method composeBox.
private static void composeBox(World worldObj, Coordinate thisCoord, Coordinate dimension, Coordinate offset, Collection<Coordinate> blocks, int maxSize, boolean solid, boolean forquarry, ChunkCoordIntPair chunk) {
int xCoord = thisCoord.getX();
int yCoord = thisCoord.getY();
int zCoord = thisCoord.getZ();
int dx = dimension.getX();
int dy = dimension.getY();
int dz = dimension.getZ();
Coordinate tl = new Coordinate(xCoord - dx / 2 + offset.getX(), yCoord - dy / 2 + offset.getY(), zCoord - dz / 2 + offset.getZ());
for (int ox = 0; ox < dx; ox++) {
int x = tl.getX() + ox;
if (xInChunk(x, chunk)) {
for (int oz = 0; oz < dz; oz++) {
int z = tl.getZ() + oz;
if (zInChunk(z, chunk)) {
for (int oy = 0; oy < dy; oy++) {
int y = tl.getY() + oy;
if (y >= 0 && y < 255) {
if (solid || ox == 0 || oy == 0 || oz == 0 || ox == (dx - 1) || oy == (dy - 1) || oz == (dz - 1)) {
placeBlockIfPossible(worldObj, blocks, maxSize, x, y, z, forquarry);
}
}
}
}
}
}
}
}
Aggregations