Search in sources :

Example 1 with TileEntityColourable

use of riskyken.armourersWorkshop.common.tileentities.TileEntityColourable in project Armourers-Workshop by RiskyKen.

the class ArmourerWorldHelper method loadSkinBlockIntoWorld.

private static void loadSkinBlockIntoWorld(World world, int x, int y, int z, int xOrigin, int yOrigin, int zOrigin, ICube blockData, ForgeDirection direction, int meta, SkinCubeData cubeData, int index, boolean mirror) {
    byte[] loc = cubeData.getCubeLocation(index);
    int shiftX = -loc[0] - 1;
    int shiftY = loc[1] + 1;
    int shiftZ = loc[2];
    if (mirror) {
        shiftX = loc[0];
    }
    int targetX = x + shiftX + xOrigin;
    int targetY = y + yOrigin - shiftY;
    int targetZ = z + shiftZ + zOrigin;
    if (world.getBlock(targetX, targetY, targetZ) == ModBlocks.boundingBox) {
        world.setBlockToAir(targetX, targetY, targetZ);
        world.removeTileEntity(targetX, targetY, targetZ);
    }
    if (world.isAirBlock(targetX, targetY, targetZ)) {
        Block targetBlock = blockData.getMinecraftBlock();
        world.setBlock(targetX, targetY, targetZ, targetBlock);
        world.setBlockMetadataWithNotify(targetX, targetY, targetZ, meta, 2);
        TileEntity te = world.getTileEntity(targetX, targetY, targetZ);
        if (te != null && te instanceof TileEntityColourable) {
            CubeColour cc = new CubeColour();
            for (int i = 0; i < 6; i++) {
                byte[] c = cubeData.getCubeColour(index, i);
                byte paintType = cubeData.getCubePaintType(index, i);
                if (mirror) {
                    if (i == 4) {
                        c = cubeData.getCubeColour(index, 5);
                        paintType = cubeData.getCubePaintType(index, 5);
                    }
                    if (i == 5) {
                        c = cubeData.getCubeColour(index, 4);
                        paintType = cubeData.getCubePaintType(index, 4);
                    }
                }
                cc.setRed(c[0], i);
                cc.setGreen(c[1], i);
                cc.setBlue(c[2], i);
                cc.setPaintType(paintType, i);
            }
            ((TileEntityColourable) te).setColour(cc);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Block(net.minecraft.block.Block) SkinBlock(riskyken.armourersWorkshop.common.skin.type.block.SkinBlock) ICubeColour(riskyken.armourersWorkshop.api.common.skin.cubes.ICubeColour) CubeColour(riskyken.armourersWorkshop.common.skin.cubes.CubeColour) TileEntityColourable(riskyken.armourersWorkshop.common.tileentities.TileEntityColourable)

Aggregations

Block (net.minecraft.block.Block)1 TileEntity (net.minecraft.tileentity.TileEntity)1 ICubeColour (riskyken.armourersWorkshop.api.common.skin.cubes.ICubeColour)1 CubeColour (riskyken.armourersWorkshop.common.skin.cubes.CubeColour)1 SkinBlock (riskyken.armourersWorkshop.common.skin.type.block.SkinBlock)1 TileEntityColourable (riskyken.armourersWorkshop.common.tileentities.TileEntityColourable)1