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