Search in sources :

Example 1 with BlockLocation

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;
}
Also used : ISkinPartType(riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType) ArrayList(java.util.ArrayList) BlockLocation(riskyken.armourersWorkshop.common.blocks.BlockLocation)

Example 2 with BlockLocation

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);
    }
}
Also used : ArrayList(java.util.ArrayList) BlockLocation(riskyken.armourersWorkshop.common.blocks.BlockLocation) SkinPart(riskyken.armourersWorkshop.common.skin.data.SkinPart)

Example 3 with BlockLocation

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));
                    }
                }
            }
        }
    }
}
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) BlockLocation(riskyken.armourersWorkshop.common.blocks.BlockLocation)

Example 4 with BlockLocation

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;
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection) ArrayList(java.util.ArrayList) Block(net.minecraft.block.Block) BlockLocation(riskyken.armourersWorkshop.common.blocks.BlockLocation) BlockColourable(riskyken.armourersWorkshop.common.blocks.BlockColourable)

Example 5 with BlockLocation

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);
                }
            }
        }
    }
}
Also used : Block(net.minecraft.block.Block) IPantableBlock(riskyken.armourersWorkshop.api.common.painting.IPantableBlock) BlockLocation(riskyken.armourersWorkshop.common.blocks.BlockLocation) IPantableBlock(riskyken.armourersWorkshop.api.common.painting.IPantableBlock)

Aggregations

BlockLocation (riskyken.armourersWorkshop.common.blocks.BlockLocation)21 Block (net.minecraft.block.Block)14 IPantableBlock (riskyken.armourersWorkshop.api.common.painting.IPantableBlock)10 TileEntity (net.minecraft.tileentity.TileEntity)8 TileEntityArmourer (riskyken.armourersWorkshop.common.tileentities.TileEntityArmourer)7 MessageClientToolPaintBlock (riskyken.armourersWorkshop.common.network.messages.client.MessageClientToolPaintBlock)5 ArrayList (java.util.ArrayList)4 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 NBTTagList (net.minecraft.nbt.NBTTagList)2 IPantable (riskyken.armourersWorkshop.api.common.painting.IPantable)2 BlockColourable (riskyken.armourersWorkshop.common.blocks.BlockColourable)2 BlockSkinnable (riskyken.armourersWorkshop.common.blocks.BlockSkinnable)2 PaintType (riskyken.armourersWorkshop.common.painting.PaintType)2 TileEntitySkinnable (riskyken.armourersWorkshop.common.tileentities.TileEntitySkinnable)2 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 Color (java.awt.Color)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1