use of riskyken.armourersWorkshop.common.blocks.BlockLocation in project Armourers-Workshop by RiskyKen.
the class ArmourerWorldHelper method getListOfPaintableCubes.
public static ArrayList<BlockLocation> getListOfPaintableCubes(World world, int x, int y, int z, ISkinType skinType) {
ArrayList<BlockLocation> blList = new ArrayList<BlockLocation>();
for (int i = 0; i < skinType.getSkinParts().size(); i++) {
ISkinPartType skinPart = skinType.getSkinParts().get(i);
getBuildingCubesForPart(world, x, y, z, skinPart, blList);
}
return blList;
}
use of riskyken.armourersWorkshop.common.blocks.BlockLocation in project Armourers-Workshop by RiskyKen.
the class ArmourerWorldHelper method copySkinCubes.
public static void copySkinCubes(World world, int x, int y, int z, ISkinPartType srcPart, ISkinPartType desPart, boolean mirror) throws SkinSaveException {
ArrayList<BlockLocation> blList = new ArrayList<BlockLocation>();
SkinPart skinPart = saveArmourPart(world, srcPart, x, y, z, ForgeDirection.UNKNOWN, false);
if (skinPart != null) {
skinPart.setSkinPart(desPart);
loadSkinPartIntoWorld(world, skinPart, x, y, z, ForgeDirection.UNKNOWN, mirror);
}
}
use of riskyken.armourersWorkshop.common.blocks.BlockLocation in project Armourers-Workshop by RiskyKen.
the class ArmourerWorldHelper method getBuildingCubesForPart.
private static void getBuildingCubesForPart(World world, int x, int y, int z, ISkinPartType skinPart, ArrayList<BlockLocation> blList) {
IRectangle3D buildSpace = skinPart.getBuildingSpace();
IPoint3D offset = skinPart.getOffset();
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)) {
blList.add(new BlockLocation(xTar, yTar, zTar));
}
}
}
}
}
}
use of riskyken.armourersWorkshop.common.blocks.BlockLocation in project Armourers-Workshop by RiskyKen.
the class BlockUtils method findTouchingBlockFaces.
public static ArrayList<BlockLocation> findTouchingBlockFaces(World world, int x, int y, int z, int side, int radius) {
ForgeDirection dir = ForgeDirection.getOrientation(side);
ArrayList<BlockLocation> blockFaces = new ArrayList<BlockLocation>();
ArrayList<BlockLocation> openList = new ArrayList<BlockLocation>();
ArrayList<BlockLocation> closedList = new ArrayList<BlockLocation>();
openList.add(new BlockLocation(x, y, z).offset(dir));
ForgeDirection[] sides = ForgeDirection.VALID_DIRECTIONS;
while (!openList.isEmpty()) {
BlockLocation loc = openList.get(0);
openList.remove(0);
Block block = world.getBlock(loc.x, loc.y, loc.z);
if (block instanceof BlockColourable) {
blockFaces.add(loc);
}
if (world.isAirBlock(loc.x, loc.y, loc.z)) {
for (int i = 0; i < sides.length; i++) {
BlockLocation sideLoc = loc.offset(sides[i]);
Block sideBlock = world.getBlock(sideLoc.x, sideLoc.y, sideLoc.z);
if (!closedList.contains(sideLoc)) {
closedList.add(sideLoc);
boolean validCube = false;
for (int ix = 0; ix < 3; ix++) {
for (int iy = 0; iy < 3; iy++) {
for (int iz = 0; iz < 3; iz++) {
Block validBlock = world.getBlock(sideLoc.x + ix - 1, sideLoc.y + iy - 1, sideLoc.z + iz - 1);
if (validBlock instanceof BlockColourable) {
validCube = true;
}
}
}
}
if (sideLoc.getDistance(x, y, z) < radius & validCube) {
openList.add(sideLoc);
// blocks.add(sideLoc);
}
}
}
}
if (closedList.size() > 5000) {
break;
}
}
return blockFaces;
}
use of riskyken.armourersWorkshop.common.blocks.BlockLocation in project Armourers-Workshop by RiskyKen.
the class TileEntityArmourer method applyToolToBlocks.
private void applyToolToBlocks(IBlockPainter tool, World world, ItemStack stack, EntityPlayer player) {
if (skinType != null) {
ArrayList<BlockLocation> paintableCubes = ArmourerWorldHelper.getListOfPaintableCubes(worldObj, xCoord, yCoord + getHeightOffset(), zCoord, skinType);
for (int i = 0; i < paintableCubes.size(); i++) {
BlockLocation bl = paintableCubes.get(i);
IPantableBlock pBlock = (IPantableBlock) worldObj.getBlock(bl.x, bl.y, bl.z);
Block block = world.getBlock(bl.x, bl.y, bl.z);
if (block instanceof IPantableBlock) {
for (int side = 0; side < 6; side++) {
tool.usedOnBlockSide(stack, player, world, bl, block, side);
}
}
}
}
}
Aggregations